move extensions to own package
This commit is contained in:
26
packages/tiptap-extensions/package.json
Normal file
26
packages/tiptap-extensions/package.json
Normal file
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"name": "tiptap-extensions",
|
||||
"version": "0.1.0",
|
||||
"description": "Extensions for tiptap",
|
||||
"homepage": "https://tiptap.scrumpy.io",
|
||||
"license": "MIT",
|
||||
"main": "dist/extensions.common.js",
|
||||
"module": "dist/extensions.esm.js",
|
||||
"unpkg": "dist/extensions.js",
|
||||
"jsdelivr": "dist/extensions.js",
|
||||
"files": [
|
||||
"src",
|
||||
"dist"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/heyscrumpy/tiptap.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/heyscrumpy/tiptap/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"tiptap": "^0.2.1",
|
||||
"tiptap-commands": "^0.1.1"
|
||||
}
|
||||
}
|
||||
14
packages/tiptap-extensions/src/index.js
Normal file
14
packages/tiptap-extensions/src/index.js
Normal file
@@ -0,0 +1,14 @@
|
||||
export { default as Blockquote } from './nodes/Blockquote'
|
||||
export { default as BulletList } from './nodes/BulletList'
|
||||
export { default as CodeBlock } from './nodes/CodeBlock'
|
||||
export { default as HardBreak } from './nodes/HardBreak'
|
||||
export { default as Heading } from './nodes/Heading'
|
||||
export { default as ListItem } from './nodes/ListItem'
|
||||
export { default as OrderedList } from './nodes/OrderedList'
|
||||
export { default as TodoItem } from './nodes/TodoItem'
|
||||
export { default as TodoList } from './nodes/TodoList'
|
||||
|
||||
export { default as Bold } from './marks/Bold'
|
||||
export { default as Code } from './marks/Code'
|
||||
export { default as Italic } from './marks/Italic'
|
||||
export { default as Link } from './marks/Link'
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Mark } from 'tiptap-models'
|
||||
import { Mark } from 'tiptap'
|
||||
import { toggleMark } from 'tiptap-commands'
|
||||
|
||||
export default class BoldMark extends Mark {
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Mark } from 'tiptap-models'
|
||||
import { Mark } from 'tiptap'
|
||||
import { toggleMark } from 'tiptap-commands'
|
||||
|
||||
export default class CodeMark extends Mark {
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Mark } from 'tiptap-models'
|
||||
import { Mark } from 'tiptap'
|
||||
import { toggleMark } from 'tiptap-commands'
|
||||
|
||||
export default class ItalicMark extends Mark {
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Mark } from 'tiptap-models'
|
||||
import { Mark } from 'tiptap'
|
||||
import { updateMark, removeMark } from 'tiptap-commands'
|
||||
|
||||
export default class LinkMark extends Mark {
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Node } from 'tiptap-models'
|
||||
import { Node } from 'tiptap'
|
||||
import { wrappingInputRule, setBlockType, wrapIn } from 'tiptap-commands'
|
||||
|
||||
export default class BlockquoteNode extends Node {
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Node } from 'tiptap-models'
|
||||
import { Node } from 'tiptap'
|
||||
import { wrappingInputRule, wrapInList, toggleList } from 'tiptap-commands'
|
||||
|
||||
export default class BulletNode extends Node {
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Node } from 'tiptap-models'
|
||||
import { Node } from 'tiptap'
|
||||
import { toggleBlockType, setBlockType, textblockTypeInputRule } from 'tiptap-commands'
|
||||
|
||||
export default class CodeBlockNode extends Node {
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Node } from 'tiptap-models'
|
||||
import { Node } from 'tiptap'
|
||||
import { chainCommands, exitCode } from 'tiptap-commands'
|
||||
|
||||
export default class HardBreakNode extends Node {
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Node } from 'tiptap-models'
|
||||
import { Node } from 'tiptap'
|
||||
import { setBlockType, textblockTypeInputRule, toggleBlockType } from 'tiptap-commands'
|
||||
|
||||
export default class HeadingNode extends Node {
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Node } from 'tiptap-models'
|
||||
import { Node } from 'tiptap'
|
||||
import { splitListItem, liftListItem, sinkListItem } from 'tiptap-commands'
|
||||
|
||||
export default class OrderedListNode extends Node {
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Node } from 'tiptap-models'
|
||||
import { Node } from 'tiptap'
|
||||
import { wrappingInputRule, wrapInList, toggleList } from 'tiptap-commands'
|
||||
|
||||
export default class OrderedListNode extends Node {
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Node } from 'tiptap-models'
|
||||
import { Node } from 'tiptap'
|
||||
import { splitListItem, liftListItem } from 'tiptap-commands'
|
||||
|
||||
export default class TodoItemNode extends Node {
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Node } from 'tiptap-models'
|
||||
import { Node } from 'tiptap'
|
||||
import { wrapInList, wrappingInputRule } from 'tiptap-commands'
|
||||
|
||||
export default class BulletNode extends Node {
|
||||
@@ -16,7 +16,6 @@ import {
|
||||
builtInKeymap,
|
||||
} from '../utils'
|
||||
import builtInNodes from '../nodes'
|
||||
import builtInMarks from '../marks'
|
||||
|
||||
export default {
|
||||
|
||||
@@ -40,7 +39,6 @@ export default {
|
||||
data() {
|
||||
const plugins = new PluginManager([
|
||||
...builtInNodes,
|
||||
...builtInMarks,
|
||||
...this.extensions,
|
||||
])
|
||||
const { nodes, marks, views } = plugins
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import Editor from './components/editor'
|
||||
import Node from './utils/node'
|
||||
import Mark from './utils/mark'
|
||||
|
||||
export { Editor }
|
||||
export { Editor, Node, Mark }
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
import Code from './Code'
|
||||
import Italic from './Italic'
|
||||
import Link from './Link'
|
||||
import Bold from './Bold'
|
||||
|
||||
export default [
|
||||
new Code(),
|
||||
new Italic(),
|
||||
new Link(),
|
||||
new Bold(),
|
||||
]
|
||||
@@ -23,10 +23,4 @@ export default class ParagraphNode extends Node {
|
||||
return setBlockType(type)
|
||||
}
|
||||
|
||||
keys({ type }) {
|
||||
return {
|
||||
'Shift-Ctrl-0': setBlockType(type),
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,29 +1,9 @@
|
||||
import Blockquote from './Blockquote'
|
||||
import BulletList from './BulletList'
|
||||
import CodeBlock from './CodeBlock'
|
||||
import Doc from './Doc'
|
||||
import HardBreak from './HardBreak'
|
||||
import Heading from './Heading'
|
||||
import ListItem from './ListItem'
|
||||
import OrderedList from './OrderedList'
|
||||
import Paragraph from './Paragraph'
|
||||
import Text from './Text'
|
||||
import TodoList from './TodoList'
|
||||
import TodoItem from './TodoItem'
|
||||
|
||||
export default [
|
||||
// essentials
|
||||
new Doc(),
|
||||
new Paragraph(),
|
||||
new Text(),
|
||||
|
||||
new Blockquote(),
|
||||
new CodeBlock(),
|
||||
new Heading({ maxLevel: 3 }),
|
||||
new HardBreak(),
|
||||
new OrderedList(),
|
||||
new BulletList(),
|
||||
new ListItem(),
|
||||
new TodoList(),
|
||||
new TodoItem(),
|
||||
new Paragraph(),
|
||||
]
|
||||
|
||||
46
packages/tiptap/src/utils/mark.js
Normal file
46
packages/tiptap/src/utils/mark.js
Normal file
@@ -0,0 +1,46 @@
|
||||
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 []
|
||||
}
|
||||
|
||||
}
|
||||
46
packages/tiptap/src/utils/node.js
Normal file
46
packages/tiptap/src/utils/node.js
Normal file
@@ -0,0 +1,46 @@
|
||||
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 []
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user