@tiptap/core 2.0.0-beta.182 → 2.0.0-beta.193
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -3
- package/src/CommandManager.ts +2 -2
- package/src/Editor.ts +1 -0
- package/src/ExtensionManager.ts +13 -4
- package/src/Mark.ts +39 -0
- package/src/PasteRule.ts +1 -1
- package/src/commands/setNodeSelection.ts +3 -5
- package/src/commands/splitBlock.ts +1 -12
- package/src/helpers/isNodeSelection.ts +1 -3
- package/src/helpers/isTextSelection.ts +1 -3
- package/src/pasteRules/nodePasteRule.ts +1 -1
- package/LICENSE.md +0 -21
- package/dist/packages/core/src/CommandManager.d.ts +0 -20
- package/dist/packages/core/src/Editor.d.ts +0 -147
- package/dist/packages/core/src/EventEmitter.d.ts +0 -11
- package/dist/packages/core/src/Extension.d.ts +0 -227
- package/dist/packages/core/src/ExtensionManager.d.ts +0 -18
- package/dist/packages/core/src/InputRule.d.ts +0 -42
- package/dist/packages/core/src/Mark.d.ts +0 -319
- package/dist/packages/core/src/Node.d.ts +0 -397
- package/dist/packages/core/src/NodeView.d.ts +0 -27
- package/dist/packages/core/src/PasteRule.d.ts +0 -42
- package/dist/packages/core/src/Tracker.d.ts +0 -11
- package/dist/packages/core/src/commands/blur.d.ts +0 -12
- package/dist/packages/core/src/commands/clearContent.d.ts +0 -12
- package/dist/packages/core/src/commands/clearNodes.d.ts +0 -12
- package/dist/packages/core/src/commands/command.d.ts +0 -12
- package/dist/packages/core/src/commands/createParagraphNear.d.ts +0 -12
- package/dist/packages/core/src/commands/deleteNode.d.ts +0 -13
- package/dist/packages/core/src/commands/deleteRange.d.ts +0 -12
- package/dist/packages/core/src/commands/deleteSelection.d.ts +0 -12
- package/dist/packages/core/src/commands/enter.d.ts +0 -12
- package/dist/packages/core/src/commands/exitCode.d.ts +0 -12
- package/dist/packages/core/src/commands/extendMarkRange.d.ts +0 -13
- package/dist/packages/core/src/commands/first.d.ts +0 -12
- package/dist/packages/core/src/commands/focus.d.ts +0 -14
- package/dist/packages/core/src/commands/forEach.d.ts +0 -14
- package/dist/packages/core/src/commands/index.d.ts +0 -50
- package/dist/packages/core/src/commands/insertContent.d.ts +0 -16
- package/dist/packages/core/src/commands/insertContentAt.d.ts +0 -16
- package/dist/packages/core/src/commands/joinBackward.d.ts +0 -12
- package/dist/packages/core/src/commands/joinForward.d.ts +0 -12
- package/dist/packages/core/src/commands/keyboardShortcut.d.ts +0 -12
- package/dist/packages/core/src/commands/lift.d.ts +0 -13
- package/dist/packages/core/src/commands/liftEmptyBlock.d.ts +0 -12
- package/dist/packages/core/src/commands/liftListItem.d.ts +0 -13
- package/dist/packages/core/src/commands/newlineInCode.d.ts +0 -12
- package/dist/packages/core/src/commands/resetAttributes.d.ts +0 -13
- package/dist/packages/core/src/commands/scrollIntoView.d.ts +0 -12
- package/dist/packages/core/src/commands/selectAll.d.ts +0 -12
- package/dist/packages/core/src/commands/selectNodeBackward.d.ts +0 -12
- package/dist/packages/core/src/commands/selectNodeForward.d.ts +0 -12
- package/dist/packages/core/src/commands/selectParentNode.d.ts +0 -12
- package/dist/packages/core/src/commands/selectTextblockEnd.d.ts +0 -12
- package/dist/packages/core/src/commands/selectTextblockStart.d.ts +0 -12
- package/dist/packages/core/src/commands/setContent.d.ts +0 -13
- package/dist/packages/core/src/commands/setMark.d.ts +0 -13
- package/dist/packages/core/src/commands/setMeta.d.ts +0 -12
- package/dist/packages/core/src/commands/setNode.d.ts +0 -13
- package/dist/packages/core/src/commands/setNodeSelection.d.ts +0 -12
- package/dist/packages/core/src/commands/setTextSelection.d.ts +0 -12
- package/dist/packages/core/src/commands/sinkListItem.d.ts +0 -13
- package/dist/packages/core/src/commands/splitBlock.d.ts +0 -14
- package/dist/packages/core/src/commands/splitListItem.d.ts +0 -13
- package/dist/packages/core/src/commands/toggleList.d.ts +0 -13
- package/dist/packages/core/src/commands/toggleMark.d.ts +0 -18
- package/dist/packages/core/src/commands/toggleNode.d.ts +0 -13
- package/dist/packages/core/src/commands/toggleWrap.d.ts +0 -13
- package/dist/packages/core/src/commands/undoInputRule.d.ts +0 -12
- package/dist/packages/core/src/commands/unsetAllMarks.d.ts +0 -12
- package/dist/packages/core/src/commands/unsetMark.d.ts +0 -18
- package/dist/packages/core/src/commands/updateAttributes.d.ts +0 -13
- package/dist/packages/core/src/commands/wrapIn.d.ts +0 -13
- package/dist/packages/core/src/commands/wrapInList.d.ts +0 -13
- package/dist/packages/core/src/extensions/clipboardTextSerializer.d.ts +0 -2
- package/dist/packages/core/src/extensions/commands.d.ts +0 -3
- package/dist/packages/core/src/extensions/editable.d.ts +0 -2
- package/dist/packages/core/src/extensions/focusEvents.d.ts +0 -2
- package/dist/packages/core/src/extensions/index.d.ts +0 -6
- package/dist/packages/core/src/extensions/keymap.d.ts +0 -2
- package/dist/packages/core/src/extensions/tabindex.d.ts +0 -2
- package/dist/packages/core/src/helpers/combineTransactionSteps.d.ts +0 -7
- package/dist/packages/core/src/helpers/createChainableState.d.ts +0 -5
- package/dist/packages/core/src/helpers/createDocument.d.ts +0 -3
- package/dist/packages/core/src/helpers/createNodeFromContent.d.ts +0 -7
- package/dist/packages/core/src/helpers/defaultBlockAt.d.ts +0 -2
- package/dist/packages/core/src/helpers/findChildren.d.ts +0 -3
- package/dist/packages/core/src/helpers/findChildrenInRange.d.ts +0 -6
- package/dist/packages/core/src/helpers/findParentNode.d.ts +0 -8
- package/dist/packages/core/src/helpers/findParentNodeClosestToPos.d.ts +0 -8
- package/dist/packages/core/src/helpers/generateHTML.d.ts +0 -2
- package/dist/packages/core/src/helpers/generateJSON.d.ts +0 -2
- package/dist/packages/core/src/helpers/generateText.d.ts +0 -5
- package/dist/packages/core/src/helpers/getAttributes.d.ts +0 -3
- package/dist/packages/core/src/helpers/getAttributesFromExtensions.d.ts +0 -6
- package/dist/packages/core/src/helpers/getChangedRanges.d.ts +0 -11
- package/dist/packages/core/src/helpers/getDebugJSON.d.ts +0 -8
- package/dist/packages/core/src/helpers/getExtensionField.d.ts +0 -2
- package/dist/packages/core/src/helpers/getHTMLFromFragment.d.ts +0 -2
- package/dist/packages/core/src/helpers/getMarkAttributes.d.ts +0 -3
- package/dist/packages/core/src/helpers/getMarkRange.d.ts +0 -3
- package/dist/packages/core/src/helpers/getMarkType.d.ts +0 -2
- package/dist/packages/core/src/helpers/getMarksBetween.d.ts +0 -3
- package/dist/packages/core/src/helpers/getNodeAttributes.d.ts +0 -3
- package/dist/packages/core/src/helpers/getNodeType.d.ts +0 -2
- package/dist/packages/core/src/helpers/getRenderedAttributes.d.ts +0 -3
- package/dist/packages/core/src/helpers/getSchema.d.ts +0 -3
- package/dist/packages/core/src/helpers/getSchemaByResolvedExtensions.d.ts +0 -3
- package/dist/packages/core/src/helpers/getSchemaTypeByName.d.ts +0 -2
- package/dist/packages/core/src/helpers/getSchemaTypeNameByName.d.ts +0 -2
- package/dist/packages/core/src/helpers/getSplittedAttributes.d.ts +0 -2
- package/dist/packages/core/src/helpers/getText.d.ts +0 -6
- package/dist/packages/core/src/helpers/getTextBetween.d.ts +0 -6
- package/dist/packages/core/src/helpers/getTextContentFromNodes.d.ts +0 -2
- package/dist/packages/core/src/helpers/getTextSerializersFromSchema.d.ts +0 -3
- package/dist/packages/core/src/helpers/index.d.ts +0 -33
- package/dist/packages/core/src/helpers/injectExtensionAttributesToParseRule.d.ts +0 -9
- package/dist/packages/core/src/helpers/isActive.d.ts +0 -2
- package/dist/packages/core/src/helpers/isExtensionRulesEnabled.d.ts +0 -2
- package/dist/packages/core/src/helpers/isList.d.ts +0 -2
- package/dist/packages/core/src/helpers/isMarkActive.d.ts +0 -3
- package/dist/packages/core/src/helpers/isNodeActive.d.ts +0 -3
- package/dist/packages/core/src/helpers/isNodeEmpty.d.ts +0 -2
- package/dist/packages/core/src/helpers/isNodeSelection.d.ts +0 -2
- package/dist/packages/core/src/helpers/isTextSelection.d.ts +0 -2
- package/dist/packages/core/src/helpers/posToDOMRect.d.ts +0 -2
- package/dist/packages/core/src/helpers/resolveFocusPosition.d.ts +0 -4
- package/dist/packages/core/src/helpers/selectionToInsertionEnd.d.ts +0 -2
- package/dist/packages/core/src/helpers/splitExtensions.d.ts +0 -9
- package/dist/packages/core/src/index.d.ts +0 -23
- package/dist/packages/core/src/inputRules/index.d.ts +0 -5
- package/dist/packages/core/src/inputRules/markInputRule.d.ts +0 -12
- package/dist/packages/core/src/inputRules/nodeInputRule.d.ts +0 -12
- package/dist/packages/core/src/inputRules/textInputRule.d.ts +0 -9
- package/dist/packages/core/src/inputRules/textblockTypeInputRule.d.ts +0 -14
- package/dist/packages/core/src/inputRules/wrappingInputRule.d.ts +0 -23
- package/dist/packages/core/src/pasteRules/index.d.ts +0 -3
- package/dist/packages/core/src/pasteRules/markPasteRule.d.ts +0 -12
- package/dist/packages/core/src/pasteRules/nodePasteRule.d.ts +0 -12
- package/dist/packages/core/src/pasteRules/textPasteRule.d.ts +0 -9
- package/dist/packages/core/src/style.d.ts +0 -1
- package/dist/packages/core/src/types.d.ts +0 -213
- package/dist/packages/core/src/utilities/callOrReturn.d.ts +0 -9
- package/dist/packages/core/src/utilities/createStyleTag.d.ts +0 -1
- package/dist/packages/core/src/utilities/deleteProps.d.ts +0 -6
- package/dist/packages/core/src/utilities/elementFromString.d.ts +0 -1
- package/dist/packages/core/src/utilities/escapeForRegEx.d.ts +0 -1
- package/dist/packages/core/src/utilities/findDuplicates.d.ts +0 -1
- package/dist/packages/core/src/utilities/fromString.d.ts +0 -1
- package/dist/packages/core/src/utilities/index.d.ts +0 -3
- package/dist/packages/core/src/utilities/isClass.d.ts +0 -1
- package/dist/packages/core/src/utilities/isEmptyObject.d.ts +0 -1
- package/dist/packages/core/src/utilities/isFunction.d.ts +0 -1
- package/dist/packages/core/src/utilities/isMacOS.d.ts +0 -1
- package/dist/packages/core/src/utilities/isNumber.d.ts +0 -1
- package/dist/packages/core/src/utilities/isObject.d.ts +0 -1
- package/dist/packages/core/src/utilities/isPlainObject.d.ts +0 -1
- package/dist/packages/core/src/utilities/isRegExp.d.ts +0 -1
- package/dist/packages/core/src/utilities/isiOS.d.ts +0 -1
- package/dist/packages/core/src/utilities/mergeAttributes.d.ts +0 -1
- package/dist/packages/core/src/utilities/mergeDeep.d.ts +0 -1
- package/dist/packages/core/src/utilities/minMax.d.ts +0 -1
- package/dist/packages/core/src/utilities/objectIncludes.d.ts +0 -8
- package/dist/packages/core/src/utilities/removeDuplicates.d.ts +0 -8
- package/dist/tiptap-core.cjs.js +0 -4275
- package/dist/tiptap-core.cjs.js.map +0 -1
- package/dist/tiptap-core.esm.js +0 -4216
- package/dist/tiptap-core.esm.js.map +0 -1
- package/dist/tiptap-core.umd.js +0 -4273
- package/dist/tiptap-core.umd.js.map +0 -1
- package/src/utilities/isClass.ts +0 -7
- package/src/utilities/isObject.ts +0 -10
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tiptap/core",
|
|
3
3
|
"description": "headless rich text editor",
|
|
4
|
-
"version": "2.0.0-beta.
|
|
4
|
+
"version": "2.0.0-beta.193",
|
|
5
5
|
"homepage": "https://tiptap.dev",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"tiptap",
|
|
@@ -37,6 +37,5 @@
|
|
|
37
37
|
"url": "https://github.com/ueberdosis/tiptap",
|
|
38
38
|
"directory": "packages/core"
|
|
39
39
|
},
|
|
40
|
-
"sideEffects": false
|
|
41
|
-
"gitHead": "3e05093f00dd4f52ddefeb2451622d3661a25123"
|
|
40
|
+
"sideEffects": false
|
|
42
41
|
}
|
package/src/CommandManager.ts
CHANGED
|
@@ -107,13 +107,13 @@ export class CommandManager {
|
|
|
107
107
|
|
|
108
108
|
public createCan(startTr?: Transaction): CanCommands {
|
|
109
109
|
const { rawCommands, state } = this
|
|
110
|
-
const dispatch =
|
|
110
|
+
const dispatch = false
|
|
111
111
|
const tr = startTr || state.tr
|
|
112
112
|
const props = this.buildProps(tr, dispatch)
|
|
113
113
|
const formattedCommands = Object.fromEntries(Object
|
|
114
114
|
.entries(rawCommands)
|
|
115
115
|
.map(([name, command]) => {
|
|
116
|
-
return [name, (...args: never[]) => command(...args)({ ...props, dispatch })]
|
|
116
|
+
return [name, (...args: never[]) => command(...args)({ ...props, dispatch: undefined })]
|
|
117
117
|
})) as unknown as SingleCommands
|
|
118
118
|
|
|
119
119
|
return {
|
package/src/Editor.ts
CHANGED
package/src/ExtensionManager.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { Node as ProsemirrorNode, Schema } from 'prosemirror-model'
|
|
|
3
3
|
import { Plugin } from 'prosemirror-state'
|
|
4
4
|
import { Decoration, EditorView } from 'prosemirror-view'
|
|
5
5
|
|
|
6
|
-
import { NodeConfig } from '.'
|
|
6
|
+
import { Mark, NodeConfig } from '.'
|
|
7
7
|
import { Editor } from './Editor'
|
|
8
8
|
import { getAttributesFromExtensions } from './helpers/getAttributesFromExtensions'
|
|
9
9
|
import { getExtensionField } from './helpers/getExtensionField'
|
|
@@ -252,6 +252,13 @@ export class ExtensionManager {
|
|
|
252
252
|
context,
|
|
253
253
|
)
|
|
254
254
|
|
|
255
|
+
let defaultBindings: Record<string, () => boolean> = {}
|
|
256
|
+
|
|
257
|
+
// bind exit handling
|
|
258
|
+
if (extension.type === 'mark' && extension.config.exitable) {
|
|
259
|
+
defaultBindings.ArrowRight = () => Mark.handleExit({ editor, mark: (extension as Mark) })
|
|
260
|
+
}
|
|
261
|
+
|
|
255
262
|
if (addKeyboardShortcuts) {
|
|
256
263
|
const bindings = Object.fromEntries(
|
|
257
264
|
Object
|
|
@@ -261,11 +268,13 @@ export class ExtensionManager {
|
|
|
261
268
|
}),
|
|
262
269
|
)
|
|
263
270
|
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
plugins.push(keyMapPlugin)
|
|
271
|
+
defaultBindings = { ...defaultBindings, ...bindings }
|
|
267
272
|
}
|
|
268
273
|
|
|
274
|
+
const keyMapPlugin = keymap(defaultBindings)
|
|
275
|
+
|
|
276
|
+
plugins.push(keyMapPlugin)
|
|
277
|
+
|
|
269
278
|
const addInputRules = getExtensionField<AnyConfig['addInputRules']>(
|
|
270
279
|
extension,
|
|
271
280
|
'addInputRules',
|
package/src/Mark.ts
CHANGED
|
@@ -304,6 +304,11 @@ declare module '@tiptap/core' {
|
|
|
304
304
|
parent: ParentConfig<MarkConfig<Options, Storage>>['excludes'],
|
|
305
305
|
}) => MarkSpec['excludes']),
|
|
306
306
|
|
|
307
|
+
/**
|
|
308
|
+
* Marks this Mark as exitable
|
|
309
|
+
*/
|
|
310
|
+
exitable?: boolean | (() => boolean),
|
|
311
|
+
|
|
307
312
|
/**
|
|
308
313
|
* Group
|
|
309
314
|
*/
|
|
@@ -486,4 +491,38 @@ export class Mark<Options = any, Storage = any> {
|
|
|
486
491
|
|
|
487
492
|
return extension
|
|
488
493
|
}
|
|
494
|
+
|
|
495
|
+
static handleExit({
|
|
496
|
+
editor,
|
|
497
|
+
mark,
|
|
498
|
+
}: {
|
|
499
|
+
editor: Editor
|
|
500
|
+
mark: Mark
|
|
501
|
+
}) {
|
|
502
|
+
const { tr } = editor.state
|
|
503
|
+
const currentPos = editor.state.selection.$from
|
|
504
|
+
const isAtEnd = currentPos.pos === currentPos.end()
|
|
505
|
+
|
|
506
|
+
if (isAtEnd) {
|
|
507
|
+
const currentMarks = currentPos.marks()
|
|
508
|
+
const isInMark = !!currentMarks.find(m => m?.type.name === mark.name)
|
|
509
|
+
|
|
510
|
+
if (!isInMark) {
|
|
511
|
+
return false
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
const removeMark = currentMarks.find(m => m?.type.name === mark.name)
|
|
515
|
+
|
|
516
|
+
if (removeMark) {
|
|
517
|
+
tr.removeStoredMark(removeMark)
|
|
518
|
+
}
|
|
519
|
+
tr.insertText(' ', currentPos.pos)
|
|
520
|
+
|
|
521
|
+
editor.view.dispatch(tr)
|
|
522
|
+
|
|
523
|
+
return true
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
return false
|
|
527
|
+
}
|
|
489
528
|
}
|
package/src/PasteRule.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NodeSelection
|
|
1
|
+
import { NodeSelection } from 'prosemirror-state'
|
|
2
2
|
|
|
3
3
|
import { RawCommands } from '../types'
|
|
4
4
|
import { minMax } from '../utilities/minMax'
|
|
@@ -17,10 +17,8 @@ declare module '@tiptap/core' {
|
|
|
17
17
|
export const setNodeSelection: RawCommands['setNodeSelection'] = position => ({ tr, dispatch }) => {
|
|
18
18
|
if (dispatch) {
|
|
19
19
|
const { doc } = tr
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
const resolvedPos = minMax(position, minPos, maxPos)
|
|
23
|
-
const selection = NodeSelection.create(doc, resolvedPos)
|
|
20
|
+
const from = minMax(position, 0, doc.content.size)
|
|
21
|
+
const selection = NodeSelection.create(doc, from)
|
|
24
22
|
|
|
25
23
|
tr.setSelection(selection)
|
|
26
24
|
}
|
|
@@ -1,21 +1,10 @@
|
|
|
1
|
-
import { ContentMatch } from 'prosemirror-model'
|
|
2
1
|
import { EditorState, NodeSelection, TextSelection } from 'prosemirror-state'
|
|
3
2
|
import { canSplit } from 'prosemirror-transform'
|
|
4
3
|
|
|
4
|
+
import { defaultBlockAt } from '../helpers/defaultBlockAt'
|
|
5
5
|
import { getSplittedAttributes } from '../helpers/getSplittedAttributes'
|
|
6
6
|
import { RawCommands } from '../types'
|
|
7
7
|
|
|
8
|
-
function defaultBlockAt(match: ContentMatch) {
|
|
9
|
-
for (let i = 0; i < match.edgeCount; i += 1) {
|
|
10
|
-
const { type } = match.edge(i)
|
|
11
|
-
|
|
12
|
-
if (type.isTextblock && !type.hasRequiredAttrs()) {
|
|
13
|
-
return type
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
return null
|
|
17
|
-
}
|
|
18
|
-
|
|
19
8
|
function ensureMarks(state: EditorState, splittableMarks?: string[]) {
|
|
20
9
|
const marks = state.storedMarks
|
|
21
10
|
|| (state.selection.$to.parentOffset && state.selection.$from.marks())
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { NodeSelection } from 'prosemirror-state'
|
|
2
2
|
|
|
3
|
-
import { isObject } from '../utilities/isObject'
|
|
4
|
-
|
|
5
3
|
export function isNodeSelection(value: unknown): value is NodeSelection {
|
|
6
|
-
return
|
|
4
|
+
return value instanceof NodeSelection
|
|
7
5
|
}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { TextSelection } from 'prosemirror-state'
|
|
2
2
|
|
|
3
|
-
import { isObject } from '../utilities/isObject'
|
|
4
|
-
|
|
5
3
|
export function isTextSelection(value: unknown): value is TextSelection {
|
|
6
|
-
return
|
|
4
|
+
return value instanceof TextSelection
|
|
7
5
|
}
|
package/LICENSE.md
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2021, überdosis GbR
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { EditorState, Transaction } from 'prosemirror-state';
|
|
2
|
-
import { Editor } from './Editor';
|
|
3
|
-
import { AnyCommands, CanCommands, ChainedCommands, CommandProps, SingleCommands } from './types';
|
|
4
|
-
export declare class CommandManager {
|
|
5
|
-
editor: Editor;
|
|
6
|
-
rawCommands: AnyCommands;
|
|
7
|
-
customState?: EditorState;
|
|
8
|
-
constructor(props: {
|
|
9
|
-
editor: Editor;
|
|
10
|
-
state?: EditorState;
|
|
11
|
-
});
|
|
12
|
-
get hasCustomState(): boolean;
|
|
13
|
-
get state(): EditorState;
|
|
14
|
-
get commands(): SingleCommands;
|
|
15
|
-
get chain(): () => ChainedCommands;
|
|
16
|
-
get can(): () => CanCommands;
|
|
17
|
-
createChain(startTr?: Transaction, shouldDispatch?: boolean): ChainedCommands;
|
|
18
|
-
createCan(startTr?: Transaction): CanCommands;
|
|
19
|
-
buildProps(tr: Transaction, shouldDispatch?: boolean): CommandProps;
|
|
20
|
-
}
|
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
import { MarkType, NodeType, Schema } from 'prosemirror-model';
|
|
2
|
-
import { EditorState, Plugin, PluginKey, Transaction } from 'prosemirror-state';
|
|
3
|
-
import { EditorView } from 'prosemirror-view';
|
|
4
|
-
import { EventEmitter } from './EventEmitter';
|
|
5
|
-
import { ExtensionManager } from './ExtensionManager';
|
|
6
|
-
import * as extensions from './extensions';
|
|
7
|
-
import { CanCommands, ChainedCommands, EditorEvents, EditorOptions, JSONContent, SingleCommands, TextSerializer } from './types';
|
|
8
|
-
export { extensions };
|
|
9
|
-
export interface HTMLElement {
|
|
10
|
-
editor?: Editor;
|
|
11
|
-
}
|
|
12
|
-
export declare class Editor extends EventEmitter<EditorEvents> {
|
|
13
|
-
private commandManager;
|
|
14
|
-
extensionManager: ExtensionManager;
|
|
15
|
-
private css;
|
|
16
|
-
schema: Schema;
|
|
17
|
-
view: EditorView;
|
|
18
|
-
isFocused: boolean;
|
|
19
|
-
extensionStorage: Record<string, any>;
|
|
20
|
-
options: EditorOptions;
|
|
21
|
-
constructor(options?: Partial<EditorOptions>);
|
|
22
|
-
/**
|
|
23
|
-
* Returns the editor storage.
|
|
24
|
-
*/
|
|
25
|
-
get storage(): Record<string, any>;
|
|
26
|
-
/**
|
|
27
|
-
* An object of all registered commands.
|
|
28
|
-
*/
|
|
29
|
-
get commands(): SingleCommands;
|
|
30
|
-
/**
|
|
31
|
-
* Create a command chain to call multiple commands at once.
|
|
32
|
-
*/
|
|
33
|
-
chain(): ChainedCommands;
|
|
34
|
-
/**
|
|
35
|
-
* Check if a command or a command chain can be executed. Without executing it.
|
|
36
|
-
*/
|
|
37
|
-
can(): CanCommands;
|
|
38
|
-
/**
|
|
39
|
-
* Inject CSS styles.
|
|
40
|
-
*/
|
|
41
|
-
private injectCSS;
|
|
42
|
-
/**
|
|
43
|
-
* Update editor options.
|
|
44
|
-
*
|
|
45
|
-
* @param options A list of options
|
|
46
|
-
*/
|
|
47
|
-
setOptions(options?: Partial<EditorOptions>): void;
|
|
48
|
-
/**
|
|
49
|
-
* Update editable state of the editor.
|
|
50
|
-
*/
|
|
51
|
-
setEditable(editable: boolean): void;
|
|
52
|
-
/**
|
|
53
|
-
* Returns whether the editor is editable.
|
|
54
|
-
*/
|
|
55
|
-
get isEditable(): boolean;
|
|
56
|
-
/**
|
|
57
|
-
* Returns the editor state.
|
|
58
|
-
*/
|
|
59
|
-
get state(): EditorState;
|
|
60
|
-
/**
|
|
61
|
-
* Register a ProseMirror plugin.
|
|
62
|
-
*
|
|
63
|
-
* @param plugin A ProseMirror plugin
|
|
64
|
-
* @param handlePlugins Control how to merge the plugin into the existing plugins.
|
|
65
|
-
*/
|
|
66
|
-
registerPlugin(plugin: Plugin, handlePlugins?: (newPlugin: Plugin, plugins: Plugin[]) => Plugin[]): void;
|
|
67
|
-
/**
|
|
68
|
-
* Unregister a ProseMirror plugin.
|
|
69
|
-
*
|
|
70
|
-
* @param nameOrPluginKey The plugins name
|
|
71
|
-
*/
|
|
72
|
-
unregisterPlugin(nameOrPluginKey: string | PluginKey): void;
|
|
73
|
-
/**
|
|
74
|
-
* Creates an extension manager.
|
|
75
|
-
*/
|
|
76
|
-
private createExtensionManager;
|
|
77
|
-
/**
|
|
78
|
-
* Creates an command manager.
|
|
79
|
-
*/
|
|
80
|
-
private createCommandManager;
|
|
81
|
-
/**
|
|
82
|
-
* Creates a ProseMirror schema.
|
|
83
|
-
*/
|
|
84
|
-
private createSchema;
|
|
85
|
-
/**
|
|
86
|
-
* Creates a ProseMirror view.
|
|
87
|
-
*/
|
|
88
|
-
private createView;
|
|
89
|
-
/**
|
|
90
|
-
* Creates all node views.
|
|
91
|
-
*/
|
|
92
|
-
createNodeViews(): void;
|
|
93
|
-
isCapturingTransaction: boolean;
|
|
94
|
-
private capturedTransaction;
|
|
95
|
-
captureTransaction(fn: Function): Transaction | null;
|
|
96
|
-
/**
|
|
97
|
-
* The callback over which to send transactions (state updates) produced by the view.
|
|
98
|
-
*
|
|
99
|
-
* @param transaction An editor state transaction
|
|
100
|
-
*/
|
|
101
|
-
private dispatchTransaction;
|
|
102
|
-
/**
|
|
103
|
-
* Get attributes of the currently selected node or mark.
|
|
104
|
-
*/
|
|
105
|
-
getAttributes(nameOrType: string | NodeType | MarkType): Record<string, any>;
|
|
106
|
-
/**
|
|
107
|
-
* Returns if the currently selected node or mark is active.
|
|
108
|
-
*
|
|
109
|
-
* @param name Name of the node or mark
|
|
110
|
-
* @param attributes Attributes of the node or mark
|
|
111
|
-
*/
|
|
112
|
-
isActive(name: string, attributes?: {}): boolean;
|
|
113
|
-
isActive(attributes: {}): boolean;
|
|
114
|
-
/**
|
|
115
|
-
* Get the document as JSON.
|
|
116
|
-
*/
|
|
117
|
-
getJSON(): JSONContent;
|
|
118
|
-
/**
|
|
119
|
-
* Get the document as HTML.
|
|
120
|
-
*/
|
|
121
|
-
getHTML(): string;
|
|
122
|
-
/**
|
|
123
|
-
* Get the document as text.
|
|
124
|
-
*/
|
|
125
|
-
getText(options?: {
|
|
126
|
-
blockSeparator?: string;
|
|
127
|
-
textSerializers?: Record<string, TextSerializer>;
|
|
128
|
-
}): string;
|
|
129
|
-
/**
|
|
130
|
-
* Check if there is no content.
|
|
131
|
-
*/
|
|
132
|
-
get isEmpty(): boolean;
|
|
133
|
-
/**
|
|
134
|
-
* Get the number of characters for the current document.
|
|
135
|
-
*
|
|
136
|
-
* @deprecated
|
|
137
|
-
*/
|
|
138
|
-
getCharacterCount(): number;
|
|
139
|
-
/**
|
|
140
|
-
* Destroy the editor.
|
|
141
|
-
*/
|
|
142
|
-
destroy(): void;
|
|
143
|
-
/**
|
|
144
|
-
* Check if the editor is already destroyed.
|
|
145
|
-
*/
|
|
146
|
-
get isDestroyed(): boolean;
|
|
147
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
declare type StringKeyOf<T> = Extract<keyof T, string>;
|
|
2
|
-
declare type CallbackType<T extends Record<string, any>, EventName extends StringKeyOf<T>> = T[EventName] extends any[] ? T[EventName] : [T[EventName]];
|
|
3
|
-
declare type CallbackFunction<T extends Record<string, any>, EventName extends StringKeyOf<T>> = (...props: CallbackType<T, EventName>) => any;
|
|
4
|
-
export declare class EventEmitter<T extends Record<string, any>> {
|
|
5
|
-
private callbacks;
|
|
6
|
-
on<EventName extends StringKeyOf<T>>(event: EventName, fn: CallbackFunction<T, EventName>): this;
|
|
7
|
-
protected emit<EventName extends StringKeyOf<T>>(event: EventName, ...args: CallbackType<T, EventName>): this;
|
|
8
|
-
off<EventName extends StringKeyOf<T>>(event: EventName, fn?: CallbackFunction<T, EventName>): this;
|
|
9
|
-
protected removeAllListeners(): void;
|
|
10
|
-
}
|
|
11
|
-
export {};
|
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
import { Plugin, Transaction } from 'prosemirror-state';
|
|
2
|
-
import { ExtensionConfig } from '.';
|
|
3
|
-
import { Editor } from './Editor';
|
|
4
|
-
import { InputRule } from './InputRule';
|
|
5
|
-
import { Mark } from './Mark';
|
|
6
|
-
import { Node } from './Node';
|
|
7
|
-
import { PasteRule } from './PasteRule';
|
|
8
|
-
import { Extensions, GlobalAttributes, KeyboardShortcutCommand, ParentConfig, RawCommands } from './types';
|
|
9
|
-
declare module '@tiptap/core' {
|
|
10
|
-
interface ExtensionConfig<Options = any, Storage = any> {
|
|
11
|
-
[key: string]: any;
|
|
12
|
-
/**
|
|
13
|
-
* Name
|
|
14
|
-
*/
|
|
15
|
-
name: string;
|
|
16
|
-
/**
|
|
17
|
-
* Priority
|
|
18
|
-
*/
|
|
19
|
-
priority?: number;
|
|
20
|
-
/**
|
|
21
|
-
* Default options
|
|
22
|
-
*/
|
|
23
|
-
defaultOptions?: Options;
|
|
24
|
-
/**
|
|
25
|
-
* Default Options
|
|
26
|
-
*/
|
|
27
|
-
addOptions?: (this: {
|
|
28
|
-
name: string;
|
|
29
|
-
parent: Exclude<ParentConfig<ExtensionConfig<Options, Storage>>['addOptions'], undefined>;
|
|
30
|
-
}) => Options;
|
|
31
|
-
/**
|
|
32
|
-
* Default Storage
|
|
33
|
-
*/
|
|
34
|
-
addStorage?: (this: {
|
|
35
|
-
name: string;
|
|
36
|
-
options: Options;
|
|
37
|
-
parent: Exclude<ParentConfig<ExtensionConfig<Options, Storage>>['addStorage'], undefined>;
|
|
38
|
-
}) => Storage;
|
|
39
|
-
/**
|
|
40
|
-
* Global attributes
|
|
41
|
-
*/
|
|
42
|
-
addGlobalAttributes?: (this: {
|
|
43
|
-
name: string;
|
|
44
|
-
options: Options;
|
|
45
|
-
storage: Storage;
|
|
46
|
-
parent: ParentConfig<ExtensionConfig<Options, Storage>>['addGlobalAttributes'];
|
|
47
|
-
}) => GlobalAttributes | {};
|
|
48
|
-
/**
|
|
49
|
-
* Raw
|
|
50
|
-
*/
|
|
51
|
-
addCommands?: (this: {
|
|
52
|
-
name: string;
|
|
53
|
-
options: Options;
|
|
54
|
-
storage: Storage;
|
|
55
|
-
editor: Editor;
|
|
56
|
-
parent: ParentConfig<ExtensionConfig<Options, Storage>>['addCommands'];
|
|
57
|
-
}) => Partial<RawCommands>;
|
|
58
|
-
/**
|
|
59
|
-
* Keyboard shortcuts
|
|
60
|
-
*/
|
|
61
|
-
addKeyboardShortcuts?: (this: {
|
|
62
|
-
name: string;
|
|
63
|
-
options: Options;
|
|
64
|
-
storage: Storage;
|
|
65
|
-
editor: Editor;
|
|
66
|
-
parent: ParentConfig<ExtensionConfig<Options, Storage>>['addKeyboardShortcuts'];
|
|
67
|
-
}) => {
|
|
68
|
-
[key: string]: KeyboardShortcutCommand;
|
|
69
|
-
};
|
|
70
|
-
/**
|
|
71
|
-
* Input rules
|
|
72
|
-
*/
|
|
73
|
-
addInputRules?: (this: {
|
|
74
|
-
name: string;
|
|
75
|
-
options: Options;
|
|
76
|
-
storage: Storage;
|
|
77
|
-
editor: Editor;
|
|
78
|
-
parent: ParentConfig<ExtensionConfig<Options, Storage>>['addInputRules'];
|
|
79
|
-
}) => InputRule[];
|
|
80
|
-
/**
|
|
81
|
-
* Paste rules
|
|
82
|
-
*/
|
|
83
|
-
addPasteRules?: (this: {
|
|
84
|
-
name: string;
|
|
85
|
-
options: Options;
|
|
86
|
-
storage: Storage;
|
|
87
|
-
editor: Editor;
|
|
88
|
-
parent: ParentConfig<ExtensionConfig<Options, Storage>>['addPasteRules'];
|
|
89
|
-
}) => PasteRule[];
|
|
90
|
-
/**
|
|
91
|
-
* ProseMirror plugins
|
|
92
|
-
*/
|
|
93
|
-
addProseMirrorPlugins?: (this: {
|
|
94
|
-
name: string;
|
|
95
|
-
options: Options;
|
|
96
|
-
storage: Storage;
|
|
97
|
-
editor: Editor;
|
|
98
|
-
parent: ParentConfig<ExtensionConfig<Options, Storage>>['addProseMirrorPlugins'];
|
|
99
|
-
}) => Plugin[];
|
|
100
|
-
/**
|
|
101
|
-
* Extensions
|
|
102
|
-
*/
|
|
103
|
-
addExtensions?: (this: {
|
|
104
|
-
name: string;
|
|
105
|
-
options: Options;
|
|
106
|
-
storage: Storage;
|
|
107
|
-
parent: ParentConfig<ExtensionConfig<Options, Storage>>['addExtensions'];
|
|
108
|
-
}) => Extensions;
|
|
109
|
-
/**
|
|
110
|
-
* Extend Node Schema
|
|
111
|
-
*/
|
|
112
|
-
extendNodeSchema?: ((this: {
|
|
113
|
-
name: string;
|
|
114
|
-
options: Options;
|
|
115
|
-
storage: Storage;
|
|
116
|
-
parent: ParentConfig<ExtensionConfig<Options, Storage>>['extendNodeSchema'];
|
|
117
|
-
}, extension: Node) => Record<string, any>) | null;
|
|
118
|
-
/**
|
|
119
|
-
* Extend Mark Schema
|
|
120
|
-
*/
|
|
121
|
-
extendMarkSchema?: ((this: {
|
|
122
|
-
name: string;
|
|
123
|
-
options: Options;
|
|
124
|
-
storage: Storage;
|
|
125
|
-
parent: ParentConfig<ExtensionConfig<Options, Storage>>['extendMarkSchema'];
|
|
126
|
-
}, extension: Mark) => Record<string, any>) | null;
|
|
127
|
-
/**
|
|
128
|
-
* The editor is not ready yet.
|
|
129
|
-
*/
|
|
130
|
-
onBeforeCreate?: ((this: {
|
|
131
|
-
name: string;
|
|
132
|
-
options: Options;
|
|
133
|
-
storage: Storage;
|
|
134
|
-
editor: Editor;
|
|
135
|
-
parent: ParentConfig<ExtensionConfig<Options, Storage>>['onBeforeCreate'];
|
|
136
|
-
}) => void) | null;
|
|
137
|
-
/**
|
|
138
|
-
* The editor is ready.
|
|
139
|
-
*/
|
|
140
|
-
onCreate?: ((this: {
|
|
141
|
-
name: string;
|
|
142
|
-
options: Options;
|
|
143
|
-
storage: Storage;
|
|
144
|
-
editor: Editor;
|
|
145
|
-
parent: ParentConfig<ExtensionConfig<Options, Storage>>['onCreate'];
|
|
146
|
-
}) => void) | null;
|
|
147
|
-
/**
|
|
148
|
-
* The content has changed.
|
|
149
|
-
*/
|
|
150
|
-
onUpdate?: ((this: {
|
|
151
|
-
name: string;
|
|
152
|
-
options: Options;
|
|
153
|
-
storage: Storage;
|
|
154
|
-
editor: Editor;
|
|
155
|
-
parent: ParentConfig<ExtensionConfig<Options, Storage>>['onUpdate'];
|
|
156
|
-
}) => void) | null;
|
|
157
|
-
/**
|
|
158
|
-
* The selection has changed.
|
|
159
|
-
*/
|
|
160
|
-
onSelectionUpdate?: ((this: {
|
|
161
|
-
name: string;
|
|
162
|
-
options: Options;
|
|
163
|
-
storage: Storage;
|
|
164
|
-
editor: Editor;
|
|
165
|
-
parent: ParentConfig<ExtensionConfig<Options, Storage>>['onSelectionUpdate'];
|
|
166
|
-
}) => void) | null;
|
|
167
|
-
/**
|
|
168
|
-
* The editor state has changed.
|
|
169
|
-
*/
|
|
170
|
-
onTransaction?: ((this: {
|
|
171
|
-
name: string;
|
|
172
|
-
options: Options;
|
|
173
|
-
storage: Storage;
|
|
174
|
-
editor: Editor;
|
|
175
|
-
parent: ParentConfig<ExtensionConfig<Options, Storage>>['onTransaction'];
|
|
176
|
-
}, props: {
|
|
177
|
-
transaction: Transaction;
|
|
178
|
-
}) => void) | null;
|
|
179
|
-
/**
|
|
180
|
-
* The editor is focused.
|
|
181
|
-
*/
|
|
182
|
-
onFocus?: ((this: {
|
|
183
|
-
name: string;
|
|
184
|
-
options: Options;
|
|
185
|
-
storage: Storage;
|
|
186
|
-
editor: Editor;
|
|
187
|
-
parent: ParentConfig<ExtensionConfig<Options, Storage>>['onFocus'];
|
|
188
|
-
}, props: {
|
|
189
|
-
event: FocusEvent;
|
|
190
|
-
}) => void) | null;
|
|
191
|
-
/**
|
|
192
|
-
* The editor isn’t focused anymore.
|
|
193
|
-
*/
|
|
194
|
-
onBlur?: ((this: {
|
|
195
|
-
name: string;
|
|
196
|
-
options: Options;
|
|
197
|
-
storage: Storage;
|
|
198
|
-
editor: Editor;
|
|
199
|
-
parent: ParentConfig<ExtensionConfig<Options, Storage>>['onBlur'];
|
|
200
|
-
}, props: {
|
|
201
|
-
event: FocusEvent;
|
|
202
|
-
}) => void) | null;
|
|
203
|
-
/**
|
|
204
|
-
* The editor is destroyed.
|
|
205
|
-
*/
|
|
206
|
-
onDestroy?: ((this: {
|
|
207
|
-
name: string;
|
|
208
|
-
options: Options;
|
|
209
|
-
storage: Storage;
|
|
210
|
-
editor: Editor;
|
|
211
|
-
parent: ParentConfig<ExtensionConfig<Options, Storage>>['onDestroy'];
|
|
212
|
-
}) => void) | null;
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
export declare class Extension<Options = any, Storage = any> {
|
|
216
|
-
type: string;
|
|
217
|
-
name: string;
|
|
218
|
-
parent: Extension | null;
|
|
219
|
-
child: Extension | null;
|
|
220
|
-
options: Options;
|
|
221
|
-
storage: Storage;
|
|
222
|
-
config: ExtensionConfig;
|
|
223
|
-
constructor(config?: Partial<ExtensionConfig<Options, Storage>>);
|
|
224
|
-
static create<O = any, S = any>(config?: Partial<ExtensionConfig<O, S>>): Extension<O, S>;
|
|
225
|
-
configure(options?: Partial<Options>): Extension<Options, Storage>;
|
|
226
|
-
extend<ExtendedOptions = Options, ExtendedStorage = Storage>(extendedConfig?: Partial<ExtensionConfig<ExtendedOptions, ExtendedStorage>>): Extension<ExtendedOptions, ExtendedStorage>;
|
|
227
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { Schema } from 'prosemirror-model';
|
|
2
|
-
import { Plugin } from 'prosemirror-state';
|
|
3
|
-
import { Editor } from './Editor';
|
|
4
|
-
import { Extensions, RawCommands } from './types';
|
|
5
|
-
export declare class ExtensionManager {
|
|
6
|
-
editor: Editor;
|
|
7
|
-
schema: Schema;
|
|
8
|
-
extensions: Extensions;
|
|
9
|
-
splittableMarks: string[];
|
|
10
|
-
constructor(extensions: Extensions, editor: Editor);
|
|
11
|
-
static resolve(extensions: Extensions): Extensions;
|
|
12
|
-
static flatten(extensions: Extensions): Extensions;
|
|
13
|
-
static sort(extensions: Extensions): Extensions;
|
|
14
|
-
get commands(): RawCommands;
|
|
15
|
-
get plugins(): Plugin[];
|
|
16
|
-
get attributes(): import("@tiptap/core").ExtensionAttribute[];
|
|
17
|
-
get nodeViews(): any;
|
|
18
|
-
}
|