@tiptap/core 3.0.0-next.5 → 3.0.0-next.7
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 +48 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +32 -17
- package/dist/index.d.ts +32 -17
- package/dist/index.js +74 -39
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/CommandManager.ts +3 -3
- package/src/Editor.ts +30 -15
- package/src/Extendable.ts +10 -9
- package/src/Extension.ts +17 -1
- package/src/ExtensionManager.ts +8 -6
- package/src/InputRule.ts +6 -4
- package/src/Mark.ts +13 -1
- package/src/MarkView.ts +3 -3
- package/src/Node.ts +13 -1
- package/src/NodePos.ts +3 -3
- package/src/NodeView.ts +3 -3
- package/src/PasteRule.ts +6 -4
- package/src/Tracker.ts +1 -1
- package/src/commands/blur.ts +1 -1
- package/src/commands/clearContent.ts +1 -1
- package/src/commands/clearNodes.ts +1 -1
- package/src/commands/command.ts +1 -1
- package/src/commands/createParagraphNear.ts +1 -1
- package/src/commands/cut.ts +1 -1
- package/src/commands/deleteCurrentNode.ts +1 -1
- package/src/commands/deleteNode.ts +2 -2
- package/src/commands/deleteRange.ts +1 -1
- package/src/commands/deleteSelection.ts +1 -1
- package/src/commands/enter.ts +1 -1
- package/src/commands/exitCode.ts +1 -1
- package/src/commands/extendMarkRange.ts +2 -2
- package/src/commands/first.ts +1 -1
- package/src/commands/focus.ts +1 -1
- package/src/commands/forEach.ts +1 -1
- package/src/commands/insertContent.ts +2 -2
- package/src/commands/insertContentAt.ts +3 -2
- package/src/commands/join.ts +1 -1
- package/src/commands/joinItemBackward.ts +1 -1
- package/src/commands/joinItemForward.ts +1 -1
- package/src/commands/joinTextblockBackward.ts +1 -1
- package/src/commands/joinTextblockForward.ts +1 -1
- package/src/commands/keyboardShortcut.ts +1 -1
- package/src/commands/lift.ts +2 -2
- package/src/commands/liftEmptyBlock.ts +1 -1
- package/src/commands/liftListItem.ts +2 -2
- package/src/commands/newlineInCode.ts +1 -1
- package/src/commands/resetAttributes.ts +2 -2
- package/src/commands/scrollIntoView.ts +1 -1
- package/src/commands/selectAll.ts +1 -1
- package/src/commands/selectNodeBackward.ts +1 -1
- package/src/commands/selectNodeForward.ts +1 -1
- package/src/commands/selectParentNode.ts +1 -1
- package/src/commands/selectTextblockEnd.ts +1 -1
- package/src/commands/selectTextblockStart.ts +1 -1
- package/src/commands/setContent.ts +2 -2
- package/src/commands/setMark.ts +3 -3
- package/src/commands/setMeta.ts +1 -1
- package/src/commands/setNode.ts +2 -2
- package/src/commands/setNodeSelection.ts +1 -1
- package/src/commands/setTextSelection.ts +1 -1
- package/src/commands/sinkListItem.ts +2 -2
- package/src/commands/splitBlock.ts +3 -2
- package/src/commands/splitListItem.ts +3 -2
- package/src/commands/toggleList.ts +3 -3
- package/src/commands/toggleMark.ts +2 -2
- package/src/commands/toggleNode.ts +2 -2
- package/src/commands/toggleWrap.ts +2 -2
- package/src/commands/undoInputRule.ts +1 -1
- package/src/commands/unsetAllMarks.ts +1 -1
- package/src/commands/unsetMark.ts +2 -2
- package/src/commands/updateAttributes.ts +3 -3
- package/src/commands/wrapIn.ts +2 -2
- package/src/commands/wrapInList.ts +2 -2
- package/src/extensions/focusEvents.ts +3 -1
- package/src/extensions/index.ts +1 -1
- package/src/helpers/combineTransactionSteps.ts +2 -2
- package/src/helpers/createChainableState.ts +1 -1
- package/src/helpers/createDocument.ts +2 -2
- package/src/helpers/createNodeFromContent.ts +3 -2
- package/src/helpers/defaultBlockAt.ts +1 -1
- package/src/helpers/findChildren.ts +2 -2
- package/src/helpers/findChildrenInRange.ts +2 -2
- package/src/helpers/findParentNode.ts +2 -2
- package/src/helpers/findParentNodeClosestToPos.ts +2 -2
- package/src/helpers/flattenExtensions.ts +1 -1
- package/src/helpers/generateHTML.ts +1 -1
- package/src/helpers/generateJSON.ts +1 -1
- package/src/helpers/generateText.ts +1 -1
- package/src/helpers/getAttributes.ts +2 -2
- package/src/helpers/getAttributesFromExtensions.ts +1 -1
- package/src/helpers/getChangedRanges.ts +2 -2
- package/src/helpers/getDebugJSON.ts +2 -2
- package/src/helpers/getExtensionField.ts +4 -4
- package/src/helpers/getHTMLFromFragment.ts +2 -1
- package/src/helpers/getMarkAttributes.ts +2 -2
- package/src/helpers/getMarkRange.ts +2 -2
- package/src/helpers/getMarkType.ts +1 -1
- package/src/helpers/getMarksBetween.ts +2 -2
- package/src/helpers/getNodeAtPosition.ts +2 -2
- package/src/helpers/getNodeAttributes.ts +2 -2
- package/src/helpers/getNodeType.ts +1 -1
- package/src/helpers/getRenderedAttributes.ts +2 -2
- package/src/helpers/getSchema.ts +3 -3
- package/src/helpers/getSchemaByResolvedExtensions.ts +3 -2
- package/src/helpers/getSchemaTypeByName.ts +1 -1
- package/src/helpers/getSchemaTypeNameByName.ts +1 -1
- package/src/helpers/getSplittedAttributes.ts +1 -1
- package/src/helpers/getText.ts +2 -2
- package/src/helpers/getTextBetween.ts +2 -2
- package/src/helpers/getTextContentFromNodes.ts +1 -1
- package/src/helpers/getTextSerializersFromSchema.ts +2 -2
- package/src/helpers/injectExtensionAttributesToParseRule.ts +2 -2
- package/src/helpers/isActive.ts +1 -1
- package/src/helpers/isAtEndOfNode.ts +1 -1
- package/src/helpers/isAtStartOfNode.ts +1 -1
- package/src/helpers/isExtensionRulesEnabled.ts +1 -1
- package/src/helpers/isList.ts +1 -1
- package/src/helpers/isMarkActive.ts +3 -3
- package/src/helpers/isNodeActive.ts +3 -3
- package/src/helpers/isNodeEmpty.ts +1 -1
- package/src/helpers/posToDOMRect.ts +1 -1
- package/src/helpers/resolveExtensions.ts +1 -1
- package/src/helpers/resolveFocusPosition.ts +2 -2
- package/src/helpers/selectionToInsertionEnd.ts +2 -1
- package/src/helpers/sortExtensions.ts +1 -1
- package/src/helpers/splitExtensions.ts +4 -4
- package/src/inputRules/markInputRule.ts +4 -3
- package/src/inputRules/nodeInputRule.ts +4 -3
- package/src/inputRules/textInputRule.ts +2 -1
- package/src/inputRules/textblockTypeInputRule.ts +4 -3
- package/src/inputRules/wrappingInputRule.ts +5 -4
- package/src/pasteRules/markPasteRule.ts +4 -3
- package/src/pasteRules/nodePasteRule.ts +4 -3
- package/src/pasteRules/textPasteRule.ts +2 -1
- package/src/types.ts +10 -10
- package/src/utilities/callOrReturn.ts +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -181,13 +181,15 @@ interface MarkConfig<Options = any, Storage = any> extends ExtendableConfig<Opti
|
|
|
181
181
|
* The Mark class is used to create custom mark extensions.
|
|
182
182
|
* @see https://tiptap.dev/api/extensions#create-a-new-extension
|
|
183
183
|
*/
|
|
184
|
-
declare class Mark<Options = any, Storage = any> extends Extendable<Options, Storage
|
|
184
|
+
declare class Mark<Options = any, Storage = any> extends Extendable<Options, Storage, MarkConfig<Options, Storage>> {
|
|
185
185
|
type: string;
|
|
186
186
|
static create<O = any, S = any>(config?: Partial<MarkConfig<O, S>>): Mark<O, S>;
|
|
187
187
|
static handleExit({ editor, mark }: {
|
|
188
188
|
editor: Editor;
|
|
189
189
|
mark: Mark;
|
|
190
190
|
}): boolean;
|
|
191
|
+
configure(options?: Partial<Options>): Mark<Options, Storage>;
|
|
192
|
+
extend<ExtendedOptions = Options, ExtendedStorage = Storage, ExtendedConfig = MarkConfig<ExtendedOptions, ExtendedStorage>>(extendedConfig?: Partial<ExtendedConfig>): Mark<ExtendedOptions, ExtendedStorage>;
|
|
191
193
|
}
|
|
192
194
|
|
|
193
195
|
interface NodeConfig<Options = any, Storage = any> extends ExtendableConfig<Options, Storage, NodeConfig<Options, Storage>, NodeType$1> {
|
|
@@ -466,9 +468,11 @@ interface NodeConfig<Options = any, Storage = any> extends ExtendableConfig<Opti
|
|
|
466
468
|
* The Node class is used to create custom node extensions.
|
|
467
469
|
* @see https://tiptap.dev/api/extensions#create-a-new-extension
|
|
468
470
|
*/
|
|
469
|
-
declare class Node<Options = any, Storage = any> extends Extendable<Options, Storage
|
|
471
|
+
declare class Node<Options = any, Storage = any> extends Extendable<Options, Storage, NodeConfig<Options, Storage>> {
|
|
470
472
|
type: string;
|
|
471
473
|
static create<O = any, S = any>(config?: Partial<NodeConfig<O, S>>): Node<O, S>;
|
|
474
|
+
configure(options?: Partial<Options>): Node<Options, Storage>;
|
|
475
|
+
extend<ExtendedOptions = Options, ExtendedStorage = Storage, ExtendedConfig = NodeConfig<ExtendedOptions, ExtendedStorage>>(extendedConfig?: Partial<ExtendedConfig>): Node<ExtendedOptions, ExtendedStorage>;
|
|
472
476
|
}
|
|
473
477
|
|
|
474
478
|
type PasteRuleMatch = {
|
|
@@ -842,22 +846,11 @@ declare class Extendable<Options = any, Storage = any, Config = ExtensionConfig<
|
|
|
842
846
|
get options(): Options;
|
|
843
847
|
get storage(): Readonly<Storage>;
|
|
844
848
|
configure(options?: Partial<Options>): Extendable<Options, Storage, ExtensionConfig<Options, Storage> | NodeConfig<Options, Storage> | MarkConfig<Options, Storage>>;
|
|
845
|
-
extend<ExtendedOptions = Options, ExtendedStorage = Storage
|
|
846
|
-
}
|
|
847
|
-
|
|
848
|
-
interface ExtensionConfig<Options = any, Storage = any> extends ExtendableConfig<Options, Storage, ExtensionConfig<Options, Storage>, null> {
|
|
849
|
-
}
|
|
850
|
-
/**
|
|
851
|
-
* The Extension class is the base class for all extensions.
|
|
852
|
-
* @see https://tiptap.dev/api/extensions#create-a-new-extension
|
|
853
|
-
*/
|
|
854
|
-
declare class Extension<Options = any, Storage = any> extends Extendable<Options, Storage> {
|
|
855
|
-
type: string;
|
|
856
|
-
static create<O = any, S = any>(config?: Partial<ExtensionConfig<O, S>>): Extension<O, S>;
|
|
849
|
+
extend<ExtendedOptions = Options, ExtendedStorage = Storage, ExtendedConfig = ExtensionConfig<ExtendedOptions, ExtendedStorage> | NodeConfig<ExtendedOptions, ExtendedStorage> | MarkConfig<ExtendedOptions, ExtendedStorage>>(extendedConfig?: Partial<ExtendedConfig>): Extendable<ExtendedOptions, ExtendedStorage>;
|
|
857
850
|
}
|
|
858
851
|
|
|
859
852
|
type AnyConfig = ExtensionConfig | NodeConfig | MarkConfig;
|
|
860
|
-
type AnyExtension =
|
|
853
|
+
type AnyExtension = Extendable;
|
|
861
854
|
type Extensions = AnyExtension[];
|
|
862
855
|
type ParentConfig<T> = Partial<{
|
|
863
856
|
[P in keyof T]: Required<T>[P] extends (...args: any) => any ? (...args: Parameters<Required<T>[P]>) => ReturnType<Required<T>[P]> : T[P];
|
|
@@ -1621,6 +1614,19 @@ interface DebugJSONContent extends JSONContent {
|
|
|
1621
1614
|
}
|
|
1622
1615
|
declare function getDebugJSON(node: Node$1, startOffset?: number): DebugJSONContent;
|
|
1623
1616
|
|
|
1617
|
+
interface ExtensionConfig<Options = any, Storage = any> extends ExtendableConfig<Options, Storage, ExtensionConfig<Options, Storage>, null> {
|
|
1618
|
+
}
|
|
1619
|
+
/**
|
|
1620
|
+
* The Extension class is the base class for all extensions.
|
|
1621
|
+
* @see https://tiptap.dev/api/extensions#create-a-new-extension
|
|
1622
|
+
*/
|
|
1623
|
+
declare class Extension<Options = any, Storage = any> extends Extendable<Options, Storage, ExtensionConfig<Options, Storage>> {
|
|
1624
|
+
type: string;
|
|
1625
|
+
static create<O = any, S = any>(config?: Partial<ExtensionConfig<O, S>>): Extension<O, S>;
|
|
1626
|
+
configure(options?: Partial<Options>): Extension<Options, Storage>;
|
|
1627
|
+
extend<ExtendedOptions = Options, ExtendedStorage = Storage, ExtendedConfig = ExtensionConfig<ExtendedOptions, ExtendedStorage>>(extendedConfig?: Partial<ExtendedConfig>): Extension<ExtendedOptions, ExtendedStorage>;
|
|
1628
|
+
}
|
|
1629
|
+
|
|
1624
1630
|
/**
|
|
1625
1631
|
* Returns a field from an extension
|
|
1626
1632
|
* @param extension The Tiptap extension
|
|
@@ -2833,6 +2839,7 @@ declare const Drop: Extension<any, any>;
|
|
|
2833
2839
|
|
|
2834
2840
|
declare const Editable: Extension<any, any>;
|
|
2835
2841
|
|
|
2842
|
+
declare const focusEventsPluginKey: PluginKey<any>;
|
|
2836
2843
|
declare const FocusEvents: Extension<any, any>;
|
|
2837
2844
|
|
|
2838
2845
|
declare const Keymap: Extension<any, any>;
|
|
@@ -2849,8 +2856,9 @@ declare const index_FocusEvents: typeof FocusEvents;
|
|
|
2849
2856
|
declare const index_Keymap: typeof Keymap;
|
|
2850
2857
|
declare const index_Paste: typeof Paste;
|
|
2851
2858
|
declare const index_Tabindex: typeof Tabindex;
|
|
2859
|
+
declare const index_focusEventsPluginKey: typeof focusEventsPluginKey;
|
|
2852
2860
|
declare namespace index {
|
|
2853
|
-
export { index_ClipboardTextSerializer as ClipboardTextSerializer, Commands$1 as Commands, index_Delete as Delete, index_Drop as Drop, index_Editable as Editable, index_FocusEvents as FocusEvents, index_Keymap as Keymap, index_Paste as Paste, index_Tabindex as Tabindex };
|
|
2861
|
+
export { index_ClipboardTextSerializer as ClipboardTextSerializer, Commands$1 as Commands, index_Delete as Delete, index_Drop as Drop, index_Editable as Editable, index_FocusEvents as FocusEvents, index_Keymap as Keymap, index_Paste as Paste, index_Tabindex as Tabindex, index_focusEventsPluginKey as focusEventsPluginKey };
|
|
2854
2862
|
}
|
|
2855
2863
|
|
|
2856
2864
|
interface TiptapEditorHTMLElement extends HTMLElement {
|
|
@@ -2875,7 +2883,14 @@ declare class Editor extends EventEmitter<EditorEvents> {
|
|
|
2875
2883
|
instanceId: string;
|
|
2876
2884
|
options: EditorOptions;
|
|
2877
2885
|
constructor(options?: Partial<EditorOptions>);
|
|
2886
|
+
/**
|
|
2887
|
+
* Attach the editor to the DOM, creating a new editor view.
|
|
2888
|
+
*/
|
|
2878
2889
|
mount(el: NonNullable<EditorOptions['element']> & {}): void;
|
|
2890
|
+
/**
|
|
2891
|
+
* Remove the editor from the DOM, but still allow remounting at a different point in time
|
|
2892
|
+
*/
|
|
2893
|
+
unmount(): void;
|
|
2879
2894
|
/**
|
|
2880
2895
|
* Returns the editor storage.
|
|
2881
2896
|
*/
|
|
@@ -2954,7 +2969,7 @@ declare class Editor extends EventEmitter<EditorEvents> {
|
|
|
2954
2969
|
*/
|
|
2955
2970
|
private createView;
|
|
2956
2971
|
/**
|
|
2957
|
-
* Creates all node views.
|
|
2972
|
+
* Creates all node and mark views.
|
|
2958
2973
|
*/
|
|
2959
2974
|
createNodeViews(): void;
|
|
2960
2975
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -181,13 +181,15 @@ interface MarkConfig<Options = any, Storage = any> extends ExtendableConfig<Opti
|
|
|
181
181
|
* The Mark class is used to create custom mark extensions.
|
|
182
182
|
* @see https://tiptap.dev/api/extensions#create-a-new-extension
|
|
183
183
|
*/
|
|
184
|
-
declare class Mark<Options = any, Storage = any> extends Extendable<Options, Storage
|
|
184
|
+
declare class Mark<Options = any, Storage = any> extends Extendable<Options, Storage, MarkConfig<Options, Storage>> {
|
|
185
185
|
type: string;
|
|
186
186
|
static create<O = any, S = any>(config?: Partial<MarkConfig<O, S>>): Mark<O, S>;
|
|
187
187
|
static handleExit({ editor, mark }: {
|
|
188
188
|
editor: Editor;
|
|
189
189
|
mark: Mark;
|
|
190
190
|
}): boolean;
|
|
191
|
+
configure(options?: Partial<Options>): Mark<Options, Storage>;
|
|
192
|
+
extend<ExtendedOptions = Options, ExtendedStorage = Storage, ExtendedConfig = MarkConfig<ExtendedOptions, ExtendedStorage>>(extendedConfig?: Partial<ExtendedConfig>): Mark<ExtendedOptions, ExtendedStorage>;
|
|
191
193
|
}
|
|
192
194
|
|
|
193
195
|
interface NodeConfig<Options = any, Storage = any> extends ExtendableConfig<Options, Storage, NodeConfig<Options, Storage>, NodeType$1> {
|
|
@@ -466,9 +468,11 @@ interface NodeConfig<Options = any, Storage = any> extends ExtendableConfig<Opti
|
|
|
466
468
|
* The Node class is used to create custom node extensions.
|
|
467
469
|
* @see https://tiptap.dev/api/extensions#create-a-new-extension
|
|
468
470
|
*/
|
|
469
|
-
declare class Node<Options = any, Storage = any> extends Extendable<Options, Storage
|
|
471
|
+
declare class Node<Options = any, Storage = any> extends Extendable<Options, Storage, NodeConfig<Options, Storage>> {
|
|
470
472
|
type: string;
|
|
471
473
|
static create<O = any, S = any>(config?: Partial<NodeConfig<O, S>>): Node<O, S>;
|
|
474
|
+
configure(options?: Partial<Options>): Node<Options, Storage>;
|
|
475
|
+
extend<ExtendedOptions = Options, ExtendedStorage = Storage, ExtendedConfig = NodeConfig<ExtendedOptions, ExtendedStorage>>(extendedConfig?: Partial<ExtendedConfig>): Node<ExtendedOptions, ExtendedStorage>;
|
|
472
476
|
}
|
|
473
477
|
|
|
474
478
|
type PasteRuleMatch = {
|
|
@@ -842,22 +846,11 @@ declare class Extendable<Options = any, Storage = any, Config = ExtensionConfig<
|
|
|
842
846
|
get options(): Options;
|
|
843
847
|
get storage(): Readonly<Storage>;
|
|
844
848
|
configure(options?: Partial<Options>): Extendable<Options, Storage, ExtensionConfig<Options, Storage> | NodeConfig<Options, Storage> | MarkConfig<Options, Storage>>;
|
|
845
|
-
extend<ExtendedOptions = Options, ExtendedStorage = Storage
|
|
846
|
-
}
|
|
847
|
-
|
|
848
|
-
interface ExtensionConfig<Options = any, Storage = any> extends ExtendableConfig<Options, Storage, ExtensionConfig<Options, Storage>, null> {
|
|
849
|
-
}
|
|
850
|
-
/**
|
|
851
|
-
* The Extension class is the base class for all extensions.
|
|
852
|
-
* @see https://tiptap.dev/api/extensions#create-a-new-extension
|
|
853
|
-
*/
|
|
854
|
-
declare class Extension<Options = any, Storage = any> extends Extendable<Options, Storage> {
|
|
855
|
-
type: string;
|
|
856
|
-
static create<O = any, S = any>(config?: Partial<ExtensionConfig<O, S>>): Extension<O, S>;
|
|
849
|
+
extend<ExtendedOptions = Options, ExtendedStorage = Storage, ExtendedConfig = ExtensionConfig<ExtendedOptions, ExtendedStorage> | NodeConfig<ExtendedOptions, ExtendedStorage> | MarkConfig<ExtendedOptions, ExtendedStorage>>(extendedConfig?: Partial<ExtendedConfig>): Extendable<ExtendedOptions, ExtendedStorage>;
|
|
857
850
|
}
|
|
858
851
|
|
|
859
852
|
type AnyConfig = ExtensionConfig | NodeConfig | MarkConfig;
|
|
860
|
-
type AnyExtension =
|
|
853
|
+
type AnyExtension = Extendable;
|
|
861
854
|
type Extensions = AnyExtension[];
|
|
862
855
|
type ParentConfig<T> = Partial<{
|
|
863
856
|
[P in keyof T]: Required<T>[P] extends (...args: any) => any ? (...args: Parameters<Required<T>[P]>) => ReturnType<Required<T>[P]> : T[P];
|
|
@@ -1621,6 +1614,19 @@ interface DebugJSONContent extends JSONContent {
|
|
|
1621
1614
|
}
|
|
1622
1615
|
declare function getDebugJSON(node: Node$1, startOffset?: number): DebugJSONContent;
|
|
1623
1616
|
|
|
1617
|
+
interface ExtensionConfig<Options = any, Storage = any> extends ExtendableConfig<Options, Storage, ExtensionConfig<Options, Storage>, null> {
|
|
1618
|
+
}
|
|
1619
|
+
/**
|
|
1620
|
+
* The Extension class is the base class for all extensions.
|
|
1621
|
+
* @see https://tiptap.dev/api/extensions#create-a-new-extension
|
|
1622
|
+
*/
|
|
1623
|
+
declare class Extension<Options = any, Storage = any> extends Extendable<Options, Storage, ExtensionConfig<Options, Storage>> {
|
|
1624
|
+
type: string;
|
|
1625
|
+
static create<O = any, S = any>(config?: Partial<ExtensionConfig<O, S>>): Extension<O, S>;
|
|
1626
|
+
configure(options?: Partial<Options>): Extension<Options, Storage>;
|
|
1627
|
+
extend<ExtendedOptions = Options, ExtendedStorage = Storage, ExtendedConfig = ExtensionConfig<ExtendedOptions, ExtendedStorage>>(extendedConfig?: Partial<ExtendedConfig>): Extension<ExtendedOptions, ExtendedStorage>;
|
|
1628
|
+
}
|
|
1629
|
+
|
|
1624
1630
|
/**
|
|
1625
1631
|
* Returns a field from an extension
|
|
1626
1632
|
* @param extension The Tiptap extension
|
|
@@ -2833,6 +2839,7 @@ declare const Drop: Extension<any, any>;
|
|
|
2833
2839
|
|
|
2834
2840
|
declare const Editable: Extension<any, any>;
|
|
2835
2841
|
|
|
2842
|
+
declare const focusEventsPluginKey: PluginKey<any>;
|
|
2836
2843
|
declare const FocusEvents: Extension<any, any>;
|
|
2837
2844
|
|
|
2838
2845
|
declare const Keymap: Extension<any, any>;
|
|
@@ -2849,8 +2856,9 @@ declare const index_FocusEvents: typeof FocusEvents;
|
|
|
2849
2856
|
declare const index_Keymap: typeof Keymap;
|
|
2850
2857
|
declare const index_Paste: typeof Paste;
|
|
2851
2858
|
declare const index_Tabindex: typeof Tabindex;
|
|
2859
|
+
declare const index_focusEventsPluginKey: typeof focusEventsPluginKey;
|
|
2852
2860
|
declare namespace index {
|
|
2853
|
-
export { index_ClipboardTextSerializer as ClipboardTextSerializer, Commands$1 as Commands, index_Delete as Delete, index_Drop as Drop, index_Editable as Editable, index_FocusEvents as FocusEvents, index_Keymap as Keymap, index_Paste as Paste, index_Tabindex as Tabindex };
|
|
2861
|
+
export { index_ClipboardTextSerializer as ClipboardTextSerializer, Commands$1 as Commands, index_Delete as Delete, index_Drop as Drop, index_Editable as Editable, index_FocusEvents as FocusEvents, index_Keymap as Keymap, index_Paste as Paste, index_Tabindex as Tabindex, index_focusEventsPluginKey as focusEventsPluginKey };
|
|
2854
2862
|
}
|
|
2855
2863
|
|
|
2856
2864
|
interface TiptapEditorHTMLElement extends HTMLElement {
|
|
@@ -2875,7 +2883,14 @@ declare class Editor extends EventEmitter<EditorEvents> {
|
|
|
2875
2883
|
instanceId: string;
|
|
2876
2884
|
options: EditorOptions;
|
|
2877
2885
|
constructor(options?: Partial<EditorOptions>);
|
|
2886
|
+
/**
|
|
2887
|
+
* Attach the editor to the DOM, creating a new editor view.
|
|
2888
|
+
*/
|
|
2878
2889
|
mount(el: NonNullable<EditorOptions['element']> & {}): void;
|
|
2890
|
+
/**
|
|
2891
|
+
* Remove the editor from the DOM, but still allow remounting at a different point in time
|
|
2892
|
+
*/
|
|
2893
|
+
unmount(): void;
|
|
2879
2894
|
/**
|
|
2880
2895
|
* Returns the editor storage.
|
|
2881
2896
|
*/
|
|
@@ -2954,7 +2969,7 @@ declare class Editor extends EventEmitter<EditorEvents> {
|
|
|
2954
2969
|
*/
|
|
2955
2970
|
private createView;
|
|
2956
2971
|
/**
|
|
2957
|
-
* Creates all node views.
|
|
2972
|
+
* Creates all node and mark views.
|
|
2958
2973
|
*/
|
|
2959
2974
|
createNodeViews(): void;
|
|
2960
2975
|
/**
|
package/dist/index.js
CHANGED
|
@@ -143,7 +143,7 @@ var CommandManager = class {
|
|
|
143
143
|
};
|
|
144
144
|
|
|
145
145
|
// src/Editor.ts
|
|
146
|
-
import { EditorState
|
|
146
|
+
import { EditorState } from "@tiptap/pm/state";
|
|
147
147
|
import { EditorView } from "@tiptap/pm/view";
|
|
148
148
|
|
|
149
149
|
// src/EventEmitter.ts
|
|
@@ -418,7 +418,7 @@ function getHTMLFromFragment(fragment, schema) {
|
|
|
418
418
|
}
|
|
419
419
|
|
|
420
420
|
// src/helpers/getSchemaByResolvedExtensions.ts
|
|
421
|
-
import { Schema as
|
|
421
|
+
import { Schema as Schema2 } from "@tiptap/pm/model";
|
|
422
422
|
|
|
423
423
|
// src/utilities/isFunction.ts
|
|
424
424
|
function isFunction(value) {
|
|
@@ -754,7 +754,7 @@ function getSchemaByResolvedExtensions(extensions, editor) {
|
|
|
754
754
|
return [extension.name, schema];
|
|
755
755
|
})
|
|
756
756
|
);
|
|
757
|
-
return new
|
|
757
|
+
return new Schema2({
|
|
758
758
|
topNode,
|
|
759
759
|
nodes,
|
|
760
760
|
marks
|
|
@@ -1564,7 +1564,7 @@ function selectionToInsertionEnd(tr, startLen, bias) {
|
|
|
1564
1564
|
}
|
|
1565
1565
|
|
|
1566
1566
|
// src/InputRule.ts
|
|
1567
|
-
import { Fragment as
|
|
1567
|
+
import { Fragment as Fragment2 } from "@tiptap/pm/model";
|
|
1568
1568
|
import { Plugin } from "@tiptap/pm/state";
|
|
1569
1569
|
var InputRule = class {
|
|
1570
1570
|
constructor(config) {
|
|
@@ -1672,7 +1672,7 @@ function inputRulesPlugin(props) {
|
|
|
1672
1672
|
if (typeof text === "string") {
|
|
1673
1673
|
text = text;
|
|
1674
1674
|
} else {
|
|
1675
|
-
text = getHTMLFromFragment(
|
|
1675
|
+
text = getHTMLFromFragment(Fragment2.from(text), state.schema);
|
|
1676
1676
|
}
|
|
1677
1677
|
const { from } = simulatedInputMeta;
|
|
1678
1678
|
const to = from + text.length;
|
|
@@ -1820,7 +1820,7 @@ var Extendable = class {
|
|
|
1820
1820
|
const extension = new this.constructor({ ...this.config, ...extendedConfig });
|
|
1821
1821
|
extension.parent = this;
|
|
1822
1822
|
this.child = extension;
|
|
1823
|
-
extension.name =
|
|
1823
|
+
extension.name = "name" in extendedConfig ? extendedConfig.name : extension.parent.name;
|
|
1824
1824
|
return extension;
|
|
1825
1825
|
}
|
|
1826
1826
|
};
|
|
@@ -1854,10 +1854,16 @@ var Mark = class _Mark extends Extendable {
|
|
|
1854
1854
|
}
|
|
1855
1855
|
return false;
|
|
1856
1856
|
}
|
|
1857
|
+
configure(options) {
|
|
1858
|
+
return super.configure(options);
|
|
1859
|
+
}
|
|
1860
|
+
extend(extendedConfig) {
|
|
1861
|
+
return super.extend(extendedConfig);
|
|
1862
|
+
}
|
|
1857
1863
|
};
|
|
1858
1864
|
|
|
1859
1865
|
// src/PasteRule.ts
|
|
1860
|
-
import { Fragment as
|
|
1866
|
+
import { Fragment as Fragment3 } from "@tiptap/pm/model";
|
|
1861
1867
|
import { Plugin as Plugin2 } from "@tiptap/pm/state";
|
|
1862
1868
|
|
|
1863
1869
|
// src/utilities/isNumber.ts
|
|
@@ -2054,7 +2060,7 @@ function pasteRulesPlugin(props) {
|
|
|
2054
2060
|
if (typeof text === "string") {
|
|
2055
2061
|
text = text;
|
|
2056
2062
|
} else {
|
|
2057
|
-
text = getHTMLFromFragment(
|
|
2063
|
+
text = getHTMLFromFragment(Fragment3.from(text), state.schema);
|
|
2058
2064
|
}
|
|
2059
2065
|
const { from: from2 } = simulatedPasteMeta;
|
|
2060
2066
|
const to2 = from2 + text.length;
|
|
@@ -2344,7 +2350,8 @@ __export(extensions_exports, {
|
|
|
2344
2350
|
FocusEvents: () => FocusEvents,
|
|
2345
2351
|
Keymap: () => Keymap,
|
|
2346
2352
|
Paste: () => Paste,
|
|
2347
|
-
Tabindex: () => Tabindex
|
|
2353
|
+
Tabindex: () => Tabindex,
|
|
2354
|
+
focusEventsPluginKey: () => focusEventsPluginKey
|
|
2348
2355
|
});
|
|
2349
2356
|
|
|
2350
2357
|
// src/extensions/clipboardTextSerializer.ts
|
|
@@ -2359,6 +2366,12 @@ var Extension = class _Extension extends Extendable {
|
|
|
2359
2366
|
static create(config = {}) {
|
|
2360
2367
|
return new _Extension(config);
|
|
2361
2368
|
}
|
|
2369
|
+
configure(options) {
|
|
2370
|
+
return super.configure(options);
|
|
2371
|
+
}
|
|
2372
|
+
extend(extendedConfig) {
|
|
2373
|
+
return super.extend(extendedConfig);
|
|
2374
|
+
}
|
|
2362
2375
|
};
|
|
2363
2376
|
|
|
2364
2377
|
// src/extensions/clipboardTextSerializer.ts
|
|
@@ -2520,14 +2533,14 @@ var createParagraphNear = () => ({ state, dispatch }) => {
|
|
|
2520
2533
|
};
|
|
2521
2534
|
|
|
2522
2535
|
// src/commands/cut.ts
|
|
2523
|
-
import { TextSelection as
|
|
2536
|
+
import { TextSelection as TextSelection3 } from "@tiptap/pm/state";
|
|
2524
2537
|
var cut = (originRange, targetPos) => ({ editor, tr }) => {
|
|
2525
2538
|
const { state } = editor;
|
|
2526
2539
|
const contentSlice = state.doc.slice(originRange.from, originRange.to);
|
|
2527
2540
|
tr.deleteRange(originRange.from, originRange.to);
|
|
2528
2541
|
const newPos = tr.mapping.map(targetPos);
|
|
2529
2542
|
tr.insert(newPos, contentSlice.content);
|
|
2530
|
-
tr.setSelection(new
|
|
2543
|
+
tr.setSelection(new TextSelection3(tr.doc.resolve(newPos - 1)));
|
|
2531
2544
|
return true;
|
|
2532
2545
|
};
|
|
2533
2546
|
|
|
@@ -2598,7 +2611,7 @@ var exitCode = () => ({ state, dispatch }) => {
|
|
|
2598
2611
|
};
|
|
2599
2612
|
|
|
2600
2613
|
// src/commands/extendMarkRange.ts
|
|
2601
|
-
import { TextSelection as
|
|
2614
|
+
import { TextSelection as TextSelection4 } from "@tiptap/pm/state";
|
|
2602
2615
|
var extendMarkRange = (typeOrName, attributes = {}) => ({ tr, state, dispatch }) => {
|
|
2603
2616
|
const type = getMarkType(typeOrName, state.schema);
|
|
2604
2617
|
const { doc, selection } = tr;
|
|
@@ -2606,7 +2619,7 @@ var extendMarkRange = (typeOrName, attributes = {}) => ({ tr, state, dispatch })
|
|
|
2606
2619
|
if (dispatch) {
|
|
2607
2620
|
const range = getMarkRange($from, type, attributes);
|
|
2608
2621
|
if (range && range.from <= from && range.to >= to) {
|
|
2609
|
-
const newSelection =
|
|
2622
|
+
const newSelection = TextSelection4.create(doc, range.from, range.to);
|
|
2610
2623
|
tr.setSelection(newSelection);
|
|
2611
2624
|
}
|
|
2612
2625
|
}
|
|
@@ -2687,7 +2700,7 @@ var insertContent = (value, options) => ({ tr, commands }) => {
|
|
|
2687
2700
|
};
|
|
2688
2701
|
|
|
2689
2702
|
// src/commands/insertContentAt.ts
|
|
2690
|
-
import { Fragment as
|
|
2703
|
+
import { Fragment as Fragment4 } from "@tiptap/pm/model";
|
|
2691
2704
|
var isFragment = (nodeOrFragment) => {
|
|
2692
2705
|
return !("type" in nodeOrFragment);
|
|
2693
2706
|
};
|
|
@@ -2745,7 +2758,7 @@ var insertContentAt = (position, value, options) => ({ tr, dispatch, editor }) =
|
|
|
2745
2758
|
if (isOnlyTextContent) {
|
|
2746
2759
|
if (Array.isArray(value)) {
|
|
2747
2760
|
newContent = value.map((v) => v.text || "").join("");
|
|
2748
|
-
} else if (value instanceof
|
|
2761
|
+
} else if (value instanceof Fragment4) {
|
|
2749
2762
|
let text = "";
|
|
2750
2763
|
value.forEach((node) => {
|
|
2751
2764
|
if (node.text) {
|
|
@@ -3184,16 +3197,16 @@ var setNodeSelection = (position) => ({ tr, dispatch }) => {
|
|
|
3184
3197
|
};
|
|
3185
3198
|
|
|
3186
3199
|
// src/commands/setTextSelection.ts
|
|
3187
|
-
import { TextSelection as
|
|
3200
|
+
import { TextSelection as TextSelection5 } from "@tiptap/pm/state";
|
|
3188
3201
|
var setTextSelection = (position) => ({ tr, dispatch }) => {
|
|
3189
3202
|
if (dispatch) {
|
|
3190
3203
|
const { doc } = tr;
|
|
3191
3204
|
const { from, to } = typeof position === "number" ? { from: position, to: position } : position;
|
|
3192
|
-
const minPos =
|
|
3193
|
-
const maxPos =
|
|
3205
|
+
const minPos = TextSelection5.atStart(doc).from;
|
|
3206
|
+
const maxPos = TextSelection5.atEnd(doc).to;
|
|
3194
3207
|
const resolvedFrom = minMax(from, minPos, maxPos);
|
|
3195
3208
|
const resolvedEnd = minMax(to, minPos, maxPos);
|
|
3196
|
-
const selection =
|
|
3209
|
+
const selection = TextSelection5.create(doc, resolvedFrom, resolvedEnd);
|
|
3197
3210
|
tr.setSelection(selection);
|
|
3198
3211
|
}
|
|
3199
3212
|
return true;
|
|
@@ -3207,7 +3220,7 @@ var sinkListItem = (typeOrName) => ({ state, dispatch }) => {
|
|
|
3207
3220
|
};
|
|
3208
3221
|
|
|
3209
3222
|
// src/commands/splitBlock.ts
|
|
3210
|
-
import { NodeSelection as NodeSelection3, TextSelection as
|
|
3223
|
+
import { NodeSelection as NodeSelection3, TextSelection as TextSelection6 } from "@tiptap/pm/state";
|
|
3211
3224
|
import { canSplit } from "@tiptap/pm/transform";
|
|
3212
3225
|
function ensureMarks(state, splittableMarks) {
|
|
3213
3226
|
const marks = state.storedMarks || state.selection.$to.parentOffset && state.selection.$from.marks();
|
|
@@ -3256,7 +3269,7 @@ var splitBlock = ({ keepMarks = true } = {}) => ({ tr, state, dispatch, editor }
|
|
|
3256
3269
|
}
|
|
3257
3270
|
if (dispatch) {
|
|
3258
3271
|
if (can) {
|
|
3259
|
-
if (selection instanceof
|
|
3272
|
+
if (selection instanceof TextSelection6) {
|
|
3260
3273
|
tr.deleteSelection();
|
|
3261
3274
|
}
|
|
3262
3275
|
tr.split(tr.mapping.map($from.pos), 1, types);
|
|
@@ -3277,8 +3290,8 @@ var splitBlock = ({ keepMarks = true } = {}) => ({ tr, state, dispatch, editor }
|
|
|
3277
3290
|
};
|
|
3278
3291
|
|
|
3279
3292
|
// src/commands/splitListItem.ts
|
|
3280
|
-
import { Fragment as
|
|
3281
|
-
import { TextSelection as
|
|
3293
|
+
import { Fragment as Fragment5, Slice } from "@tiptap/pm/model";
|
|
3294
|
+
import { TextSelection as TextSelection7 } from "@tiptap/pm/state";
|
|
3282
3295
|
import { canSplit as canSplit2 } from "@tiptap/pm/transform";
|
|
3283
3296
|
var splitListItem = (typeOrName, overrideAttrs = {}) => ({ tr, state, dispatch, editor }) => {
|
|
3284
3297
|
var _a;
|
|
@@ -3298,10 +3311,10 @@ var splitListItem = (typeOrName, overrideAttrs = {}) => ({ tr, state, dispatch,
|
|
|
3298
3311
|
return false;
|
|
3299
3312
|
}
|
|
3300
3313
|
if (dispatch) {
|
|
3301
|
-
let wrap =
|
|
3314
|
+
let wrap = Fragment5.empty;
|
|
3302
3315
|
const depthBefore = $from.index(-1) ? 1 : $from.index(-2) ? 2 : 3;
|
|
3303
3316
|
for (let d = $from.depth - depthBefore; d >= $from.depth - 3; d -= 1) {
|
|
3304
|
-
wrap =
|
|
3317
|
+
wrap = Fragment5.from($from.node(d).copy(wrap));
|
|
3305
3318
|
}
|
|
3306
3319
|
const depthAfter = (
|
|
3307
3320
|
// eslint-disable-next-line no-nested-ternary
|
|
@@ -3312,7 +3325,7 @@ var splitListItem = (typeOrName, overrideAttrs = {}) => ({ tr, state, dispatch,
|
|
|
3312
3325
|
...overrideAttrs
|
|
3313
3326
|
};
|
|
3314
3327
|
const nextType2 = ((_a = type.contentMatch.defaultType) == null ? void 0 : _a.createAndFill(newNextTypeAttributes2)) || void 0;
|
|
3315
|
-
wrap = wrap.append(
|
|
3328
|
+
wrap = wrap.append(Fragment5.from(type.createAndFill(null, nextType2) || void 0));
|
|
3316
3329
|
const start = $from.before($from.depth - (depthBefore - 1));
|
|
3317
3330
|
tr.replace(start, $from.after(-depthAfter), new Slice(wrap, 4 - depthBefore, 0));
|
|
3318
3331
|
let sel = -1;
|
|
@@ -3325,7 +3338,7 @@ var splitListItem = (typeOrName, overrideAttrs = {}) => ({ tr, state, dispatch,
|
|
|
3325
3338
|
}
|
|
3326
3339
|
});
|
|
3327
3340
|
if (sel > -1) {
|
|
3328
|
-
tr.setSelection(
|
|
3341
|
+
tr.setSelection(TextSelection7.near(tr.doc.resolve(sel)));
|
|
3329
3342
|
}
|
|
3330
3343
|
tr.scrollIntoView();
|
|
3331
3344
|
}
|
|
@@ -3780,13 +3793,14 @@ var Editable = Extension.create({
|
|
|
3780
3793
|
|
|
3781
3794
|
// src/extensions/focusEvents.ts
|
|
3782
3795
|
import { Plugin as Plugin6, PluginKey as PluginKey4 } from "@tiptap/pm/state";
|
|
3796
|
+
var focusEventsPluginKey = new PluginKey4("focusEvents");
|
|
3783
3797
|
var FocusEvents = Extension.create({
|
|
3784
3798
|
name: "focusEvents",
|
|
3785
3799
|
addProseMirrorPlugins() {
|
|
3786
3800
|
const { editor } = this;
|
|
3787
3801
|
return [
|
|
3788
3802
|
new Plugin6({
|
|
3789
|
-
key:
|
|
3803
|
+
key: focusEventsPluginKey,
|
|
3790
3804
|
props: {
|
|
3791
3805
|
handleDOMEvents: {
|
|
3792
3806
|
focus: (view, event) => {
|
|
@@ -4228,6 +4242,7 @@ function createStyleTag(style2, nonce, suffix) {
|
|
|
4228
4242
|
var Editor = class extends EventEmitter {
|
|
4229
4243
|
constructor(options = {}) {
|
|
4230
4244
|
super();
|
|
4245
|
+
this.css = null;
|
|
4231
4246
|
this.editorView = null;
|
|
4232
4247
|
this.isFocused = false;
|
|
4233
4248
|
/**
|
|
@@ -4290,7 +4305,7 @@ var Editor = class extends EventEmitter {
|
|
|
4290
4305
|
this.on("delete", this.options.onDelete);
|
|
4291
4306
|
const initialDoc = this.createDoc();
|
|
4292
4307
|
const selection = resolveFocusPosition(initialDoc, this.options.autofocus);
|
|
4293
|
-
this.editorState =
|
|
4308
|
+
this.editorState = EditorState.create({
|
|
4294
4309
|
doc: initialDoc,
|
|
4295
4310
|
schema: this.schema,
|
|
4296
4311
|
selection: selection || void 0
|
|
@@ -4299,6 +4314,9 @@ var Editor = class extends EventEmitter {
|
|
|
4299
4314
|
this.mount(this.options.element);
|
|
4300
4315
|
}
|
|
4301
4316
|
}
|
|
4317
|
+
/**
|
|
4318
|
+
* Attach the editor to the DOM, creating a new editor view.
|
|
4319
|
+
*/
|
|
4302
4320
|
mount(el) {
|
|
4303
4321
|
if (typeof document === "undefined") {
|
|
4304
4322
|
throw new Error(
|
|
@@ -4315,6 +4333,23 @@ var Editor = class extends EventEmitter {
|
|
|
4315
4333
|
this.isInitialized = true;
|
|
4316
4334
|
}, 0);
|
|
4317
4335
|
}
|
|
4336
|
+
/**
|
|
4337
|
+
* Remove the editor from the DOM, but still allow remounting at a different point in time
|
|
4338
|
+
*/
|
|
4339
|
+
unmount() {
|
|
4340
|
+
var _a;
|
|
4341
|
+
if (this.editorView) {
|
|
4342
|
+
const dom = this.editorView.dom;
|
|
4343
|
+
if (dom == null ? void 0 : dom.editor) {
|
|
4344
|
+
delete dom.editor;
|
|
4345
|
+
}
|
|
4346
|
+
this.editorView.destroy();
|
|
4347
|
+
}
|
|
4348
|
+
this.editorView = null;
|
|
4349
|
+
this.isInitialized = false;
|
|
4350
|
+
(_a = this.css) == null ? void 0 : _a.remove();
|
|
4351
|
+
this.css = null;
|
|
4352
|
+
}
|
|
4318
4353
|
/**
|
|
4319
4354
|
* Returns the editor storage.
|
|
4320
4355
|
*/
|
|
@@ -4562,7 +4597,7 @@ var Editor = class extends EventEmitter {
|
|
|
4562
4597
|
dom.editor = this;
|
|
4563
4598
|
}
|
|
4564
4599
|
/**
|
|
4565
|
-
* Creates all node views.
|
|
4600
|
+
* Creates all node and mark views.
|
|
4566
4601
|
*/
|
|
4567
4602
|
createNodeViews() {
|
|
4568
4603
|
if (this.view.isDestroyed) {
|
|
@@ -4706,13 +4741,7 @@ var Editor = class extends EventEmitter {
|
|
|
4706
4741
|
*/
|
|
4707
4742
|
destroy() {
|
|
4708
4743
|
this.emit("destroy");
|
|
4709
|
-
|
|
4710
|
-
const dom = this.editorView.dom;
|
|
4711
|
-
if (dom && dom.editor) {
|
|
4712
|
-
delete dom.editor;
|
|
4713
|
-
}
|
|
4714
|
-
this.editorView.destroy();
|
|
4715
|
-
}
|
|
4744
|
+
this.unmount();
|
|
4716
4745
|
this.removeAllListeners();
|
|
4717
4746
|
}
|
|
4718
4747
|
/**
|
|
@@ -4881,7 +4910,7 @@ function wrappingInputRule(config) {
|
|
|
4881
4910
|
}
|
|
4882
4911
|
|
|
4883
4912
|
// src/jsx-runtime.ts
|
|
4884
|
-
function
|
|
4913
|
+
function Fragment6(props) {
|
|
4885
4914
|
return props.children;
|
|
4886
4915
|
}
|
|
4887
4916
|
var h = (tag, attributes) => {
|
|
@@ -4958,6 +4987,12 @@ var Node3 = class _Node extends Extendable {
|
|
|
4958
4987
|
static create(config = {}) {
|
|
4959
4988
|
return new _Node(config);
|
|
4960
4989
|
}
|
|
4990
|
+
configure(options) {
|
|
4991
|
+
return super.configure(options);
|
|
4992
|
+
}
|
|
4993
|
+
extend(extendedConfig) {
|
|
4994
|
+
return super.extend(extendedConfig);
|
|
4995
|
+
}
|
|
4961
4996
|
};
|
|
4962
4997
|
|
|
4963
4998
|
// src/NodeView.ts
|
|
@@ -5252,7 +5287,7 @@ export {
|
|
|
5252
5287
|
CommandManager,
|
|
5253
5288
|
Editor,
|
|
5254
5289
|
Extension,
|
|
5255
|
-
|
|
5290
|
+
Fragment6 as Fragment,
|
|
5256
5291
|
InputRule,
|
|
5257
5292
|
Mark,
|
|
5258
5293
|
MarkView,
|