move extensions to own package

This commit is contained in:
Philipp Kühn
2018-08-23 22:08:19 +02:00
parent 2ef23d3003
commit e2176f00fd
32 changed files with 420 additions and 65 deletions

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

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -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(),
]

View File

@@ -23,10 +23,4 @@ export default class ParagraphNode extends Node {
return setBlockType(type)
}
keys({ type }) {
return {
'Shift-Ctrl-0': setBlockType(type),
}
}
}

View File

@@ -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(),
]

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

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