add tiptap-models
This commit is contained in:
@@ -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"
|
||||
}
|
||||
}
|
||||
|
||||
22
packages/tiptap-models/package.json
Normal file
22
packages/tiptap-models/package.json
Normal 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"
|
||||
}
|
||||
}
|
||||
2
packages/tiptap-models/src/index.js
Normal file
2
packages/tiptap-models/src/index.js
Normal file
@@ -0,0 +1,2 @@
|
||||
export { default as Mark } from './models/mark'
|
||||
export { default as Node } from './models/node'
|
||||
@@ -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",
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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 }) {
|
||||
|
||||
|
||||
@@ -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,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,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