add some extensions
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@tiptap/core",
|
"name": "@tiptap/core",
|
||||||
"version": "0.1.0",
|
"version": "2.0.0",
|
||||||
"source": "index.ts",
|
"source": "index.ts",
|
||||||
"main": "dist/tiptap-core.js",
|
"main": "dist/tiptap-core.js",
|
||||||
"umd:main": "dist/tiptap-core.umd.js",
|
"umd:main": "dist/tiptap-core.umd.js",
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ type EditorContent = string | JSON
|
|||||||
interface Options {
|
interface Options {
|
||||||
element?: Node
|
element?: Node
|
||||||
content: EditorContent
|
content: EditorContent
|
||||||
|
extensions: [any?]
|
||||||
injectCSS: Boolean
|
injectCSS: Boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35,6 +36,7 @@ export class Editor {
|
|||||||
options: Options = {
|
options: Options = {
|
||||||
content: '',
|
content: '',
|
||||||
injectCSS: true,
|
injectCSS: true,
|
||||||
|
extensions: [],
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(options: Options) {
|
constructor(options: Options) {
|
||||||
@@ -141,7 +143,7 @@ export class Editor {
|
|||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
this[name] = this.chainCommand((...args: any) => {
|
this[name] = this.chainCommand((...args: any) => {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
return method(resolve as Function, this as Editor, ...args as any)
|
return method(resolve, this, ...args)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import { Editor } from './Editor'
|
import { Editor } from './Editor'
|
||||||
|
|
||||||
export default class Extension {
|
export default abstract class Extension {
|
||||||
|
|
||||||
|
public abstract name: string
|
||||||
|
|
||||||
editor: any
|
editor: any
|
||||||
options: { [key: string]: any } = {}
|
options: { [key: string]: any } = {}
|
||||||
@@ -21,10 +23,6 @@ export default class Extension {
|
|||||||
this.editor = editor
|
this.editor = editor
|
||||||
}
|
}
|
||||||
|
|
||||||
get name(): any {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
get type(): any {
|
get type(): any {
|
||||||
return 'extension'
|
return 'extension'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import Extension from './Extension'
|
import Extension from './Extension'
|
||||||
|
|
||||||
export default class Node extends Extension {
|
export default abstract class Node extends Extension {
|
||||||
|
|
||||||
constructor(options = {}) {
|
constructor(options = {}) {
|
||||||
super(options)
|
super(options)
|
||||||
@@ -8,20 +8,22 @@ export default class Node extends Extension {
|
|||||||
|
|
||||||
// protected type = 'node'
|
// protected type = 'node'
|
||||||
|
|
||||||
get type() {
|
// get type() {
|
||||||
return 'node'
|
// return 'node'
|
||||||
}
|
// }
|
||||||
|
|
||||||
get view(): any {
|
// get view(): any {
|
||||||
return null
|
// return null
|
||||||
}
|
// }
|
||||||
|
|
||||||
get schema(): any {
|
// get schema(): any {
|
||||||
return null
|
// return null
|
||||||
}
|
// }
|
||||||
|
|
||||||
command() {
|
public abstract schema: any
|
||||||
return () => {}
|
|
||||||
}
|
// command() {
|
||||||
|
// return () => {}
|
||||||
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,18 +2,6 @@ import { Node } from '@tiptap/core'
|
|||||||
|
|
||||||
export default class Document extends Node {
|
export default class Document extends Node {
|
||||||
|
|
||||||
// get name() {
|
|
||||||
// return 'document'
|
|
||||||
// }
|
|
||||||
|
|
||||||
// get schema() {
|
|
||||||
// return {
|
|
||||||
// content: 'block+',
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// type = 'nope'
|
|
||||||
|
|
||||||
name = 'document'
|
name = 'document'
|
||||||
|
|
||||||
schema = {
|
schema = {
|
||||||
|
|||||||
17
packages/tiptap-document-extension/package.json
Normal file
17
packages/tiptap-document-extension/package.json
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"name": "@tiptap/document-extension",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"source": "index.ts",
|
||||||
|
"main": "dist/tiptap-document-extension.js",
|
||||||
|
"umd:main": "dist/tiptap-document-extension.umd.js",
|
||||||
|
"module": "dist/tiptap-document-extension.mjs",
|
||||||
|
"unpkg": "dist/tiptap-document-extension.js",
|
||||||
|
"jsdelivr": "dist/tiptap-document-extension.js",
|
||||||
|
"files": [
|
||||||
|
"src",
|
||||||
|
"dist"
|
||||||
|
],
|
||||||
|
"peerDependencies": {
|
||||||
|
"@tiptap/core": "2.x"
|
||||||
|
}
|
||||||
|
}
|
||||||
15
packages/tiptap-paragraph-extension/index.ts
Normal file
15
packages/tiptap-paragraph-extension/index.ts
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
import { Node } from '@tiptap/core'
|
||||||
|
|
||||||
|
export default class Paragraph extends Node {
|
||||||
|
|
||||||
|
name = 'paragraph'
|
||||||
|
|
||||||
|
schema = {
|
||||||
|
content: 'inline*',
|
||||||
|
group: 'block',
|
||||||
|
draggable: false,
|
||||||
|
parseDOM: [{ tag: 'p' }],
|
||||||
|
toDOM: () => ['p', 0],
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
17
packages/tiptap-paragraph-extension/package.json
Normal file
17
packages/tiptap-paragraph-extension/package.json
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"name": "@tiptap/paragraph-extension",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"source": "index.ts",
|
||||||
|
"main": "dist/tiptap-paragraph-extension.js",
|
||||||
|
"umd:main": "dist/tiptap-paragraph-extension.umd.js",
|
||||||
|
"module": "dist/tiptap-paragraph-extension.mjs",
|
||||||
|
"unpkg": "dist/tiptap-paragraph-extension.js",
|
||||||
|
"jsdelivr": "dist/tiptap-paragraph-extension.js",
|
||||||
|
"files": [
|
||||||
|
"src",
|
||||||
|
"dist"
|
||||||
|
],
|
||||||
|
"peerDependencies": {
|
||||||
|
"@tiptap/core": "2.x"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@tiptap/vue",
|
"name": "@tiptap/vue",
|
||||||
"version": "0.1.0",
|
"version": "1.0.0",
|
||||||
"source": "index.ts",
|
"source": "index.ts",
|
||||||
"main": "dist/tiptap-vue.js",
|
"main": "dist/tiptap-vue.js",
|
||||||
"umd:main": "dist/tiptap-vue.umd.js",
|
"umd:main": "dist/tiptap-vue.umd.js",
|
||||||
|
|||||||
@@ -6,12 +6,18 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import Editor from '@tiptap/core'
|
import Editor from '@tiptap/core'
|
||||||
|
import Doc from '@tiptap/document-extension'
|
||||||
|
import Paragraph from '@tiptap/paragraph-extension'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
mounted() {
|
mounted() {
|
||||||
window.editor = new Editor({
|
window.editor = new Editor({
|
||||||
element: this.$refs.editor,
|
element: this.$refs.editor,
|
||||||
content: '<p>foo</p>',
|
content: '<p>foo</p>',
|
||||||
|
extensions: [
|
||||||
|
new Doc(),
|
||||||
|
new Paragraph(),
|
||||||
|
],
|
||||||
})
|
})
|
||||||
// .focus('end')
|
// .focus('end')
|
||||||
// .insertText('foo')
|
// .insertText('foo')
|
||||||
|
|||||||
Reference in New Issue
Block a user