add tiptap-models
This commit is contained in:
@@ -91,6 +91,7 @@
|
||||
"prosemirror-utils": "^0.6.5",
|
||||
"prosemirror-view": "^1.4.3",
|
||||
"tiptap-commands": "^0.1.0",
|
||||
"tiptap-utils": "^0.1.1"
|
||||
"tiptap-models": "^0.1.0",
|
||||
"tiptap-utils": "^0.2.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Mark } from '../utils'
|
||||
import { Mark } from 'tiptap-models'
|
||||
import { toggleMark } from 'tiptap-commands'
|
||||
|
||||
export default class BoldMark extends Mark {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Mark } from '../utils'
|
||||
import { Mark } from 'tiptap-models'
|
||||
import { toggleMark } from 'tiptap-commands'
|
||||
|
||||
export default class CodeMark extends Mark {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Mark } from '../utils'
|
||||
import { Mark } from 'tiptap-models'
|
||||
import { toggleMark } from 'tiptap-commands'
|
||||
|
||||
export default class ItalicMark extends Mark {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Mark } from '../utils'
|
||||
import { Mark } from 'tiptap-models'
|
||||
import { updateMark, removeMark } from 'tiptap-commands'
|
||||
|
||||
export default class LinkMark extends Mark {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Node } from '../utils'
|
||||
import { Node } from 'tiptap-models'
|
||||
import { wrappingInputRule, setBlockType, wrapIn } from 'tiptap-commands'
|
||||
|
||||
export default class BlockquoteNode extends Node {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Node } from '../utils'
|
||||
import { Node } from 'tiptap-models'
|
||||
import { wrappingInputRule, wrapInList, toggleList } from 'tiptap-commands'
|
||||
|
||||
export default class BulletNode extends Node {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Node } from '../utils'
|
||||
import { Node } from 'tiptap-models'
|
||||
import { toggleBlockType, setBlockType, textblockTypeInputRule } from 'tiptap-commands'
|
||||
|
||||
export default class CodeBlockNode extends Node {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Node } from '../utils'
|
||||
import { Node } from 'tiptap-models'
|
||||
|
||||
export default class DocNode extends Node {
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Node } from '../utils'
|
||||
import { Node } from 'tiptap-models'
|
||||
import { chainCommands, exitCode } from 'tiptap-commands'
|
||||
|
||||
export default class HardBreakNode extends Node {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Node } from '../utils'
|
||||
import { Node } from 'tiptap-models'
|
||||
import { setBlockType, textblockTypeInputRule, toggleBlockType } from 'tiptap-commands'
|
||||
|
||||
export default class HeadingNode extends Node {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Node } from '../utils'
|
||||
import { Node } from 'tiptap-models'
|
||||
import { splitListItem, liftListItem, sinkListItem } from 'tiptap-commands'
|
||||
|
||||
export default class OrderedListNode extends Node {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Node } from '../utils'
|
||||
import { Node } from 'tiptap-models'
|
||||
import { wrappingInputRule, wrapInList, toggleList } from 'tiptap-commands'
|
||||
|
||||
export default class OrderedListNode extends Node {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Node } from '../utils'
|
||||
import { Node } from 'tiptap-models'
|
||||
import { setBlockType } from 'tiptap-commands'
|
||||
|
||||
export default class ParagraphNode extends Node {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Node } from '../utils'
|
||||
import { Node } from 'tiptap-models'
|
||||
|
||||
export default class TextNode extends Node {
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Node } from '../utils'
|
||||
import { Node } from 'tiptap-models'
|
||||
import { splitListItem, liftListItem } from 'tiptap-commands'
|
||||
|
||||
export default class TodoItemNode extends Node {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Node } from '../utils'
|
||||
import { Node } from 'tiptap-models'
|
||||
import { wrapInList, wrappingInputRule } from 'tiptap-commands'
|
||||
|
||||
export default class BulletNode extends Node {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { markIsActive, nodeIsActive, getMarkAttrs } from '.'
|
||||
import { markIsActive, nodeIsActive, getMarkAttrs } from 'tiptap-utils'
|
||||
|
||||
export default function ({ schema, state, commands }) {
|
||||
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
export default function (state, type) {
|
||||
const { from, to } = state.selection
|
||||
let marks = []
|
||||
|
||||
state.doc.nodesBetween(from, to, node => {
|
||||
marks = [...marks, ...node.marks]
|
||||
})
|
||||
|
||||
const mark = marks.find(mark => mark.type.name === type.name)
|
||||
|
||||
if (mark) {
|
||||
return mark.attrs
|
||||
}
|
||||
|
||||
return {}
|
||||
}
|
||||
@@ -3,10 +3,5 @@ export { default as builtInKeymap } from './builtInKeymap'
|
||||
export { default as ComponentView } from './ComponentView'
|
||||
export { default as initNodeViews } from './initNodeViews'
|
||||
export { default as isMac } from './isMac'
|
||||
export { default as getMarkAttrs } from './getMarkAttrs'
|
||||
export { default as markIsActive } from './markIsActive'
|
||||
export { default as nodeIsActive } from './nodeIsActive'
|
||||
export { default as menuBubble } from './menuBubble'
|
||||
export { default as Node } from './node'
|
||||
export { default as Mark } from './mark'
|
||||
export { default as PluginManager } from './PluginManager'
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
export default class Mark {
|
||||
|
||||
constructor(options = {}) {
|
||||
this.options = {
|
||||
...this.defaultOptions,
|
||||
...options,
|
||||
}
|
||||
}
|
||||
|
||||
get name() {
|
||||
return null
|
||||
}
|
||||
|
||||
get defaultOptions() {
|
||||
return {}
|
||||
}
|
||||
|
||||
get type() {
|
||||
return 'mark'
|
||||
}
|
||||
|
||||
get view() {
|
||||
return null
|
||||
}
|
||||
|
||||
get schema() {
|
||||
return null
|
||||
}
|
||||
|
||||
get plugins() {
|
||||
return []
|
||||
}
|
||||
|
||||
command() {
|
||||
return () => {}
|
||||
}
|
||||
|
||||
keys() {
|
||||
return {}
|
||||
}
|
||||
|
||||
inputRules() {
|
||||
return []
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
export default function (state, type) {
|
||||
const {
|
||||
from,
|
||||
$from,
|
||||
to,
|
||||
empty,
|
||||
} = state.selection
|
||||
|
||||
if (empty) {
|
||||
return !!type.isInSet(state.storedMarks || $from.marks())
|
||||
}
|
||||
|
||||
return !!state.doc.rangeHasMark(from, to, type)
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
export default class Node {
|
||||
|
||||
constructor(options = {}) {
|
||||
this.options = {
|
||||
...this.defaultOptions,
|
||||
...options,
|
||||
}
|
||||
}
|
||||
|
||||
get name() {
|
||||
return null
|
||||
}
|
||||
|
||||
get defaultOptions() {
|
||||
return {}
|
||||
}
|
||||
|
||||
get type() {
|
||||
return 'node'
|
||||
}
|
||||
|
||||
get view() {
|
||||
return null
|
||||
}
|
||||
|
||||
get schema() {
|
||||
return null
|
||||
}
|
||||
|
||||
get plugins() {
|
||||
return []
|
||||
}
|
||||
|
||||
command() {
|
||||
return () => {}
|
||||
}
|
||||
|
||||
keys() {
|
||||
return {}
|
||||
}
|
||||
|
||||
inputRules() {
|
||||
return []
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
import { findParentNode } from 'prosemirror-utils'
|
||||
|
||||
export default function (state, type, attrs) {
|
||||
const predicate = node => node.type === type
|
||||
const parent = findParentNode(predicate)(state.selection)
|
||||
|
||||
if (attrs === {} || !parent) {
|
||||
return !!parent
|
||||
}
|
||||
|
||||
return parent.node.hasMarkup(type, attrs)
|
||||
}
|
||||
Reference in New Issue
Block a user