@kerebron/extension-menu 0.4.27 → 0.4.29
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/esm/CustomMenuPlugin.d.ts +117 -0
- package/esm/CustomMenuPlugin.d.ts.map +1 -0
- package/esm/CustomMenuPlugin.js +1634 -0
- package/esm/CustomMenuPlugin.js.map +1 -0
- package/esm/ExtensionCustomMenu.d.ts +11 -0
- package/esm/ExtensionCustomMenu.d.ts.map +1 -0
- package/esm/ExtensionCustomMenu.js +19 -0
- package/esm/ExtensionCustomMenu.js.map +1 -0
- package/esm/_dnt.shims.d.ts +2 -0
- package/esm/_dnt.shims.d.ts.map +1 -0
- package/esm/_dnt.shims.js +58 -0
- package/esm/_dnt.shims.js.map +1 -0
- package/esm/buildMenu.d.ts +5 -0
- package/esm/buildMenu.d.ts.map +1 -0
- package/esm/buildMenu.js +447 -0
- package/esm/buildMenu.js.map +1 -0
- package/esm/icons.d.ts +15 -0
- package/esm/icons.d.ts.map +1 -0
- package/esm/icons.js +213 -0
- package/esm/icons.js.map +1 -0
- package/esm/menu.d.ts +83 -0
- package/esm/menu.d.ts.map +1 -0
- package/esm/menu.js +334 -0
- package/esm/menu.js.map +1 -0
- package/esm/mod.d.ts +3 -0
- package/esm/mod.d.ts.map +1 -0
- package/esm/mod.js +3 -0
- package/esm/mod.js.map +1 -0
- package/esm/package.json +3 -0
- package/esm/prompt.d.ts +36 -0
- package/esm/prompt.d.ts.map +1 -0
- package/esm/prompt.js +165 -0
- package/esm/prompt.js.map +1 -0
- package/package.json +6 -3
- package/src/CustomMenuPlugin.ts +1996 -0
- package/src/ExtensionCustomMenu.ts +29 -0
- package/src/_dnt.shims.ts +60 -0
- package/src/buildMenu.ts +560 -0
- package/src/icons.ts +262 -0
- package/src/menu.ts +473 -0
- package/src/mod.ts +9 -0
- package/src/prompt.ts +205 -0
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { EditorState, Plugin } from 'prosemirror-state';
|
|
2
|
+
import { EditorView } from 'prosemirror-view';
|
|
3
|
+
import type { CoreEditor } from '@kerebron/editor';
|
|
4
|
+
import { CustomMenuOptions } from './ExtensionCustomMenu.js';
|
|
5
|
+
import type { MenuElement } from './menu.js';
|
|
6
|
+
interface ToolItem {
|
|
7
|
+
id: string;
|
|
8
|
+
label: string;
|
|
9
|
+
element: MenuElement;
|
|
10
|
+
order: number;
|
|
11
|
+
groupIndex: number;
|
|
12
|
+
}
|
|
13
|
+
export declare class CustomMenuView {
|
|
14
|
+
readonly editorView: EditorView;
|
|
15
|
+
readonly editor: CoreEditor;
|
|
16
|
+
readonly content: readonly (readonly MenuElement[])[];
|
|
17
|
+
wrapper: HTMLElement;
|
|
18
|
+
toolbar: HTMLElement;
|
|
19
|
+
overflowMenu: HTMLElement;
|
|
20
|
+
pinnedDropdownMenu: HTMLElement | null;
|
|
21
|
+
tools: ToolItem[];
|
|
22
|
+
root: Document | ShadowRoot;
|
|
23
|
+
resizeHandle: HTMLElement;
|
|
24
|
+
editorContainer: HTMLElement;
|
|
25
|
+
private closeOverflowHandler;
|
|
26
|
+
private closePinnedDropdownHandler;
|
|
27
|
+
private keydownHandler;
|
|
28
|
+
private submenuStack;
|
|
29
|
+
private pinnedDropdownStack;
|
|
30
|
+
private resizeObserver;
|
|
31
|
+
private draggedItem;
|
|
32
|
+
private dragStartTimer;
|
|
33
|
+
private isDragging;
|
|
34
|
+
private isDraggingFromOverflow;
|
|
35
|
+
private dragPlaceholder;
|
|
36
|
+
private dragGhost;
|
|
37
|
+
private dragSourceWrapper;
|
|
38
|
+
private currentOverflowTools;
|
|
39
|
+
private defaultOrder;
|
|
40
|
+
private focusedToolbarIndex;
|
|
41
|
+
constructor(editorView: EditorView, editor: CoreEditor, content: readonly (readonly MenuElement[])[]);
|
|
42
|
+
/**
|
|
43
|
+
* Close all open menus (overflow menu and pinned dropdowns).
|
|
44
|
+
* Optionally returns focus to a specific element.
|
|
45
|
+
*/
|
|
46
|
+
private closeAllMenus;
|
|
47
|
+
/**
|
|
48
|
+
* Get all focusable toolbar items (buttons).
|
|
49
|
+
*/
|
|
50
|
+
private getToolbarButtons;
|
|
51
|
+
/**
|
|
52
|
+
* Setup keyboard navigation for toolbar (WCAG toolbar pattern).
|
|
53
|
+
* - Left/Right arrows move between items
|
|
54
|
+
* - Home/End jump to first/last item
|
|
55
|
+
* - Escape closes menus
|
|
56
|
+
*/
|
|
57
|
+
private setupKeyboardNavigation;
|
|
58
|
+
private initializeTools;
|
|
59
|
+
/**
|
|
60
|
+
* Generate a stable ID from a label by converting it to a kebab-case slug.
|
|
61
|
+
* Falls back to a hash if the label is empty or contains only special characters.
|
|
62
|
+
*/
|
|
63
|
+
private generateStableId;
|
|
64
|
+
/**
|
|
65
|
+
* Simple hash function for generating stable IDs from strings.
|
|
66
|
+
*/
|
|
67
|
+
private simpleHash;
|
|
68
|
+
private extractLabel;
|
|
69
|
+
private loadOrderState;
|
|
70
|
+
private saveOrderState;
|
|
71
|
+
/**
|
|
72
|
+
* Check if the current order differs from the default order.
|
|
73
|
+
*/
|
|
74
|
+
private hasCustomOrder;
|
|
75
|
+
/**
|
|
76
|
+
* Reset toolbar to default order, clearing any customizations.
|
|
77
|
+
*/
|
|
78
|
+
private resetToDefault;
|
|
79
|
+
/**
|
|
80
|
+
* Create a reset button element.
|
|
81
|
+
* @param iconOnly - If true, show only the icon (for toolbar); if false, show icon + text (for overflow menu)
|
|
82
|
+
*/
|
|
83
|
+
private createResetButton;
|
|
84
|
+
private showSubmenu;
|
|
85
|
+
private goBack;
|
|
86
|
+
private showPinnedDropdown;
|
|
87
|
+
private pinnedDropdownGoBack;
|
|
88
|
+
private pinnedDropdownShowSubmenu;
|
|
89
|
+
private renderPinnedDropdown;
|
|
90
|
+
private renderOverflowMenu;
|
|
91
|
+
private render;
|
|
92
|
+
private setupDragHandlers;
|
|
93
|
+
/**
|
|
94
|
+
* Set up drag handlers for overflow menu items.
|
|
95
|
+
* Long-hold initiates drag to toolbar, short click activates the item.
|
|
96
|
+
*/
|
|
97
|
+
private setupOverflowDragHandlers;
|
|
98
|
+
/**
|
|
99
|
+
* Start dragging an item from the overflow menu to the toolbar.
|
|
100
|
+
*/
|
|
101
|
+
private startOverflowDrag;
|
|
102
|
+
/**
|
|
103
|
+
* Close the overflow menu programmatically.
|
|
104
|
+
*/
|
|
105
|
+
private closeOverflowMenu;
|
|
106
|
+
private cleanupOverflowDrag;
|
|
107
|
+
private startDrag;
|
|
108
|
+
private cleanupDrag;
|
|
109
|
+
private setupResize;
|
|
110
|
+
update(view: EditorView, prevState: EditorState): void;
|
|
111
|
+
destroy(): void;
|
|
112
|
+
}
|
|
113
|
+
export declare class CustomMenuPlugin extends Plugin {
|
|
114
|
+
constructor(editor: CoreEditor, options: CustomMenuOptions);
|
|
115
|
+
}
|
|
116
|
+
export {};
|
|
117
|
+
//# sourceMappingURL=CustomMenuPlugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CustomMenuPlugin.d.ts","sourceRoot":"","sources":["../src/CustomMenuPlugin.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAY7C,UAAU,QAAQ;IAChB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,WAAW,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,qBAAa,cAAc;IAqCvB,QAAQ,CAAC,UAAU,EAAE,UAAU;IAC/B,QAAQ,CAAC,MAAM,EAAE,U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