@rtif-sdk/web 1.0.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/LICENSE +21 -0
- package/README.md +67 -0
- package/dist/block-drag-handler.d.ts +189 -0
- package/dist/block-drag-handler.d.ts.map +1 -0
- package/dist/block-drag-handler.js +745 -0
- package/dist/block-drag-handler.js.map +1 -0
- package/dist/block-renderer.d.ts +402 -0
- package/dist/block-renderer.d.ts.map +1 -0
- package/dist/block-renderer.js +424 -0
- package/dist/block-renderer.js.map +1 -0
- package/dist/clipboard.d.ts +178 -0
- package/dist/clipboard.d.ts.map +1 -0
- package/dist/clipboard.js +432 -0
- package/dist/clipboard.js.map +1 -0
- package/dist/command-bus.d.ts +113 -0
- package/dist/command-bus.d.ts.map +1 -0
- package/dist/command-bus.js +70 -0
- package/dist/command-bus.js.map +1 -0
- package/dist/composition.d.ts +220 -0
- package/dist/composition.d.ts.map +1 -0
- package/dist/composition.js +271 -0
- package/dist/composition.js.map +1 -0
- package/dist/content-extraction.d.ts +69 -0
- package/dist/content-extraction.d.ts.map +1 -0
- package/dist/content-extraction.js +228 -0
- package/dist/content-extraction.js.map +1 -0
- package/dist/content-handler-file.d.ts +40 -0
- package/dist/content-handler-file.d.ts.map +1 -0
- package/dist/content-handler-file.js +91 -0
- package/dist/content-handler-file.js.map +1 -0
- package/dist/content-handler-image.d.ts +82 -0
- package/dist/content-handler-image.d.ts.map +1 -0
- package/dist/content-handler-image.js +120 -0
- package/dist/content-handler-image.js.map +1 -0
- package/dist/content-handler-url.d.ts +129 -0
- package/dist/content-handler-url.d.ts.map +1 -0
- package/dist/content-handler-url.js +244 -0
- package/dist/content-handler-url.js.map +1 -0
- package/dist/content-handlers.d.ts +67 -0
- package/dist/content-handlers.d.ts.map +1 -0
- package/dist/content-handlers.js +263 -0
- package/dist/content-handlers.js.map +1 -0
- package/dist/content-pipeline.d.ts +383 -0
- package/dist/content-pipeline.d.ts.map +1 -0
- package/dist/content-pipeline.js +232 -0
- package/dist/content-pipeline.js.map +1 -0
- package/dist/cursor-nav.d.ts +149 -0
- package/dist/cursor-nav.d.ts.map +1 -0
- package/dist/cursor-nav.js +230 -0
- package/dist/cursor-nav.js.map +1 -0
- package/dist/cursor-rect.d.ts +65 -0
- package/dist/cursor-rect.d.ts.map +1 -0
- package/dist/cursor-rect.js +98 -0
- package/dist/cursor-rect.js.map +1 -0
- package/dist/drop-indicator.d.ts +108 -0
- package/dist/drop-indicator.d.ts.map +1 -0
- package/dist/drop-indicator.js +236 -0
- package/dist/drop-indicator.js.map +1 -0
- package/dist/editor.d.ts +41 -0
- package/dist/editor.d.ts.map +1 -0
- package/dist/editor.js +710 -0
- package/dist/editor.js.map +1 -0
- package/dist/floating-toolbar.d.ts +93 -0
- package/dist/floating-toolbar.d.ts.map +1 -0
- package/dist/floating-toolbar.js +159 -0
- package/dist/floating-toolbar.js.map +1 -0
- package/dist/index.d.ts +62 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +119 -0
- package/dist/index.js.map +1 -0
- package/dist/input-bridge.d.ts +273 -0
- package/dist/input-bridge.d.ts.map +1 -0
- package/dist/input-bridge.js +884 -0
- package/dist/input-bridge.js.map +1 -0
- package/dist/link-popover.d.ts +38 -0
- package/dist/link-popover.d.ts.map +1 -0
- package/dist/link-popover.js +278 -0
- package/dist/link-popover.js.map +1 -0
- package/dist/mark-renderer.d.ts +275 -0
- package/dist/mark-renderer.d.ts.map +1 -0
- package/dist/mark-renderer.js +210 -0
- package/dist/mark-renderer.js.map +1 -0
- package/dist/perf.d.ts +145 -0
- package/dist/perf.d.ts.map +1 -0
- package/dist/perf.js +260 -0
- package/dist/perf.js.map +1 -0
- package/dist/plugin-kit.d.ts +265 -0
- package/dist/plugin-kit.d.ts.map +1 -0
- package/dist/plugin-kit.js +234 -0
- package/dist/plugin-kit.js.map +1 -0
- package/dist/plugins/alignment-plugin.d.ts +68 -0
- package/dist/plugins/alignment-plugin.d.ts.map +1 -0
- package/dist/plugins/alignment-plugin.js +98 -0
- package/dist/plugins/alignment-plugin.js.map +1 -0
- package/dist/plugins/block-utils.d.ts +113 -0
- package/dist/plugins/block-utils.d.ts.map +1 -0
- package/dist/plugins/block-utils.js +191 -0
- package/dist/plugins/block-utils.js.map +1 -0
- package/dist/plugins/blockquote-plugin.d.ts +39 -0
- package/dist/plugins/blockquote-plugin.d.ts.map +1 -0
- package/dist/plugins/blockquote-plugin.js +88 -0
- package/dist/plugins/blockquote-plugin.js.map +1 -0
- package/dist/plugins/bold-plugin.d.ts +37 -0
- package/dist/plugins/bold-plugin.d.ts.map +1 -0
- package/dist/plugins/bold-plugin.js +48 -0
- package/dist/plugins/bold-plugin.js.map +1 -0
- package/dist/plugins/callout-plugin.d.ts +100 -0
- package/dist/plugins/callout-plugin.d.ts.map +1 -0
- package/dist/plugins/callout-plugin.js +200 -0
- package/dist/plugins/callout-plugin.js.map +1 -0
- package/dist/plugins/code-block-plugin.d.ts +62 -0
- package/dist/plugins/code-block-plugin.d.ts.map +1 -0
- package/dist/plugins/code-block-plugin.js +176 -0
- package/dist/plugins/code-block-plugin.js.map +1 -0
- package/dist/plugins/code-plugin.d.ts +37 -0
- package/dist/plugins/code-plugin.d.ts.map +1 -0
- package/dist/plugins/code-plugin.js +48 -0
- package/dist/plugins/code-plugin.js.map +1 -0
- package/dist/plugins/embed-plugin.d.ts +90 -0
- package/dist/plugins/embed-plugin.d.ts.map +1 -0
- package/dist/plugins/embed-plugin.js +147 -0
- package/dist/plugins/embed-plugin.js.map +1 -0
- package/dist/plugins/font-family-plugin.d.ts +58 -0
- package/dist/plugins/font-family-plugin.d.ts.map +1 -0
- package/dist/plugins/font-family-plugin.js +57 -0
- package/dist/plugins/font-family-plugin.js.map +1 -0
- package/dist/plugins/font-size-plugin.d.ts +57 -0
- package/dist/plugins/font-size-plugin.d.ts.map +1 -0
- package/dist/plugins/font-size-plugin.js +56 -0
- package/dist/plugins/font-size-plugin.js.map +1 -0
- package/dist/plugins/heading-plugin.d.ts +52 -0
- package/dist/plugins/heading-plugin.d.ts.map +1 -0
- package/dist/plugins/heading-plugin.js +114 -0
- package/dist/plugins/heading-plugin.js.map +1 -0
- package/dist/plugins/hr-plugin.d.ts +33 -0
- package/dist/plugins/hr-plugin.d.ts.map +1 -0
- package/dist/plugins/hr-plugin.js +75 -0
- package/dist/plugins/hr-plugin.js.map +1 -0
- package/dist/plugins/image-plugin.d.ts +115 -0
- package/dist/plugins/image-plugin.d.ts.map +1 -0
- package/dist/plugins/image-plugin.js +199 -0
- package/dist/plugins/image-plugin.js.map +1 -0
- package/dist/plugins/indent-plugin.d.ts +62 -0
- package/dist/plugins/indent-plugin.d.ts.map +1 -0
- package/dist/plugins/indent-plugin.js +128 -0
- package/dist/plugins/indent-plugin.js.map +1 -0
- package/dist/plugins/index.d.ts +45 -0
- package/dist/plugins/index.d.ts.map +1 -0
- package/dist/plugins/index.js +42 -0
- package/dist/plugins/index.js.map +1 -0
- package/dist/plugins/italic-plugin.d.ts +37 -0
- package/dist/plugins/italic-plugin.d.ts.map +1 -0
- package/dist/plugins/italic-plugin.js +48 -0
- package/dist/plugins/italic-plugin.js.map +1 -0
- package/dist/plugins/link-plugin.d.ts +129 -0
- package/dist/plugins/link-plugin.d.ts.map +1 -0
- package/dist/plugins/link-plugin.js +212 -0
- package/dist/plugins/link-plugin.js.map +1 -0
- package/dist/plugins/list-plugin.d.ts +53 -0
- package/dist/plugins/list-plugin.d.ts.map +1 -0
- package/dist/plugins/list-plugin.js +309 -0
- package/dist/plugins/list-plugin.js.map +1 -0
- package/dist/plugins/mark-utils.d.ts +173 -0
- package/dist/plugins/mark-utils.d.ts.map +1 -0
- package/dist/plugins/mark-utils.js +425 -0
- package/dist/plugins/mark-utils.js.map +1 -0
- package/dist/plugins/mention-plugin.d.ts +191 -0
- package/dist/plugins/mention-plugin.d.ts.map +1 -0
- package/dist/plugins/mention-plugin.js +295 -0
- package/dist/plugins/mention-plugin.js.map +1 -0
- package/dist/plugins/strikethrough-plugin.d.ts +37 -0
- package/dist/plugins/strikethrough-plugin.d.ts.map +1 -0
- package/dist/plugins/strikethrough-plugin.js +48 -0
- package/dist/plugins/strikethrough-plugin.js.map +1 -0
- package/dist/plugins/text-color-plugin.d.ts +57 -0
- package/dist/plugins/text-color-plugin.d.ts.map +1 -0
- package/dist/plugins/text-color-plugin.js +56 -0
- package/dist/plugins/text-color-plugin.js.map +1 -0
- package/dist/plugins/underline-plugin.d.ts +37 -0
- package/dist/plugins/underline-plugin.d.ts.map +1 -0
- package/dist/plugins/underline-plugin.js +48 -0
- package/dist/plugins/underline-plugin.js.map +1 -0
- package/dist/presets.d.ts +95 -0
- package/dist/presets.d.ts.map +1 -0
- package/dist/presets.js +159 -0
- package/dist/presets.js.map +1 -0
- package/dist/renderer.d.ts +125 -0
- package/dist/renderer.d.ts.map +1 -0
- package/dist/renderer.js +415 -0
- package/dist/renderer.js.map +1 -0
- package/dist/scroll-to-cursor.d.ts +25 -0
- package/dist/scroll-to-cursor.d.ts.map +1 -0
- package/dist/scroll-to-cursor.js +59 -0
- package/dist/scroll-to-cursor.js.map +1 -0
- package/dist/selection-sync.d.ts +159 -0
- package/dist/selection-sync.d.ts.map +1 -0
- package/dist/selection-sync.js +527 -0
- package/dist/selection-sync.js.map +1 -0
- package/dist/shortcut-handler.d.ts +98 -0
- package/dist/shortcut-handler.d.ts.map +1 -0
- package/dist/shortcut-handler.js +155 -0
- package/dist/shortcut-handler.js.map +1 -0
- package/dist/toolbar.d.ts +103 -0
- package/dist/toolbar.d.ts.map +1 -0
- package/dist/toolbar.js +134 -0
- package/dist/toolbar.js.map +1 -0
- package/dist/trigger-manager.d.ts +205 -0
- package/dist/trigger-manager.d.ts.map +1 -0
- package/dist/trigger-manager.js +466 -0
- package/dist/trigger-manager.js.map +1 -0
- package/dist/types.d.ts +216 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +30 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cursor and selection rectangle API for positioning floating UI.
|
|
3
|
+
*
|
|
4
|
+
* Provides viewport-coordinate rectangles at document offsets. Used by
|
|
5
|
+
* TriggerManager to position dropdowns and by consumers for custom
|
|
6
|
+
* floating UI (mention pickers, slash-command menus, etc.).
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
import type { Document } from '@rtif-sdk/core';
|
|
11
|
+
/**
|
|
12
|
+
* API for querying screen-space rectangles at cursor positions.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* const api = createCursorRectAPI(root, () => engine.state.doc);
|
|
17
|
+
* const rect = api.getCursorRect();
|
|
18
|
+
* if (rect) {
|
|
19
|
+
* dropdown.style.top = `${rect.bottom}px`;
|
|
20
|
+
* dropdown.style.left = `${rect.left}px`;
|
|
21
|
+
* }
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export interface CursorRectAPI {
|
|
25
|
+
/**
|
|
26
|
+
* Get the bounding rect of the current collapsed caret.
|
|
27
|
+
*
|
|
28
|
+
* @returns The caret rect, or null if no selection or selection is not inside the editor
|
|
29
|
+
*/
|
|
30
|
+
getCursorRect(): DOMRect | null;
|
|
31
|
+
/**
|
|
32
|
+
* Get the bounding rect at a specific absolute document offset.
|
|
33
|
+
*
|
|
34
|
+
* @param offset - Absolute RTIF document offset
|
|
35
|
+
* @returns The rect at that offset, or null if the offset can't be resolved
|
|
36
|
+
*/
|
|
37
|
+
getRectAtOffset(offset: number): DOMRect | null;
|
|
38
|
+
/**
|
|
39
|
+
* Get the bounding rect of the full selection range.
|
|
40
|
+
*
|
|
41
|
+
* @returns The selection bounding rect, or null if no selection
|
|
42
|
+
*/
|
|
43
|
+
getSelectionRect(): DOMRect | null;
|
|
44
|
+
/**
|
|
45
|
+
* Get the bounding rect of the editor root element.
|
|
46
|
+
*
|
|
47
|
+
* @returns The editor root's bounding client rect
|
|
48
|
+
*/
|
|
49
|
+
getEditorRect(): DOMRect;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Create a CursorRectAPI instance.
|
|
53
|
+
*
|
|
54
|
+
* @param root - The editor's root element (`[data-rtif-root]`)
|
|
55
|
+
* @param getDoc - Function that returns the current RTIF document
|
|
56
|
+
* @returns A CursorRectAPI instance
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```ts
|
|
60
|
+
* const cursorRect = createCursorRectAPI(root, () => engine.state.doc);
|
|
61
|
+
* const rect = cursorRect.getCursorRect();
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
export declare function createCursorRectAPI(root: HTMLElement, getDoc: () => Document): CursorRectAPI;
|
|
65
|
+
//# sourceMappingURL=cursor-rect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cursor-rect.d.ts","sourceRoot":"","sources":["../src/cursor-rect.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAI/C;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,aAAa;IAC5B;;;;OAIG;IACH,aAAa,IAAI,OAAO,GAAG,IAAI,CAAC;IAEhC;;;;;OAKG;IACH,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;IAEhD;;;;OAIG;IACH,gBAAgB,IAAI,OAAO,GAAG,IAAI,CAAC;IAEnC;;;;OAIG;IACH,aAAa,IAAI,OAAO,CAAC;CAC1B;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,WAAW,EACjB,MAAM,EAAE,MAAM,QAAQ,GACrB,aAAa,CAgEf"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cursor and selection rectangle API for positioning floating UI.
|
|
3
|
+
*
|
|
4
|
+
* Provides viewport-coordinate rectangles at document offsets. Used by
|
|
5
|
+
* TriggerManager to position dropdowns and by consumers for custom
|
|
6
|
+
* floating UI (mention pickers, slash-command menus, etc.).
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
import { resolve } from '@rtif-sdk/core';
|
|
11
|
+
import { rtifOffsetToDomPoint } from './selection-sync.js';
|
|
12
|
+
/**
|
|
13
|
+
* Create a CursorRectAPI instance.
|
|
14
|
+
*
|
|
15
|
+
* @param root - The editor's root element (`[data-rtif-root]`)
|
|
16
|
+
* @param getDoc - Function that returns the current RTIF document
|
|
17
|
+
* @returns A CursorRectAPI instance
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* const cursorRect = createCursorRectAPI(root, () => engine.state.doc);
|
|
22
|
+
* const rect = cursorRect.getCursorRect();
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export function createCursorRectAPI(root, getDoc) {
|
|
26
|
+
return {
|
|
27
|
+
getCursorRect() {
|
|
28
|
+
const sel = window.getSelection();
|
|
29
|
+
if (!sel || sel.rangeCount === 0)
|
|
30
|
+
return null;
|
|
31
|
+
// Verify selection is inside the editor
|
|
32
|
+
if (!sel.anchorNode || !root.contains(sel.anchorNode))
|
|
33
|
+
return null;
|
|
34
|
+
const range = sel.getRangeAt(0);
|
|
35
|
+
const rect = range.getBoundingClientRect();
|
|
36
|
+
// Browsers return an all-zero rect for collapsed cursors in empty blocks.
|
|
37
|
+
// Fall back to the block element's rect.
|
|
38
|
+
if (rect.width === 0 && rect.height === 0 && rect.top === 0 && rect.left === 0) {
|
|
39
|
+
return getFallbackRect(root, sel.anchorNode);
|
|
40
|
+
}
|
|
41
|
+
return rect;
|
|
42
|
+
},
|
|
43
|
+
getRectAtOffset(offset) {
|
|
44
|
+
const doc = getDoc();
|
|
45
|
+
try {
|
|
46
|
+
resolve(doc, offset); // validate offset
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
const domPoint = rtifOffsetToDomPoint(root, doc, offset);
|
|
52
|
+
if (!domPoint)
|
|
53
|
+
return null;
|
|
54
|
+
const range = document.createRange();
|
|
55
|
+
try {
|
|
56
|
+
range.setStart(domPoint.node, domPoint.offset);
|
|
57
|
+
range.collapse(true);
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
const rect = range.getBoundingClientRect();
|
|
63
|
+
// Fall back for empty blocks
|
|
64
|
+
if (rect.width === 0 && rect.height === 0 && rect.top === 0 && rect.left === 0) {
|
|
65
|
+
return getFallbackRect(root, domPoint.node);
|
|
66
|
+
}
|
|
67
|
+
return rect;
|
|
68
|
+
},
|
|
69
|
+
getSelectionRect() {
|
|
70
|
+
const sel = window.getSelection();
|
|
71
|
+
if (!sel || sel.rangeCount === 0)
|
|
72
|
+
return null;
|
|
73
|
+
if (!sel.anchorNode || !root.contains(sel.anchorNode))
|
|
74
|
+
return null;
|
|
75
|
+
const range = sel.getRangeAt(0);
|
|
76
|
+
return range.getBoundingClientRect();
|
|
77
|
+
},
|
|
78
|
+
getEditorRect() {
|
|
79
|
+
return root.getBoundingClientRect();
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Get a fallback rect from the nearest block element when the browser
|
|
85
|
+
* returns an all-zero rect (e.g., collapsed cursor in empty block).
|
|
86
|
+
*/
|
|
87
|
+
function getFallbackRect(root, node) {
|
|
88
|
+
let current = node;
|
|
89
|
+
while (current && current !== root) {
|
|
90
|
+
if (current instanceof HTMLElement &&
|
|
91
|
+
current.hasAttribute('data-rtif-block')) {
|
|
92
|
+
return current.getBoundingClientRect();
|
|
93
|
+
}
|
|
94
|
+
current = current.parentNode;
|
|
95
|
+
}
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=cursor-rect.js.map
|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CAAC;QACtC,CAAC;KACF,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,SAAS,eAAe,CAAC,IAAiB,EAAE,IAAU;IACpD,IAAI,OAAO,GAAgB,IAAI,CAAC;IAChC,OAAO,OAAO,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;QACnC,IACE,OAAO,YAAY,WAAW;YAC9B,OAAO,CAAC,YAAY,CAAC,iBAAiB,CAAC,EACvC,CAAC;YACD,OAAO,OAAO,CAAC,qBAAqB,EAAE,CAAC;QACzC,CAAC;QACD,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC;IAC/B,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Drop indicator — visual feedback for drag-and-drop operations.
|
|
3
|
+
*
|
|
4
|
+
* Provides two display modes:
|
|
5
|
+
* - **File overlay**: Full-editor dashed border with "Drop file to upload" text
|
|
6
|
+
* - **Between-blocks line**: Thin horizontal line above or below a block element
|
|
7
|
+
*
|
|
8
|
+
* Uses CSS classes and custom properties for theming. The accent color defaults
|
|
9
|
+
* to `#2563eb` but can be overridden via `--rtif-accent-color`.
|
|
10
|
+
*
|
|
11
|
+
* @module
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Visual indicator for drag-and-drop operations in the editor.
|
|
15
|
+
*
|
|
16
|
+
* Creates and manages absolutely positioned DOM elements within the editor
|
|
17
|
+
* container to show where dropped content will land.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* const indicator = new DropIndicator(editorRoot);
|
|
22
|
+
*
|
|
23
|
+
* // Show file drop overlay
|
|
24
|
+
* indicator.showForFile();
|
|
25
|
+
*
|
|
26
|
+
* // Show line between blocks
|
|
27
|
+
* const blockEl = root.querySelector('[data-rtif-block="b2"]')!;
|
|
28
|
+
* indicator.showBetweenBlocks(blockEl, 'before');
|
|
29
|
+
*
|
|
30
|
+
* // Hide indicator
|
|
31
|
+
* indicator.hide();
|
|
32
|
+
*
|
|
33
|
+
* // Clean up
|
|
34
|
+
* indicator.destroy();
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export declare class DropIndicator {
|
|
38
|
+
private readonly _container;
|
|
39
|
+
private _lineEl;
|
|
40
|
+
private _overlayEl;
|
|
41
|
+
private _destroyed;
|
|
42
|
+
/**
|
|
43
|
+
* Create a drop indicator attached to the given container element.
|
|
44
|
+
*
|
|
45
|
+
* The container should be the editor's root element or a wrapper with
|
|
46
|
+
* `position: relative` for correct absolute positioning.
|
|
47
|
+
*
|
|
48
|
+
* @param container - The parent element for indicator DOM elements
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```ts
|
|
52
|
+
* const indicator = new DropIndicator(editorRoot);
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
constructor(container: HTMLElement);
|
|
56
|
+
/**
|
|
57
|
+
* Show a full-editor overlay for file drops.
|
|
58
|
+
*
|
|
59
|
+
* Displays a dashed border overlay with centered "Drop file to upload" text.
|
|
60
|
+
* Hides any existing between-blocks line indicator.
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```ts
|
|
64
|
+
* indicator.showForFile();
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
showForFile(): void;
|
|
68
|
+
/**
|
|
69
|
+
* Show a thin horizontal line before or after a block element.
|
|
70
|
+
*
|
|
71
|
+
* Calculates the position relative to the container and places a 2px line
|
|
72
|
+
* at the appropriate edge of the target block. Hides any existing file overlay.
|
|
73
|
+
*
|
|
74
|
+
* @param blockEl - The block element to position relative to
|
|
75
|
+
* @param position - Whether to show the line 'before' (above) or 'after' (below) the block
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```ts
|
|
79
|
+
* const block = root.querySelector('[data-rtif-block="b2"]')!;
|
|
80
|
+
* indicator.showBetweenBlocks(block, 'before');
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
|
+
showBetweenBlocks(blockEl: Element, position: 'before' | 'after'): void;
|
|
84
|
+
/**
|
|
85
|
+
* Hide all indicators (both line and overlay).
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* ```ts
|
|
89
|
+
* indicator.hide();
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
92
|
+
hide(): void;
|
|
93
|
+
/**
|
|
94
|
+
* Destroy the indicator, removing all DOM elements.
|
|
95
|
+
*
|
|
96
|
+
* After calling destroy(), the indicator instance is inert and all
|
|
97
|
+
* methods become no-ops.
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* ```ts
|
|
101
|
+
* indicator.destroy();
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
104
|
+
destroy(): void;
|
|
105
|
+
private _hideLine;
|
|
106
|
+
private _hideOverlay;
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=drop-indicator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"drop-indicator.d.ts","sourceRoot":"","sources":["../src/drop-indicator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAaH;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAc;IACzC,OAAO,CAAC,OAAO,CAA4B;IAC3C,OAAO,CAAC,UAAU,CAA4B;IAC9C,OAAO,CAAC,UAAU,CAAS;IAE3B;;;;;;;;;;;;OAYG;gBACS,SAAS,EAAE,WAAW;IAmBlC;;;;;;;;;;OAUG;IACH,WAAW,IAAI,IAAI;IAcnB;;;;;;;;;;;;;;OAcG;IACH,iBAAiB,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,GAAG,OAAO,GAAG,IAAI;IA0BvE;;;;;;;OAOG;IACH,IAAI,IAAI,IAAI;IAMZ;;;;;;;;;;OAUG;IACH,OAAO,IAAI,IAAI;IAmBf,OAAO,CAAC,SAAS;IAMjB,OAAO,CAAC,YAAY;CAKrB"}
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Drop indicator — visual feedback for drag-and-drop operations.
|
|
3
|
+
*
|
|
4
|
+
* Provides two display modes:
|
|
5
|
+
* - **File overlay**: Full-editor dashed border with "Drop file to upload" text
|
|
6
|
+
* - **Between-blocks line**: Thin horizontal line above or below a block element
|
|
7
|
+
*
|
|
8
|
+
* Uses CSS classes and custom properties for theming. The accent color defaults
|
|
9
|
+
* to `#2563eb` but can be overridden via `--rtif-accent-color`.
|
|
10
|
+
*
|
|
11
|
+
* @module
|
|
12
|
+
*/
|
|
13
|
+
// ---------------------------------------------------------------------------
|
|
14
|
+
// CSS class names
|
|
15
|
+
// ---------------------------------------------------------------------------
|
|
16
|
+
const CSS_LINE = 'rtif-drop-indicator';
|
|
17
|
+
const CSS_OVERLAY = 'rtif-drop-overlay';
|
|
18
|
+
// ---------------------------------------------------------------------------
|
|
19
|
+
// DropIndicator class
|
|
20
|
+
// ---------------------------------------------------------------------------
|
|
21
|
+
/**
|
|
22
|
+
* Visual indicator for drag-and-drop operations in the editor.
|
|
23
|
+
*
|
|
24
|
+
* Creates and manages absolutely positioned DOM elements within the editor
|
|
25
|
+
* container to show where dropped content will land.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```ts
|
|
29
|
+
* const indicator = new DropIndicator(editorRoot);
|
|
30
|
+
*
|
|
31
|
+
* // Show file drop overlay
|
|
32
|
+
* indicator.showForFile();
|
|
33
|
+
*
|
|
34
|
+
* // Show line between blocks
|
|
35
|
+
* const blockEl = root.querySelector('[data-rtif-block="b2"]')!;
|
|
36
|
+
* indicator.showBetweenBlocks(blockEl, 'before');
|
|
37
|
+
*
|
|
38
|
+
* // Hide indicator
|
|
39
|
+
* indicator.hide();
|
|
40
|
+
*
|
|
41
|
+
* // Clean up
|
|
42
|
+
* indicator.destroy();
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export class DropIndicator {
|
|
46
|
+
_container;
|
|
47
|
+
_lineEl = null;
|
|
48
|
+
_overlayEl = null;
|
|
49
|
+
_destroyed = false;
|
|
50
|
+
/**
|
|
51
|
+
* Create a drop indicator attached to the given container element.
|
|
52
|
+
*
|
|
53
|
+
* The container should be the editor's root element or a wrapper with
|
|
54
|
+
* `position: relative` for correct absolute positioning.
|
|
55
|
+
*
|
|
56
|
+
* @param container - The parent element for indicator DOM elements
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```ts
|
|
60
|
+
* const indicator = new DropIndicator(editorRoot);
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
constructor(container) {
|
|
64
|
+
this._container = container;
|
|
65
|
+
// Ensure the container has positioning context for absolute children
|
|
66
|
+
const computed = typeof getComputedStyle === 'function'
|
|
67
|
+
? getComputedStyle(container)
|
|
68
|
+
: null;
|
|
69
|
+
if (computed &&
|
|
70
|
+
computed.position !== 'relative' &&
|
|
71
|
+
computed.position !== 'absolute' &&
|
|
72
|
+
computed.position !== 'fixed' &&
|
|
73
|
+
computed.position !== 'sticky') {
|
|
74
|
+
container.style.position = 'relative';
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Show a full-editor overlay for file drops.
|
|
79
|
+
*
|
|
80
|
+
* Displays a dashed border overlay with centered "Drop file to upload" text.
|
|
81
|
+
* Hides any existing between-blocks line indicator.
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```ts
|
|
85
|
+
* indicator.showForFile();
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
showForFile() {
|
|
89
|
+
if (this._destroyed)
|
|
90
|
+
return;
|
|
91
|
+
// Hide the line if showing overlay
|
|
92
|
+
this._hideLine();
|
|
93
|
+
if (!this._overlayEl) {
|
|
94
|
+
this._overlayEl = createOverlayElement();
|
|
95
|
+
this._container.appendChild(this._overlayEl);
|
|
96
|
+
}
|
|
97
|
+
this._overlayEl.style.display = 'flex';
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Show a thin horizontal line before or after a block element.
|
|
101
|
+
*
|
|
102
|
+
* Calculates the position relative to the container and places a 2px line
|
|
103
|
+
* at the appropriate edge of the target block. Hides any existing file overlay.
|
|
104
|
+
*
|
|
105
|
+
* @param blockEl - The block element to position relative to
|
|
106
|
+
* @param position - Whether to show the line 'before' (above) or 'after' (below) the block
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* ```ts
|
|
110
|
+
* const block = root.querySelector('[data-rtif-block="b2"]')!;
|
|
111
|
+
* indicator.showBetweenBlocks(block, 'before');
|
|
112
|
+
* ```
|
|
113
|
+
*/
|
|
114
|
+
showBetweenBlocks(blockEl, position) {
|
|
115
|
+
if (this._destroyed)
|
|
116
|
+
return;
|
|
117
|
+
// Hide the overlay if showing line
|
|
118
|
+
this._hideOverlay();
|
|
119
|
+
if (!this._lineEl) {
|
|
120
|
+
this._lineEl = createLineElement();
|
|
121
|
+
this._container.appendChild(this._lineEl);
|
|
122
|
+
}
|
|
123
|
+
// Position relative to container
|
|
124
|
+
const containerRect = this._container.getBoundingClientRect();
|
|
125
|
+
const blockRect = blockEl.getBoundingClientRect();
|
|
126
|
+
const top = position === 'before'
|
|
127
|
+
? blockRect.top - containerRect.top
|
|
128
|
+
: blockRect.bottom - containerRect.top;
|
|
129
|
+
this._lineEl.style.top = `${top}px`;
|
|
130
|
+
this._lineEl.style.left = '0';
|
|
131
|
+
this._lineEl.style.right = '0';
|
|
132
|
+
this._lineEl.style.display = '';
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Hide all indicators (both line and overlay).
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* ```ts
|
|
139
|
+
* indicator.hide();
|
|
140
|
+
* ```
|
|
141
|
+
*/
|
|
142
|
+
hide() {
|
|
143
|
+
if (this._destroyed)
|
|
144
|
+
return;
|
|
145
|
+
this._hideLine();
|
|
146
|
+
this._hideOverlay();
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Destroy the indicator, removing all DOM elements.
|
|
150
|
+
*
|
|
151
|
+
* After calling destroy(), the indicator instance is inert and all
|
|
152
|
+
* methods become no-ops.
|
|
153
|
+
*
|
|
154
|
+
* @example
|
|
155
|
+
* ```ts
|
|
156
|
+
* indicator.destroy();
|
|
157
|
+
* ```
|
|
158
|
+
*/
|
|
159
|
+
destroy() {
|
|
160
|
+
if (this._destroyed)
|
|
161
|
+
return;
|
|
162
|
+
this._destroyed = true;
|
|
163
|
+
if (this._lineEl && this._lineEl.parentNode) {
|
|
164
|
+
this._lineEl.parentNode.removeChild(this._lineEl);
|
|
165
|
+
}
|
|
166
|
+
this._lineEl = null;
|
|
167
|
+
if (this._overlayEl && this._overlayEl.parentNode) {
|
|
168
|
+
this._overlayEl.parentNode.removeChild(this._overlayEl);
|
|
169
|
+
}
|
|
170
|
+
this._overlayEl = null;
|
|
171
|
+
}
|
|
172
|
+
// -----------------------------------------------------------------------
|
|
173
|
+
// Private helpers
|
|
174
|
+
// -----------------------------------------------------------------------
|
|
175
|
+
_hideLine() {
|
|
176
|
+
if (this._lineEl) {
|
|
177
|
+
this._lineEl.style.display = 'none';
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
_hideOverlay() {
|
|
181
|
+
if (this._overlayEl) {
|
|
182
|
+
this._overlayEl.style.display = 'none';
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
// ---------------------------------------------------------------------------
|
|
187
|
+
// DOM element factories
|
|
188
|
+
// ---------------------------------------------------------------------------
|
|
189
|
+
/**
|
|
190
|
+
* Create the thin horizontal line element for between-blocks indication.
|
|
191
|
+
*/
|
|
192
|
+
function createLineElement() {
|
|
193
|
+
const el = document.createElement('div');
|
|
194
|
+
el.className = CSS_LINE;
|
|
195
|
+
el.style.position = 'absolute';
|
|
196
|
+
el.style.height = '2px';
|
|
197
|
+
el.style.left = '0';
|
|
198
|
+
el.style.right = '0';
|
|
199
|
+
el.style.backgroundColor =
|
|
200
|
+
'var(--rtif-accent-color, #2563eb)';
|
|
201
|
+
el.style.pointerEvents = 'none';
|
|
202
|
+
el.style.zIndex = '10';
|
|
203
|
+
el.style.display = 'none';
|
|
204
|
+
el.setAttribute('aria-hidden', 'true');
|
|
205
|
+
return el;
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Create the full-editor overlay element for file drops.
|
|
209
|
+
*/
|
|
210
|
+
function createOverlayElement() {
|
|
211
|
+
const el = document.createElement('div');
|
|
212
|
+
el.className = CSS_OVERLAY;
|
|
213
|
+
el.style.position = 'absolute';
|
|
214
|
+
el.style.inset = '0';
|
|
215
|
+
el.style.zIndex = '20';
|
|
216
|
+
el.style.pointerEvents = 'none';
|
|
217
|
+
el.style.border =
|
|
218
|
+
'2px dashed var(--rtif-accent-color, #2563eb)';
|
|
219
|
+
el.style.borderRadius = '4px';
|
|
220
|
+
el.style.backgroundColor = 'rgba(37, 99, 235, 0.05)';
|
|
221
|
+
// Centered label — starts hidden, showForFile() removes display:none
|
|
222
|
+
el.style.display = 'none';
|
|
223
|
+
el.style.alignItems = 'center';
|
|
224
|
+
el.style.justifyContent = 'center';
|
|
225
|
+
const label = document.createElement('span');
|
|
226
|
+
label.textContent = 'Drop file to upload';
|
|
227
|
+
label.style.color = 'var(--rtif-accent-color, #2563eb)';
|
|
228
|
+
label.style.fontSize = '14px';
|
|
229
|
+
label.style.fontWeight = '500';
|
|
230
|
+
label.style.pointerEvents = 'none';
|
|
231
|
+
label.style.userSelect = 'none';
|
|
232
|
+
el.appendChild(label);
|
|
233
|
+
el.setAttribute('aria-hidden', 'true');
|
|
234
|
+
return el;
|
|
235
|
+
}
|
|
236
|
+
//# sourceMappingURL=drop-indicator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"drop-indicator.js","sourceRoot":"","sources":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AAM,CAAC;IAC9B,KAAK,CAAC,KAAK,CAAC,UAAU,GAAG,KAAK,CAAC;IAC/B,KAAK,CAAC,KAAK,CAAC,aAAa,GAAG,MAAM,CAAC;IACnC,KAAK,CAAC,KAAK,CAAC,UAAU,GAAG,MAAM,CAAC;IAChC,EAAE,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IAEtB,EAAE,CAAC,YAAY,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;IACvC,OAAO,EAAE,CAAC;AACZ,CAAC"}
|
package/dist/editor.d.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Web editor entry point — composes all modules into a single `WebEditor`.
|
|
3
|
+
*
|
|
4
|
+
* The `createWebEditor()` factory sets up a contenteditable element, wires
|
|
5
|
+
* the input bridge, renderer, selection sync, composition handler, clipboard,
|
|
6
|
+
* cursor navigation, command bus, shortcut handler, content pipeline, and
|
|
7
|
+
* drag-and-drop handling. It returns a {@link WebEditor} handle for imperative
|
|
8
|
+
* control (focus, blur, destroy).
|
|
9
|
+
*
|
|
10
|
+
* @module
|
|
11
|
+
*/
|
|
12
|
+
import type { WebEditorConfig, WebEditor } from './types.js';
|
|
13
|
+
/**
|
|
14
|
+
* Create a web editor instance backed by the RTIF engine.
|
|
15
|
+
*
|
|
16
|
+
* Sets up `contenteditable`, attaches all event handlers, performs the initial
|
|
17
|
+
* render, and optionally auto-focuses. Returns a {@link WebEditor} handle.
|
|
18
|
+
*
|
|
19
|
+
* @param config - Editor configuration (root element, engine, options)
|
|
20
|
+
* @returns A WebEditor instance with imperative control methods
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```ts
|
|
24
|
+
* import { createEngine } from '@rtif-sdk/engine';
|
|
25
|
+
* import { createWebEditor } from '@rtif-sdk/web';
|
|
26
|
+
*
|
|
27
|
+
* const engine = createEngine({
|
|
28
|
+
* initialDoc: { version: 1, blocks: [{ id: 'b1', type: 'text', spans: [{ text: '' }] }] },
|
|
29
|
+
* });
|
|
30
|
+
*
|
|
31
|
+
* const editor = createWebEditor({
|
|
32
|
+
* root: document.getElementById('editor')!,
|
|
33
|
+
* engine,
|
|
34
|
+
* accessibleLabel: 'Document editor',
|
|
35
|
+
* });
|
|
36
|
+
*
|
|
37
|
+
* editor.focus();
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export declare function createWebEditor(config: WebEditorConfig): WebEditor;
|
|
41
|
+
//# sourceMappingURL=editor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editor.d.ts","sourceRoot":"","sources":["../src/editor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAKH,OAAO,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AA8C7D;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,eAAe,GAAG,SAAS,CA4oBlE"}
|