@tiptap/core 3.10.8 → 3.11.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 +132 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +61 -4
- package/dist/index.d.ts +61 -4
- package/dist/index.js +125 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/Editor.ts +5 -0
- package/src/commands/index.ts +2 -0
- package/src/commands/setTextDirection.ts +51 -0
- package/src/commands/unsetTextDirection.ts +51 -0
- package/src/extensions/index.ts +1 -0
- package/src/extensions/textDirection.ts +86 -0
- package/src/types.ts +10 -1
package/dist/index.d.cts
CHANGED
|
@@ -1164,6 +1164,14 @@ interface EditorOptions {
|
|
|
1164
1164
|
* Whether the editor is editable
|
|
1165
1165
|
*/
|
|
1166
1166
|
editable: boolean;
|
|
1167
|
+
/**
|
|
1168
|
+
* The default text direction for all content in the editor.
|
|
1169
|
+
* When set to 'ltr' or 'rtl', all nodes will have the corresponding dir attribute.
|
|
1170
|
+
* When set to 'auto', the dir attribute will be set based on content detection.
|
|
1171
|
+
* When undefined, no dir attribute will be added.
|
|
1172
|
+
* @default undefined
|
|
1173
|
+
*/
|
|
1174
|
+
textDirection?: 'ltr' | 'rtl' | 'auto';
|
|
1167
1175
|
/**
|
|
1168
1176
|
* The editor's props
|
|
1169
1177
|
*/
|
|
@@ -1217,7 +1225,7 @@ interface EditorOptions {
|
|
|
1217
1225
|
*
|
|
1218
1226
|
* @default true
|
|
1219
1227
|
*/
|
|
1220
|
-
enableCoreExtensions?: boolean | Partial<Record<'editable' | 'clipboardTextSerializer' | 'commands' | 'focusEvents' | 'keymap' | 'tabindex' | 'drop' | 'paste' | 'delete', false>>;
|
|
1228
|
+
enableCoreExtensions?: boolean | Partial<Record<'editable' | 'clipboardTextSerializer' | 'commands' | 'focusEvents' | 'keymap' | 'tabindex' | 'drop' | 'paste' | 'delete' | 'textDirection', false>>;
|
|
1221
1229
|
/**
|
|
1222
1230
|
* If `true`, the editor will check the content for errors on initialization.
|
|
1223
1231
|
* Emitting the `contentError` event if the content is invalid.
|
|
@@ -2946,6 +2954,23 @@ declare module '@tiptap/core' {
|
|
|
2946
2954
|
}
|
|
2947
2955
|
declare const setNodeSelection: RawCommands['setNodeSelection'];
|
|
2948
2956
|
|
|
2957
|
+
declare module '@tiptap/core' {
|
|
2958
|
+
interface Commands<ReturnType> {
|
|
2959
|
+
setTextDirection: {
|
|
2960
|
+
/**
|
|
2961
|
+
* Set the text direction for nodes.
|
|
2962
|
+
* If no position is provided, it will use the current selection.
|
|
2963
|
+
* @param direction The text direction to set ('ltr', 'rtl', or 'auto')
|
|
2964
|
+
* @param position Optional position or range to apply the direction to
|
|
2965
|
+
* @example editor.commands.setTextDirection('rtl')
|
|
2966
|
+
* @example editor.commands.setTextDirection('ltr', { from: 0, to: 10 })
|
|
2967
|
+
*/
|
|
2968
|
+
setTextDirection: (direction: 'ltr' | 'rtl' | 'auto', position?: number | Range) => ReturnType;
|
|
2969
|
+
};
|
|
2970
|
+
}
|
|
2971
|
+
}
|
|
2972
|
+
declare const setTextDirection: RawCommands['setTextDirection'];
|
|
2973
|
+
|
|
2949
2974
|
declare module '@tiptap/core' {
|
|
2950
2975
|
interface Commands<ReturnType> {
|
|
2951
2976
|
setTextSelection: {
|
|
@@ -3133,6 +3158,22 @@ declare module '@tiptap/core' {
|
|
|
3133
3158
|
}
|
|
3134
3159
|
declare const unsetMark: RawCommands['unsetMark'];
|
|
3135
3160
|
|
|
3161
|
+
declare module '@tiptap/core' {
|
|
3162
|
+
interface Commands<ReturnType> {
|
|
3163
|
+
unsetTextDirection: {
|
|
3164
|
+
/**
|
|
3165
|
+
* Remove the text direction attribute from nodes.
|
|
3166
|
+
* If no position is provided, it will use the current selection.
|
|
3167
|
+
* @param position Optional position or range to remove the direction from
|
|
3168
|
+
* @example editor.commands.unsetTextDirection()
|
|
3169
|
+
* @example editor.commands.unsetTextDirection({ from: 0, to: 10 })
|
|
3170
|
+
*/
|
|
3171
|
+
unsetTextDirection: (position?: number | Range) => ReturnType;
|
|
3172
|
+
};
|
|
3173
|
+
}
|
|
3174
|
+
}
|
|
3175
|
+
declare const unsetTextDirection: RawCommands['unsetTextDirection'];
|
|
3176
|
+
|
|
3136
3177
|
declare module '@tiptap/core' {
|
|
3137
3178
|
interface Commands<ReturnType> {
|
|
3138
3179
|
updateAttributes: {
|
|
@@ -3233,6 +3274,7 @@ declare const index$2_setMark: typeof setMark;
|
|
|
3233
3274
|
declare const index$2_setMeta: typeof setMeta;
|
|
3234
3275
|
declare const index$2_setNode: typeof setNode;
|
|
3235
3276
|
declare const index$2_setNodeSelection: typeof setNodeSelection;
|
|
3277
|
+
declare const index$2_setTextDirection: typeof setTextDirection;
|
|
3236
3278
|
declare const index$2_setTextSelection: typeof setTextSelection;
|
|
3237
3279
|
declare const index$2_sinkListItem: typeof sinkListItem;
|
|
3238
3280
|
declare const index$2_splitBlock: typeof splitBlock;
|
|
@@ -3244,11 +3286,12 @@ declare const index$2_toggleWrap: typeof toggleWrap;
|
|
|
3244
3286
|
declare const index$2_undoInputRule: typeof undoInputRule;
|
|
3245
3287
|
declare const index$2_unsetAllMarks: typeof unsetAllMarks;
|
|
3246
3288
|
declare const index$2_unsetMark: typeof unsetMark;
|
|
3289
|
+
declare const index$2_unsetTextDirection: typeof unsetTextDirection;
|
|
3247
3290
|
declare const index$2_updateAttributes: typeof updateAttributes;
|
|
3248
3291
|
declare const index$2_wrapIn: typeof wrapIn;
|
|
3249
3292
|
declare const index$2_wrapInList: typeof wrapInList;
|
|
3250
3293
|
declare namespace index$2 {
|
|
3251
|
-
export { type index$2_InsertContentAtOptions as InsertContentAtOptions, type index$2_InsertContentOptions as InsertContentOptions, type index$2_SetContentOptions as SetContentOptions, index$2_blur as blur, index$2_clearContent as clearContent, index$2_clearNodes as clearNodes, index$2_command as command, index$2_createParagraphNear as createParagraphNear, index$2_cut as cut, index$2_deleteCurrentNode as deleteCurrentNode, index$2_deleteNode as deleteNode, index$2_deleteRange as deleteRange, index$2_deleteSelection as deleteSelection, index$2_enter as enter, index$2_exitCode as exitCode, index$2_extendMarkRange as extendMarkRange, index$2_first as first, index$2_focus as focus, index$2_forEach as forEach, index$2_insertContent as insertContent, index$2_insertContentAt as insertContentAt, index$2_joinBackward as joinBackward, index$2_joinDown as joinDown, index$2_joinForward as joinForward, index$2_joinItemBackward as joinItemBackward, index$2_joinItemForward as joinItemForward, index$2_joinTextblockBackward as joinTextblockBackward, index$2_joinTextblockForward as joinTextblockForward, index$2_joinUp as joinUp, index$2_keyboardShortcut as keyboardShortcut, index$2_lift as lift, index$2_liftEmptyBlock as liftEmptyBlock, index$2_liftListItem as liftListItem, index$2_newlineInCode as newlineInCode, index$2_resetAttributes as resetAttributes, index$2_scrollIntoView as scrollIntoView, index$2_selectAll as selectAll, index$2_selectNodeBackward as selectNodeBackward, index$2_selectNodeForward as selectNodeForward, index$2_selectParentNode as selectParentNode, index$2_selectTextblockEnd as selectTextblockEnd, index$2_selectTextblockStart as selectTextblockStart, index$2_setContent as setContent, index$2_setMark as setMark, index$2_setMeta as setMeta, index$2_setNode as setNode, index$2_setNodeSelection as setNodeSelection, index$2_setTextSelection as setTextSelection, index$2_sinkListItem as sinkListItem, index$2_splitBlock as splitBlock, index$2_splitListItem as splitListItem, index$2_toggleList as toggleList, index$2_toggleMark as toggleMark, index$2_toggleNode as toggleNode, index$2_toggleWrap as toggleWrap, index$2_undoInputRule as undoInputRule, index$2_unsetAllMarks as unsetAllMarks, index$2_unsetMark as unsetMark, index$2_updateAttributes as updateAttributes, index$2_wrapIn as wrapIn, index$2_wrapInList as wrapInList };
|
|
3294
|
+
export { type index$2_InsertContentAtOptions as InsertContentAtOptions, type index$2_InsertContentOptions as InsertContentOptions, type index$2_SetContentOptions as SetContentOptions, index$2_blur as blur, index$2_clearContent as clearContent, index$2_clearNodes as clearNodes, index$2_command as command, index$2_createParagraphNear as createParagraphNear, index$2_cut as cut, index$2_deleteCurrentNode as deleteCurrentNode, index$2_deleteNode as deleteNode, index$2_deleteRange as deleteRange, index$2_deleteSelection as deleteSelection, index$2_enter as enter, index$2_exitCode as exitCode, index$2_extendMarkRange as extendMarkRange, index$2_first as first, index$2_focus as focus, index$2_forEach as forEach, index$2_insertContent as insertContent, index$2_insertContentAt as insertContentAt, index$2_joinBackward as joinBackward, index$2_joinDown as joinDown, index$2_joinForward as joinForward, index$2_joinItemBackward as joinItemBackward, index$2_joinItemForward as joinItemForward, index$2_joinTextblockBackward as joinTextblockBackward, index$2_joinTextblockForward as joinTextblockForward, index$2_joinUp as joinUp, index$2_keyboardShortcut as keyboardShortcut, index$2_lift as lift, index$2_liftEmptyBlock as liftEmptyBlock, index$2_liftListItem as liftListItem, index$2_newlineInCode as newlineInCode, index$2_resetAttributes as resetAttributes, index$2_scrollIntoView as scrollIntoView, index$2_selectAll as selectAll, index$2_selectNodeBackward as selectNodeBackward, index$2_selectNodeForward as selectNodeForward, index$2_selectParentNode as selectParentNode, index$2_selectTextblockEnd as selectTextblockEnd, index$2_selectTextblockStart as selectTextblockStart, index$2_setContent as setContent, index$2_setMark as setMark, index$2_setMeta as setMeta, index$2_setNode as setNode, index$2_setNodeSelection as setNodeSelection, index$2_setTextDirection as setTextDirection, index$2_setTextSelection as setTextSelection, index$2_sinkListItem as sinkListItem, index$2_splitBlock as splitBlock, index$2_splitListItem as splitListItem, index$2_toggleList as toggleList, index$2_toggleMark as toggleMark, index$2_toggleNode as toggleNode, index$2_toggleWrap as toggleWrap, index$2_undoInputRule as undoInputRule, index$2_unsetAllMarks as unsetAllMarks, index$2_unsetMark as unsetMark, index$2_unsetTextDirection as unsetTextDirection, index$2_updateAttributes as updateAttributes, index$2_wrapIn as wrapIn, index$2_wrapInList as wrapInList };
|
|
3252
3295
|
}
|
|
3253
3296
|
|
|
3254
3297
|
declare const Commands$1: Extension<any, any>;
|
|
@@ -3271,6 +3314,19 @@ declare const Paste: Extension<any, any>;
|
|
|
3271
3314
|
|
|
3272
3315
|
declare const Tabindex: Extension<any, any>;
|
|
3273
3316
|
|
|
3317
|
+
interface TextDirectionOptions {
|
|
3318
|
+
direction: 'ltr' | 'rtl' | 'auto' | undefined;
|
|
3319
|
+
}
|
|
3320
|
+
/**
|
|
3321
|
+
* The TextDirection extension adds support for setting text direction (LTR/RTL/auto)
|
|
3322
|
+
* on all nodes in the editor.
|
|
3323
|
+
*
|
|
3324
|
+
* This extension adds a global `dir` attribute to all node types, which can be used
|
|
3325
|
+
* to control bidirectional text rendering. The direction can be set globally via
|
|
3326
|
+
* editor options or per-node using commands.
|
|
3327
|
+
*/
|
|
3328
|
+
declare const TextDirection: Extension<TextDirectionOptions, any>;
|
|
3329
|
+
|
|
3274
3330
|
declare const index$1_ClipboardTextSerializer: typeof ClipboardTextSerializer;
|
|
3275
3331
|
declare const index$1_Delete: typeof Delete;
|
|
3276
3332
|
declare const index$1_Drop: typeof Drop;
|
|
@@ -3279,9 +3335,10 @@ declare const index$1_FocusEvents: typeof FocusEvents;
|
|
|
3279
3335
|
declare const index$1_Keymap: typeof Keymap;
|
|
3280
3336
|
declare const index$1_Paste: typeof Paste;
|
|
3281
3337
|
declare const index$1_Tabindex: typeof Tabindex;
|
|
3338
|
+
declare const index$1_TextDirection: typeof TextDirection;
|
|
3282
3339
|
declare const index$1_focusEventsPluginKey: typeof focusEventsPluginKey;
|
|
3283
3340
|
declare namespace index$1 {
|
|
3284
|
-
export { index$1_ClipboardTextSerializer as ClipboardTextSerializer, Commands$1 as Commands, index$1_Delete as Delete, index$1_Drop as Drop, index$1_Editable as Editable, index$1_FocusEvents as FocusEvents, index$1_Keymap as Keymap, index$1_Paste as Paste, index$1_Tabindex as Tabindex, index$1_focusEventsPluginKey as focusEventsPluginKey };
|
|
3341
|
+
export { index$1_ClipboardTextSerializer as ClipboardTextSerializer, Commands$1 as Commands, index$1_Delete as Delete, index$1_Drop as Drop, index$1_Editable as Editable, index$1_FocusEvents as FocusEvents, index$1_Keymap as Keymap, index$1_Paste as Paste, index$1_Tabindex as Tabindex, index$1_TextDirection as TextDirection, index$1_focusEventsPluginKey as focusEventsPluginKey };
|
|
3285
3342
|
}
|
|
3286
3343
|
|
|
3287
3344
|
interface TiptapEditorHTMLElement extends HTMLElement {
|
|
@@ -4586,4 +4643,4 @@ interface Commands<ReturnType = any> {
|
|
|
4586
4643
|
interface Storage {
|
|
4587
4644
|
}
|
|
4588
4645
|
|
|
4589
|
-
export { type AnyCommands, type AnyConfig, type AnyExtension, type AtomBlockMarkdownSpecOptions, type Attribute, type Attributes$1 as Attributes, type BlockMarkdownSpecOptions, type BlockParserConfig, type CanCommands, type ChainedCommands, type ChangedRange, type Command, CommandManager, type CommandProps, type CommandSpec, type Commands, type Content, type CreateNodeFromContentOptions, type DOMNode, type DOMOutputSpecArray$1 as DOMOutputSpecArray, type DecorationType, type DecorationWithType, type Diff, type Dispatch, type DocumentType, Editor, type EditorEvents, type EditorOptions, type EnableRules, Extendable, type ExtendableConfig, type ExtendedRegExpMatchArray, Extension, type ExtensionAttribute, type ExtensionConfig, type Extensions, type FocusPosition, Fragment, type FullMarkdownHelpers, type GlobalAttributes, type HTMLContent, type InlineMarkdownSpecOptions, InputRule, type InputRuleFinder, type InputRuleMatch, type InsertContentAtOptions, type InsertContentOptions, type JSONContent, type KeyboardShortcutCommand, type KeysWithTypeOf, Mark, type MarkConfig, type MarkRange, type MarkType, MarkView, type MarkViewProps, type MarkViewRenderer, type MarkViewRendererOptions, type MarkViewRendererProps, type MarkdownExtensionSpec, type MarkdownHelpers, type MarkdownLexerConfiguration, type MarkdownParseHelpers, type MarkdownParseResult, type MarkdownRendererHelpers, type MarkdownToken, type MarkdownTokenizer, type MaybeReturnType, type MaybeThisParameterType, Node, type NodeConfig, NodePos, type NodeRange, type NodeType, NodeView, type NodeViewProps, type NodeViewRenderer, type NodeViewRendererOptions, type NodeViewRendererProps, type NodeWithPos, type Overwrite, type ParentConfig, type ParsedBlock, PasteRule, type PasteRuleFinder, type PasteRuleMatch, type PickValue, type Predicate, type Primitive, type Range, type RawCommands, type RemoveThis, type RenderContext, type ResizableNodeDimensions, ResizableNodeView, type ResizableNodeViewDirection, type ResizableNodeViewOptions, ResizableNodeview, type SetContentOptions, type SingleCommands, type Storage, type TextSerializer, type TextType, type TiptapEditorHTMLElement, Tracker, type TrackerResult, type UnionCommands, type UnionToIntersection, type ValuesOf, blur, callOrReturn, canInsertNode, clearContent, clearNodes, combineTransactionSteps, command, index$2 as commands, createAtomBlockMarkdownSpec, createBlockMarkdownSpec, createChainableState, createDocument, h as createElement, createInlineMarkdownSpec, createNodeFromContent, createParagraphNear, createStyleTag, cut, defaultBlockAt, deleteCurrentNode, deleteNode, deleteProps, deleteRange, deleteSelection, elementFromString, enter, escapeForRegEx, exitCode, extendMarkRange, index$1 as extensions, findChildren, findChildrenInRange, findDuplicates, findParentNode, findParentNodeClosestToPos, first, flattenExtensions, focus, forEach, fromString, generateHTML, generateJSON, generateText, getAttributes, getAttributesFromExtensions, getChangedRanges, getDebugJSON, getExtensionField, getHTMLFromFragment, getMarkAttributes, getMarkRange, getMarkType, getMarksBetween, getNodeAtPosition, getNodeAttributes, getNodeType, getRenderedAttributes, getSchema, getSchemaByResolvedExtensions, getSchemaTypeByName, getSchemaTypeNameByName, getSplittedAttributes, getText, getTextBetween, getTextContentFromNodes, getTextSerializersFromSchema, h, injectExtensionAttributesToParseRule, inputRulesPlugin, insertContent, insertContentAt, isActive, isAndroid, isAtEndOfNode, isAtStartOfNode, isEmptyObject, isExtensionRulesEnabled, isFunction, isList, isMacOS, isMarkActive, isNodeActive, isNodeEmpty, isNodeSelection, isNumber, isPlainObject, isRegExp, isString, isTextSelection, isiOS, joinBackward, joinDown, joinForward, joinItemBackward, joinItemForward, joinTextblockBackward, joinTextblockForward, joinUp, keyboardShortcut, lift, liftEmptyBlock, liftListItem, markInputRule, markPasteRule, index as markdown, mergeAttributes, mergeDeep, minMax, newlineInCode, nodeInputRule, nodePasteRule, objectIncludes, parseAttributes, parseIndentedBlocks, pasteRulesPlugin, posToDOMRect, removeDuplicates, renderNestedMarkdownContent, resetAttributes, resolveExtensions, resolveFocusPosition, rewriteUnknownContent, scrollIntoView, selectAll, selectNodeBackward, selectNodeForward, selectParentNode, selectTextblockEnd, selectTextblockStart, selectionToInsertionEnd, serializeAttributes, setContent, setMark, setMeta, setNode, setNodeSelection, setTextSelection, sinkListItem, sortExtensions, splitBlock, splitExtensions, splitListItem, textInputRule, textPasteRule, textblockTypeInputRule, toggleList, toggleMark, toggleNode, toggleWrap, undoInputRule, unsetAllMarks, unsetMark, updateAttributes, updateMarkViewAttributes, wrapIn, wrapInList, wrappingInputRule };
|
|
4646
|
+
export { type AnyCommands, type AnyConfig, type AnyExtension, type AtomBlockMarkdownSpecOptions, type Attribute, type Attributes$1 as Attributes, type BlockMarkdownSpecOptions, type BlockParserConfig, type CanCommands, type ChainedCommands, type ChangedRange, type Command, CommandManager, type CommandProps, type CommandSpec, type Commands, type Content, type CreateNodeFromContentOptions, type DOMNode, type DOMOutputSpecArray$1 as DOMOutputSpecArray, type DecorationType, type DecorationWithType, type Diff, type Dispatch, type DocumentType, Editor, type EditorEvents, type EditorOptions, type EnableRules, Extendable, type ExtendableConfig, type ExtendedRegExpMatchArray, Extension, type ExtensionAttribute, type ExtensionConfig, type Extensions, type FocusPosition, Fragment, type FullMarkdownHelpers, type GlobalAttributes, type HTMLContent, type InlineMarkdownSpecOptions, InputRule, type InputRuleFinder, type InputRuleMatch, type InsertContentAtOptions, type InsertContentOptions, type JSONContent, type KeyboardShortcutCommand, type KeysWithTypeOf, Mark, type MarkConfig, type MarkRange, type MarkType, MarkView, type MarkViewProps, type MarkViewRenderer, type MarkViewRendererOptions, type MarkViewRendererProps, type MarkdownExtensionSpec, type MarkdownHelpers, type MarkdownLexerConfiguration, type MarkdownParseHelpers, type MarkdownParseResult, type MarkdownRendererHelpers, type MarkdownToken, type MarkdownTokenizer, type MaybeReturnType, type MaybeThisParameterType, Node, type NodeConfig, NodePos, type NodeRange, type NodeType, NodeView, type NodeViewProps, type NodeViewRenderer, type NodeViewRendererOptions, type NodeViewRendererProps, type NodeWithPos, type Overwrite, type ParentConfig, type ParsedBlock, PasteRule, type PasteRuleFinder, type PasteRuleMatch, type PickValue, type Predicate, type Primitive, type Range, type RawCommands, type RemoveThis, type RenderContext, type ResizableNodeDimensions, ResizableNodeView, type ResizableNodeViewDirection, type ResizableNodeViewOptions, ResizableNodeview, type SetContentOptions, type SingleCommands, type Storage, type TextSerializer, type TextType, type TiptapEditorHTMLElement, Tracker, type TrackerResult, type UnionCommands, type UnionToIntersection, type ValuesOf, blur, callOrReturn, canInsertNode, clearContent, clearNodes, combineTransactionSteps, command, index$2 as commands, createAtomBlockMarkdownSpec, createBlockMarkdownSpec, createChainableState, createDocument, h as createElement, createInlineMarkdownSpec, createNodeFromContent, createParagraphNear, createStyleTag, cut, defaultBlockAt, deleteCurrentNode, deleteNode, deleteProps, deleteRange, deleteSelection, elementFromString, enter, escapeForRegEx, exitCode, extendMarkRange, index$1 as extensions, findChildren, findChildrenInRange, findDuplicates, findParentNode, findParentNodeClosestToPos, first, flattenExtensions, focus, forEach, fromString, generateHTML, generateJSON, generateText, getAttributes, getAttributesFromExtensions, getChangedRanges, getDebugJSON, getExtensionField, getHTMLFromFragment, getMarkAttributes, getMarkRange, getMarkType, getMarksBetween, getNodeAtPosition, getNodeAttributes, getNodeType, getRenderedAttributes, getSchema, getSchemaByResolvedExtensions, getSchemaTypeByName, getSchemaTypeNameByName, getSplittedAttributes, getText, getTextBetween, getTextContentFromNodes, getTextSerializersFromSchema, h, injectExtensionAttributesToParseRule, inputRulesPlugin, insertContent, insertContentAt, isActive, isAndroid, isAtEndOfNode, isAtStartOfNode, isEmptyObject, isExtensionRulesEnabled, isFunction, isList, isMacOS, isMarkActive, isNodeActive, isNodeEmpty, isNodeSelection, isNumber, isPlainObject, isRegExp, isString, isTextSelection, isiOS, joinBackward, joinDown, joinForward, joinItemBackward, joinItemForward, joinTextblockBackward, joinTextblockForward, joinUp, keyboardShortcut, lift, liftEmptyBlock, liftListItem, markInputRule, markPasteRule, index as markdown, mergeAttributes, mergeDeep, minMax, newlineInCode, nodeInputRule, nodePasteRule, objectIncludes, parseAttributes, parseIndentedBlocks, pasteRulesPlugin, posToDOMRect, removeDuplicates, renderNestedMarkdownContent, resetAttributes, resolveExtensions, resolveFocusPosition, rewriteUnknownContent, scrollIntoView, selectAll, selectNodeBackward, selectNodeForward, selectParentNode, selectTextblockEnd, selectTextblockStart, selectionToInsertionEnd, serializeAttributes, setContent, setMark, setMeta, setNode, setNodeSelection, setTextDirection, setTextSelection, sinkListItem, sortExtensions, splitBlock, splitExtensions, splitListItem, textInputRule, textPasteRule, textblockTypeInputRule, toggleList, toggleMark, toggleNode, toggleWrap, undoInputRule, unsetAllMarks, unsetMark, unsetTextDirection, updateAttributes, updateMarkViewAttributes, wrapIn, wrapInList, wrappingInputRule };
|
package/dist/index.d.ts
CHANGED
|
@@ -1164,6 +1164,14 @@ interface EditorOptions {
|
|
|
1164
1164
|
* Whether the editor is editable
|
|
1165
1165
|
*/
|
|
1166
1166
|
editable: boolean;
|
|
1167
|
+
/**
|
|
1168
|
+
* The default text direction for all content in the editor.
|
|
1169
|
+
* When set to 'ltr' or 'rtl', all nodes will have the corresponding dir attribute.
|
|
1170
|
+
* When set to 'auto', the dir attribute will be set based on content detection.
|
|
1171
|
+
* When undefined, no dir attribute will be added.
|
|
1172
|
+
* @default undefined
|
|
1173
|
+
*/
|
|
1174
|
+
textDirection?: 'ltr' | 'rtl' | 'auto';
|
|
1167
1175
|
/**
|
|
1168
1176
|
* The editor's props
|
|
1169
1177
|
*/
|
|
@@ -1217,7 +1225,7 @@ interface EditorOptions {
|
|
|
1217
1225
|
*
|
|
1218
1226
|
* @default true
|
|
1219
1227
|
*/
|
|
1220
|
-
enableCoreExtensions?: boolean | Partial<Record<'editable' | 'clipboardTextSerializer' | 'commands' | 'focusEvents' | 'keymap' | 'tabindex' | 'drop' | 'paste' | 'delete', false>>;
|
|
1228
|
+
enableCoreExtensions?: boolean | Partial<Record<'editable' | 'clipboardTextSerializer' | 'commands' | 'focusEvents' | 'keymap' | 'tabindex' | 'drop' | 'paste' | 'delete' | 'textDirection', false>>;
|
|
1221
1229
|
/**
|
|
1222
1230
|
* If `true`, the editor will check the content for errors on initialization.
|
|
1223
1231
|
* Emitting the `contentError` event if the content is invalid.
|
|
@@ -2946,6 +2954,23 @@ declare module '@tiptap/core' {
|
|
|
2946
2954
|
}
|
|
2947
2955
|
declare const setNodeSelection: RawCommands['setNodeSelection'];
|
|
2948
2956
|
|
|
2957
|
+
declare module '@tiptap/core' {
|
|
2958
|
+
interface Commands<ReturnType> {
|
|
2959
|
+
setTextDirection: {
|
|
2960
|
+
/**
|
|
2961
|
+
* Set the text direction for nodes.
|
|
2962
|
+
* If no position is provided, it will use the current selection.
|
|
2963
|
+
* @param direction The text direction to set ('ltr', 'rtl', or 'auto')
|
|
2964
|
+
* @param position Optional position or range to apply the direction to
|
|
2965
|
+
* @example editor.commands.setTextDirection('rtl')
|
|
2966
|
+
* @example editor.commands.setTextDirection('ltr', { from: 0, to: 10 })
|
|
2967
|
+
*/
|
|
2968
|
+
setTextDirection: (direction: 'ltr' | 'rtl' | 'auto', position?: number | Range) => ReturnType;
|
|
2969
|
+
};
|
|
2970
|
+
}
|
|
2971
|
+
}
|
|
2972
|
+
declare const setTextDirection: RawCommands['setTextDirection'];
|
|
2973
|
+
|
|
2949
2974
|
declare module '@tiptap/core' {
|
|
2950
2975
|
interface Commands<ReturnType> {
|
|
2951
2976
|
setTextSelection: {
|
|
@@ -3133,6 +3158,22 @@ declare module '@tiptap/core' {
|
|
|
3133
3158
|
}
|
|
3134
3159
|
declare const unsetMark: RawCommands['unsetMark'];
|
|
3135
3160
|
|
|
3161
|
+
declare module '@tiptap/core' {
|
|
3162
|
+
interface Commands<ReturnType> {
|
|
3163
|
+
unsetTextDirection: {
|
|
3164
|
+
/**
|
|
3165
|
+
* Remove the text direction attribute from nodes.
|
|
3166
|
+
* If no position is provided, it will use the current selection.
|
|
3167
|
+
* @param position Optional position or range to remove the direction from
|
|
3168
|
+
* @example editor.commands.unsetTextDirection()
|
|
3169
|
+
* @example editor.commands.unsetTextDirection({ from: 0, to: 10 })
|
|
3170
|
+
*/
|
|
3171
|
+
unsetTextDirection: (position?: number | Range) => ReturnType;
|
|
3172
|
+
};
|
|
3173
|
+
}
|
|
3174
|
+
}
|
|
3175
|
+
declare const unsetTextDirection: RawCommands['unsetTextDirection'];
|
|
3176
|
+
|
|
3136
3177
|
declare module '@tiptap/core' {
|
|
3137
3178
|
interface Commands<ReturnType> {
|
|
3138
3179
|
updateAttributes: {
|
|
@@ -3233,6 +3274,7 @@ declare const index$2_setMark: typeof setMark;
|
|
|
3233
3274
|
declare const index$2_setMeta: typeof setMeta;
|
|
3234
3275
|
declare const index$2_setNode: typeof setNode;
|
|
3235
3276
|
declare const index$2_setNodeSelection: typeof setNodeSelection;
|
|
3277
|
+
declare const index$2_setTextDirection: typeof setTextDirection;
|
|
3236
3278
|
declare const index$2_setTextSelection: typeof setTextSelection;
|
|
3237
3279
|
declare const index$2_sinkListItem: typeof sinkListItem;
|
|
3238
3280
|
declare const index$2_splitBlock: typeof splitBlock;
|
|
@@ -3244,11 +3286,12 @@ declare const index$2_toggleWrap: typeof toggleWrap;
|
|
|
3244
3286
|
declare const index$2_undoInputRule: typeof undoInputRule;
|
|
3245
3287
|
declare const index$2_unsetAllMarks: typeof unsetAllMarks;
|
|
3246
3288
|
declare const index$2_unsetMark: typeof unsetMark;
|
|
3289
|
+
declare const index$2_unsetTextDirection: typeof unsetTextDirection;
|
|
3247
3290
|
declare const index$2_updateAttributes: typeof updateAttributes;
|
|
3248
3291
|
declare const index$2_wrapIn: typeof wrapIn;
|
|
3249
3292
|
declare const index$2_wrapInList: typeof wrapInList;
|
|
3250
3293
|
declare namespace index$2 {
|
|
3251
|
-
export { type index$2_InsertContentAtOptions as InsertContentAtOptions, type index$2_InsertContentOptions as InsertContentOptions, type index$2_SetContentOptions as SetContentOptions, index$2_blur as blur, index$2_clearContent as clearContent, index$2_clearNodes as clearNodes, index$2_command as command, index$2_createParagraphNear as createParagraphNear, index$2_cut as cut, index$2_deleteCurrentNode as deleteCurrentNode, index$2_deleteNode as deleteNode, index$2_deleteRange as deleteRange, index$2_deleteSelection as deleteSelection, index$2_enter as enter, index$2_exitCode as exitCode, index$2_extendMarkRange as extendMarkRange, index$2_first as first, index$2_focus as focus, index$2_forEach as forEach, index$2_insertContent as insertContent, index$2_insertContentAt as insertContentAt, index$2_joinBackward as joinBackward, index$2_joinDown as joinDown, index$2_joinForward as joinForward, index$2_joinItemBackward as joinItemBackward, index$2_joinItemForward as joinItemForward, index$2_joinTextblockBackward as joinTextblockBackward, index$2_joinTextblockForward as joinTextblockForward, index$2_joinUp as joinUp, index$2_keyboardShortcut as keyboardShortcut, index$2_lift as lift, index$2_liftEmptyBlock as liftEmptyBlock, index$2_liftListItem as liftListItem, index$2_newlineInCode as newlineInCode, index$2_resetAttributes as resetAttributes, index$2_scrollIntoView as scrollIntoView, index$2_selectAll as selectAll, index$2_selectNodeBackward as selectNodeBackward, index$2_selectNodeForward as selectNodeForward, index$2_selectParentNode as selectParentNode, index$2_selectTextblockEnd as selectTextblockEnd, index$2_selectTextblockStart as selectTextblockStart, index$2_setContent as setContent, index$2_setMark as setMark, index$2_setMeta as setMeta, index$2_setNode as setNode, index$2_setNodeSelection as setNodeSelection, index$2_setTextSelection as setTextSelection, index$2_sinkListItem as sinkListItem, index$2_splitBlock as splitBlock, index$2_splitListItem as splitListItem, index$2_toggleList as toggleList, index$2_toggleMark as toggleMark, index$2_toggleNode as toggleNode, index$2_toggleWrap as toggleWrap, index$2_undoInputRule as undoInputRule, index$2_unsetAllMarks as unsetAllMarks, index$2_unsetMark as unsetMark, index$2_updateAttributes as updateAttributes, index$2_wrapIn as wrapIn, index$2_wrapInList as wrapInList };
|
|
3294
|
+
export { type index$2_InsertContentAtOptions as InsertContentAtOptions, type index$2_InsertContentOptions as InsertContentOptions, type index$2_SetContentOptions as SetContentOptions, index$2_blur as blur, index$2_clearContent as clearContent, index$2_clearNodes as clearNodes, index$2_command as command, index$2_createParagraphNear as createParagraphNear, index$2_cut as cut, index$2_deleteCurrentNode as deleteCurrentNode, index$2_deleteNode as deleteNode, index$2_deleteRange as deleteRange, index$2_deleteSelection as deleteSelection, index$2_enter as enter, index$2_exitCode as exitCode, index$2_extendMarkRange as extendMarkRange, index$2_first as first, index$2_focus as focus, index$2_forEach as forEach, index$2_insertContent as insertContent, index$2_insertContentAt as insertContentAt, index$2_joinBackward as joinBackward, index$2_joinDown as joinDown, index$2_joinForward as joinForward, index$2_joinItemBackward as joinItemBackward, index$2_joinItemForward as joinItemForward, index$2_joinTextblockBackward as joinTextblockBackward, index$2_joinTextblockForward as joinTextblockForward, index$2_joinUp as joinUp, index$2_keyboardShortcut as keyboardShortcut, index$2_lift as lift, index$2_liftEmptyBlock as liftEmptyBlock, index$2_liftListItem as liftListItem, index$2_newlineInCode as newlineInCode, index$2_resetAttributes as resetAttributes, index$2_scrollIntoView as scrollIntoView, index$2_selectAll as selectAll, index$2_selectNodeBackward as selectNodeBackward, index$2_selectNodeForward as selectNodeForward, index$2_selectParentNode as selectParentNode, index$2_selectTextblockEnd as selectTextblockEnd, index$2_selectTextblockStart as selectTextblockStart, index$2_setContent as setContent, index$2_setMark as setMark, index$2_setMeta as setMeta, index$2_setNode as setNode, index$2_setNodeSelection as setNodeSelection, index$2_setTextDirection as setTextDirection, index$2_setTextSelection as setTextSelection, index$2_sinkListItem as sinkListItem, index$2_splitBlock as splitBlock, index$2_splitListItem as splitListItem, index$2_toggleList as toggleList, index$2_toggleMark as toggleMark, index$2_toggleNode as toggleNode, index$2_toggleWrap as toggleWrap, index$2_undoInputRule as undoInputRule, index$2_unsetAllMarks as unsetAllMarks, index$2_unsetMark as unsetMark, index$2_unsetTextDirection as unsetTextDirection, index$2_updateAttributes as updateAttributes, index$2_wrapIn as wrapIn, index$2_wrapInList as wrapInList };
|
|
3252
3295
|
}
|
|
3253
3296
|
|
|
3254
3297
|
declare const Commands$1: Extension<any, any>;
|
|
@@ -3271,6 +3314,19 @@ declare const Paste: Extension<any, any>;
|
|
|
3271
3314
|
|
|
3272
3315
|
declare const Tabindex: Extension<any, any>;
|
|
3273
3316
|
|
|
3317
|
+
interface TextDirectionOptions {
|
|
3318
|
+
direction: 'ltr' | 'rtl' | 'auto' | undefined;
|
|
3319
|
+
}
|
|
3320
|
+
/**
|
|
3321
|
+
* The TextDirection extension adds support for setting text direction (LTR/RTL/auto)
|
|
3322
|
+
* on all nodes in the editor.
|
|
3323
|
+
*
|
|
3324
|
+
* This extension adds a global `dir` attribute to all node types, which can be used
|
|
3325
|
+
* to control bidirectional text rendering. The direction can be set globally via
|
|
3326
|
+
* editor options or per-node using commands.
|
|
3327
|
+
*/
|
|
3328
|
+
declare const TextDirection: Extension<TextDirectionOptions, any>;
|
|
3329
|
+
|
|
3274
3330
|
declare const index$1_ClipboardTextSerializer: typeof ClipboardTextSerializer;
|
|
3275
3331
|
declare const index$1_Delete: typeof Delete;
|
|
3276
3332
|
declare const index$1_Drop: typeof Drop;
|
|
@@ -3279,9 +3335,10 @@ declare const index$1_FocusEvents: typeof FocusEvents;
|
|
|
3279
3335
|
declare const index$1_Keymap: typeof Keymap;
|
|
3280
3336
|
declare const index$1_Paste: typeof Paste;
|
|
3281
3337
|
declare const index$1_Tabindex: typeof Tabindex;
|
|
3338
|
+
declare const index$1_TextDirection: typeof TextDirection;
|
|
3282
3339
|
declare const index$1_focusEventsPluginKey: typeof focusEventsPluginKey;
|
|
3283
3340
|
declare namespace index$1 {
|
|
3284
|
-
export { index$1_ClipboardTextSerializer as ClipboardTextSerializer, Commands$1 as Commands, index$1_Delete as Delete, index$1_Drop as Drop, index$1_Editable as Editable, index$1_FocusEvents as FocusEvents, index$1_Keymap as Keymap, index$1_Paste as Paste, index$1_Tabindex as Tabindex, index$1_focusEventsPluginKey as focusEventsPluginKey };
|
|
3341
|
+
export { index$1_ClipboardTextSerializer as ClipboardTextSerializer, Commands$1 as Commands, index$1_Delete as Delete, index$1_Drop as Drop, index$1_Editable as Editable, index$1_FocusEvents as FocusEvents, index$1_Keymap as Keymap, index$1_Paste as Paste, index$1_Tabindex as Tabindex, index$1_TextDirection as TextDirection, index$1_focusEventsPluginKey as focusEventsPluginKey };
|
|
3285
3342
|
}
|
|
3286
3343
|
|
|
3287
3344
|
interface TiptapEditorHTMLElement extends HTMLElement {
|
|
@@ -4586,4 +4643,4 @@ interface Commands<ReturnType = any> {
|
|
|
4586
4643
|
interface Storage {
|
|
4587
4644
|
}
|
|
4588
4645
|
|
|
4589
|
-
export { type AnyCommands, type AnyConfig, type AnyExtension, type AtomBlockMarkdownSpecOptions, type Attribute, type Attributes$1 as Attributes, type BlockMarkdownSpecOptions, type BlockParserConfig, type CanCommands, type ChainedCommands, type ChangedRange, type Command, CommandManager, type CommandProps, type CommandSpec, type Commands, type Content, type CreateNodeFromContentOptions, type DOMNode, type DOMOutputSpecArray$1 as DOMOutputSpecArray, type DecorationType, type DecorationWithType, type Diff, type Dispatch, type DocumentType, Editor, type EditorEvents, type EditorOptions, type EnableRules, Extendable, type ExtendableConfig, type ExtendedRegExpMatchArray, Extension, type ExtensionAttribute, type ExtensionConfig, type Extensions, type FocusPosition, Fragment, type FullMarkdownHelpers, type GlobalAttributes, type HTMLContent, type InlineMarkdownSpecOptions, InputRule, type InputRuleFinder, type InputRuleMatch, type InsertContentAtOptions, type InsertContentOptions, type JSONContent, type KeyboardShortcutCommand, type KeysWithTypeOf, Mark, type MarkConfig, type MarkRange, type MarkType, MarkView, type MarkViewProps, type MarkViewRenderer, type MarkViewRendererOptions, type MarkViewRendererProps, type MarkdownExtensionSpec, type MarkdownHelpers, type MarkdownLexerConfiguration, type MarkdownParseHelpers, type MarkdownParseResult, type MarkdownRendererHelpers, type MarkdownToken, type MarkdownTokenizer, type MaybeReturnType, type MaybeThisParameterType, Node, type NodeConfig, NodePos, type NodeRange, type NodeType, NodeView, type NodeViewProps, type NodeViewRenderer, type NodeViewRendererOptions, type NodeViewRendererProps, type NodeWithPos, type Overwrite, type ParentConfig, type ParsedBlock, PasteRule, type PasteRuleFinder, type PasteRuleMatch, type PickValue, type Predicate, type Primitive, type Range, type RawCommands, type RemoveThis, type RenderContext, type ResizableNodeDimensions, ResizableNodeView, type ResizableNodeViewDirection, type ResizableNodeViewOptions, ResizableNodeview, type SetContentOptions, type SingleCommands, type Storage, type TextSerializer, type TextType, type TiptapEditorHTMLElement, Tracker, type TrackerResult, type UnionCommands, type UnionToIntersection, type ValuesOf, blur, callOrReturn, canInsertNode, clearContent, clearNodes, combineTransactionSteps, command, index$2 as commands, createAtomBlockMarkdownSpec, createBlockMarkdownSpec, createChainableState, createDocument, h as createElement, createInlineMarkdownSpec, createNodeFromContent, createParagraphNear, createStyleTag, cut, defaultBlockAt, deleteCurrentNode, deleteNode, deleteProps, deleteRange, deleteSelection, elementFromString, enter, escapeForRegEx, exitCode, extendMarkRange, index$1 as extensions, findChildren, findChildrenInRange, findDuplicates, findParentNode, findParentNodeClosestToPos, first, flattenExtensions, focus, forEach, fromString, generateHTML, generateJSON, generateText, getAttributes, getAttributesFromExtensions, getChangedRanges, getDebugJSON, getExtensionField, getHTMLFromFragment, getMarkAttributes, getMarkRange, getMarkType, getMarksBetween, getNodeAtPosition, getNodeAttributes, getNodeType, getRenderedAttributes, getSchema, getSchemaByResolvedExtensions, getSchemaTypeByName, getSchemaTypeNameByName, getSplittedAttributes, getText, getTextBetween, getTextContentFromNodes, getTextSerializersFromSchema, h, injectExtensionAttributesToParseRule, inputRulesPlugin, insertContent, insertContentAt, isActive, isAndroid, isAtEndOfNode, isAtStartOfNode, isEmptyObject, isExtensionRulesEnabled, isFunction, isList, isMacOS, isMarkActive, isNodeActive, isNodeEmpty, isNodeSelection, isNumber, isPlainObject, isRegExp, isString, isTextSelection, isiOS, joinBackward, joinDown, joinForward, joinItemBackward, joinItemForward, joinTextblockBackward, joinTextblockForward, joinUp, keyboardShortcut, lift, liftEmptyBlock, liftListItem, markInputRule, markPasteRule, index as markdown, mergeAttributes, mergeDeep, minMax, newlineInCode, nodeInputRule, nodePasteRule, objectIncludes, parseAttributes, parseIndentedBlocks, pasteRulesPlugin, posToDOMRect, removeDuplicates, renderNestedMarkdownContent, resetAttributes, resolveExtensions, resolveFocusPosition, rewriteUnknownContent, scrollIntoView, selectAll, selectNodeBackward, selectNodeForward, selectParentNode, selectTextblockEnd, selectTextblockStart, selectionToInsertionEnd, serializeAttributes, setContent, setMark, setMeta, setNode, setNodeSelection, setTextSelection, sinkListItem, sortExtensions, splitBlock, splitExtensions, splitListItem, textInputRule, textPasteRule, textblockTypeInputRule, toggleList, toggleMark, toggleNode, toggleWrap, undoInputRule, unsetAllMarks, unsetMark, updateAttributes, updateMarkViewAttributes, wrapIn, wrapInList, wrappingInputRule };
|
|
4646
|
+
export { type AnyCommands, type AnyConfig, type AnyExtension, type AtomBlockMarkdownSpecOptions, type Attribute, type Attributes$1 as Attributes, type BlockMarkdownSpecOptions, type BlockParserConfig, type CanCommands, type ChainedCommands, type ChangedRange, type Command, CommandManager, type CommandProps, type CommandSpec, type Commands, type Content, type CreateNodeFromContentOptions, type DOMNode, type DOMOutputSpecArray$1 as DOMOutputSpecArray, type DecorationType, type DecorationWithType, type Diff, type Dispatch, type DocumentType, Editor, type EditorEvents, type EditorOptions, type EnableRules, Extendable, type ExtendableConfig, type ExtendedRegExpMatchArray, Extension, type ExtensionAttribute, type ExtensionConfig, type Extensions, type FocusPosition, Fragment, type FullMarkdownHelpers, type GlobalAttributes, type HTMLContent, type InlineMarkdownSpecOptions, InputRule, type InputRuleFinder, type InputRuleMatch, type InsertContentAtOptions, type InsertContentOptions, type JSONContent, type KeyboardShortcutCommand, type KeysWithTypeOf, Mark, type MarkConfig, type MarkRange, type MarkType, MarkView, type MarkViewProps, type MarkViewRenderer, type MarkViewRendererOptions, type MarkViewRendererProps, type MarkdownExtensionSpec, type MarkdownHelpers, type MarkdownLexerConfiguration, type MarkdownParseHelpers, type MarkdownParseResult, type MarkdownRendererHelpers, type MarkdownToken, type MarkdownTokenizer, type MaybeReturnType, type MaybeThisParameterType, Node, type NodeConfig, NodePos, type NodeRange, type NodeType, NodeView, type NodeViewProps, type NodeViewRenderer, type NodeViewRendererOptions, type NodeViewRendererProps, type NodeWithPos, type Overwrite, type ParentConfig, type ParsedBlock, PasteRule, type PasteRuleFinder, type PasteRuleMatch, type PickValue, type Predicate, type Primitive, type Range, type RawCommands, type RemoveThis, type RenderContext, type ResizableNodeDimensions, ResizableNodeView, type ResizableNodeViewDirection, type ResizableNodeViewOptions, ResizableNodeview, type SetContentOptions, type SingleCommands, type Storage, type TextSerializer, type TextType, type TiptapEditorHTMLElement, Tracker, type TrackerResult, type UnionCommands, type UnionToIntersection, type ValuesOf, blur, callOrReturn, canInsertNode, clearContent, clearNodes, combineTransactionSteps, command, index$2 as commands, createAtomBlockMarkdownSpec, createBlockMarkdownSpec, createChainableState, createDocument, h as createElement, createInlineMarkdownSpec, createNodeFromContent, createParagraphNear, createStyleTag, cut, defaultBlockAt, deleteCurrentNode, deleteNode, deleteProps, deleteRange, deleteSelection, elementFromString, enter, escapeForRegEx, exitCode, extendMarkRange, index$1 as extensions, findChildren, findChildrenInRange, findDuplicates, findParentNode, findParentNodeClosestToPos, first, flattenExtensions, focus, forEach, fromString, generateHTML, generateJSON, generateText, getAttributes, getAttributesFromExtensions, getChangedRanges, getDebugJSON, getExtensionField, getHTMLFromFragment, getMarkAttributes, getMarkRange, getMarkType, getMarksBetween, getNodeAtPosition, getNodeAttributes, getNodeType, getRenderedAttributes, getSchema, getSchemaByResolvedExtensions, getSchemaTypeByName, getSchemaTypeNameByName, getSplittedAttributes, getText, getTextBetween, getTextContentFromNodes, getTextSerializersFromSchema, h, injectExtensionAttributesToParseRule, inputRulesPlugin, insertContent, insertContentAt, isActive, isAndroid, isAtEndOfNode, isAtStartOfNode, isEmptyObject, isExtensionRulesEnabled, isFunction, isList, isMacOS, isMarkActive, isNodeActive, isNodeEmpty, isNodeSelection, isNumber, isPlainObject, isRegExp, isString, isTextSelection, isiOS, joinBackward, joinDown, joinForward, joinItemBackward, joinItemForward, joinTextblockBackward, joinTextblockForward, joinUp, keyboardShortcut, lift, liftEmptyBlock, liftListItem, markInputRule, markPasteRule, index as markdown, mergeAttributes, mergeDeep, minMax, newlineInCode, nodeInputRule, nodePasteRule, objectIncludes, parseAttributes, parseIndentedBlocks, pasteRulesPlugin, posToDOMRect, removeDuplicates, renderNestedMarkdownContent, resetAttributes, resolveExtensions, resolveFocusPosition, rewriteUnknownContent, scrollIntoView, selectAll, selectNodeBackward, selectNodeForward, selectParentNode, selectTextblockEnd, selectTextblockStart, selectionToInsertionEnd, serializeAttributes, setContent, setMark, setMeta, setNode, setNodeSelection, setTextDirection, setTextSelection, sinkListItem, sortExtensions, splitBlock, splitExtensions, splitListItem, textInputRule, textPasteRule, textblockTypeInputRule, toggleList, toggleMark, toggleNode, toggleWrap, undoInputRule, unsetAllMarks, unsetMark, unsetTextDirection, updateAttributes, updateMarkViewAttributes, wrapIn, wrapInList, wrappingInputRule };
|
package/dist/index.js
CHANGED
|
@@ -189,6 +189,7 @@ __export(commands_exports, {
|
|
|
189
189
|
setMeta: () => setMeta,
|
|
190
190
|
setNode: () => setNode,
|
|
191
191
|
setNodeSelection: () => setNodeSelection,
|
|
192
|
+
setTextDirection: () => setTextDirection,
|
|
192
193
|
setTextSelection: () => setTextSelection,
|
|
193
194
|
sinkListItem: () => sinkListItem,
|
|
194
195
|
splitBlock: () => splitBlock,
|
|
@@ -200,6 +201,7 @@ __export(commands_exports, {
|
|
|
200
201
|
undoInputRule: () => undoInputRule,
|
|
201
202
|
unsetAllMarks: () => unsetAllMarks,
|
|
202
203
|
unsetMark: () => unsetMark,
|
|
204
|
+
unsetTextDirection: () => unsetTextDirection,
|
|
203
205
|
updateAttributes: () => updateAttributes,
|
|
204
206
|
wrapIn: () => wrapIn,
|
|
205
207
|
wrapInList: () => wrapInList
|
|
@@ -2328,6 +2330,35 @@ var setNodeSelection = (position) => ({ tr, dispatch }) => {
|
|
|
2328
2330
|
return true;
|
|
2329
2331
|
};
|
|
2330
2332
|
|
|
2333
|
+
// src/commands/setTextDirection.ts
|
|
2334
|
+
var setTextDirection = (direction, position) => ({ tr, state, dispatch }) => {
|
|
2335
|
+
const { selection } = state;
|
|
2336
|
+
let from;
|
|
2337
|
+
let to;
|
|
2338
|
+
if (typeof position === "number") {
|
|
2339
|
+
from = position;
|
|
2340
|
+
to = position;
|
|
2341
|
+
} else if (position && "from" in position && "to" in position) {
|
|
2342
|
+
from = position.from;
|
|
2343
|
+
to = position.to;
|
|
2344
|
+
} else {
|
|
2345
|
+
from = selection.from;
|
|
2346
|
+
to = selection.to;
|
|
2347
|
+
}
|
|
2348
|
+
if (dispatch) {
|
|
2349
|
+
tr.doc.nodesBetween(from, to, (node, pos) => {
|
|
2350
|
+
if (node.isText) {
|
|
2351
|
+
return;
|
|
2352
|
+
}
|
|
2353
|
+
tr.setNodeMarkup(pos, void 0, {
|
|
2354
|
+
...node.attrs,
|
|
2355
|
+
dir: direction
|
|
2356
|
+
});
|
|
2357
|
+
});
|
|
2358
|
+
}
|
|
2359
|
+
return true;
|
|
2360
|
+
};
|
|
2361
|
+
|
|
2331
2362
|
// src/commands/setTextSelection.ts
|
|
2332
2363
|
import { TextSelection as TextSelection5 } from "@tiptap/pm/state";
|
|
2333
2364
|
var setTextSelection = (position) => ({ tr, dispatch }) => {
|
|
@@ -2691,6 +2722,34 @@ var unsetMark = (typeOrName, options = {}) => ({ tr, state, dispatch }) => {
|
|
|
2691
2722
|
return true;
|
|
2692
2723
|
};
|
|
2693
2724
|
|
|
2725
|
+
// src/commands/unsetTextDirection.ts
|
|
2726
|
+
var unsetTextDirection = (position) => ({ tr, state, dispatch }) => {
|
|
2727
|
+
const { selection } = state;
|
|
2728
|
+
let from;
|
|
2729
|
+
let to;
|
|
2730
|
+
if (typeof position === "number") {
|
|
2731
|
+
from = position;
|
|
2732
|
+
to = position;
|
|
2733
|
+
} else if (position && "from" in position && "to" in position) {
|
|
2734
|
+
from = position.from;
|
|
2735
|
+
to = position.to;
|
|
2736
|
+
} else {
|
|
2737
|
+
from = selection.from;
|
|
2738
|
+
to = selection.to;
|
|
2739
|
+
}
|
|
2740
|
+
if (dispatch) {
|
|
2741
|
+
tr.doc.nodesBetween(from, to, (node, pos) => {
|
|
2742
|
+
if (node.isText) {
|
|
2743
|
+
return;
|
|
2744
|
+
}
|
|
2745
|
+
const newAttrs = { ...node.attrs };
|
|
2746
|
+
delete newAttrs.dir;
|
|
2747
|
+
tr.setNodeMarkup(pos, void 0, newAttrs);
|
|
2748
|
+
});
|
|
2749
|
+
}
|
|
2750
|
+
return true;
|
|
2751
|
+
};
|
|
2752
|
+
|
|
2694
2753
|
// src/commands/updateAttributes.ts
|
|
2695
2754
|
var updateAttributes = (typeOrName, attributes = {}) => ({ tr, state, dispatch }) => {
|
|
2696
2755
|
let nodeType = null;
|
|
@@ -3667,6 +3726,7 @@ __export(extensions_exports, {
|
|
|
3667
3726
|
Keymap: () => Keymap,
|
|
3668
3727
|
Paste: () => Paste,
|
|
3669
3728
|
Tabindex: () => Tabindex,
|
|
3729
|
+
TextDirection: () => TextDirection,
|
|
3670
3730
|
focusEventsPluginKey: () => focusEventsPluginKey
|
|
3671
3731
|
});
|
|
3672
3732
|
|
|
@@ -4036,6 +4096,66 @@ var Tabindex = Extension.create({
|
|
|
4036
4096
|
}
|
|
4037
4097
|
});
|
|
4038
4098
|
|
|
4099
|
+
// src/extensions/textDirection.ts
|
|
4100
|
+
import { Plugin as Plugin10, PluginKey as PluginKey8 } from "@tiptap/pm/state";
|
|
4101
|
+
var TextDirection = Extension.create({
|
|
4102
|
+
name: "textDirection",
|
|
4103
|
+
addOptions() {
|
|
4104
|
+
return {
|
|
4105
|
+
direction: void 0
|
|
4106
|
+
};
|
|
4107
|
+
},
|
|
4108
|
+
addGlobalAttributes() {
|
|
4109
|
+
if (!this.options.direction) {
|
|
4110
|
+
return [];
|
|
4111
|
+
}
|
|
4112
|
+
const { nodeExtensions } = splitExtensions(this.extensions);
|
|
4113
|
+
return [
|
|
4114
|
+
{
|
|
4115
|
+
types: nodeExtensions.filter((extension) => extension.name !== "text").map((extension) => extension.name),
|
|
4116
|
+
attributes: {
|
|
4117
|
+
dir: {
|
|
4118
|
+
default: this.options.direction,
|
|
4119
|
+
parseHTML: (element) => {
|
|
4120
|
+
const dir = element.getAttribute("dir");
|
|
4121
|
+
if (dir && (dir === "ltr" || dir === "rtl" || dir === "auto")) {
|
|
4122
|
+
return dir;
|
|
4123
|
+
}
|
|
4124
|
+
return this.options.direction;
|
|
4125
|
+
},
|
|
4126
|
+
renderHTML: (attributes) => {
|
|
4127
|
+
if (!attributes.dir) {
|
|
4128
|
+
return {};
|
|
4129
|
+
}
|
|
4130
|
+
return {
|
|
4131
|
+
dir: attributes.dir
|
|
4132
|
+
};
|
|
4133
|
+
}
|
|
4134
|
+
}
|
|
4135
|
+
}
|
|
4136
|
+
}
|
|
4137
|
+
];
|
|
4138
|
+
},
|
|
4139
|
+
addProseMirrorPlugins() {
|
|
4140
|
+
return [
|
|
4141
|
+
new Plugin10({
|
|
4142
|
+
key: new PluginKey8("textDirection"),
|
|
4143
|
+
props: {
|
|
4144
|
+
attributes: () => {
|
|
4145
|
+
const direction = this.options.direction;
|
|
4146
|
+
if (!direction) {
|
|
4147
|
+
return {};
|
|
4148
|
+
}
|
|
4149
|
+
return {
|
|
4150
|
+
dir: direction
|
|
4151
|
+
};
|
|
4152
|
+
}
|
|
4153
|
+
}
|
|
4154
|
+
})
|
|
4155
|
+
];
|
|
4156
|
+
}
|
|
4157
|
+
});
|
|
4158
|
+
|
|
4039
4159
|
// src/NodePos.ts
|
|
4040
4160
|
var NodePos = class _NodePos {
|
|
4041
4161
|
constructor(pos, editor, isBlock = false, node = null) {
|
|
@@ -4327,6 +4447,7 @@ var Editor = class extends EventEmitter {
|
|
|
4327
4447
|
extensions: [],
|
|
4328
4448
|
autofocus: false,
|
|
4329
4449
|
editable: true,
|
|
4450
|
+
textDirection: void 0,
|
|
4330
4451
|
editorProps: {},
|
|
4331
4452
|
parseOptions: {},
|
|
4332
4453
|
coreExtensionOptions: {},
|
|
@@ -4604,7 +4725,10 @@ var Editor = class extends EventEmitter {
|
|
|
4604
4725
|
Tabindex,
|
|
4605
4726
|
Drop,
|
|
4606
4727
|
Paste,
|
|
4607
|
-
Delete
|
|
4728
|
+
Delete,
|
|
4729
|
+
TextDirection.configure({
|
|
4730
|
+
direction: this.options.textDirection
|
|
4731
|
+
})
|
|
4608
4732
|
].filter((ext) => {
|
|
4609
4733
|
if (typeof this.options.enableCoreExtensions === "object") {
|
|
4610
4734
|
return this.options.enableCoreExtensions[ext.name] !== false;
|