@tiptap/core 2.3.2 → 2.4.0
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/dist/index.cjs +273 -64
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +273 -64
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +273 -64
- package/dist/index.umd.js.map +1 -1
- package/dist/packages/core/src/Extension.d.ts +129 -14
- package/dist/packages/core/src/ExtensionManager.d.ts +37 -0
- package/dist/packages/core/src/Mark.d.ts +129 -14
- package/dist/packages/core/src/Node.d.ts +226 -30
- package/dist/packages/core/src/NodeView.d.ts +4 -0
- package/dist/packages/core/src/PasteRule.d.ts +4 -0
- package/dist/packages/core/src/commands/blur.d.ts +1 -0
- package/dist/packages/core/src/commands/clearContent.d.ts +2 -0
- package/dist/packages/core/src/commands/clearNodes.d.ts +1 -0
- package/dist/packages/core/src/commands/command.d.ts +6 -0
- package/dist/packages/core/src/commands/createParagraphNear.d.ts +1 -0
- package/dist/packages/core/src/commands/cut.d.ts +5 -0
- package/dist/packages/core/src/commands/deleteCurrentNode.d.ts +1 -0
- package/dist/packages/core/src/commands/deleteNode.d.ts +3 -1
- package/dist/packages/core/src/commands/deleteRange.d.ts +2 -0
- package/dist/packages/core/src/commands/deleteSelection.d.ts +1 -0
- package/dist/packages/core/src/commands/enter.d.ts +1 -0
- package/dist/packages/core/src/commands/exitCode.d.ts +1 -0
- package/dist/packages/core/src/commands/extendMarkRange.d.ts +14 -2
- package/dist/packages/core/src/commands/first.d.ts +2 -0
- package/dist/packages/core/src/commands/focus.d.ts +14 -1
- package/dist/packages/core/src/commands/insertContent.d.ts +17 -1
- package/dist/packages/core/src/commands/insertContentAt.d.ts +20 -1
- package/dist/packages/core/src/commands/join.d.ts +12 -4
- package/dist/packages/core/src/commands/joinItemBackward.d.ts +2 -1
- package/dist/packages/core/src/commands/joinItemForward.d.ts +2 -1
- package/dist/packages/core/src/commands/keyboardShortcut.d.ts +2 -0
- package/dist/packages/core/src/commands/lift.d.ts +5 -1
- package/dist/packages/core/src/commands/liftEmptyBlock.d.ts +2 -1
- package/dist/packages/core/src/commands/liftListItem.d.ts +3 -1
- package/dist/packages/core/src/commands/newlineInCode.d.ts +1 -0
- package/dist/packages/core/src/commands/resetAttributes.d.ts +3 -0
- package/dist/packages/core/src/commands/scrollIntoView.d.ts +1 -0
- package/dist/packages/core/src/commands/selectAll.d.ts +1 -0
- package/dist/packages/core/src/commands/selectNodeBackward.d.ts +1 -0
- package/dist/packages/core/src/commands/selectNodeForward.d.ts +1 -0
- package/dist/packages/core/src/commands/selectParentNode.d.ts +1 -0
- package/dist/packages/core/src/commands/selectTextblockEnd.d.ts +1 -0
- package/dist/packages/core/src/commands/selectTextblockStart.d.ts +1 -0
- package/dist/packages/core/src/commands/setContent.d.ts +19 -1
- package/dist/packages/core/src/commands/setMark.d.ts +2 -0
- package/dist/packages/core/src/commands/setMeta.d.ts +3 -0
- package/dist/packages/core/src/commands/setNode.d.ts +3 -0
- package/dist/packages/core/src/commands/setNodeSelection.d.ts +2 -0
- package/dist/packages/core/src/commands/setTextSelection.d.ts +2 -0
- package/dist/packages/core/src/commands/sinkListItem.d.ts +2 -0
- package/dist/packages/core/src/commands/splitBlock.d.ts +3 -0
- package/dist/packages/core/src/commands/splitListItem.d.ts +2 -0
- package/dist/packages/core/src/commands/toggleList.d.ts +5 -0
- package/dist/packages/core/src/commands/toggleMark.d.ts +13 -1
- package/dist/packages/core/src/commands/toggleNode.d.ts +4 -0
- package/dist/packages/core/src/commands/toggleWrap.d.ts +3 -0
- package/dist/packages/core/src/commands/undoInputRule.d.ts +1 -0
- package/dist/packages/core/src/commands/unsetAllMarks.d.ts +1 -0
- package/dist/packages/core/src/commands/unsetMark.d.ts +8 -1
- package/dist/packages/core/src/commands/updateAttributes.d.ts +12 -1
- package/dist/packages/core/src/commands/wrapIn.d.ts +3 -0
- package/dist/packages/core/src/commands/wrapInList.d.ts +3 -0
- package/dist/packages/core/src/helpers/combineTransactionSteps.d.ts +3 -0
- package/dist/packages/core/src/helpers/createChainableState.d.ts +5 -0
- package/dist/packages/core/src/helpers/createDocument.d.ts +7 -0
- package/dist/packages/core/src/helpers/createNodeFromContent.d.ts +7 -0
- package/dist/packages/core/src/helpers/defaultBlockAt.d.ts +5 -0
- package/dist/packages/core/src/helpers/findChildren.d.ts +6 -0
- package/dist/packages/core/src/helpers/findChildrenInRange.d.ts +4 -0
- package/dist/packages/core/src/helpers/findParentNode.d.ts +8 -0
- package/dist/packages/core/src/helpers/findParentNodeClosestToPos.d.ts +9 -0
- package/dist/packages/core/src/helpers/generateHTML.d.ts +6 -0
- package/dist/packages/core/src/helpers/generateJSON.d.ts +6 -0
- package/dist/packages/core/src/helpers/generateText.d.ts +7 -0
- package/dist/packages/core/src/helpers/getAttributes.d.ts +6 -0
- package/dist/packages/core/src/helpers/getExtensionField.d.ts +7 -0
- package/dist/packages/core/src/helpers/getSchemaByResolvedExtensions.d.ts +6 -0
- package/dist/packages/core/src/helpers/getSchemaTypeByName.d.ts +6 -0
- package/dist/packages/core/src/helpers/getSchemaTypeNameByName.d.ts +6 -0
- package/dist/packages/core/src/helpers/getSplittedAttributes.d.ts +7 -0
- package/dist/packages/core/src/helpers/getText.d.ts +9 -0
- package/dist/packages/core/src/helpers/getTextBetween.d.ts +8 -0
- package/dist/packages/core/src/helpers/getTextContentFromNodes.d.ts +6 -0
- package/dist/packages/core/src/helpers/getTextSerializersFromSchema.d.ts +5 -0
- package/dist/packages/core/src/inputRules/markInputRule.d.ts +1 -0
- package/dist/packages/core/src/inputRules/nodeInputRule.d.ts +1 -0
- package/dist/packages/core/src/inputRules/textInputRule.d.ts +1 -0
- package/dist/packages/core/src/inputRules/textblockTypeInputRule.d.ts +1 -0
- package/dist/packages/core/src/inputRules/wrappingInputRule.d.ts +1 -0
- package/dist/packages/core/src/pasteRules/markPasteRule.d.ts +1 -0
- package/dist/packages/core/src/pasteRules/nodePasteRule.d.ts +1 -0
- package/dist/packages/core/src/pasteRules/textPasteRule.d.ts +1 -0
- package/package.json +2 -2
- package/src/Extension.ts +130 -14
- package/src/ExtensionManager.ts +117 -85
- package/src/Mark.ts +129 -14
- package/src/Node.ts +226 -30
- package/src/NodeView.ts +4 -0
- package/src/PasteRule.ts +4 -0
- package/src/commands/blur.ts +1 -0
- package/src/commands/clearContent.ts +2 -0
- package/src/commands/clearNodes.ts +1 -0
- package/src/commands/command.ts +6 -0
- package/src/commands/createParagraphNear.ts +1 -0
- package/src/commands/cut.ts +5 -0
- package/src/commands/deleteCurrentNode.ts +1 -0
- package/src/commands/deleteNode.ts +3 -1
- package/src/commands/deleteRange.ts +2 -0
- package/src/commands/deleteSelection.ts +1 -0
- package/src/commands/enter.ts +1 -0
- package/src/commands/exitCode.ts +1 -0
- package/src/commands/extendMarkRange.ts +12 -1
- package/src/commands/first.ts +2 -0
- package/src/commands/focus.ts +12 -0
- package/src/commands/insertContent.ts +16 -0
- package/src/commands/insertContentAt.ts +19 -0
- package/src/commands/join.ts +12 -4
- package/src/commands/joinItemBackward.ts +2 -1
- package/src/commands/joinItemForward.ts +2 -1
- package/src/commands/keyboardShortcut.ts +2 -0
- package/src/commands/lift.ts +5 -1
- package/src/commands/liftEmptyBlock.ts +2 -1
- package/src/commands/liftListItem.ts +3 -1
- package/src/commands/newlineInCode.ts +1 -0
- package/src/commands/resetAttributes.ts +3 -0
- package/src/commands/scrollIntoView.ts +1 -0
- package/src/commands/selectAll.ts +1 -0
- package/src/commands/selectNodeBackward.ts +1 -0
- package/src/commands/selectNodeForward.ts +1 -0
- package/src/commands/selectParentNode.ts +1 -0
- package/src/commands/selectTextblockEnd.ts +1 -0
- package/src/commands/selectTextblockStart.ts +1 -0
- package/src/commands/setContent.ts +17 -0
- package/src/commands/setMark.ts +2 -0
- package/src/commands/setMeta.ts +3 -0
- package/src/commands/setNode.ts +3 -0
- package/src/commands/setNodeSelection.ts +2 -0
- package/src/commands/setTextSelection.ts +2 -0
- package/src/commands/sinkListItem.ts +2 -0
- package/src/commands/splitBlock.ts +3 -0
- package/src/commands/splitListItem.ts +2 -0
- package/src/commands/toggleList.ts +5 -0
- package/src/commands/toggleMark.ts +12 -0
- package/src/commands/toggleNode.ts +4 -0
- package/src/commands/toggleWrap.ts +3 -0
- package/src/commands/undoInputRule.ts +1 -0
- package/src/commands/unsetAllMarks.ts +1 -0
- package/src/commands/unsetMark.ts +7 -0
- package/src/commands/updateAttributes.ts +10 -0
- package/src/commands/wrapIn.ts +3 -0
- package/src/commands/wrapInList.ts +3 -0
- package/src/extensions/keymap.ts +7 -1
- package/src/helpers/combineTransactionSteps.ts +3 -0
- package/src/helpers/createChainableState.ts +5 -0
- package/src/helpers/createDocument.ts +7 -0
- package/src/helpers/createNodeFromContent.ts +16 -3
- package/src/helpers/defaultBlockAt.ts +5 -0
- package/src/helpers/findChildren.ts +6 -0
- package/src/helpers/findChildrenInRange.ts +4 -0
- package/src/helpers/findParentNode.ts +8 -0
- package/src/helpers/findParentNodeClosestToPos.ts +9 -0
- package/src/helpers/generateHTML.ts +6 -0
- package/src/helpers/generateJSON.ts +6 -0
- package/src/helpers/generateText.ts +7 -0
- package/src/helpers/getAttributes.ts +6 -0
- package/src/helpers/getExtensionField.ts +7 -0
- package/src/helpers/getSchemaByResolvedExtensions.ts +6 -0
- package/src/helpers/getSchemaTypeByName.ts +6 -0
- package/src/helpers/getSchemaTypeNameByName.ts +6 -0
- package/src/helpers/getSplittedAttributes.ts +7 -0
- package/src/helpers/getText.ts +9 -0
- package/src/helpers/getTextBetween.ts +12 -10
- package/src/helpers/getTextContentFromNodes.ts +6 -0
- package/src/helpers/getTextSerializersFromSchema.ts +5 -0
- package/src/inputRules/markInputRule.ts +1 -0
- package/src/inputRules/nodeInputRule.ts +1 -0
- package/src/inputRules/textInputRule.ts +1 -0
- package/src/inputRules/textblockTypeInputRule.ts +1 -0
- package/src/inputRules/wrappingInputRule.ts +1 -0
- package/src/pasteRules/markPasteRule.ts +1 -0
- package/src/pasteRules/nodePasteRule.ts +1 -0
- package/src/pasteRules/textPasteRule.ts +1 -0
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import { Extensions, JSONContent, TextSerializer } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Generate raw text from a JSONContent
|
|
4
|
+
* @param doc The JSONContent to generate text from
|
|
5
|
+
* @param extensions The extensions to use for the schema
|
|
6
|
+
* @param options Options for the text generation f.e. blockSeparator or textSerializers
|
|
7
|
+
* @returns The generated text
|
|
8
|
+
*/
|
|
2
9
|
export declare function generateText(doc: JSONContent, extensions: Extensions, options?: {
|
|
3
10
|
blockSeparator?: string;
|
|
4
11
|
textSerializers?: Record<string, TextSerializer>;
|
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
import { MarkType, NodeType } from '@tiptap/pm/model';
|
|
2
2
|
import { EditorState } from '@tiptap/pm/state';
|
|
3
|
+
/**
|
|
4
|
+
* Get node or mark attributes by type or name on the current editor state
|
|
5
|
+
* @param state The current editor state
|
|
6
|
+
* @param typeOrName The node or mark type or name
|
|
7
|
+
* @returns The attributes of the node or mark or an empty object
|
|
8
|
+
*/
|
|
3
9
|
export declare function getAttributes(state: EditorState, typeOrName: string | NodeType | MarkType): Record<string, any>;
|
|
@@ -1,2 +1,9 @@
|
|
|
1
1
|
import { AnyExtension, MaybeThisParameterType, RemoveThis } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Returns a field from an extension
|
|
4
|
+
* @param extension The Tiptap extension
|
|
5
|
+
* @param field The field, for example `renderHTML` or `priority`
|
|
6
|
+
* @param context The context object that should be passed as `this` into the function
|
|
7
|
+
* @returns The field value
|
|
8
|
+
*/
|
|
2
9
|
export declare function getExtensionField<T = any>(extension: AnyExtension, field: string, context?: Omit<MaybeThisParameterType<T>, 'parent'>): RemoveThis<T>;
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import { Schema } from '@tiptap/pm/model';
|
|
2
2
|
import { Editor } from '../index.js';
|
|
3
3
|
import { Extensions } from '../types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Creates a new Prosemirror schema based on the given extensions.
|
|
6
|
+
* @param extensions An array of Tiptap extensions
|
|
7
|
+
* @param editor The editor instance
|
|
8
|
+
* @returns A Prosemirror schema
|
|
9
|
+
*/
|
|
4
10
|
export declare function getSchemaByResolvedExtensions(extensions: Extensions, editor?: Editor): Schema;
|
|
@@ -1,2 +1,8 @@
|
|
|
1
1
|
import { MarkType, NodeType, Schema } from '@tiptap/pm/model';
|
|
2
|
+
/**
|
|
3
|
+
* Tries to get a node or mark type by its name.
|
|
4
|
+
* @param name The name of the node or mark type
|
|
5
|
+
* @param schema The Prosemiror schema to search in
|
|
6
|
+
* @returns The node or mark type, or null if it doesn't exist
|
|
7
|
+
*/
|
|
2
8
|
export declare function getSchemaTypeByName(name: string, schema: Schema): NodeType | MarkType | null;
|
|
@@ -1,2 +1,8 @@
|
|
|
1
1
|
import { Schema } from '@tiptap/pm/model';
|
|
2
|
+
/**
|
|
3
|
+
* Get the type of a schema item by its name.
|
|
4
|
+
* @param name The name of the schema item
|
|
5
|
+
* @param schema The Prosemiror schema to search in
|
|
6
|
+
* @returns The type of the schema item (`node` or `mark`), or null if it doesn't exist
|
|
7
|
+
*/
|
|
2
8
|
export declare function getSchemaTypeNameByName(name: string, schema: Schema): 'node' | 'mark' | null;
|
|
@@ -1,2 +1,9 @@
|
|
|
1
1
|
import { ExtensionAttribute } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Return attributes of an extension that should be splitted by keepOnSplit flag
|
|
4
|
+
* @param extensionAttributes Array of extension attributes
|
|
5
|
+
* @param typeName The type of the extension
|
|
6
|
+
* @param attributes The attributes of the extension
|
|
7
|
+
* @returns The splitted attributes
|
|
8
|
+
*/
|
|
2
9
|
export declare function getSplittedAttributes(extensionAttributes: ExtensionAttribute[], typeName: string, attributes: Record<string, any>): Record<string, any>;
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import { Node as ProseMirrorNode } from '@tiptap/pm/model';
|
|
2
2
|
import { TextSerializer } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Gets the text of a Prosemirror node
|
|
5
|
+
* @param node The Prosemirror node
|
|
6
|
+
* @param options Options for the text serializer & block separator
|
|
7
|
+
* @returns The text of the node
|
|
8
|
+
* @example ```js
|
|
9
|
+
* const text = getText(node, { blockSeparator: '\n' })
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
3
12
|
export declare function getText(node: ProseMirrorNode, options?: {
|
|
4
13
|
blockSeparator?: string;
|
|
5
14
|
textSerializers?: Record<string, TextSerializer>;
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import { Node as ProseMirrorNode } from '@tiptap/pm/model';
|
|
2
2
|
import { Range, TextSerializer } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Gets the text between two positions in a Prosemirror node
|
|
5
|
+
* and serializes it using the given text serializers and block separator (see getText)
|
|
6
|
+
* @param startNode The Prosemirror node to start from
|
|
7
|
+
* @param range The range of the text to get
|
|
8
|
+
* @param options Options for the text serializer & block separator
|
|
9
|
+
* @returns The text between the two positions
|
|
10
|
+
*/
|
|
3
11
|
export declare function getTextBetween(startNode: ProseMirrorNode, range: Range, options?: {
|
|
4
12
|
blockSeparator?: string;
|
|
5
13
|
textSerializers?: Record<string, TextSerializer>;
|
|
@@ -1,2 +1,8 @@
|
|
|
1
1
|
import { ResolvedPos } from '@tiptap/pm/model';
|
|
2
|
+
/**
|
|
3
|
+
* Returns the text content of a resolved prosemirror position
|
|
4
|
+
* @param $from The resolved position to get the text content from
|
|
5
|
+
* @param maxMatch The maximum number of characters to match
|
|
6
|
+
* @returns The text content
|
|
7
|
+
*/
|
|
2
8
|
export declare const getTextContentFromNodes: ($from: ResolvedPos, maxMatch?: number) => string;
|
|
@@ -1,3 +1,8 @@
|
|
|
1
1
|
import { Schema } from '@tiptap/pm/model';
|
|
2
2
|
import { TextSerializer } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Find text serializers `toText` in a Prosemirror schema
|
|
5
|
+
* @param schema The Prosemirror schema to search in
|
|
6
|
+
* @returns A record of text serializers by node name
|
|
7
|
+
*/
|
|
3
8
|
export declare function getTextSerializersFromSchema(schema: Schema): Record<string, TextSerializer>;
|
|
@@ -4,6 +4,7 @@ import { ExtendedRegExpMatchArray } from '../types.js';
|
|
|
4
4
|
/**
|
|
5
5
|
* Build an input rule that adds a mark when the
|
|
6
6
|
* matched text is typed into it.
|
|
7
|
+
* @see https://tiptap.dev/guide/custom-extensions/#input-rules
|
|
7
8
|
*/
|
|
8
9
|
export declare function markInputRule(config: {
|
|
9
10
|
find: InputRuleFinder;
|
|
@@ -4,6 +4,7 @@ import { ExtendedRegExpMatchArray } from '../types.js';
|
|
|
4
4
|
/**
|
|
5
5
|
* Build an input rule that adds a node when the
|
|
6
6
|
* matched text is typed into it.
|
|
7
|
+
* @see https://tiptap.dev/guide/custom-extensions/#input-rules
|
|
7
8
|
*/
|
|
8
9
|
export declare function nodeInputRule(config: {
|
|
9
10
|
/**
|
|
@@ -2,6 +2,7 @@ import { InputRule, InputRuleFinder } from '../InputRule.js';
|
|
|
2
2
|
/**
|
|
3
3
|
* Build an input rule that replaces text when the
|
|
4
4
|
* matched text is typed into it.
|
|
5
|
+
* @see https://tiptap.dev/guide/custom-extensions/#input-rules
|
|
5
6
|
*/
|
|
6
7
|
export declare function textInputRule(config: {
|
|
7
8
|
find: InputRuleFinder;
|
|
@@ -6,6 +6,7 @@ import { ExtendedRegExpMatchArray } from '../types.js';
|
|
|
6
6
|
* matched text is typed into it. When using a regular expresion you’ll
|
|
7
7
|
* probably want the regexp to start with `^`, so that the pattern can
|
|
8
8
|
* only occur at the start of a textblock.
|
|
9
|
+
* @see https://tiptap.dev/guide/custom-extensions/#input-rules
|
|
9
10
|
*/
|
|
10
11
|
export declare function textblockTypeInputRule(config: {
|
|
11
12
|
find: InputRuleFinder;
|
|
@@ -15,6 +15,7 @@ import { ExtendedRegExpMatchArray } from '../types.js';
|
|
|
15
15
|
* two nodes. You can pass a join predicate, which takes a regular
|
|
16
16
|
* expression match and the node before the wrapped node, and can
|
|
17
17
|
* return a boolean to indicate whether a join should happen.
|
|
18
|
+
* @see https://tiptap.dev/guide/custom-extensions/#input-rules
|
|
18
19
|
*/
|
|
19
20
|
export declare function wrappingInputRule(config: {
|
|
20
21
|
find: InputRuleFinder;
|
|
@@ -4,6 +4,7 @@ import { ExtendedRegExpMatchArray } from '../types.js';
|
|
|
4
4
|
/**
|
|
5
5
|
* Build an paste rule that adds a mark when the
|
|
6
6
|
* matched text is pasted into it.
|
|
7
|
+
* @see https://tiptap.dev/guide/custom-extensions/#paste-rules
|
|
7
8
|
*/
|
|
8
9
|
export declare function markPasteRule(config: {
|
|
9
10
|
find: PasteRuleFinder;
|
|
@@ -4,6 +4,7 @@ import { ExtendedRegExpMatchArray } from '../types.js';
|
|
|
4
4
|
/**
|
|
5
5
|
* Build an paste rule that adds a node when the
|
|
6
6
|
* matched text is pasted into it.
|
|
7
|
+
* @see https://tiptap.dev/guide/custom-extensions/#paste-rules
|
|
7
8
|
*/
|
|
8
9
|
export declare function nodePasteRule(config: {
|
|
9
10
|
find: PasteRuleFinder;
|
|
@@ -2,6 +2,7 @@ import { PasteRule, PasteRuleFinder } from '../PasteRule.js';
|
|
|
2
2
|
/**
|
|
3
3
|
* Build an paste rule that replaces text when the
|
|
4
4
|
* matched text is pasted into it.
|
|
5
|
+
* @see https://tiptap.dev/guide/custom-extensions/#paste-rules
|
|
5
6
|
*/
|
|
6
7
|
export declare function textPasteRule(config: {
|
|
7
8
|
find: PasteRuleFinder;
|
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.
|
|
4
|
+
"version": "2.4.0",
|
|
5
5
|
"homepage": "https://tiptap.dev",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"tiptap",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"dist"
|
|
33
33
|
],
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@tiptap/pm": "^2.
|
|
35
|
+
"@tiptap/pm": "^2.4.0"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
38
|
"@tiptap/pm": "^2.0.0"
|
package/src/Extension.ts
CHANGED
|
@@ -23,22 +23,40 @@ declare module '@tiptap/core' {
|
|
|
23
23
|
[key: string]: any
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
|
-
*
|
|
26
|
+
* The extension name - this must be unique.
|
|
27
|
+
* It will be used to identify the extension.
|
|
28
|
+
*
|
|
29
|
+
* @example 'myExtension'
|
|
27
30
|
*/
|
|
28
31
|
name: string
|
|
29
32
|
|
|
30
33
|
/**
|
|
31
|
-
*
|
|
34
|
+
* The priority of your extension. The higher, the later it will be called
|
|
35
|
+
* and will take precedence over other extensions with a lower priority.
|
|
36
|
+
* @default 1000
|
|
37
|
+
* @example 1001
|
|
32
38
|
*/
|
|
33
39
|
priority?: number
|
|
34
40
|
|
|
35
41
|
/**
|
|
36
|
-
*
|
|
42
|
+
* The default options for this extension.
|
|
43
|
+
* @example
|
|
44
|
+
* defaultOptions: {
|
|
45
|
+
* myOption: 'foo',
|
|
46
|
+
* myOtherOption: 10,
|
|
47
|
+
* }
|
|
37
48
|
*/
|
|
38
49
|
defaultOptions?: Options
|
|
39
50
|
|
|
40
51
|
/**
|
|
41
|
-
*
|
|
52
|
+
* This method will add options to this extension
|
|
53
|
+
* @see https://tiptap.dev/guide/custom-extensions#settings
|
|
54
|
+
* @example
|
|
55
|
+
* addOptions() {
|
|
56
|
+
* return {
|
|
57
|
+
* myOption: 'foo',
|
|
58
|
+
* myOtherOption: 10,
|
|
59
|
+
* }
|
|
42
60
|
*/
|
|
43
61
|
addOptions?: (this: {
|
|
44
62
|
name: string
|
|
@@ -46,7 +64,13 @@ declare module '@tiptap/core' {
|
|
|
46
64
|
}) => Options
|
|
47
65
|
|
|
48
66
|
/**
|
|
49
|
-
*
|
|
67
|
+
* The default storage this extension can save data to.
|
|
68
|
+
* @see https://tiptap.dev/guide/custom-extensions#storage
|
|
69
|
+
* @example
|
|
70
|
+
* defaultStorage: {
|
|
71
|
+
* prefetchedUsers: [],
|
|
72
|
+
* loading: false,
|
|
73
|
+
* }
|
|
50
74
|
*/
|
|
51
75
|
addStorage?: (this: {
|
|
52
76
|
name: string
|
|
@@ -55,7 +79,30 @@ declare module '@tiptap/core' {
|
|
|
55
79
|
}) => Storage
|
|
56
80
|
|
|
57
81
|
/**
|
|
58
|
-
*
|
|
82
|
+
* This function adds globalAttributes to specific nodes.
|
|
83
|
+
* @see https://tiptap.dev/guide/custom-extensions#global-attributes
|
|
84
|
+
* @example
|
|
85
|
+
* addGlobalAttributes() {
|
|
86
|
+
* return [
|
|
87
|
+
* {
|
|
88
|
+
// Extend the following extensions
|
|
89
|
+
* types: [
|
|
90
|
+
* 'heading',
|
|
91
|
+
* 'paragraph',
|
|
92
|
+
* ],
|
|
93
|
+
* // … with those attributes
|
|
94
|
+
* attributes: {
|
|
95
|
+
* textAlign: {
|
|
96
|
+
* default: 'left',
|
|
97
|
+
* renderHTML: attributes => ({
|
|
98
|
+
* style: `text-align: ${attributes.textAlign}`,
|
|
99
|
+
* }),
|
|
100
|
+
* parseHTML: element => element.style.textAlign || 'left',
|
|
101
|
+
* },
|
|
102
|
+
* },
|
|
103
|
+
* },
|
|
104
|
+
* ]
|
|
105
|
+
* }
|
|
59
106
|
*/
|
|
60
107
|
addGlobalAttributes?: (this: {
|
|
61
108
|
name: string
|
|
@@ -65,7 +112,14 @@ declare module '@tiptap/core' {
|
|
|
65
112
|
}) => GlobalAttributes | {}
|
|
66
113
|
|
|
67
114
|
/**
|
|
68
|
-
*
|
|
115
|
+
* This function adds commands to the editor
|
|
116
|
+
* @see https://tiptap.dev/guide/custom-extensions#keyboard-shortcuts
|
|
117
|
+
* @example
|
|
118
|
+
* addCommands() {
|
|
119
|
+
* return {
|
|
120
|
+
* myCommand: () => ({ chain }) => chain().setMark('type', 'foo').run(),
|
|
121
|
+
* }
|
|
122
|
+
* }
|
|
69
123
|
*/
|
|
70
124
|
addCommands?: (this: {
|
|
71
125
|
name: string
|
|
@@ -76,7 +130,14 @@ declare module '@tiptap/core' {
|
|
|
76
130
|
}) => Partial<RawCommands>
|
|
77
131
|
|
|
78
132
|
/**
|
|
79
|
-
*
|
|
133
|
+
* This function registers keyboard shortcuts.
|
|
134
|
+
* @see https://tiptap.dev/guide/custom-extensions#keyboard-shortcuts
|
|
135
|
+
* @example
|
|
136
|
+
* addKeyboardShortcuts() {
|
|
137
|
+
* return {
|
|
138
|
+
* 'Mod-l': () => this.editor.commands.toggleBulletList(),
|
|
139
|
+
* }
|
|
140
|
+
* },
|
|
80
141
|
*/
|
|
81
142
|
addKeyboardShortcuts?: (this: {
|
|
82
143
|
name: string
|
|
@@ -89,7 +150,17 @@ declare module '@tiptap/core' {
|
|
|
89
150
|
}
|
|
90
151
|
|
|
91
152
|
/**
|
|
92
|
-
*
|
|
153
|
+
* This function adds input rules to the editor.
|
|
154
|
+
* @see https://tiptap.dev/guide/custom-extensions#input-rules
|
|
155
|
+
* @example
|
|
156
|
+
* addInputRules() {
|
|
157
|
+
* return [
|
|
158
|
+
* markInputRule({
|
|
159
|
+
* find: inputRegex,
|
|
160
|
+
* type: this.type,
|
|
161
|
+
* }),
|
|
162
|
+
* ]
|
|
163
|
+
* },
|
|
93
164
|
*/
|
|
94
165
|
addInputRules?: (this: {
|
|
95
166
|
name: string
|
|
@@ -100,7 +171,17 @@ declare module '@tiptap/core' {
|
|
|
100
171
|
}) => InputRule[]
|
|
101
172
|
|
|
102
173
|
/**
|
|
103
|
-
*
|
|
174
|
+
* This function adds paste rules to the editor.
|
|
175
|
+
* @see https://tiptap.dev/guide/custom-extensions#paste-rules
|
|
176
|
+
* @example
|
|
177
|
+
* addPasteRules() {
|
|
178
|
+
* return [
|
|
179
|
+
* markPasteRule({
|
|
180
|
+
* find: pasteRegex,
|
|
181
|
+
* type: this.type,
|
|
182
|
+
* }),
|
|
183
|
+
* ]
|
|
184
|
+
* },
|
|
104
185
|
*/
|
|
105
186
|
addPasteRules?: (this: {
|
|
106
187
|
name: string
|
|
@@ -111,7 +192,14 @@ declare module '@tiptap/core' {
|
|
|
111
192
|
}) => PasteRule[]
|
|
112
193
|
|
|
113
194
|
/**
|
|
114
|
-
*
|
|
195
|
+
* This function adds Prosemirror plugins to the editor
|
|
196
|
+
* @see https://tiptap.dev/guide/custom-extensions#prosemirror-plugins
|
|
197
|
+
* @example
|
|
198
|
+
* addProseMirrorPlugins() {
|
|
199
|
+
* return [
|
|
200
|
+
* customPlugin(),
|
|
201
|
+
* ]
|
|
202
|
+
* }
|
|
115
203
|
*/
|
|
116
204
|
addProseMirrorPlugins?: (this: {
|
|
117
205
|
name: string
|
|
@@ -122,7 +210,16 @@ declare module '@tiptap/core' {
|
|
|
122
210
|
}) => Plugin[]
|
|
123
211
|
|
|
124
212
|
/**
|
|
125
|
-
*
|
|
213
|
+
* This function adds additional extensions to the editor. This is useful for
|
|
214
|
+
* building extension kits.
|
|
215
|
+
* @example
|
|
216
|
+
* addExtensions() {
|
|
217
|
+
* return [
|
|
218
|
+
* BulletList,
|
|
219
|
+
* OrderedList,
|
|
220
|
+
* ListItem
|
|
221
|
+
* ]
|
|
222
|
+
* }
|
|
126
223
|
*/
|
|
127
224
|
addExtensions?: (this: {
|
|
128
225
|
name: string
|
|
@@ -132,7 +229,14 @@ declare module '@tiptap/core' {
|
|
|
132
229
|
}) => Extensions
|
|
133
230
|
|
|
134
231
|
/**
|
|
135
|
-
*
|
|
232
|
+
* This function extends the schema of the node.
|
|
233
|
+
* @example
|
|
234
|
+
* extendNodeSchema() {
|
|
235
|
+
* return {
|
|
236
|
+
* group: 'inline',
|
|
237
|
+
* selectable: false,
|
|
238
|
+
* }
|
|
239
|
+
* }
|
|
136
240
|
*/
|
|
137
241
|
extendNodeSchema?:
|
|
138
242
|
| ((
|
|
@@ -147,7 +251,14 @@ declare module '@tiptap/core' {
|
|
|
147
251
|
| null
|
|
148
252
|
|
|
149
253
|
/**
|
|
150
|
-
*
|
|
254
|
+
* This function extends the schema of the mark.
|
|
255
|
+
* @example
|
|
256
|
+
* extendMarkSchema() {
|
|
257
|
+
* return {
|
|
258
|
+
* group: 'inline',
|
|
259
|
+
* selectable: false,
|
|
260
|
+
* }
|
|
261
|
+
* }
|
|
151
262
|
*/
|
|
152
263
|
extendMarkSchema?:
|
|
153
264
|
| ((
|
|
@@ -282,6 +393,10 @@ declare module '@tiptap/core' {
|
|
|
282
393
|
}
|
|
283
394
|
}
|
|
284
395
|
|
|
396
|
+
/**
|
|
397
|
+
* The Extension class is the base class for all extensions.
|
|
398
|
+
* @see https://tiptap.dev/api/extensions#create-a-new-extension
|
|
399
|
+
*/
|
|
285
400
|
export class Extension<Options = any, Storage = any> {
|
|
286
401
|
type = 'extension'
|
|
287
402
|
|
|
@@ -342,6 +457,7 @@ export class Extension<Options = any, Storage = any> {
|
|
|
342
457
|
// with different calls of `configure`
|
|
343
458
|
const extension = this.extend()
|
|
344
459
|
|
|
460
|
+
extension.parent = this.parent
|
|
345
461
|
extension.options = mergeDeep(this.options as Record<string, any>, options) as Options
|
|
346
462
|
|
|
347
463
|
extension.storage = callOrReturn(
|