add tiptap-models

This commit is contained in:
Philipp Kühn
2018-08-23 11:13:59 +02:00
parent 0552faa68a
commit 9fafc6b00f
32 changed files with 136 additions and 113 deletions

View File

@@ -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"
}
}

View File

@@ -1,4 +1,4 @@
import { Mark } from '../utils'
import { Mark } from 'tiptap-models'
import { toggleMark } from 'tiptap-commands'
export default class BoldMark extends Mark {

View File

@@ -1,4 +1,4 @@
import { Mark } from '../utils'
import { Mark } from 'tiptap-models'
import { toggleMark } from 'tiptap-commands'
export default class CodeMark extends Mark {

View File

@@ -1,4 +1,4 @@
import { Mark } from '../utils'
import { Mark } from 'tiptap-models'
import { toggleMark } from 'tiptap-commands'
export default class ItalicMark extends Mark {

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -1,4 +1,4 @@
import { Node } from '../utils'
import { Node } from 'tiptap-models'
export default class DocNode extends Node {

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -1,4 +1,4 @@
import { Node } from '../utils'
import { Node } from 'tiptap-models'
import { setBlockType } from 'tiptap-commands'
export default class ParagraphNode extends Node {

View File

@@ -1,4 +1,4 @@
import { Node } from '../utils'
import { Node } from 'tiptap-models'
export default class TextNode extends Node {

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -1,4 +1,4 @@
import { markIsActive, nodeIsActive, getMarkAttrs } from '.'
import { markIsActive, nodeIsActive, getMarkAttrs } from 'tiptap-utils'
export default function ({ schema, state, commands }) {

View File

@@ -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 {}
}

View File

@@ -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'

View File

@@ -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 []
}
}

View File

@@ -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)
}

View File

@@ -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 []
}
}

View File

@@ -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)
}