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

@@ -23,6 +23,6 @@
"prosemirror-commands": "^1.0.7",
"prosemirror-inputrules": "^1.0.1",
"prosemirror-schema-list": "^1.0.1",
"tiptap-utils": "^0.1.1"
"tiptap-utils": "^0.2.0"
}
}

View File

@@ -0,0 +1,22 @@
{
"name": "tiptap-models",
"version": "0.1.1",
"description": "Models for tiptap",
"homepage": "https://tiptap.scrumpy.io",
"license": "MIT",
"main": "dist/models.common.js",
"module": "dist/models.esm.js",
"unpkg": "dist/models.js",
"jsdelivr": "dist/models.js",
"files": [
"src",
"dist"
],
"repository": {
"type": "git",
"url": "git+https://github.com/heyscrumpy/tiptap.git"
},
"bugs": {
"url": "https://github.com/heyscrumpy/tiptap/issues"
}
}

View File

@@ -0,0 +1,2 @@
export { default as Mark } from './models/mark'
export { default as Node } from './models/node'

View File

@@ -1,6 +1,6 @@
{
"name": "tiptap-utils",
"version": "0.1.1",
"version": "0.2.0",
"description": "Utility functions for tiptap",
"homepage": "https://tiptap.scrumpy.io",
"license": "MIT",

View File

@@ -1,2 +1,3 @@
export { default as getMarkAttrs } from './utils/getMarkAttrs'
export { default as markIsActive } from './utils/markIsActive'
export { default as nodeIsActive } from './utils/nodeIsActive'

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

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