@threadlabs/looma 0.44.2 → 0.44.4
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/components/shared/icons.js +1 -0
- package/components/ui-badge/ui-badge.html +7 -6
- package/components/ui-button/ui-button.html +47 -2
- package/components/ui-card/ui-card.html +6 -6
- package/components/ui-color-picker/ui-color-picker.html +12 -5
- package/components/ui-color-picker/ui-color-picker.js +20 -6
- package/components/ui-dialog/ui-dialog.html +5 -6
- package/components/ui-icon/ui-icon.html +1 -0
- package/components/ui-icon-button/ui-icon-button.html +59 -4
- package/components/ui-menu/ui-menu.html +5 -6
- package/components/ui-number-input/ui-number-input.html +7 -0
- package/components/ui-popover/ui-popover.html +5 -6
- package/components/ui-slider/ui-slider.html +6 -0
- package/components/ui-tooltip/ui-tooltip.html +8 -5
- package/components/ui-tree-item/ui-tree-item.html +7 -1
- package/dist/index.js +1 -1
- package/docs/README.md +8 -4
- package/docs/catalog.json +469 -3704
- package/docs/customizer-render.mjs +55 -36
- package/docs/customizer.js +48 -33
- package/docs/fonts.mjs +28 -0
- package/docs/theme.mjs +39 -14
- package/editor/file-uploads.d.ts +3 -1
- package/editor/icons.d.ts +1 -0
- package/editor/index.js +2 -1
- package/package.json +1 -1
- package/styles/ui-badge.css +11 -10
- package/styles/ui-button.css +47 -2
- package/styles/ui-card.css +4 -4
- package/styles/ui-color-picker.css +105 -2
- package/styles/ui-dialog.css +10 -12
- package/styles/ui-icon-button.css +59 -4
- package/styles/ui-menu.css +5 -6
- package/styles/ui-number-input.css +6 -0
- package/styles/ui-popover.css +5 -6
- package/styles/ui-slider.css +3 -0
- package/styles/ui-tooltip.css +8 -5
- package/styles/ui-tree-item.css +12 -2
- package/theme-system.css +28 -16
- package/tokens.css +7 -0
- package/vanilla/UiColorPicker.d.ts +1 -0
- package/vanilla/UiColorPicker.js +32 -28
- package/vanilla/UiIcon.js +1 -1
- package/vanilla/UiNumberInput.d.ts +1 -0
- package/vanilla/UiNumberInput.js +53 -43
- package/vanilla/UiSlider.d.ts +1 -0
- package/vanilla/UiSlider.js +65 -57
- package/vanilla/UiTreeItem.js +1 -1
- package/vue/UiBadge.vue +7 -9
- package/vue/UiButton.vue +56 -2
- package/vue/UiCard.vue +13 -5
- package/vue/UiColorPicker.d.ts +6 -0
- package/vue/UiColorPicker.vue +156 -6
- package/vue/UiDialog.vue +22 -12
- package/vue/UiIcon.vue +1 -0
- package/vue/UiIconButton.vue +62 -4
- package/vue/UiMenu.vue +11 -6
- package/vue/UiNumberInput.d.ts +6 -0
- package/vue/UiNumberInput.vue +47 -1
- package/vue/UiPopover.vue +11 -6
- package/vue/UiSlider.d.ts +6 -0
- package/vue/UiSlider.vue +37 -1
- package/vue/UiTooltip.vue +11 -5
- package/vue/UiTreeItem.vue +19 -3
- package/vue/chunks/UiBadge.js +1 -1
- package/vue/chunks/UiButton.js +1 -1
- package/vue/chunks/UiCard.js +2 -2
- package/vue/chunks/UiColorPicker.js +60 -11
- package/vue/chunks/UiDialog.js +1 -1
- package/vue/chunks/UiIcon.js +5 -1
- package/vue/chunks/UiIconButton.js +1 -1
- package/vue/chunks/UiMenu.js +1 -1
- package/vue/chunks/UiNumberInput.js +31 -2
- package/vue/chunks/UiPopover.js +1 -1
- package/vue/chunks/UiSlider.js +33 -2
- package/vue/chunks/UiTooltip.js +1 -1
- package/vue/chunks/UiTreeItem.js +3 -3
- package/vue/chunks/compact.js +1 -1
- package/vue/components.css +457 -84
- package/vue/editor/index.js +109 -57
- package/docs/examples/ui-editor-footnote-editor/examples/01-note.behavior.js +0 -9
- package/docs/examples/ui-editor-mention-menu/examples/00-preview.behavior.js +0 -1
- package/docs/examples/ui-editor-slash-menu/examples/00-preview.behavior.js +0 -81
- package/docs/examples/ui-editor-table-overlay/examples/00-preview.behavior.js +0 -24
package/vue/editor/index.js
CHANGED
|
@@ -2,6 +2,7 @@ import { n as LoomaCompactEditor } from "../chunks/compact.js";
|
|
|
2
2
|
import { Teleport, computed, defineComponent, h, nextTick, onBeforeUnmount, onMounted, onUpdated, reactive, ref, shallowRef, useId, watch } from "vue";
|
|
3
3
|
import { DEFAULT_MENTION_RESULT_LIMIT, LOOMA_ICONS, createLoomaMentionExtension, createLoomaSlashCommandExtension, getActiveTableUiState, getDefaultEditorExtensions, getDefaultSlashCommands, getTableOfContentsEntries, getVisualViewportRect, handleTableAction, handleTableOverlayAction, measureTableOverlayGeometry, normalizeActiveTableColumnWidths, normalizeTableOfContentsConfig } from "@threadlabs/looma/editor";
|
|
4
4
|
import { Button, Card, Cluster, EditorBlockActions, EditorChipEditor, EditorCodeLanguage, EditorFootnoteEditor, EditorImageToolbar, EditorInsertTableGrid, EditorLinkCard, EditorLinkForm, EditorMentionMenu, EditorMentionMenuItem, EditorSlashMenu, EditorSlashMenuGroup, EditorSlashMenuItem, EditorSurface, EditorTableContextMenu, EditorTableOverlay, EditorTableToolbar, EditorToolbar, IconButton, Popover, Stack, StatusMessage, Text, Tooltip } from "@threadlabs/looma/vue";
|
|
5
|
+
import { closeHistory } from "@tiptap/pm/history";
|
|
5
6
|
import { Editor, Extension, InputRule, Node as Node$1, PasteRule, getText, getTextSerializersFromSchema, isNodeSelection, mergeAttributes, nodeInputRule, posToDOMRect } from "@tiptap/core";
|
|
6
7
|
import { Editor as Editor$1 } from "@tiptap/vue-3";
|
|
7
8
|
import { AllSelection, NodeSelection, Plugin, PluginKey, Selection, TextSelection } from "@tiptap/pm/state";
|
|
@@ -9,7 +10,6 @@ import { Decoration, DecorationSet } from "@tiptap/pm/view";
|
|
|
9
10
|
import { createLowlight } from "lowlight";
|
|
10
11
|
import { RequestEvent, componentRegistry } from "@nextwebwg/html-next/runtime";
|
|
11
12
|
import "@tiptap/pm/tables";
|
|
12
|
-
import { closeHistory } from "@tiptap/pm/history";
|
|
13
13
|
import { DOMParser, DOMSerializer, Fragment as Fragment$1, Slice } from "@tiptap/pm/model";
|
|
14
14
|
import "@tiptap/pm/transform";
|
|
15
15
|
import { IndexedList, NONCONFORMING, READY_INPUT, UNRESOLVED_INPUT, acceptProps, activateModule, armElement, attachGeneratedController, awaitInput, buildTemplate, checkBoolean, checkConstrained, checkFormat, checkInteger, checkNumber, checkObject, checkSelected, checkString, clearRegion, computedCycle, defineComponent as defineComponent$1, detailCheck, dispatchDeclared, dispose, evaluateInput, fillSlot, formatOf, generatedInputs, hostState, inputRead, keywordFormat, manageProps, notifyPropertySet, project, readIndex, readMember, readonlyView, readsChanged, rec, recordValue, replaceRoot, textCall, toAttribute, toText, trackContainer, truthy, writeAttribute, writeUrlAttribute } from "@nextwebwg/html-next/generated-runtime";
|
|
@@ -49,68 +49,102 @@ var EDITOR_ADAPTER_COMPONENT_TAG_MAP = {
|
|
|
49
49
|
};
|
|
50
50
|
//#endregion
|
|
51
51
|
//#region src/editor/file-uploads.ts
|
|
52
|
-
/** Captures the caret before
|
|
52
|
+
/** Captures the caret before transport and retains its mapped position for an explicit retry. */
|
|
53
53
|
function createFileUploads(options) {
|
|
54
|
+
const { editor } = options;
|
|
54
55
|
let active;
|
|
55
|
-
const state = (uploading, progress = null) => options.onState?.({
|
|
56
|
+
const state = (uploading, progress = null, failed = null) => options.onState?.({
|
|
56
57
|
uploading,
|
|
57
|
-
progress
|
|
58
|
+
progress,
|
|
59
|
+
failed
|
|
58
60
|
});
|
|
61
|
+
const finish = (job) => {
|
|
62
|
+
if (active !== job) return;
|
|
63
|
+
if (job) editor.off("transaction", job.map);
|
|
64
|
+
active = void 0;
|
|
65
|
+
state(false);
|
|
66
|
+
};
|
|
67
|
+
const cancel = (job) => {
|
|
68
|
+
if (active !== job) return;
|
|
69
|
+
job?.controller?.abort();
|
|
70
|
+
finish(job);
|
|
71
|
+
};
|
|
72
|
+
const run = async (job) => {
|
|
73
|
+
const upload = options.upload();
|
|
74
|
+
if (!upload || editor.isDestroyed || !editor.isEditable) {
|
|
75
|
+
cancel(job);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
const controller = new AbortController();
|
|
79
|
+
job.controller = controller;
|
|
80
|
+
job.failed = false;
|
|
81
|
+
const current = () => active === job && job.controller === controller && !controller.signal.aborted;
|
|
82
|
+
state(true);
|
|
83
|
+
try {
|
|
84
|
+
const answer = await upload(job.file, {
|
|
85
|
+
signal: controller.signal,
|
|
86
|
+
progress: (loaded, total) => {
|
|
87
|
+
if (current() && !job.failed) state(true, {
|
|
88
|
+
loaded,
|
|
89
|
+
total
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
if (!current()) return;
|
|
94
|
+
if (!answer || editor.isDestroyed || !editor.isEditable) {
|
|
95
|
+
finish(job);
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
if (!/^(?:https?:\/\/|\/(?!\/))/.test(answer.href) || !Number.isSafeInteger(answer.size) || answer.size < 0) throw new Error("Invalid file descriptor");
|
|
99
|
+
const size = answer.size < 1e3 ? `${answer.size} B` : answer.size < 1e6 ? `${Math.ceil(answer.size / 1e3)} KB` : `${Number((answer.size / 1e6).toFixed(1))} MB`;
|
|
100
|
+
editor.view.dispatch(closeHistory(editor.state.tr));
|
|
101
|
+
editor.chain().focus().insertContentAt(job.position, [{
|
|
102
|
+
type: "text",
|
|
103
|
+
text: answer.name || job.file.name,
|
|
104
|
+
marks: [{
|
|
105
|
+
type: "link",
|
|
106
|
+
attrs: {
|
|
107
|
+
href: answer.href,
|
|
108
|
+
target: "_blank",
|
|
109
|
+
rel: "noopener noreferrer"
|
|
110
|
+
}
|
|
111
|
+
}]
|
|
112
|
+
}, {
|
|
113
|
+
type: "text",
|
|
114
|
+
text: ` (${answer.contentType || "application/octet-stream"}, ${size}) `
|
|
115
|
+
}]).run();
|
|
116
|
+
editor.view.dispatch(closeHistory(editor.state.tr));
|
|
117
|
+
if (current()) finish(job);
|
|
118
|
+
} catch (error) {
|
|
119
|
+
if (!current()) return;
|
|
120
|
+
job.failed = true;
|
|
121
|
+
state(false, null, job.file);
|
|
122
|
+
options.onError(error, job.file);
|
|
123
|
+
}
|
|
124
|
+
};
|
|
59
125
|
return {
|
|
60
126
|
cancel() {
|
|
61
|
-
active
|
|
62
|
-
state(false);
|
|
127
|
+
cancel(active);
|
|
63
128
|
},
|
|
64
129
|
async insert(file) {
|
|
65
|
-
|
|
66
|
-
if (
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
editor.on("transaction", map);
|
|
76
|
-
state(true);
|
|
77
|
-
try {
|
|
78
|
-
const answer = await upload(file, {
|
|
79
|
-
signal: controller.signal,
|
|
80
|
-
progress: (loaded, total) => {
|
|
81
|
-
if (!controller.signal.aborted) state(true, {
|
|
82
|
-
loaded,
|
|
83
|
-
total
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
if (!answer || controller.signal.aborted || editor.isDestroyed || !editor.isEditable) return;
|
|
88
|
-
if (!/^(?:https?:\/\/|\/(?!\/))/.test(answer.href) || !Number.isSafeInteger(answer.size) || answer.size < 0) throw new Error("Invalid file descriptor");
|
|
89
|
-
const size = answer.size < 1e3 ? `${answer.size} B` : answer.size < 1e6 ? `${Math.ceil(answer.size / 1e3)} KB` : `${Number((answer.size / 1e6).toFixed(1))} MB`;
|
|
90
|
-
editor.chain().focus().insertContentAt(position, [{
|
|
91
|
-
type: "text",
|
|
92
|
-
text: answer.name || file.name,
|
|
93
|
-
marks: [{
|
|
94
|
-
type: "link",
|
|
95
|
-
attrs: {
|
|
96
|
-
href: answer.href,
|
|
97
|
-
target: "_blank",
|
|
98
|
-
rel: "noopener noreferrer"
|
|
99
|
-
}
|
|
100
|
-
}]
|
|
101
|
-
}, {
|
|
102
|
-
type: "text",
|
|
103
|
-
text: ` (${answer.contentType || "application/octet-stream"}, ${size}) `
|
|
104
|
-
}]).run();
|
|
105
|
-
} catch (error) {
|
|
106
|
-
if (!controller.signal.aborted) options.onError(error, file);
|
|
107
|
-
} finally {
|
|
108
|
-
editor.off("transaction", map);
|
|
109
|
-
if (active === controller) {
|
|
110
|
-
active = void 0;
|
|
111
|
-
state(false);
|
|
130
|
+
cancel(active);
|
|
131
|
+
if (editor.isDestroyed || !editor.isEditable) return;
|
|
132
|
+
const job = {
|
|
133
|
+
file,
|
|
134
|
+
position: editor.state.selection.from,
|
|
135
|
+
failed: false,
|
|
136
|
+
map: ({ transaction }) => {
|
|
137
|
+
const mapped = transaction.mapping.mapResult(job.position);
|
|
138
|
+
if (mapped.deletedAcross) cancel(job);
|
|
139
|
+
else job.position = mapped.pos;
|
|
112
140
|
}
|
|
113
|
-
}
|
|
141
|
+
};
|
|
142
|
+
active = job;
|
|
143
|
+
editor.on("transaction", job.map);
|
|
144
|
+
await run(job);
|
|
145
|
+
},
|
|
146
|
+
async retry() {
|
|
147
|
+
if (active?.failed) await run(active);
|
|
114
148
|
}
|
|
115
149
|
};
|
|
116
150
|
}
|
|
@@ -7047,6 +7081,10 @@ function createUiIcon(options = {}, html) {
|
|
|
7047
7081
|
"cy": "12",
|
|
7048
7082
|
"r": "3"
|
|
7049
7083
|
}],
|
|
7084
|
+
"slash": [{
|
|
7085
|
+
"tag": "path",
|
|
7086
|
+
"d": "M22 2 2 22"
|
|
7087
|
+
}],
|
|
7050
7088
|
"split": [
|
|
7051
7089
|
{
|
|
7052
7090
|
"tag": "path",
|
|
@@ -15235,7 +15273,7 @@ var EMPTY_DOCUMENT = {
|
|
|
15235
15273
|
type: "doc",
|
|
15236
15274
|
content: []
|
|
15237
15275
|
};
|
|
15238
|
-
var uploadProgressText = (progress) => progress && progress.total > 0 ?
|
|
15276
|
+
var uploadProgressText = (progress, label = "Uploading image…") => progress && progress.total > 0 ? `${label} ${Math.round(Math.min(1, progress.loaded / progress.total) * 100)}%` : label;
|
|
15239
15277
|
var editorInstanceSequence = 0;
|
|
15240
15278
|
function slashMenuRows(items) {
|
|
15241
15279
|
const groups = [];
|
|
@@ -15440,7 +15478,8 @@ var LoomaEditor = defineComponent({
|
|
|
15440
15478
|
const attachmentInput = ref(null);
|
|
15441
15479
|
const fileUploadState = shallowRef({
|
|
15442
15480
|
uploading: false,
|
|
15443
|
-
progress: null
|
|
15481
|
+
progress: null,
|
|
15482
|
+
failed: null
|
|
15444
15483
|
});
|
|
15445
15484
|
let attachmentUploads;
|
|
15446
15485
|
const tablePickerAnchorId = `looma-editor-table-picker-${useId().replace(/[^a-zA-Z0-9_-]/g, "")}`;
|
|
@@ -16890,13 +16929,26 @@ var LoomaEditor = defineComponent({
|
|
|
16890
16929
|
onChange: onAttachmentChange
|
|
16891
16930
|
}),
|
|
16892
16931
|
fileUploadState.value.uploading ? h(StatusMessage, { kind: "loading" }, {
|
|
16893
|
-
default: () => "Attaching file…",
|
|
16932
|
+
default: () => uploadProgressText(fileUploadState.value.progress, "Attaching file…"),
|
|
16894
16933
|
action: () => h(Button, {
|
|
16895
16934
|
size: "sm",
|
|
16896
16935
|
variant: "ghost",
|
|
16897
16936
|
onClick: () => attachmentUploads?.cancel()
|
|
16898
16937
|
}, () => "Cancel")
|
|
16899
16938
|
}) : null,
|
|
16939
|
+
fileUploadState.value.failed ? h(StatusMessage, { kind: "error" }, {
|
|
16940
|
+
default: () => "Couldn’t attach file.",
|
|
16941
|
+
action: () => [h(Button, {
|
|
16942
|
+
size: "sm",
|
|
16943
|
+
variant: "ghost",
|
|
16944
|
+
onClick: () => attachmentUploads?.cancel()
|
|
16945
|
+
}, () => "Dismiss"), h(Button, {
|
|
16946
|
+
size: "sm",
|
|
16947
|
+
onClick: () => {
|
|
16948
|
+
attachmentUploads?.retry();
|
|
16949
|
+
}
|
|
16950
|
+
}, () => "Retry")]
|
|
16951
|
+
}) : null,
|
|
16900
16952
|
uploadState.value.uploading ? h(StatusMessage, { kind: "loading" }, {
|
|
16901
16953
|
default: () => uploadProgressText(uploadState.value.progress),
|
|
16902
16954
|
action: () => h(Button, {
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { componentRegistry } from "@nextwebwg/html-next/runtime";
|
|
2
|
-
export default function setupExample(root) {
|
|
3
|
-
const popover = root.querySelector('[data-note-popover]');
|
|
4
|
-
const editor = root.querySelector('[data-note-editor]');
|
|
5
|
-
const done = () => { if (popover)
|
|
6
|
-
componentRegistry.update(popover, { open: false }); };
|
|
7
|
-
editor?.addEventListener("done", done);
|
|
8
|
-
return () => editor?.removeEventListener("done", done);
|
|
9
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { openPicker as default } from "../../ui-editor-slash-menu/examples/00-preview.behavior.js";
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { componentRegistry } from "@nextwebwg/html-next/runtime";
|
|
2
|
-
/** The host owns keyboard selection and dismissal for editor suggestion surfaces. */
|
|
3
|
-
export function openPicker(root) {
|
|
4
|
-
const trigger = root.querySelector("[data-demo-trigger]");
|
|
5
|
-
const surface = root.querySelector("[data-demo-surface]");
|
|
6
|
-
if (!trigger || !surface)
|
|
7
|
-
return () => { };
|
|
8
|
-
let open = false, selectedIndex = 0, frame = 0;
|
|
9
|
-
const options = () => [...surface.querySelectorAll('[role="option"]')].filter(option => !option.hidden && option.getAttribute("aria-disabled") !== "true");
|
|
10
|
-
const select = (index) => {
|
|
11
|
-
const rows = options();
|
|
12
|
-
selectedIndex = rows.length ? (index + rows.length) % rows.length : 0;
|
|
13
|
-
componentRegistry.update(surface, { selectedIndex });
|
|
14
|
-
const active = rows[selectedIndex];
|
|
15
|
-
if (active?.id)
|
|
16
|
-
surface.setAttribute("aria-activedescendant", active.id);
|
|
17
|
-
};
|
|
18
|
-
const close = () => {
|
|
19
|
-
open = false;
|
|
20
|
-
cancelAnimationFrame(frame);
|
|
21
|
-
componentRegistry.update(surface, { open: false });
|
|
22
|
-
trigger.setAttribute("aria-expanded", "false");
|
|
23
|
-
};
|
|
24
|
-
const commit = () => { close(); trigger.focus(); };
|
|
25
|
-
const toggle = () => {
|
|
26
|
-
if (open) {
|
|
27
|
-
close();
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
open = true;
|
|
31
|
-
selectedIndex = 0;
|
|
32
|
-
componentRegistry.update(surface, { open: true, selectedIndex, anchorRect: trigger.getBoundingClientRect().toJSON() });
|
|
33
|
-
trigger.setAttribute("aria-expanded", "true");
|
|
34
|
-
frame = requestAnimationFrame(() => { select(0); surface.focus(); });
|
|
35
|
-
};
|
|
36
|
-
const keyboard = (event) => {
|
|
37
|
-
if (!open) {
|
|
38
|
-
if (event.key === "ArrowDown" || event.key === "ArrowUp") {
|
|
39
|
-
event.preventDefault();
|
|
40
|
-
toggle();
|
|
41
|
-
}
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
if (event.key === "Escape") {
|
|
45
|
-
event.preventDefault();
|
|
46
|
-
commit();
|
|
47
|
-
}
|
|
48
|
-
else if (event.key === "ArrowDown" || event.key === "ArrowUp") {
|
|
49
|
-
event.preventDefault();
|
|
50
|
-
select(selectedIndex + (event.key === "ArrowDown" ? 1 : -1));
|
|
51
|
-
}
|
|
52
|
-
else if (event.key === "Enter") {
|
|
53
|
-
event.preventDefault();
|
|
54
|
-
options()[selectedIndex]?.click();
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
const highlight = (event) => select(event.detail.index);
|
|
58
|
-
const reposition = () => { if (open)
|
|
59
|
-
componentRegistry.update(surface, { anchorRect: trigger.getBoundingClientRect().toJSON() }); };
|
|
60
|
-
const view = root.ownerDocument.defaultView;
|
|
61
|
-
const outside = (event) => { if (open && !surface.contains(event.target) && !trigger.contains(event.target))
|
|
62
|
-
close(); };
|
|
63
|
-
trigger.addEventListener("click", toggle);
|
|
64
|
-
root.addEventListener("keydown", keyboard);
|
|
65
|
-
surface.addEventListener("select", commit);
|
|
66
|
-
surface.addEventListener("highlight", highlight);
|
|
67
|
-
view?.addEventListener("scroll", reposition, { capture: true, passive: true });
|
|
68
|
-
view?.addEventListener("resize", reposition);
|
|
69
|
-
root.ownerDocument.addEventListener("pointerdown", outside);
|
|
70
|
-
return () => {
|
|
71
|
-
cancelAnimationFrame(frame);
|
|
72
|
-
trigger.removeEventListener("click", toggle);
|
|
73
|
-
root.removeEventListener("keydown", keyboard);
|
|
74
|
-
surface.removeEventListener("select", commit);
|
|
75
|
-
surface.removeEventListener("highlight", highlight);
|
|
76
|
-
view?.removeEventListener("scroll", reposition, true);
|
|
77
|
-
view?.removeEventListener("resize", reposition);
|
|
78
|
-
root.ownerDocument.removeEventListener("pointerdown", outside);
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
export default openPicker;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { componentRegistry } from "@nextwebwg/html-next/runtime";
|
|
2
|
-
/** Keep the controls aligned with the real cells at every preview width. */
|
|
3
|
-
export default function setup(root) {
|
|
4
|
-
const surface = root.querySelector("[data-demo-table-controls]");
|
|
5
|
-
const table = surface?.querySelector("table");
|
|
6
|
-
if (!surface || !table)
|
|
7
|
-
return () => { };
|
|
8
|
-
const measure = () => {
|
|
9
|
-
const origin = surface.getBoundingClientRect();
|
|
10
|
-
const rows = [...table.rows], cells = [...(rows[0]?.cells ?? [])];
|
|
11
|
-
if (!rows.length || !cells.length)
|
|
12
|
-
return;
|
|
13
|
-
const cell = cells[0].getBoundingClientRect();
|
|
14
|
-
componentRegistry.update(surface, { geometry: {
|
|
15
|
-
rowBoundaries: [...rows.map(row => row.getBoundingClientRect().top - origin.top), rows.at(-1).getBoundingClientRect().bottom - origin.top],
|
|
16
|
-
columnBoundaries: [...cells.map(cell => cell.getBoundingClientRect().left - origin.left), cells.at(-1).getBoundingClientRect().right - origin.left],
|
|
17
|
-
activeCell: { left: cell.left - origin.left, top: cell.top - origin.top, width: cell.width, height: cell.height, rowIndex: 0, columnIndex: 0 },
|
|
18
|
-
} });
|
|
19
|
-
};
|
|
20
|
-
const observer = new ResizeObserver(measure);
|
|
21
|
-
observer.observe(table);
|
|
22
|
-
measure();
|
|
23
|
-
return () => observer.disconnect();
|
|
24
|
-
}
|