@domternal/core 0.12.1 → 0.14.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 +165 -41
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +42 -4
- package/dist/index.d.ts +42 -4
- package/dist/index.js +164 -41
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.cts
CHANGED
|
@@ -481,6 +481,12 @@ interface ToolbarButton {
|
|
|
481
481
|
toolbar?: boolean;
|
|
482
482
|
/** Bubble menu context name. When set, this item is included in the default bubble menu for this context. */
|
|
483
483
|
bubbleMenu?: string;
|
|
484
|
+
/**
|
|
485
|
+
* Keep this button enabled in a read-only editor (view-only actions such
|
|
486
|
+
* as a history panel toggle); by default every button is disabled there.
|
|
487
|
+
* @default false
|
|
488
|
+
*/
|
|
489
|
+
allowReadOnly?: boolean;
|
|
484
490
|
}
|
|
485
491
|
/**
|
|
486
492
|
* A dropdown toolbar item containing multiple buttons.
|
|
@@ -2565,6 +2571,18 @@ interface PositionFloatingOptions {
|
|
|
2565
2571
|
* otherwise cover app chrome above the editor) pass the wrapper here.
|
|
2566
2572
|
*/
|
|
2567
2573
|
boundary?: Element;
|
|
2574
|
+
/**
|
|
2575
|
+
* Shrink-to-fit for vertical placements: writes the available space (px)
|
|
2576
|
+
* to the `--dm-available-height` custom property on the element; the
|
|
2577
|
+
* stylesheet opts in with e.g.
|
|
2578
|
+
* `max-height: min(22rem, var(--dm-available-height, 100vh))` plus
|
|
2579
|
+
* `box-sizing: border-box`. The element stays on the preferred side while
|
|
2580
|
+
* at least `minHeight` px fit there, then flips to the opposite side.
|
|
2581
|
+
*/
|
|
2582
|
+
constrainHeight?: {
|
|
2583
|
+
/** Smallest useful height in px before flipping to the opposite side. */
|
|
2584
|
+
minHeight: number;
|
|
2585
|
+
};
|
|
2568
2586
|
}
|
|
2569
2587
|
/**
|
|
2570
2588
|
* Positions a floating element relative to a reference element or virtual rect,
|
|
@@ -2656,6 +2674,23 @@ declare function copyThemeClass(view: {
|
|
|
2656
2674
|
dom: Element;
|
|
2657
2675
|
}, target: Element): void;
|
|
2658
2676
|
|
|
2677
|
+
/**
|
|
2678
|
+
* Sends a short status message to screen readers through one shared
|
|
2679
|
+
* `aria-live="polite"` region inside `.dm-editor` (WCAG 4.1.3 Status
|
|
2680
|
+
* Messages). Visual UI already shows the outcome; this is the non-visual
|
|
2681
|
+
* channel for actions whose effect a screen reader cannot otherwise
|
|
2682
|
+
* perceive (a block moving between columns, a column resize, ...).
|
|
2683
|
+
*
|
|
2684
|
+
* The region is created lazily on first use, tagged `data-dm-editor-ui`
|
|
2685
|
+
* like every other editor-owned floating element, and visually hidden
|
|
2686
|
+
* with the standard clip technique (`display: none` would silence it).
|
|
2687
|
+
* Polite, not assertive: announcements queue behind the screen reader's
|
|
2688
|
+
* typing echo instead of interrupting it.
|
|
2689
|
+
*/
|
|
2690
|
+
declare function announce(view: {
|
|
2691
|
+
dom: Element;
|
|
2692
|
+
}, message: string): void;
|
|
2693
|
+
|
|
2659
2694
|
/**
|
|
2660
2695
|
* Return focus to the editor on the next frame after a toolbar / menu command,
|
|
2661
2696
|
* UNLESS the command moved focus into a popover input the user is meant to type
|
|
@@ -2682,7 +2717,8 @@ declare function refocusEditorAfterCommand(view: {
|
|
|
2682
2717
|
* supplied one. Returns a richer item set when the editor (or any
|
|
2683
2718
|
* ancestor) carries the `.dm-notion-mode` class - that class is the
|
|
2684
2719
|
* project-wide signal that the host is rendering Notion-style UX, so
|
|
2685
|
-
* the bubble menu mirrors it by
|
|
2720
|
+
* the bubble menu mirrors it by leading with `ai` and including `link`
|
|
2721
|
+
* and `textAlign`.
|
|
2686
2722
|
*
|
|
2687
2723
|
* Consumers can always override by passing their own `contexts` prop.
|
|
2688
2724
|
*/
|
|
@@ -3727,6 +3763,8 @@ declare class Node<Options = unknown, Storage = unknown> extends Extension<Optio
|
|
|
3727
3763
|
interface ToolbarControllerEditor {
|
|
3728
3764
|
readonly toolbarItems: ToolbarItem[];
|
|
3729
3765
|
readonly storage: Record<string, unknown>;
|
|
3766
|
+
/** Read-only editors disable every button without allowReadOnly. */
|
|
3767
|
+
readonly isEditable: boolean;
|
|
3730
3768
|
isActive(nameOrAttributes: string | {
|
|
3731
3769
|
name: string;
|
|
3732
3770
|
attributes?: Record<string, unknown>;
|
|
@@ -5723,7 +5761,7 @@ declare const uniqueIDPluginKey: PluginKey<any>;
|
|
|
5723
5761
|
interface UniqueIDOptions {
|
|
5724
5762
|
/**
|
|
5725
5763
|
* Node types that should receive unique IDs.
|
|
5726
|
-
* @default ['paragraph', 'heading', 'blockquote', 'codeBlock', 'bulletList', 'orderedList', 'taskList', 'listItem', 'taskItem', 'image', 'horizontalRule']
|
|
5764
|
+
* @default ['paragraph', 'heading', 'blockquote', 'codeBlock', 'bulletList', 'orderedList', 'taskList', 'listItem', 'taskItem', 'image', 'horizontalRule', 'table']
|
|
5727
5765
|
*/
|
|
5728
5766
|
types: string[];
|
|
5729
5767
|
/**
|
|
@@ -6464,6 +6502,6 @@ declare const StarterKit: Extension<StarterKitOptions, unknown>;
|
|
|
6464
6502
|
* @domternal/core
|
|
6465
6503
|
* Framework-agnostic ProseMirror editor engine
|
|
6466
6504
|
*/
|
|
6467
|
-
declare const VERSION = "0.
|
|
6505
|
+
declare const VERSION = "0.14.0";
|
|
6468
6506
|
|
|
6469
|
-
export { type AnyExtension, type AnyExtensionConfig, type AttributeSpec, type AttributeSpecs, type AutolinkPluginOptions, BaseKeymap, type BaseKeymapOptions, BlockColor, type BlockColorOptions, Blockquote, type BlockquoteOptions, Bold, type BoldOptions, BubbleMenu, type BubbleMenuOptions, type BuildCommandPropsOptions, BulletList, type BulletListOptions, type CanChainedCommands, CanChecker, type CanCheckerEditor, type CanCheckerOptions, type CanCommands, ChainBuilder, type ChainBuilderEditor, type ChainBuilderOptions, type ChainFailure, type ChainedCommands, CharacterCount, type CharacterCountOptions, type CharacterCountStorage, type ClearContentOptions, ClearFormatting, Code, CodeBlock, type CodeBlockOptions, type CodeOptions, type Command, type CommandEditor, CommandManager, type CommandManagerEditor, type CommandMap, type CommandProps, type CommandPropsEditor, type CommandSpec, type Content, type ContentErrorProps, type CreateBubbleMenuPluginOptions, type CreateDocumentOptions, type CreateEventProps, type CreateFloatingMenuPluginOptions, DEFAULT_BLOCK_COLORS, DEFAULT_BLOCK_COLOR_TYPES, DEFAULT_HIGHLIGHT_COLORS, DEFAULT_NOTION_COLOR_PALETTE, DEFAULT_TEXT_COLORS, Document$1 as Document, Dropcursor, type DropcursorOptions, Editor, type EditorEventName, type EditorEvents, type EditorInstance, type EditorOptions, EventEmitter, Extension, type ExtensionConfig, ExtensionConfigurationError, type ExtensionEditor, ExtensionManager, type ExtensionManagerEditor, type ExtensionManagerOptions, FLOATING_MENU_META, FLOATING_MENU_NO_FOCUS, type FindChildResult, type FindParentNodeResult, FloatingMenuController, type FloatingMenuGroup, type FloatingMenuItem, type FloatingMenuItemsOverride, type FloatingMenuKeymap, type FloatingMenuOptions, Focus, type FocusEventProps, type FocusOptions, type FocusPosition, FontFamily, type FontFamilyOptions, FontSize, type FontSizeOptions, Gapcursor, type GenerateHTMLOptions, type GenerateJSONOptions, type GenerateTextOptions, type GlobalAttributeSpec, type GlobalAttributes, HardBreak, type HardBreakOptions, Heading, type HeadingOptions, Highlight, type HighlightOptions, History, type HistoryOptions, HorizontalRule, type HorizontalRuleOptions, type IconSet, type InlineStyleOverrides, type InsertAsListItemChildArgs, type InsertAsListItemChildResult, InvisibleChars, type InvisibleCharsOptions, type InvisibleCharsStorage, type IsNodeEmptyOptions, type IsValidUrlOptions, Italic, type ItalicOptions, type JSONAttribute, type JSONContent, type JSONMark, type KeyboardShortcutCommand, LIST_ITEM_TYPE_NAMES, LineHeight, type LineHeightOptions, Link, type LinkAttributes, type LinkClickPluginOptions, type LinkExitPluginOptions, type LinkOptions, type LinkPastePluginOptions, LinkPopover, type LinkPopoverOptions, ListIndent, ListItem, type ListItemCursorContext, type ListItemOptions, ListKeymap, type ListKeymapOptions, Mark, type MarkConfig, type MarkInputRuleOptions, type MarkParseRule, type MarkRange, type MarkRenderHTMLProps, type MountEventProps, Node, type NodeConfig, type NodeInputRuleOptions, type NodeParseRule, type NodeRenderHTMLProps, type NodeViewContext, NotionColorPicker, type NotionColorPickerOptions, type NotionColorPickerStorage, OrderedList, type OrderedListOptions, Paragraph, type ParagraphOptions, Placeholder, type PlaceholderOptions, type PositionFloatingOptions, type Range, type RawCommands, Selection, SelectionDecoration, type SelectionDecorationOptions, type SelectionOptions, type SelectionStorage, type SetContentOptions, type SingleCommands, type SplitListForInsertRange, StarterKit, type StarterKitOptions, Strike, type StrikeOptions, Subscript, type SubscriptOptions, Superscript, type SuperscriptOptions, TaskItem, type TaskItemOptions, TaskList, type TaskListOptions, Text, TextAlign, type TextAlignOptions, TextColor, type TextColorOptions, type TextInputRuleOptions, TextStyle, type TextStyleOptions, type TextblockTypeInputRuleOptions, type ToolbarButton, ToolbarController, type ToolbarControllerEditor, type ToolbarDropdown, type ToolbarGroup, type ToolbarItem, type ToolbarLayoutDropdown, type ToolbarLayoutEntry, type ToolbarSeparator, TrailingNode, type TrailingNodeOptions, type TransactionEventProps, Typography, type TypographyOptions, Underline, type UnderlineOptions, UniqueID, type UniqueIDOptions, VERSION, type WrappingInputRuleOptions, applyInlineStyles, autolinkPlugin, autolinkPluginKey, blur, bubbleMenuPluginKey, buildCommandProps, builtInCommands, callOrReturn, characterCountPluginKey, clearContent, copyThemeClass, createAccumulatingDispatch, createBubbleMenuPlugin, createCanChecker, createChainBuilder, createDocument, createFloatingMenuPlugin, defaultBlockAt, defaultBubbleContexts, defaultFloatingMenuShouldShow, defaultIcons, deleteSelection, findChildren, findListItemAncestorDepth, findParentNode, floatingMenuPluginKey, focus, focusPluginKey, generateHTML, generateJSON, generateText, getListItemCursorContext, getMarkRange, groupFloatingMenuItems, hideFloatingMenu, indentBlockAsListChild, inlineStyles, insertAsListItemChild, insertChildrenZoneSibling, insertContent, insertText, invisibleCharsPluginKey, isDocumentEmpty, isInListItemLabel, isInsideListItem, isNodeEmpty, isValidUrl, lift, liftCurrentListItem, liftEmptyChildrenZoneParagraph, linkClickPlugin, linkClickPluginKey, linkExitPlugin, linkExitPluginKey, linkPastePlugin, linkPastePluginKey, markInputRule, markInputRulePatterns, nodeInputRule, outdentBlockFromListItem, placeholderPluginKey, positionFloating, positionFloatingOnce, refocusEditorAfterCommand, resetAttributes, selectAll, selectNodeBackward, selectionDecorationPluginKey, setBlockType, setContent, setMark, showFloatingMenu, splitListForInsert, stripInlineColorConflicts, textInputRule, textblockTypeInputRule, toggleBlockType, toggleList, toggleMark, toggleWrap, uniqueIDPluginKey, unsetAllMarks, unsetMark, updateAttributes, wrapIn, wrappingInputRule, writeToClipboard };
|
|
6507
|
+
export { type AnyExtension, type AnyExtensionConfig, type AttributeSpec, type AttributeSpecs, type AutolinkPluginOptions, BaseKeymap, type BaseKeymapOptions, BlockColor, type BlockColorOptions, Blockquote, type BlockquoteOptions, Bold, type BoldOptions, BubbleMenu, type BubbleMenuOptions, type BuildCommandPropsOptions, BulletList, type BulletListOptions, type CanChainedCommands, CanChecker, type CanCheckerEditor, type CanCheckerOptions, type CanCommands, ChainBuilder, type ChainBuilderEditor, type ChainBuilderOptions, type ChainFailure, type ChainedCommands, CharacterCount, type CharacterCountOptions, type CharacterCountStorage, type ClearContentOptions, ClearFormatting, Code, CodeBlock, type CodeBlockOptions, type CodeOptions, type Command, type CommandEditor, CommandManager, type CommandManagerEditor, type CommandMap, type CommandProps, type CommandPropsEditor, type CommandSpec, type Content, type ContentErrorProps, type CreateBubbleMenuPluginOptions, type CreateDocumentOptions, type CreateEventProps, type CreateFloatingMenuPluginOptions, DEFAULT_BLOCK_COLORS, DEFAULT_BLOCK_COLOR_TYPES, DEFAULT_HIGHLIGHT_COLORS, DEFAULT_NOTION_COLOR_PALETTE, DEFAULT_TEXT_COLORS, Document$1 as Document, Dropcursor, type DropcursorOptions, Editor, type EditorEventName, type EditorEvents, type EditorInstance, type EditorOptions, EventEmitter, Extension, type ExtensionConfig, type ExtensionConfigBase, ExtensionConfigurationError, type ExtensionEditor, ExtensionManager, type ExtensionManagerEditor, type ExtensionManagerOptions, FLOATING_MENU_META, FLOATING_MENU_NO_FOCUS, type FindChildResult, type FindParentNodeResult, FloatingMenuController, type FloatingMenuGroup, type FloatingMenuItem, type FloatingMenuItemsOverride, type FloatingMenuKeymap, type FloatingMenuOptions, Focus, type FocusEventProps, type FocusOptions, type FocusPosition, FontFamily, type FontFamilyOptions, FontSize, type FontSizeOptions, Gapcursor, type GenerateHTMLOptions, type GenerateJSONOptions, type GenerateTextOptions, type GlobalAttributeSpec, type GlobalAttributes, HardBreak, type HardBreakOptions, Heading, type HeadingOptions, Highlight, type HighlightOptions, History, type HistoryOptions, HorizontalRule, type HorizontalRuleOptions, type IconSet, type InlineStyleOverrides, type InsertAsListItemChildArgs, type InsertAsListItemChildResult, InvisibleChars, type InvisibleCharsOptions, type InvisibleCharsStorage, type IsNodeEmptyOptions, type IsValidUrlOptions, Italic, type ItalicOptions, type JSONAttribute, type JSONContent, type JSONMark, type KeyboardShortcutCommand, LIST_ITEM_TYPE_NAMES, LineHeight, type LineHeightOptions, Link, type LinkAttributes, type LinkClickPluginOptions, type LinkExitPluginOptions, type LinkOptions, type LinkPastePluginOptions, LinkPopover, type LinkPopoverOptions, ListIndent, ListItem, type ListItemCursorContext, type ListItemOptions, ListKeymap, type ListKeymapOptions, Mark, type MarkConfig, type MarkInputRuleOptions, type MarkParseRule, type MarkRange, type MarkRenderHTMLProps, type MountEventProps, Node, type NodeConfig, type NodeInputRuleOptions, type NodeParseRule, type NodeRenderHTMLProps, type NodeViewContext, NotionColorPicker, type NotionColorPickerOptions, type NotionColorPickerStorage, OrderedList, type OrderedListOptions, Paragraph, type ParagraphOptions, Placeholder, type PlaceholderOptions, type PositionFloatingOptions, type Range, type RawCommands, Selection, SelectionDecoration, type SelectionDecorationOptions, type SelectionOptions, type SelectionStorage, type SetContentOptions, type SingleCommands, type SplitListForInsertRange, StarterKit, type StarterKitOptions, Strike, type StrikeOptions, Subscript, type SubscriptOptions, Superscript, type SuperscriptOptions, TaskItem, type TaskItemOptions, TaskList, type TaskListOptions, Text, TextAlign, type TextAlignOptions, TextColor, type TextColorOptions, type TextInputRuleOptions, TextStyle, type TextStyleOptions, type TextblockTypeInputRuleOptions, type ToolbarButton, ToolbarController, type ToolbarControllerEditor, type ToolbarDropdown, type ToolbarGroup, type ToolbarItem, type ToolbarLayoutDropdown, type ToolbarLayoutEntry, type ToolbarSeparator, TrailingNode, type TrailingNodeOptions, type TransactionEventProps, Typography, type TypographyOptions, Underline, type UnderlineOptions, UniqueID, type UniqueIDOptions, VERSION, type WrappingInputRuleOptions, announce, applyInlineStyles, autolinkPlugin, autolinkPluginKey, blur, bubbleMenuPluginKey, buildCommandProps, builtInCommands, callOrReturn, characterCountPluginKey, clearContent, copyThemeClass, createAccumulatingDispatch, createBubbleMenuPlugin, createCanChecker, createChainBuilder, createDocument, createFloatingMenuPlugin, defaultBlockAt, defaultBubbleContexts, defaultFloatingMenuShouldShow, defaultIcons, deleteSelection, findChildren, findListItemAncestorDepth, findParentNode, floatingMenuPluginKey, focus, focusPluginKey, generateHTML, generateJSON, generateText, getListItemCursorContext, getMarkRange, groupFloatingMenuItems, hideFloatingMenu, indentBlockAsListChild, inlineStyles, insertAsListItemChild, insertChildrenZoneSibling, insertContent, insertText, invisibleCharsPluginKey, isDocumentEmpty, isInListItemLabel, isInsideListItem, isNodeEmpty, isValidUrl, lift, liftCurrentListItem, liftEmptyChildrenZoneParagraph, linkClickPlugin, linkClickPluginKey, linkExitPlugin, linkExitPluginKey, linkPastePlugin, linkPastePluginKey, markInputRule, markInputRulePatterns, nodeInputRule, outdentBlockFromListItem, placeholderPluginKey, positionFloating, positionFloatingOnce, refocusEditorAfterCommand, resetAttributes, selectAll, selectNodeBackward, selectionDecorationPluginKey, setBlockType, setContent, setMark, showFloatingMenu, splitListForInsert, stripInlineColorConflicts, textInputRule, textblockTypeInputRule, toggleBlockType, toggleList, toggleMark, toggleWrap, uniqueIDPluginKey, unsetAllMarks, unsetMark, updateAttributes, wrapIn, wrappingInputRule, writeToClipboard };
|
package/dist/index.d.ts
CHANGED
|
@@ -481,6 +481,12 @@ interface ToolbarButton {
|
|
|
481
481
|
toolbar?: boolean;
|
|
482
482
|
/** Bubble menu context name. When set, this item is included in the default bubble menu for this context. */
|
|
483
483
|
bubbleMenu?: string;
|
|
484
|
+
/**
|
|
485
|
+
* Keep this button enabled in a read-only editor (view-only actions such
|
|
486
|
+
* as a history panel toggle); by default every button is disabled there.
|
|
487
|
+
* @default false
|
|
488
|
+
*/
|
|
489
|
+
allowReadOnly?: boolean;
|
|
484
490
|
}
|
|
485
491
|
/**
|
|
486
492
|
* A dropdown toolbar item containing multiple buttons.
|
|
@@ -2565,6 +2571,18 @@ interface PositionFloatingOptions {
|
|
|
2565
2571
|
* otherwise cover app chrome above the editor) pass the wrapper here.
|
|
2566
2572
|
*/
|
|
2567
2573
|
boundary?: Element;
|
|
2574
|
+
/**
|
|
2575
|
+
* Shrink-to-fit for vertical placements: writes the available space (px)
|
|
2576
|
+
* to the `--dm-available-height` custom property on the element; the
|
|
2577
|
+
* stylesheet opts in with e.g.
|
|
2578
|
+
* `max-height: min(22rem, var(--dm-available-height, 100vh))` plus
|
|
2579
|
+
* `box-sizing: border-box`. The element stays on the preferred side while
|
|
2580
|
+
* at least `minHeight` px fit there, then flips to the opposite side.
|
|
2581
|
+
*/
|
|
2582
|
+
constrainHeight?: {
|
|
2583
|
+
/** Smallest useful height in px before flipping to the opposite side. */
|
|
2584
|
+
minHeight: number;
|
|
2585
|
+
};
|
|
2568
2586
|
}
|
|
2569
2587
|
/**
|
|
2570
2588
|
* Positions a floating element relative to a reference element or virtual rect,
|
|
@@ -2656,6 +2674,23 @@ declare function copyThemeClass(view: {
|
|
|
2656
2674
|
dom: Element;
|
|
2657
2675
|
}, target: Element): void;
|
|
2658
2676
|
|
|
2677
|
+
/**
|
|
2678
|
+
* Sends a short status message to screen readers through one shared
|
|
2679
|
+
* `aria-live="polite"` region inside `.dm-editor` (WCAG 4.1.3 Status
|
|
2680
|
+
* Messages). Visual UI already shows the outcome; this is the non-visual
|
|
2681
|
+
* channel for actions whose effect a screen reader cannot otherwise
|
|
2682
|
+
* perceive (a block moving between columns, a column resize, ...).
|
|
2683
|
+
*
|
|
2684
|
+
* The region is created lazily on first use, tagged `data-dm-editor-ui`
|
|
2685
|
+
* like every other editor-owned floating element, and visually hidden
|
|
2686
|
+
* with the standard clip technique (`display: none` would silence it).
|
|
2687
|
+
* Polite, not assertive: announcements queue behind the screen reader's
|
|
2688
|
+
* typing echo instead of interrupting it.
|
|
2689
|
+
*/
|
|
2690
|
+
declare function announce(view: {
|
|
2691
|
+
dom: Element;
|
|
2692
|
+
}, message: string): void;
|
|
2693
|
+
|
|
2659
2694
|
/**
|
|
2660
2695
|
* Return focus to the editor on the next frame after a toolbar / menu command,
|
|
2661
2696
|
* UNLESS the command moved focus into a popover input the user is meant to type
|
|
@@ -2682,7 +2717,8 @@ declare function refocusEditorAfterCommand(view: {
|
|
|
2682
2717
|
* supplied one. Returns a richer item set when the editor (or any
|
|
2683
2718
|
* ancestor) carries the `.dm-notion-mode` class - that class is the
|
|
2684
2719
|
* project-wide signal that the host is rendering Notion-style UX, so
|
|
2685
|
-
* the bubble menu mirrors it by
|
|
2720
|
+
* the bubble menu mirrors it by leading with `ai` and including `link`
|
|
2721
|
+
* and `textAlign`.
|
|
2686
2722
|
*
|
|
2687
2723
|
* Consumers can always override by passing their own `contexts` prop.
|
|
2688
2724
|
*/
|
|
@@ -3727,6 +3763,8 @@ declare class Node<Options = unknown, Storage = unknown> extends Extension<Optio
|
|
|
3727
3763
|
interface ToolbarControllerEditor {
|
|
3728
3764
|
readonly toolbarItems: ToolbarItem[];
|
|
3729
3765
|
readonly storage: Record<string, unknown>;
|
|
3766
|
+
/** Read-only editors disable every button without allowReadOnly. */
|
|
3767
|
+
readonly isEditable: boolean;
|
|
3730
3768
|
isActive(nameOrAttributes: string | {
|
|
3731
3769
|
name: string;
|
|
3732
3770
|
attributes?: Record<string, unknown>;
|
|
@@ -5723,7 +5761,7 @@ declare const uniqueIDPluginKey: PluginKey<any>;
|
|
|
5723
5761
|
interface UniqueIDOptions {
|
|
5724
5762
|
/**
|
|
5725
5763
|
* Node types that should receive unique IDs.
|
|
5726
|
-
* @default ['paragraph', 'heading', 'blockquote', 'codeBlock', 'bulletList', 'orderedList', 'taskList', 'listItem', 'taskItem', 'image', 'horizontalRule']
|
|
5764
|
+
* @default ['paragraph', 'heading', 'blockquote', 'codeBlock', 'bulletList', 'orderedList', 'taskList', 'listItem', 'taskItem', 'image', 'horizontalRule', 'table']
|
|
5727
5765
|
*/
|
|
5728
5766
|
types: string[];
|
|
5729
5767
|
/**
|
|
@@ -6464,6 +6502,6 @@ declare const StarterKit: Extension<StarterKitOptions, unknown>;
|
|
|
6464
6502
|
* @domternal/core
|
|
6465
6503
|
* Framework-agnostic ProseMirror editor engine
|
|
6466
6504
|
*/
|
|
6467
|
-
declare const VERSION = "0.
|
|
6505
|
+
declare const VERSION = "0.14.0";
|
|
6468
6506
|
|
|
6469
|
-
export { type AnyExtension, type AnyExtensionConfig, type AttributeSpec, type AttributeSpecs, type AutolinkPluginOptions, BaseKeymap, type BaseKeymapOptions, BlockColor, type BlockColorOptions, Blockquote, type BlockquoteOptions, Bold, type BoldOptions, BubbleMenu, type BubbleMenuOptions, type BuildCommandPropsOptions, BulletList, type BulletListOptions, type CanChainedCommands, CanChecker, type CanCheckerEditor, type CanCheckerOptions, type CanCommands, ChainBuilder, type ChainBuilderEditor, type ChainBuilderOptions, type ChainFailure, type ChainedCommands, CharacterCount, type CharacterCountOptions, type CharacterCountStorage, type ClearContentOptions, ClearFormatting, Code, CodeBlock, type CodeBlockOptions, type CodeOptions, type Command, type CommandEditor, CommandManager, type CommandManagerEditor, type CommandMap, type CommandProps, type CommandPropsEditor, type CommandSpec, type Content, type ContentErrorProps, type CreateBubbleMenuPluginOptions, type CreateDocumentOptions, type CreateEventProps, type CreateFloatingMenuPluginOptions, DEFAULT_BLOCK_COLORS, DEFAULT_BLOCK_COLOR_TYPES, DEFAULT_HIGHLIGHT_COLORS, DEFAULT_NOTION_COLOR_PALETTE, DEFAULT_TEXT_COLORS, Document$1 as Document, Dropcursor, type DropcursorOptions, Editor, type EditorEventName, type EditorEvents, type EditorInstance, type EditorOptions, EventEmitter, Extension, type ExtensionConfig, ExtensionConfigurationError, type ExtensionEditor, ExtensionManager, type ExtensionManagerEditor, type ExtensionManagerOptions, FLOATING_MENU_META, FLOATING_MENU_NO_FOCUS, type FindChildResult, type FindParentNodeResult, FloatingMenuController, type FloatingMenuGroup, type FloatingMenuItem, type FloatingMenuItemsOverride, type FloatingMenuKeymap, type FloatingMenuOptions, Focus, type FocusEventProps, type FocusOptions, type FocusPosition, FontFamily, type FontFamilyOptions, FontSize, type FontSizeOptions, Gapcursor, type GenerateHTMLOptions, type GenerateJSONOptions, type GenerateTextOptions, type GlobalAttributeSpec, type GlobalAttributes, HardBreak, type HardBreakOptions, Heading, type HeadingOptions, Highlight, type HighlightOptions, History, type HistoryOptions, HorizontalRule, type HorizontalRuleOptions, type IconSet, type InlineStyleOverrides, type InsertAsListItemChildArgs, type InsertAsListItemChildResult, InvisibleChars, type InvisibleCharsOptions, type InvisibleCharsStorage, type IsNodeEmptyOptions, type IsValidUrlOptions, Italic, type ItalicOptions, type JSONAttribute, type JSONContent, type JSONMark, type KeyboardShortcutCommand, LIST_ITEM_TYPE_NAMES, LineHeight, type LineHeightOptions, Link, type LinkAttributes, type LinkClickPluginOptions, type LinkExitPluginOptions, type LinkOptions, type LinkPastePluginOptions, LinkPopover, type LinkPopoverOptions, ListIndent, ListItem, type ListItemCursorContext, type ListItemOptions, ListKeymap, type ListKeymapOptions, Mark, type MarkConfig, type MarkInputRuleOptions, type MarkParseRule, type MarkRange, type MarkRenderHTMLProps, type MountEventProps, Node, type NodeConfig, type NodeInputRuleOptions, type NodeParseRule, type NodeRenderHTMLProps, type NodeViewContext, NotionColorPicker, type NotionColorPickerOptions, type NotionColorPickerStorage, OrderedList, type OrderedListOptions, Paragraph, type ParagraphOptions, Placeholder, type PlaceholderOptions, type PositionFloatingOptions, type Range, type RawCommands, Selection, SelectionDecoration, type SelectionDecorationOptions, type SelectionOptions, type SelectionStorage, type SetContentOptions, type SingleCommands, type SplitListForInsertRange, StarterKit, type StarterKitOptions, Strike, type StrikeOptions, Subscript, type SubscriptOptions, Superscript, type SuperscriptOptions, TaskItem, type TaskItemOptions, TaskList, type TaskListOptions, Text, TextAlign, type TextAlignOptions, TextColor, type TextColorOptions, type TextInputRuleOptions, TextStyle, type TextStyleOptions, type TextblockTypeInputRuleOptions, type ToolbarButton, ToolbarController, type ToolbarControllerEditor, type ToolbarDropdown, type ToolbarGroup, type ToolbarItem, type ToolbarLayoutDropdown, type ToolbarLayoutEntry, type ToolbarSeparator, TrailingNode, type TrailingNodeOptions, type TransactionEventProps, Typography, type TypographyOptions, Underline, type UnderlineOptions, UniqueID, type UniqueIDOptions, VERSION, type WrappingInputRuleOptions, applyInlineStyles, autolinkPlugin, autolinkPluginKey, blur, bubbleMenuPluginKey, buildCommandProps, builtInCommands, callOrReturn, characterCountPluginKey, clearContent, copyThemeClass, createAccumulatingDispatch, createBubbleMenuPlugin, createCanChecker, createChainBuilder, createDocument, createFloatingMenuPlugin, defaultBlockAt, defaultBubbleContexts, defaultFloatingMenuShouldShow, defaultIcons, deleteSelection, findChildren, findListItemAncestorDepth, findParentNode, floatingMenuPluginKey, focus, focusPluginKey, generateHTML, generateJSON, generateText, getListItemCursorContext, getMarkRange, groupFloatingMenuItems, hideFloatingMenu, indentBlockAsListChild, inlineStyles, insertAsListItemChild, insertChildrenZoneSibling, insertContent, insertText, invisibleCharsPluginKey, isDocumentEmpty, isInListItemLabel, isInsideListItem, isNodeEmpty, isValidUrl, lift, liftCurrentListItem, liftEmptyChildrenZoneParagraph, linkClickPlugin, linkClickPluginKey, linkExitPlugin, linkExitPluginKey, linkPastePlugin, linkPastePluginKey, markInputRule, markInputRulePatterns, nodeInputRule, outdentBlockFromListItem, placeholderPluginKey, positionFloating, positionFloatingOnce, refocusEditorAfterCommand, resetAttributes, selectAll, selectNodeBackward, selectionDecorationPluginKey, setBlockType, setContent, setMark, showFloatingMenu, splitListForInsert, stripInlineColorConflicts, textInputRule, textblockTypeInputRule, toggleBlockType, toggleList, toggleMark, toggleWrap, uniqueIDPluginKey, unsetAllMarks, unsetMark, updateAttributes, wrapIn, wrappingInputRule, writeToClipboard };
|
|
6507
|
+
export { type AnyExtension, type AnyExtensionConfig, type AttributeSpec, type AttributeSpecs, type AutolinkPluginOptions, BaseKeymap, type BaseKeymapOptions, BlockColor, type BlockColorOptions, Blockquote, type BlockquoteOptions, Bold, type BoldOptions, BubbleMenu, type BubbleMenuOptions, type BuildCommandPropsOptions, BulletList, type BulletListOptions, type CanChainedCommands, CanChecker, type CanCheckerEditor, type CanCheckerOptions, type CanCommands, ChainBuilder, type ChainBuilderEditor, type ChainBuilderOptions, type ChainFailure, type ChainedCommands, CharacterCount, type CharacterCountOptions, type CharacterCountStorage, type ClearContentOptions, ClearFormatting, Code, CodeBlock, type CodeBlockOptions, type CodeOptions, type Command, type CommandEditor, CommandManager, type CommandManagerEditor, type CommandMap, type CommandProps, type CommandPropsEditor, type CommandSpec, type Content, type ContentErrorProps, type CreateBubbleMenuPluginOptions, type CreateDocumentOptions, type CreateEventProps, type CreateFloatingMenuPluginOptions, DEFAULT_BLOCK_COLORS, DEFAULT_BLOCK_COLOR_TYPES, DEFAULT_HIGHLIGHT_COLORS, DEFAULT_NOTION_COLOR_PALETTE, DEFAULT_TEXT_COLORS, Document$1 as Document, Dropcursor, type DropcursorOptions, Editor, type EditorEventName, type EditorEvents, type EditorInstance, type EditorOptions, EventEmitter, Extension, type ExtensionConfig, type ExtensionConfigBase, ExtensionConfigurationError, type ExtensionEditor, ExtensionManager, type ExtensionManagerEditor, type ExtensionManagerOptions, FLOATING_MENU_META, FLOATING_MENU_NO_FOCUS, type FindChildResult, type FindParentNodeResult, FloatingMenuController, type FloatingMenuGroup, type FloatingMenuItem, type FloatingMenuItemsOverride, type FloatingMenuKeymap, type FloatingMenuOptions, Focus, type FocusEventProps, type FocusOptions, type FocusPosition, FontFamily, type FontFamilyOptions, FontSize, type FontSizeOptions, Gapcursor, type GenerateHTMLOptions, type GenerateJSONOptions, type GenerateTextOptions, type GlobalAttributeSpec, type GlobalAttributes, HardBreak, type HardBreakOptions, Heading, type HeadingOptions, Highlight, type HighlightOptions, History, type HistoryOptions, HorizontalRule, type HorizontalRuleOptions, type IconSet, type InlineStyleOverrides, type InsertAsListItemChildArgs, type InsertAsListItemChildResult, InvisibleChars, type InvisibleCharsOptions, type InvisibleCharsStorage, type IsNodeEmptyOptions, type IsValidUrlOptions, Italic, type ItalicOptions, type JSONAttribute, type JSONContent, type JSONMark, type KeyboardShortcutCommand, LIST_ITEM_TYPE_NAMES, LineHeight, type LineHeightOptions, Link, type LinkAttributes, type LinkClickPluginOptions, type LinkExitPluginOptions, type LinkOptions, type LinkPastePluginOptions, LinkPopover, type LinkPopoverOptions, ListIndent, ListItem, type ListItemCursorContext, type ListItemOptions, ListKeymap, type ListKeymapOptions, Mark, type MarkConfig, type MarkInputRuleOptions, type MarkParseRule, type MarkRange, type MarkRenderHTMLProps, type MountEventProps, Node, type NodeConfig, type NodeInputRuleOptions, type NodeParseRule, type NodeRenderHTMLProps, type NodeViewContext, NotionColorPicker, type NotionColorPickerOptions, type NotionColorPickerStorage, OrderedList, type OrderedListOptions, Paragraph, type ParagraphOptions, Placeholder, type PlaceholderOptions, type PositionFloatingOptions, type Range, type RawCommands, Selection, SelectionDecoration, type SelectionDecorationOptions, type SelectionOptions, type SelectionStorage, type SetContentOptions, type SingleCommands, type SplitListForInsertRange, StarterKit, type StarterKitOptions, Strike, type StrikeOptions, Subscript, type SubscriptOptions, Superscript, type SuperscriptOptions, TaskItem, type TaskItemOptions, TaskList, type TaskListOptions, Text, TextAlign, type TextAlignOptions, TextColor, type TextColorOptions, type TextInputRuleOptions, TextStyle, type TextStyleOptions, type TextblockTypeInputRuleOptions, type ToolbarButton, ToolbarController, type ToolbarControllerEditor, type ToolbarDropdown, type ToolbarGroup, type ToolbarItem, type ToolbarLayoutDropdown, type ToolbarLayoutEntry, type ToolbarSeparator, TrailingNode, type TrailingNodeOptions, type TransactionEventProps, Typography, type TypographyOptions, Underline, type UnderlineOptions, UniqueID, type UniqueIDOptions, VERSION, type WrappingInputRuleOptions, announce, applyInlineStyles, autolinkPlugin, autolinkPluginKey, blur, bubbleMenuPluginKey, buildCommandProps, builtInCommands, callOrReturn, characterCountPluginKey, clearContent, copyThemeClass, createAccumulatingDispatch, createBubbleMenuPlugin, createCanChecker, createChainBuilder, createDocument, createFloatingMenuPlugin, defaultBlockAt, defaultBubbleContexts, defaultFloatingMenuShouldShow, defaultIcons, deleteSelection, findChildren, findListItemAncestorDepth, findParentNode, floatingMenuPluginKey, focus, focusPluginKey, generateHTML, generateJSON, generateText, getListItemCursorContext, getMarkRange, groupFloatingMenuItems, hideFloatingMenu, indentBlockAsListChild, inlineStyles, insertAsListItemChild, insertChildrenZoneSibling, insertContent, insertText, invisibleCharsPluginKey, isDocumentEmpty, isInListItemLabel, isInsideListItem, isNodeEmpty, isValidUrl, lift, liftCurrentListItem, liftEmptyChildrenZoneParagraph, linkClickPlugin, linkClickPluginKey, linkExitPlugin, linkExitPluginKey, linkPastePlugin, linkPastePluginKey, markInputRule, markInputRulePatterns, nodeInputRule, outdentBlockFromListItem, placeholderPluginKey, positionFloating, positionFloatingOnce, refocusEditorAfterCommand, resetAttributes, selectAll, selectNodeBackward, selectionDecorationPluginKey, setBlockType, setContent, setMark, showFloatingMenu, splitListForInsert, stripInlineColorConflicts, textInputRule, textblockTypeInputRule, toggleBlockType, toggleList, toggleMark, toggleWrap, uniqueIDPluginKey, unsetAllMarks, unsetMark, updateAttributes, wrapIn, wrappingInputRule, writeToClipboard };
|
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import { splitBlock, chainCommands, newlineInCode, createParagraphNear, liftEmpt
|
|
|
7
7
|
import { InputRule } from '@domternal/pm/inputrules';
|
|
8
8
|
import { canJoin, canSplit, findWrapping, liftTarget } from '@domternal/pm/transform';
|
|
9
9
|
import { liftListItem, sinkListItem, splitListItem, wrapRangeInList } from '@domternal/pm/schema-list';
|
|
10
|
-
import {
|
|
10
|
+
import { autoUpdate, hide, offset, size, flip, shift, computePosition } from '@floating-ui/dom';
|
|
11
11
|
import { find } from 'linkifyjs';
|
|
12
12
|
import { history, redo, undo } from '@domternal/pm/history';
|
|
13
13
|
import { dropCursor } from '@domternal/pm/dropcursor';
|
|
@@ -1391,6 +1391,8 @@ var setContent = (content, options = {}) => ({ state, tr, dispatch }) => {
|
|
|
1391
1391
|
return true;
|
|
1392
1392
|
}
|
|
1393
1393
|
tr.replaceWith(0, tr.doc.content.size, doc.content);
|
|
1394
|
+
const $end = tr.doc.resolve(tr.doc.content.size);
|
|
1395
|
+
tr.setSelection(TextSelection.between($end, $end, -1));
|
|
1394
1396
|
if (!emitUpdate) {
|
|
1395
1397
|
tr.setMeta("addToHistory", false);
|
|
1396
1398
|
tr.setMeta("skipUpdate", true);
|
|
@@ -4063,16 +4065,50 @@ var Editor = class _Editor extends EventEmitter {
|
|
|
4063
4065
|
return super.emit(event, ...args);
|
|
4064
4066
|
}
|
|
4065
4067
|
};
|
|
4066
|
-
|
|
4067
|
-
|
|
4068
|
+
var OPPOSITE_SIDE = {
|
|
4069
|
+
top: "bottom",
|
|
4070
|
+
bottom: "top",
|
|
4071
|
+
left: "right",
|
|
4072
|
+
right: "left"
|
|
4073
|
+
};
|
|
4074
|
+
function oppositePlacement(placement) {
|
|
4075
|
+
const [side = "", alignment] = placement.split("-");
|
|
4076
|
+
const opposite = OPPOSITE_SIDE[side] ?? side;
|
|
4077
|
+
return alignment ? `${opposite}-${alignment}` : opposite;
|
|
4078
|
+
}
|
|
4079
|
+
function buildMiddleware(options, placementOpt) {
|
|
4068
4080
|
const paddingOpt = options?.padding ?? 10;
|
|
4069
4081
|
const overflowOpts = options?.boundary ? { padding: paddingOpt, boundary: options.boundary } : { padding: paddingOpt };
|
|
4070
|
-
const
|
|
4071
|
-
|
|
4072
|
-
|
|
4073
|
-
|
|
4074
|
-
|
|
4075
|
-
|
|
4082
|
+
const constrain = options?.constrainHeight;
|
|
4083
|
+
const middleware = [offset(options?.offsetValue ?? 4)];
|
|
4084
|
+
if (constrain) {
|
|
4085
|
+
middleware.push(
|
|
4086
|
+
size({
|
|
4087
|
+
...overflowOpts,
|
|
4088
|
+
apply({ availableHeight, elements }) {
|
|
4089
|
+
elements.floating.style.setProperty(
|
|
4090
|
+
"--dm-available-height",
|
|
4091
|
+
`${String(Math.max(constrain.minHeight, Math.floor(availableHeight)))}px`
|
|
4092
|
+
);
|
|
4093
|
+
}
|
|
4094
|
+
})
|
|
4095
|
+
);
|
|
4096
|
+
middleware.push(
|
|
4097
|
+
flip({
|
|
4098
|
+
...overflowOpts,
|
|
4099
|
+
crossAxis: false,
|
|
4100
|
+
fallbackPlacements: [oppositePlacement(placementOpt)]
|
|
4101
|
+
})
|
|
4102
|
+
);
|
|
4103
|
+
} else {
|
|
4104
|
+
middleware.push(flip(overflowOpts));
|
|
4105
|
+
}
|
|
4106
|
+
middleware.push(shift(overflowOpts));
|
|
4107
|
+
return middleware;
|
|
4108
|
+
}
|
|
4109
|
+
function positionFloating(reference, floating, options) {
|
|
4110
|
+
const placementOpt = options?.placement ?? "bottom";
|
|
4111
|
+
const middleware = [...buildMiddleware(options, placementOpt), hide()];
|
|
4076
4112
|
const update = () => {
|
|
4077
4113
|
void computePosition(
|
|
4078
4114
|
reference,
|
|
@@ -4100,13 +4136,7 @@ function positionFloating(reference, floating, options) {
|
|
|
4100
4136
|
}
|
|
4101
4137
|
function positionFloatingOnce(reference, floating, options) {
|
|
4102
4138
|
const placementOpt = options?.placement ?? "bottom";
|
|
4103
|
-
const
|
|
4104
|
-
const overflowOpts = options?.boundary ? { padding: paddingOpt, boundary: options.boundary } : { padding: paddingOpt };
|
|
4105
|
-
const middleware = [
|
|
4106
|
-
offset(options?.offsetValue ?? 4),
|
|
4107
|
-
flip(overflowOpts),
|
|
4108
|
-
shift(overflowOpts)
|
|
4109
|
-
];
|
|
4139
|
+
const middleware = buildMiddleware(options, placementOpt);
|
|
4110
4140
|
const update = () => {
|
|
4111
4141
|
void computePosition(
|
|
4112
4142
|
reference,
|
|
@@ -4174,6 +4204,23 @@ function copyThemeClass(view, target) {
|
|
|
4174
4204
|
});
|
|
4175
4205
|
}
|
|
4176
4206
|
|
|
4207
|
+
// src/utils/announce.ts
|
|
4208
|
+
function announce(view, message) {
|
|
4209
|
+
const editorEl = view.dom.closest(".dm-editor");
|
|
4210
|
+
if (!(editorEl instanceof HTMLElement)) return;
|
|
4211
|
+
let region = editorEl.querySelector(":scope > .dm-live-region");
|
|
4212
|
+
if (!region) {
|
|
4213
|
+
region = document.createElement("div");
|
|
4214
|
+
region.className = "dm-live-region";
|
|
4215
|
+
region.setAttribute("data-dm-editor-ui", "");
|
|
4216
|
+
region.setAttribute("role", "status");
|
|
4217
|
+
region.setAttribute("aria-live", "polite");
|
|
4218
|
+
region.style.cssText = "position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);clip-path:inset(50%);white-space:nowrap;";
|
|
4219
|
+
editorEl.appendChild(region);
|
|
4220
|
+
}
|
|
4221
|
+
region.textContent = region.textContent === message ? `${message}\xA0` : message;
|
|
4222
|
+
}
|
|
4223
|
+
|
|
4177
4224
|
// src/utils/refocusEditorAfterCommand.ts
|
|
4178
4225
|
function refocusEditorAfterCommand(view) {
|
|
4179
4226
|
requestAnimationFrame(() => {
|
|
@@ -4192,6 +4239,10 @@ function refocusEditorAfterCommand(view) {
|
|
|
4192
4239
|
// src/utils/defaultBubbleContexts.ts
|
|
4193
4240
|
var NOTION_MODE_CLASS = "dm-notion-mode";
|
|
4194
4241
|
var NOTION_TEXT_CONTEXT = Object.freeze([
|
|
4242
|
+
// `ai` leads (Notion's "Ask AI"); skipped with its leading separator when
|
|
4243
|
+
// the pro extension is absent, exactly like `mathInline`.
|
|
4244
|
+
"ai",
|
|
4245
|
+
"|",
|
|
4195
4246
|
"bold",
|
|
4196
4247
|
"italic",
|
|
4197
4248
|
"underline",
|
|
@@ -4677,6 +4728,7 @@ var ToolbarController = class _ToolbarController {
|
|
|
4677
4728
|
* Executes a toolbar button's command.
|
|
4678
4729
|
*/
|
|
4679
4730
|
executeCommand(item) {
|
|
4731
|
+
if (!this.editor.isEditable && item.allowReadOnly !== true) return;
|
|
4680
4732
|
_ToolbarController.executeItem(this.editor, item);
|
|
4681
4733
|
this.updateActiveStates();
|
|
4682
4734
|
}
|
|
@@ -4919,16 +4971,20 @@ var ToolbarController = class _ToolbarController {
|
|
|
4919
4971
|
checkButtonDisabled(item, canProxy) {
|
|
4920
4972
|
const wasDisabled = this._disabledMap.get(item.name) ?? false;
|
|
4921
4973
|
let nowDisabled = false;
|
|
4922
|
-
|
|
4923
|
-
|
|
4924
|
-
|
|
4925
|
-
|
|
4926
|
-
|
|
4927
|
-
|
|
4928
|
-
|
|
4974
|
+
if (!this.editor.isEditable && item.allowReadOnly !== true) {
|
|
4975
|
+
nowDisabled = true;
|
|
4976
|
+
} else {
|
|
4977
|
+
try {
|
|
4978
|
+
if (item.emitEvent) {
|
|
4979
|
+
nowDisabled = this.editor.isActive("codeBlock");
|
|
4980
|
+
} else if (canProxy) {
|
|
4981
|
+
const canCmd = canProxy[item.command];
|
|
4982
|
+
if (canCmd) {
|
|
4983
|
+
nowDisabled = item.commandArgs?.length ? !canCmd(...item.commandArgs) : !canCmd();
|
|
4984
|
+
}
|
|
4929
4985
|
}
|
|
4986
|
+
} catch {
|
|
4930
4987
|
}
|
|
4931
|
-
} catch {
|
|
4932
4988
|
}
|
|
4933
4989
|
if (wasDisabled !== nowDisabled) {
|
|
4934
4990
|
this._disabledMap.set(item.name, nowDisabled);
|
|
@@ -5340,6 +5396,7 @@ function createFloatingMenuPlugin(options) {
|
|
|
5340
5396
|
};
|
|
5341
5397
|
hideMenu();
|
|
5342
5398
|
const isVisibleNow = (view) => {
|
|
5399
|
+
if (!editor.isEditable) return false;
|
|
5343
5400
|
const wantsShow = shouldShow({ editor, view, state: view.state });
|
|
5344
5401
|
if (!requireExplicitTrigger) return wantsShow;
|
|
5345
5402
|
const triggered = pluginKey.getState(view.state)?.triggered ?? false;
|
|
@@ -5719,7 +5776,8 @@ var Heading = Node2.create({
|
|
|
5719
5776
|
key: new PluginKey("headingKeydownFix"),
|
|
5720
5777
|
props: {
|
|
5721
5778
|
handleDOMEvents: {
|
|
5722
|
-
keydown(
|
|
5779
|
+
keydown(view, event) {
|
|
5780
|
+
if (!view.editable) return false;
|
|
5723
5781
|
if (!event.altKey || !(event.metaKey || event.ctrlKey)) return false;
|
|
5724
5782
|
const level = codeToLevel[event.code];
|
|
5725
5783
|
if (level === void 0) return false;
|
|
@@ -8172,6 +8230,18 @@ var Placeholder = Extension.create({
|
|
|
8172
8230
|
new Plugin({
|
|
8173
8231
|
key: placeholderPluginKey,
|
|
8174
8232
|
props: {
|
|
8233
|
+
// Focus and blur repaint the decorations: PM only recomputes
|
|
8234
|
+
// them when a transaction dispatches.
|
|
8235
|
+
handleDOMEvents: {
|
|
8236
|
+
focus: (view) => {
|
|
8237
|
+
view.dispatch(view.state.tr.setMeta(placeholderPluginKey, true));
|
|
8238
|
+
return false;
|
|
8239
|
+
},
|
|
8240
|
+
blur: (view) => {
|
|
8241
|
+
view.dispatch(view.state.tr.setMeta(placeholderPluginKey, false));
|
|
8242
|
+
return false;
|
|
8243
|
+
}
|
|
8244
|
+
},
|
|
8175
8245
|
decorations: ({ doc, selection }) => {
|
|
8176
8246
|
const editor = this.editor;
|
|
8177
8247
|
if (!editor) return DecorationSet.empty;
|
|
@@ -8187,6 +8257,10 @@ var Placeholder = Extension.create({
|
|
|
8187
8257
|
"data-placeholder": getPlaceholderText(node, pos)
|
|
8188
8258
|
});
|
|
8189
8259
|
if (showOnlyCurrent) {
|
|
8260
|
+
const view = editor.view;
|
|
8261
|
+
if (!isDocEmpty && view?.hasFocus() !== true) {
|
|
8262
|
+
return DecorationSet.empty;
|
|
8263
|
+
}
|
|
8190
8264
|
const { $anchor } = selection;
|
|
8191
8265
|
if ($anchor.depth === 0) return DecorationSet.empty;
|
|
8192
8266
|
const node = $anchor.parent;
|
|
@@ -8782,7 +8856,13 @@ var UniqueID = Extension.create({
|
|
|
8782
8856
|
"listItem",
|
|
8783
8857
|
"taskItem",
|
|
8784
8858
|
"image",
|
|
8785
|
-
"horizontalRule"
|
|
8859
|
+
"horizontalRule",
|
|
8860
|
+
// Listed even though it lives in a separate package, exactly as
|
|
8861
|
+
// `image` already is: a global attribute only installs on types the
|
|
8862
|
+
// schema actually has, so naming it is inert when the table extension
|
|
8863
|
+
// is not loaded. Without it a table is the one block the block menu
|
|
8864
|
+
// cannot Copy link, and the one an id-anchored feature cannot address.
|
|
8865
|
+
"table"
|
|
8786
8866
|
],
|
|
8787
8867
|
attributeName: "id",
|
|
8788
8868
|
generateID: generateUUID,
|
|
@@ -8810,7 +8890,8 @@ var UniqueID = Extension.create({
|
|
|
8810
8890
|
addProseMirrorPlugins() {
|
|
8811
8891
|
const { types, attributeName, generateID, filterDuplicates } = this.options;
|
|
8812
8892
|
const editor = this.editor;
|
|
8813
|
-
const transformPastedSlice = (slice) => {
|
|
8893
|
+
const transformPastedSlice = (slice, view) => {
|
|
8894
|
+
if (view?.dragging?.move === true) return slice;
|
|
8814
8895
|
const existingIDs = /* @__PURE__ */ new Set();
|
|
8815
8896
|
editor?.state.doc.descendants((node) => {
|
|
8816
8897
|
const id = node.attrs[attributeName];
|
|
@@ -8844,7 +8925,36 @@ var UniqueID = Extension.create({
|
|
|
8844
8925
|
slice.openEnd
|
|
8845
8926
|
);
|
|
8846
8927
|
};
|
|
8847
|
-
const
|
|
8928
|
+
const incumbentPositions = (oldDoc, mapPos) => {
|
|
8929
|
+
const incumbents = /* @__PURE__ */ new Map();
|
|
8930
|
+
oldDoc.descendants((node, pos) => {
|
|
8931
|
+
if (!types.includes(node.type.name)) return;
|
|
8932
|
+
const id = node.attrs[attributeName];
|
|
8933
|
+
if (id && !incumbents.has(id)) incumbents.set(id, mapPos(pos));
|
|
8934
|
+
});
|
|
8935
|
+
return incumbents;
|
|
8936
|
+
};
|
|
8937
|
+
const assignMissingIDs = (doc, tr, incumbents) => {
|
|
8938
|
+
const winners = /* @__PURE__ */ new Map();
|
|
8939
|
+
if (incumbents && incumbents.size > 0) {
|
|
8940
|
+
const occurrences = /* @__PURE__ */ new Map();
|
|
8941
|
+
doc.descendants((node, pos) => {
|
|
8942
|
+
if (!types.includes(node.type.name)) return;
|
|
8943
|
+
const id = node.attrs[attributeName];
|
|
8944
|
+
if (!id) return;
|
|
8945
|
+
const list = occurrences.get(id);
|
|
8946
|
+
if (list) list.push(pos);
|
|
8947
|
+
else occurrences.set(id, [pos]);
|
|
8948
|
+
});
|
|
8949
|
+
for (const [id, positions] of occurrences) {
|
|
8950
|
+
if (positions.length < 2) continue;
|
|
8951
|
+
const incumbentPos = incumbents.get(id);
|
|
8952
|
+
winners.set(
|
|
8953
|
+
id,
|
|
8954
|
+
incumbentPos !== void 0 && positions.includes(incumbentPos) ? incumbentPos : positions[0]
|
|
8955
|
+
);
|
|
8956
|
+
}
|
|
8957
|
+
}
|
|
8848
8958
|
const seen = /* @__PURE__ */ new Set();
|
|
8849
8959
|
doc.descendants((node, pos) => {
|
|
8850
8960
|
if (!types.includes(node.type.name)) return;
|
|
@@ -8859,7 +8969,9 @@ var UniqueID = Extension.create({
|
|
|
8859
8969
|
});
|
|
8860
8970
|
return;
|
|
8861
8971
|
}
|
|
8862
|
-
|
|
8972
|
+
const winner = winners.get(existingID);
|
|
8973
|
+
const yieldsToWinner = winner !== void 0 && winner !== pos;
|
|
8974
|
+
if (seen.has(existingID) || yieldsToWinner) {
|
|
8863
8975
|
let id = generateID();
|
|
8864
8976
|
while (seen.has(id)) id = generateID();
|
|
8865
8977
|
seen.add(id);
|
|
@@ -8881,6 +8993,7 @@ var UniqueID = Extension.create({
|
|
|
8881
8993
|
const tr = editorView.state.tr;
|
|
8882
8994
|
assignMissingIDs(editorView.state.doc, tr);
|
|
8883
8995
|
if (tr.docChanged) {
|
|
8996
|
+
tr.setMeta("addToHistory", false);
|
|
8884
8997
|
editorView.dispatch(tr);
|
|
8885
8998
|
}
|
|
8886
8999
|
}, 0);
|
|
@@ -8891,12 +9004,18 @@ var UniqueID = Extension.create({
|
|
|
8891
9004
|
};
|
|
8892
9005
|
},
|
|
8893
9006
|
// Ensure new nodes get IDs
|
|
8894
|
-
appendTransaction(transactions,
|
|
9007
|
+
appendTransaction(transactions, oldState, newState) {
|
|
8895
9008
|
const docChanged = transactions.some((tr2) => tr2.docChanged);
|
|
8896
9009
|
if (!docChanged) return null;
|
|
9010
|
+
const mapForward = (pos) => transactions.reduce((p, transaction) => transaction.mapping.map(p), pos);
|
|
8897
9011
|
const tr = newState.tr;
|
|
8898
|
-
assignMissingIDs(newState.doc, tr);
|
|
8899
|
-
|
|
9012
|
+
assignMissingIDs(newState.doc, tr, incumbentPositions(oldState.doc, mapForward));
|
|
9013
|
+
if (!tr.docChanged) return null;
|
|
9014
|
+
const ridesAlongWithAnEdit = transactions.some(
|
|
9015
|
+
(transaction) => transaction.docChanged && transaction.getMeta("addToHistory") !== false
|
|
9016
|
+
);
|
|
9017
|
+
if (!ridesAlongWithAnEdit) tr.setMeta("addToHistory", false);
|
|
9018
|
+
return tr;
|
|
8900
9019
|
},
|
|
8901
9020
|
// Handle paste - filter duplicates
|
|
8902
9021
|
props: filterDuplicates ? {
|
|
@@ -9865,14 +9984,14 @@ var FontSize = Extension.create({
|
|
|
9865
9984
|
addToolbarItems() {
|
|
9866
9985
|
if (this.options.fontSizes.length === 0) return [];
|
|
9867
9986
|
const sizes = this.options.fontSizes;
|
|
9868
|
-
const items = sizes.map((
|
|
9987
|
+
const items = sizes.map((size2, i) => ({
|
|
9869
9988
|
type: "button",
|
|
9870
|
-
name: `fontSize-${
|
|
9989
|
+
name: `fontSize-${size2}`,
|
|
9871
9990
|
command: "setFontSize",
|
|
9872
|
-
commandArgs: [
|
|
9873
|
-
isActive: { name: "textStyle", attributes: { fontSize:
|
|
9991
|
+
commandArgs: [size2],
|
|
9992
|
+
isActive: { name: "textStyle", attributes: { fontSize: size2 } },
|
|
9874
9993
|
icon: "textSize",
|
|
9875
|
-
label:
|
|
9994
|
+
label: size2,
|
|
9876
9995
|
priority: 200 - i
|
|
9877
9996
|
}));
|
|
9878
9997
|
if (this.options.showReset) {
|
|
@@ -10336,7 +10455,7 @@ function createBubbleMenuPlugin(options) {
|
|
|
10336
10455
|
if (from !== prevValue.from || to !== prevValue.to) {
|
|
10337
10456
|
suppressed = false;
|
|
10338
10457
|
}
|
|
10339
|
-
const visible = !suppressed && !selection.empty && shouldShow({
|
|
10458
|
+
const visible = !suppressed && !selection.empty && editor.isEditable && shouldShow({
|
|
10340
10459
|
editor,
|
|
10341
10460
|
view: editor.view,
|
|
10342
10461
|
state: newState,
|
|
@@ -10376,7 +10495,7 @@ function createBubbleMenuPlugin(options) {
|
|
|
10376
10495
|
if (mouseDown) return;
|
|
10377
10496
|
const { selection } = editor.view.state;
|
|
10378
10497
|
const { from, to } = selection;
|
|
10379
|
-
const show = !selection.empty && shouldShow({
|
|
10498
|
+
const show = !selection.empty && editor.isEditable && shouldShow({
|
|
10380
10499
|
editor,
|
|
10381
10500
|
view: editor.view,
|
|
10382
10501
|
state: editor.view.state,
|
|
@@ -10412,6 +10531,10 @@ function createBubbleMenuPlugin(options) {
|
|
|
10412
10531
|
return {
|
|
10413
10532
|
update: (view, prevState) => {
|
|
10414
10533
|
if (view.composing) return;
|
|
10534
|
+
if (!view.editable) {
|
|
10535
|
+
hideMenu();
|
|
10536
|
+
return;
|
|
10537
|
+
}
|
|
10415
10538
|
const state = pluginKey.getState(view.state);
|
|
10416
10539
|
const prevPluginState = pluginKey.getState(prevState);
|
|
10417
10540
|
if (state?.visible === prevPluginState?.visible && state?.from === prevPluginState?.from && state?.to === prevPluginState?.to && !(state?.visible && view.state.doc !== prevState.doc)) {
|
|
@@ -10544,8 +10667,8 @@ var StarterKit = Extension.create({
|
|
|
10544
10667
|
});
|
|
10545
10668
|
|
|
10546
10669
|
// src/index.ts
|
|
10547
|
-
var VERSION = "0.
|
|
10670
|
+
var VERSION = "0.14.0";
|
|
10548
10671
|
|
|
10549
|
-
export { BaseKeymap, BlockColor, Blockquote, Bold, BubbleMenu, BulletList, CanChecker, ChainBuilder, CharacterCount, ClearFormatting, Code, CodeBlock, CommandManager, DEFAULT_BLOCK_COLORS, DEFAULT_BLOCK_COLOR_TYPES, DEFAULT_HIGHLIGHT_COLORS, DEFAULT_NOTION_COLOR_PALETTE, DEFAULT_TEXT_COLORS, Document, Dropcursor, Editor, EventEmitter, Extension, ExtensionConfigurationError, ExtensionManager, FLOATING_MENU_META, FLOATING_MENU_NO_FOCUS, FloatingMenuController, Focus, FontFamily, FontSize, Gapcursor, HardBreak, Heading, Highlight, History, HorizontalRule, InvisibleChars, Italic, LIST_ITEM_TYPE_NAMES, LineHeight, Link, LinkPopover, ListIndent, ListItem, ListKeymap, Mark, Node2 as Node, NotionColorPicker, OrderedList, Paragraph, Placeholder, Selection5 as Selection, SelectionDecoration, StarterKit, Strike, Subscript, Superscript, TaskItem, TaskList, Text, TextAlign, TextColor, TextStyle, ToolbarController, TrailingNode, Typography, Underline, UniqueID, VERSION, applyInlineStyles, autolinkPlugin, autolinkPluginKey, blur, bubbleMenuPluginKey, buildCommandProps, builtInCommands, callOrReturn, characterCountPluginKey, clearContent, copyThemeClass, createAccumulatingDispatch, createBubbleMenuPlugin, createCanChecker, createChainBuilder, createDocument, createFloatingMenuPlugin, defaultBlockAt, defaultBubbleContexts, defaultFloatingMenuShouldShow, defaultIcons, deleteSelection, findChildren, findListItemAncestorDepth, findParentNode, floatingMenuPluginKey, focus, focusPluginKey, generateHTML, generateJSON, generateText, getListItemCursorContext, getMarkRange, groupFloatingMenuItems, hideFloatingMenu, indentBlockAsListChild, inlineStyles, insertAsListItemChild, insertChildrenZoneSibling, insertContent, insertText, invisibleCharsPluginKey, isDocumentEmpty, isInListItemLabel, isInsideListItem, isNodeEmpty, isValidUrl, lift, liftCurrentListItem, liftEmptyChildrenZoneParagraph, linkClickPlugin, linkClickPluginKey, linkExitPlugin, linkExitPluginKey, linkPastePlugin, linkPastePluginKey, markInputRule, markInputRulePatterns, nodeInputRule, outdentBlockFromListItem, placeholderPluginKey, positionFloating, positionFloatingOnce, refocusEditorAfterCommand, resetAttributes, selectAll, selectNodeBackward, selectionDecorationPluginKey, setBlockType, setContent, setMark, showFloatingMenu, splitListForInsert, stripInlineColorConflicts, textInputRule, textblockTypeInputRule, toggleBlockType, toggleList, toggleMark, toggleWrap, uniqueIDPluginKey, unsetAllMarks, unsetMark, updateAttributes, wrapIn, wrappingInputRule, writeToClipboard };
|
|
10672
|
+
export { BaseKeymap, BlockColor, Blockquote, Bold, BubbleMenu, BulletList, CanChecker, ChainBuilder, CharacterCount, ClearFormatting, Code, CodeBlock, CommandManager, DEFAULT_BLOCK_COLORS, DEFAULT_BLOCK_COLOR_TYPES, DEFAULT_HIGHLIGHT_COLORS, DEFAULT_NOTION_COLOR_PALETTE, DEFAULT_TEXT_COLORS, Document, Dropcursor, Editor, EventEmitter, Extension, ExtensionConfigurationError, ExtensionManager, FLOATING_MENU_META, FLOATING_MENU_NO_FOCUS, FloatingMenuController, Focus, FontFamily, FontSize, Gapcursor, HardBreak, Heading, Highlight, History, HorizontalRule, InvisibleChars, Italic, LIST_ITEM_TYPE_NAMES, LineHeight, Link, LinkPopover, ListIndent, ListItem, ListKeymap, Mark, Node2 as Node, NotionColorPicker, OrderedList, Paragraph, Placeholder, Selection5 as Selection, SelectionDecoration, StarterKit, Strike, Subscript, Superscript, TaskItem, TaskList, Text, TextAlign, TextColor, TextStyle, ToolbarController, TrailingNode, Typography, Underline, UniqueID, VERSION, announce, applyInlineStyles, autolinkPlugin, autolinkPluginKey, blur, bubbleMenuPluginKey, buildCommandProps, builtInCommands, callOrReturn, characterCountPluginKey, clearContent, copyThemeClass, createAccumulatingDispatch, createBubbleMenuPlugin, createCanChecker, createChainBuilder, createDocument, createFloatingMenuPlugin, defaultBlockAt, defaultBubbleContexts, defaultFloatingMenuShouldShow, defaultIcons, deleteSelection, findChildren, findListItemAncestorDepth, findParentNode, floatingMenuPluginKey, focus, focusPluginKey, generateHTML, generateJSON, generateText, getListItemCursorContext, getMarkRange, groupFloatingMenuItems, hideFloatingMenu, indentBlockAsListChild, inlineStyles, insertAsListItemChild, insertChildrenZoneSibling, insertContent, insertText, invisibleCharsPluginKey, isDocumentEmpty, isInListItemLabel, isInsideListItem, isNodeEmpty, isValidUrl, lift, liftCurrentListItem, liftEmptyChildrenZoneParagraph, linkClickPlugin, linkClickPluginKey, linkExitPlugin, linkExitPluginKey, linkPastePlugin, linkPastePluginKey, markInputRule, markInputRulePatterns, nodeInputRule, outdentBlockFromListItem, placeholderPluginKey, positionFloating, positionFloatingOnce, refocusEditorAfterCommand, resetAttributes, selectAll, selectNodeBackward, selectionDecorationPluginKey, setBlockType, setContent, setMark, showFloatingMenu, splitListForInsert, stripInlineColorConflicts, textInputRule, textblockTypeInputRule, toggleBlockType, toggleList, toggleMark, toggleWrap, uniqueIDPluginKey, unsetAllMarks, unsetMark, updateAttributes, wrapIn, wrappingInputRule, writeToClipboard };
|
|
10550
10673
|
//# sourceMappingURL=index.js.map
|
|
10551
10674
|
//# sourceMappingURL=index.js.map
|