@pixerate/editor-svelte 0.15.2 → 0.16.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/BubbleMenu.svelte.d.ts +14 -0
- package/dist/BubbleMenu.svelte.d.ts.map +1 -0
- package/{src → dist}/EditableTextNodeEditor.svelte +1 -1
- package/dist/EditableTextNodeEditor.svelte.d.ts +26 -0
- package/dist/EditableTextNodeEditor.svelte.d.ts.map +1 -0
- package/dist/TemplateRenderer.svelte.d.ts +14 -0
- package/dist/TemplateRenderer.svelte.d.ts.map +1 -0
- package/dist/canvas/AgentPresenceLayer.svelte.d.ts +9 -0
- package/dist/canvas/AgentPresenceLayer.svelte.d.ts.map +1 -0
- package/dist/canvas/FloatingHorizontalScrollbar.svelte.d.ts +9 -0
- package/dist/canvas/FloatingHorizontalScrollbar.svelte.d.ts.map +1 -0
- package/dist/canvas/createCanvasClipboard.svelte.d.ts +32 -0
- package/dist/canvas/createCanvasClipboard.svelte.d.ts.map +1 -0
- package/dist/canvas/createCanvasClipboard.svelte.js +171 -0
- package/dist/canvas/createCanvasDisplacement.d.ts +32 -0
- package/dist/canvas/createCanvasDisplacement.d.ts.map +1 -0
- package/dist/canvas/createCanvasDisplacement.js +170 -0
- package/dist/canvas/createCanvasDocking.svelte.d.ts +56 -0
- package/dist/canvas/createCanvasDocking.svelte.d.ts.map +1 -0
- package/dist/canvas/createCanvasDocking.svelte.js +227 -0
- package/dist/canvas/createCanvasExplosion.svelte.d.ts +31 -0
- package/dist/canvas/createCanvasExplosion.svelte.d.ts.map +1 -0
- package/dist/canvas/createCanvasExplosion.svelte.js +346 -0
- package/dist/canvas/createCanvasGraph.svelte.d.ts +62 -0
- package/dist/canvas/createCanvasGraph.svelte.d.ts.map +1 -0
- package/dist/canvas/createCanvasGraph.svelte.js +223 -0
- package/dist/canvas/createCanvasInteractions.svelte.d.ts +28 -0
- package/dist/canvas/createCanvasInteractions.svelte.d.ts.map +1 -0
- package/dist/canvas/createCanvasInteractions.svelte.js +95 -0
- package/dist/canvas/createCanvasLayout.d.ts +22 -0
- package/dist/canvas/createCanvasLayout.d.ts.map +1 -0
- package/dist/canvas/createCanvasLayout.js +76 -0
- package/dist/canvas/createCanvasMultiDrag.svelte.d.ts +61 -0
- package/dist/canvas/createCanvasMultiDrag.svelte.d.ts.map +1 -0
- package/dist/canvas/createCanvasMultiDrag.svelte.js +105 -0
- package/dist/canvas/createCanvasNodeSync.svelte.d.ts +58 -0
- package/dist/canvas/createCanvasNodeSync.svelte.d.ts.map +1 -0
- package/dist/canvas/createCanvasNodeSync.svelte.js +82 -0
- package/dist/canvas/createCanvasSelection.svelte.d.ts +26 -0
- package/dist/canvas/createCanvasSelection.svelte.d.ts.map +1 -0
- package/dist/canvas/createCanvasSelection.svelte.js +26 -0
- package/dist/canvas/createCanvasShortcuts.d.ts +9 -0
- package/dist/canvas/createCanvasShortcuts.d.ts.map +1 -0
- package/dist/canvas/createCanvasShortcuts.js +97 -0
- package/dist/canvas/createCanvasTrajectory.d.ts +31 -0
- package/dist/canvas/createCanvasTrajectory.d.ts.map +1 -0
- package/dist/canvas/createCanvasTrajectory.js +141 -0
- package/dist/canvas/createStreamingCanvas.svelte.d.ts +19 -0
- package/dist/canvas/createStreamingCanvas.svelte.d.ts.map +1 -0
- package/dist/canvas/createStreamingCanvas.svelte.js +32 -0
- package/dist/canvas/index.d.ts +18 -688
- package/dist/canvas/index.d.ts.map +1 -0
- package/dist/canvas/index.js +34 -1839
- package/dist/canvas/types.d.ts +183 -0
- package/dist/canvas/types.d.ts.map +1 -0
- package/dist/canvas/types.js +1 -0
- package/dist/createNavigationGuard.svelte.d.ts +24 -0
- package/dist/createNavigationGuard.svelte.d.ts.map +1 -0
- package/dist/createNavigationGuard.svelte.js +65 -0
- package/dist/editor.svelte.d.ts +23 -0
- package/dist/editor.svelte.d.ts.map +1 -0
- package/dist/editor.svelte.js +41 -0
- package/dist/history/createHistoryShortcuts.d.ts +24 -0
- package/dist/history/createHistoryShortcuts.d.ts.map +1 -0
- package/dist/history/createHistoryShortcuts.js +57 -0
- package/dist/history/history.svelte.d.ts +18 -0
- package/dist/history/history.svelte.d.ts.map +1 -0
- package/dist/history/history.svelte.js +43 -0
- package/dist/history/index.d.ts +3 -0
- package/dist/history/index.d.ts.map +1 -0
- package/dist/history/index.js +2 -0
- package/{src → dist}/image-editor/ImageEditor.svelte +1 -1
- package/dist/image-editor/ImageEditor.svelte.d.ts +17 -0
- package/dist/image-editor/ImageEditor.svelte.d.ts.map +1 -0
- package/dist/image-editor/imageEditorState.svelte.d.ts +50 -0
- package/dist/image-editor/imageEditorState.svelte.d.ts.map +1 -0
- package/dist/image-editor/imageEditorState.svelte.js +132 -0
- package/dist/image-editor/index.d.ts +6 -16
- package/dist/image-editor/index.d.ts.map +1 -0
- package/dist/image-editor/index.js +2 -9
- package/dist/index.d.ts +20 -249
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -1119
- package/dist/navigationGuard.d.ts +21 -0
- package/dist/navigationGuard.d.ts.map +1 -0
- package/dist/navigationGuard.js +59 -0
- package/{src → dist}/spreadsheet/FormulaBar.svelte +1 -1
- package/dist/spreadsheet/FormulaBar.svelte.d.ts +17 -0
- package/dist/spreadsheet/FormulaBar.svelte.d.ts.map +1 -0
- package/{src → dist}/spreadsheet/SpreadsheetEditor.svelte +1 -1
- package/dist/spreadsheet/SpreadsheetEditor.svelte.d.ts +22 -0
- package/dist/spreadsheet/SpreadsheetEditor.svelte.d.ts.map +1 -0
- package/dist/spreadsheet/index.d.ts +9 -0
- package/dist/spreadsheet/index.d.ts.map +1 -0
- package/{src/spreadsheet/index.ts → dist/spreadsheet/index.js} +1 -1
- package/dist/spreadsheet/spreadsheet.svelte.d.ts +33 -0
- package/dist/spreadsheet/spreadsheet.svelte.d.ts.map +1 -0
- package/dist/spreadsheet/spreadsheet.svelte.js +160 -0
- package/package.json +14 -16
- package/dist/canvas/index.js.map +0 -1
- package/dist/chunk-HEOI4UNF.js +0 -1191
- package/dist/chunk-HEOI4UNF.js.map +0 -1
- package/dist/image-editor/index.js.map +0 -1
- package/dist/index.css +0 -50
- package/dist/index.css.map +0 -1
- package/dist/index.js.map +0 -1
- package/src/canvas/__tests__/canvas-clipboard.test.ts +0 -154
- package/src/canvas/__tests__/canvas-docking.test.ts +0 -288
- package/src/canvas/__tests__/canvas-explosion.test.ts +0 -634
- package/src/canvas/__tests__/canvas-graph.test.ts +0 -159
- package/src/canvas/__tests__/canvas-interactions.test.ts +0 -86
- package/src/canvas/__tests__/canvas-layout.test.ts +0 -75
- package/src/canvas/__tests__/canvas-multi-drag.test.ts +0 -112
- package/src/canvas/__tests__/canvas-node-sync.svelte.test.ts +0 -104
- package/src/canvas/__tests__/canvas-shortcuts.test.ts +0 -59
- package/src/canvas/createCanvasClipboard.svelte.ts +0 -219
- package/src/canvas/createCanvasDisplacement.ts +0 -253
- package/src/canvas/createCanvasDocking.svelte.ts +0 -355
- package/src/canvas/createCanvasExplosion.svelte.ts +0 -457
- package/src/canvas/createCanvasGraph.svelte.ts +0 -330
- package/src/canvas/createCanvasInteractions.svelte.ts +0 -112
- package/src/canvas/createCanvasLayout.ts +0 -129
- package/src/canvas/createCanvasMultiDrag.svelte.ts +0 -175
- package/src/canvas/createCanvasNodeSync.svelte.ts +0 -150
- package/src/canvas/createCanvasSelection.svelte.ts +0 -51
- package/src/canvas/createCanvasShortcuts.ts +0 -99
- package/src/canvas/createCanvasTrajectory.ts +0 -207
- package/src/canvas/createStreamingCanvas.svelte.ts +0 -56
- package/src/canvas/index.d.ts +0 -688
- package/src/canvas/index.ts +0 -126
- package/src/canvas/types.ts +0 -223
- package/src/createNavigationGuard.svelte.ts +0 -97
- package/src/editor.svelte.ts +0 -65
- package/src/history/createHistoryShortcuts.ts +0 -95
- package/src/history/history.svelte.ts +0 -68
- package/src/history/index.ts +0 -2
- package/src/image-editor/imageEditorState.svelte.ts +0 -151
- package/src/image-editor/index.d.ts +0 -16
- package/src/image-editor/index.ts +0 -2
- package/src/index.d.ts +0 -249
- package/src/index.ts +0 -89
- package/src/navigationGuard.ts +0 -82
- package/src/spreadsheet/spreadsheet.svelte.ts +0 -176
- package/src/svelte.d.ts +0 -5
- /package/{src → dist}/BubbleMenu.svelte +0 -0
- /package/{src → dist}/TemplateRenderer.svelte +0 -0
- /package/{src → dist}/canvas/AgentPresenceLayer.svelte +0 -0
- /package/{src → dist}/canvas/FloatingHorizontalScrollbar.svelte +0 -0
- /package/{src → dist}/canvas/README.md +0 -0
package/dist/index.js
CHANGED
|
@@ -1,1119 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
// src/editor.svelte.ts
|
|
12
|
-
import * as $ from "svelte/internal/client";
|
|
13
|
-
import { Editor } from "@tiptap/core";
|
|
14
|
-
import { createRichTextPreset } from "@pixerate/editor";
|
|
15
|
-
var initiateEditor = (element, content, extensions, options) => {
|
|
16
|
-
const { richTextOptions, ...editorOptions } = options || {};
|
|
17
|
-
const defaultPreset = createRichTextPreset(richTextOptions);
|
|
18
|
-
const editor = new Editor({
|
|
19
|
-
element,
|
|
20
|
-
content,
|
|
21
|
-
extensions: [...defaultPreset, ...extensions ?? []],
|
|
22
|
-
autofocus: false,
|
|
23
|
-
...editorOptions
|
|
24
|
-
});
|
|
25
|
-
return editor;
|
|
26
|
-
};
|
|
27
|
-
function createReactiveEditor(initialContent = "", extensions = [], options = {}) {
|
|
28
|
-
let editorInstance;
|
|
29
|
-
return {
|
|
30
|
-
get current() {
|
|
31
|
-
return editorInstance;
|
|
32
|
-
},
|
|
33
|
-
mount(element) {
|
|
34
|
-
editorInstance = initiateEditor(element, initialContent, extensions, options);
|
|
35
|
-
return editorInstance;
|
|
36
|
-
},
|
|
37
|
-
destroy() {
|
|
38
|
-
if (editorInstance) {
|
|
39
|
-
editorInstance.destroy();
|
|
40
|
-
editorInstance = void 0;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// src/EditableTextNodeEditor.svelte
|
|
47
|
-
var root = $2.from_html(`<div class="flex items-center justify-center p-4 text-sm text-gray-500">Loading editor...</div>`);
|
|
48
|
-
var root_1 = $2.from_html(`<div draggable="false"><!> <div></div></div>`);
|
|
49
|
-
function EditableTextNodeEditor($$anchor, $$props) {
|
|
50
|
-
$2.push($$props, true);
|
|
51
|
-
let className = $2.prop($$props, "class", 3, ""), editorClass = $2.prop($$props, "editorClass", 3, ""), content = $2.prop($$props, "content", 3, void 0), showMenu = $2.prop($$props, "showMenu", 3, true), editable = $2.prop($$props, "editable", 3, true), editor = $2.prop($$props, "editor", 15), extensions = $2.prop($$props, "extensions", 19, () => []), placeholder = $2.prop($$props, "placeholder", 3, ""), markdown = $2.prop($$props, "markdown", 3, void 0), richTextOptions = $2.prop($$props, "richTextOptions", 19, () => ({})), autofocus = $2.prop($$props, "autofocus", 3, false), image = $2.prop($$props, "image", 3, void 0), uploadImage = $2.prop($$props, "uploadImage", 3, void 0), onUploadError = $2.prop($$props, "onUploadError", 3, void 0);
|
|
52
|
-
let element = $2.state(void 0);
|
|
53
|
-
$2.user_effect(() => {
|
|
54
|
-
if (editor() && editor().isEditable !== editable()) {
|
|
55
|
-
editor().setEditable(editable());
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
onMount(() => {
|
|
59
|
-
editor(initiateEditor($2.get(element), content(), extensions(), {
|
|
60
|
-
richTextOptions: {
|
|
61
|
-
placeholder: placeholder(),
|
|
62
|
-
...markdown() !== void 0 ? { markdown: markdown() } : {},
|
|
63
|
-
...image() !== void 0 || uploadImage() !== void 0 || onUploadError() !== void 0 ? {
|
|
64
|
-
image: image() === false ? false : {
|
|
65
|
-
...typeof image() === "object" ? image() : {},
|
|
66
|
-
...uploadImage() ? { upload: uploadImage() } : {},
|
|
67
|
-
...onUploadError() ? { onUploadError: onUploadError() } : {}
|
|
68
|
-
}
|
|
69
|
-
} : {},
|
|
70
|
-
...richTextOptions()
|
|
71
|
-
},
|
|
72
|
-
editable: editable(),
|
|
73
|
-
autofocus: autofocus(),
|
|
74
|
-
onCreate: $$props.onCreate,
|
|
75
|
-
onUpdate: $$props.onUpdate,
|
|
76
|
-
onFocus() {
|
|
77
|
-
if ($$props.onFocus) $$props.onFocus();
|
|
78
|
-
},
|
|
79
|
-
onBlur() {
|
|
80
|
-
if ($$props.onBlur) $$props.onBlur();
|
|
81
|
-
}
|
|
82
|
-
}));
|
|
83
|
-
});
|
|
84
|
-
onDestroy(() => {
|
|
85
|
-
if (editor()) {
|
|
86
|
-
editor().destroy();
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
var div = root_1();
|
|
90
|
-
var node = $2.child(div);
|
|
91
|
-
{
|
|
92
|
-
var consequent = ($$anchor2) => {
|
|
93
|
-
var div_1 = root();
|
|
94
|
-
$2.append($$anchor2, div_1);
|
|
95
|
-
};
|
|
96
|
-
$2.if(node, ($$render) => {
|
|
97
|
-
if (!editor()) $$render(consequent);
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
var div_2 = $2.sibling(node, 2);
|
|
101
|
-
$2.bind_this(div_2, ($$value) => $2.set(element, $$value), () => $2.get(element));
|
|
102
|
-
$2.reset(div);
|
|
103
|
-
$2.template_effect(
|
|
104
|
-
($0) => {
|
|
105
|
-
$2.set_class(div, 1, `pixerate-editor-container ${className()}`);
|
|
106
|
-
$2.set_class(div_2, 1, $0);
|
|
107
|
-
},
|
|
108
|
-
[
|
|
109
|
-
() => $2.clsx(`pixerate-editor-content prose dark:prose-invert w-full max-w-none focus:outline-none ${editorClass()}`.trim())
|
|
110
|
-
]
|
|
111
|
-
);
|
|
112
|
-
$2.append($$anchor, div);
|
|
113
|
-
$2.pop();
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
// src/BubbleMenu.svelte
|
|
117
|
-
import "svelte/internal/disclose-version";
|
|
118
|
-
import * as $3 from "svelte/internal/client";
|
|
119
|
-
import { BubbleMenuPlugin } from "@tiptap/extension-bubble-menu";
|
|
120
|
-
var root2 = $3.from_html(`<div style="visibility: hidden;"><!></div>`);
|
|
121
|
-
function BubbleMenu($$anchor, $$props) {
|
|
122
|
-
$3.push($$props, true);
|
|
123
|
-
let className = $3.prop($$props, "class", 3, "flex h-fit w-fit items-center gap-1 rounded-md border border-gray-200 bg-white p-1 shadow-md"), pluginKey = $3.prop($$props, "pluginKey", 3, "bubbleMenu"), shouldShow = $3.prop($$props, "shouldShow", 3, null), updateDelay = $3.prop($$props, "updateDelay", 3, 250), tippyOptions = $3.prop($$props, "tippyOptions", 19, () => ({}));
|
|
124
|
-
let menuElement = $3.state(void 0);
|
|
125
|
-
$3.user_effect(() => {
|
|
126
|
-
if ($$props.editor && $3.get(menuElement)) {
|
|
127
|
-
const plugin = BubbleMenuPlugin({
|
|
128
|
-
pluginKey: pluginKey(),
|
|
129
|
-
editor: $$props.editor,
|
|
130
|
-
element: $3.get(menuElement),
|
|
131
|
-
tippyOptions: {
|
|
132
|
-
duration: 100,
|
|
133
|
-
appendTo: () => document.body,
|
|
134
|
-
...tippyOptions()
|
|
135
|
-
},
|
|
136
|
-
shouldShow: shouldShow(),
|
|
137
|
-
updateDelay: updateDelay()
|
|
138
|
-
});
|
|
139
|
-
$$props.editor.registerPlugin(plugin);
|
|
140
|
-
return () => {
|
|
141
|
-
$$props.editor.unregisterPlugin(pluginKey());
|
|
142
|
-
};
|
|
143
|
-
}
|
|
144
|
-
});
|
|
145
|
-
var div = root2();
|
|
146
|
-
var node = $3.child(div);
|
|
147
|
-
{
|
|
148
|
-
var consequent = ($$anchor2) => {
|
|
149
|
-
var fragment = $3.comment();
|
|
150
|
-
var node_1 = $3.first_child(fragment);
|
|
151
|
-
$3.snippet(node_1, () => $$props.children);
|
|
152
|
-
$3.append($$anchor2, fragment);
|
|
153
|
-
};
|
|
154
|
-
$3.if(node, ($$render) => {
|
|
155
|
-
if ($$props.children) $$render(consequent);
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
$3.reset(div);
|
|
159
|
-
$3.bind_this(div, ($$value) => $3.set(menuElement, $$value), () => $3.get(menuElement));
|
|
160
|
-
$3.template_effect(() => $3.set_class(div, 1, $3.clsx(className())));
|
|
161
|
-
$3.append($$anchor, div);
|
|
162
|
-
$3.pop();
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
// src/TemplateRenderer.svelte
|
|
166
|
-
import "svelte/internal/disclose-version";
|
|
167
|
-
import * as $4 from "svelte/internal/client";
|
|
168
|
-
import { tokenizePrompt, resolveTemplates } from "@pixerate/editor";
|
|
169
|
-
var root3 = $4.from_html(`<span class="inline-flex items-center px-1.5 py-0.5 mx-0.5 text-xs font-semibold rounded-md border border-[var(--color-to)]/40 bg-gradient-to-r from-[var(--color-from)]/15 to-[var(--color-to)]/15 text-[var(--color-to)] hover:brightness-110 cursor-pointer transition-all"> </span>`);
|
|
170
|
-
var root_12 = $4.from_html(`<span class="inline-flex items-center px-1.5 py-0.5 mx-0.5 text-xs font-medium rounded-md border border-violet-400/40 bg-violet-400/15 text-violet-600 hover:brightness-110 cursor-pointer transition-all"> </span>`);
|
|
171
|
-
var root_2 = $4.from_html(`<span class="inline-flex items-center px-1.5 py-0.5 mx-0.5 text-xs italic font-medium rounded-md border border-rose-400/40 bg-rose-400/15 text-rose-600"> </span>`);
|
|
172
|
-
var root_3 = $4.from_html(`<span> </span>`);
|
|
173
|
-
var root_4 = $4.from_html(`<div></div>`);
|
|
174
|
-
function TemplateRenderer($$anchor, $$props) {
|
|
175
|
-
$4.push($$props, true);
|
|
176
|
-
let templates = $4.prop($$props, "templates", 19, () => []), resolve = $4.prop($$props, "resolve", 3, false), className = $4.prop($$props, "class", 3, "font-mono text-sm leading-relaxed whitespace-pre-wrap break-words");
|
|
177
|
-
let displayText = $4.derived(() => resolve() && templates().length > 0 ? resolveTemplates($$props.content, templates()) : $$props.content);
|
|
178
|
-
let tokens = $4.derived(() => tokenizePrompt($4.get(displayText)));
|
|
179
|
-
var div = root_4();
|
|
180
|
-
$4.each(div, 21, () => $4.get(tokens), $4.index, ($$anchor2, token) => {
|
|
181
|
-
var fragment = $4.comment();
|
|
182
|
-
var node = $4.first_child(fragment);
|
|
183
|
-
{
|
|
184
|
-
var consequent = ($$anchor3) => {
|
|
185
|
-
const colors = $4.derived(() => $$props.templateColorMap?.get($4.get(token).value) || { from: "#f43f5e", to: "#8b5cf6" });
|
|
186
|
-
var span = root3();
|
|
187
|
-
var text = $4.only_child(span, true);
|
|
188
|
-
$4.template_effect(() => {
|
|
189
|
-
$4.set_style(span, `--color-from: ${$4.get(colors).from}; --color-to: ${$4.get(colors).to};`);
|
|
190
|
-
$4.set_attribute(span, "title", `Template: ${$4.get(token).value}`);
|
|
191
|
-
$4.set_text(text, `{{${$4.get(token).value}}}`);
|
|
192
|
-
});
|
|
193
|
-
$4.delegated("click", span, () => $$props.onTemplateClick?.($4.get(token).value));
|
|
194
|
-
$4.append($$anchor3, span);
|
|
195
|
-
};
|
|
196
|
-
var consequent_1 = ($$anchor3) => {
|
|
197
|
-
var span_1 = root_12();
|
|
198
|
-
var text_1 = $4.only_child(span_1, true);
|
|
199
|
-
$4.template_effect(() => {
|
|
200
|
-
$4.set_attribute(span_1, "title", `Variable: ${$4.get(token).value}`);
|
|
201
|
-
$4.set_text(text_1, `{${$4.get(token).value}}`);
|
|
202
|
-
});
|
|
203
|
-
$4.delegated("click", span_1, () => $$props.onVariableClick?.($4.get(token).value));
|
|
204
|
-
$4.append($$anchor3, span_1);
|
|
205
|
-
};
|
|
206
|
-
var consequent_2 = ($$anchor3) => {
|
|
207
|
-
var span_2 = root_2();
|
|
208
|
-
var text_2 = $4.only_child(span_2, true);
|
|
209
|
-
$4.template_effect(() => {
|
|
210
|
-
$4.set_attribute(span_2, "title", `Instruction: ${$4.get(token).value}`);
|
|
211
|
-
$4.set_text(text_2, `__${$4.get(token).value}__`);
|
|
212
|
-
});
|
|
213
|
-
$4.append($$anchor3, span_2);
|
|
214
|
-
};
|
|
215
|
-
var alternate = ($$anchor3) => {
|
|
216
|
-
var span_3 = root_3();
|
|
217
|
-
var text_3 = $4.only_child(span_3, true);
|
|
218
|
-
$4.template_effect(() => $4.set_text(text_3, $4.get(token).value));
|
|
219
|
-
$4.append($$anchor3, span_3);
|
|
220
|
-
};
|
|
221
|
-
$4.if(node, ($$render) => {
|
|
222
|
-
if ($4.get(token).type === "template") $$render(consequent);
|
|
223
|
-
else if ($4.get(token).type === "variable") $$render(consequent_1, 1);
|
|
224
|
-
else if ($4.get(token).type === "instruction") $$render(consequent_2, 2);
|
|
225
|
-
else $$render(alternate, -1);
|
|
226
|
-
});
|
|
227
|
-
}
|
|
228
|
-
$4.append($$anchor2, fragment);
|
|
229
|
-
});
|
|
230
|
-
$4.reset(div);
|
|
231
|
-
$4.template_effect(() => $4.set_class(div, 1, $4.clsx(className())));
|
|
232
|
-
$4.append($$anchor, div);
|
|
233
|
-
$4.pop();
|
|
234
|
-
}
|
|
235
|
-
$4.delegate(["click"]);
|
|
236
|
-
|
|
237
|
-
// src/navigationGuard.ts
|
|
238
|
-
function navigationGuard(node, options) {
|
|
239
|
-
let isDirty = options.isDirty;
|
|
240
|
-
let enabled = options.enabled ?? true;
|
|
241
|
-
let onBlocked = options.onBlocked;
|
|
242
|
-
function handleBeforeUnload(e) {
|
|
243
|
-
if (!enabled || !isDirty) return;
|
|
244
|
-
e.preventDefault();
|
|
245
|
-
e.returnValue = "";
|
|
246
|
-
}
|
|
247
|
-
function handleClick(e) {
|
|
248
|
-
if (!enabled || !isDirty) return;
|
|
249
|
-
const target = e.target;
|
|
250
|
-
const anchor = target?.closest?.("a");
|
|
251
|
-
if (!anchor) return;
|
|
252
|
-
if (anchor.target === "_blank") return;
|
|
253
|
-
if (typeof window !== "undefined") {
|
|
254
|
-
const isInternal = anchor.host === window.location.host;
|
|
255
|
-
if (!isInternal) return;
|
|
256
|
-
if (anchor.pathname === window.location.pathname && anchor.search === window.location.search) {
|
|
257
|
-
return;
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
e.preventDefault();
|
|
261
|
-
e.stopPropagation();
|
|
262
|
-
const href = anchor.href;
|
|
263
|
-
onBlocked?.(href);
|
|
264
|
-
}
|
|
265
|
-
if (typeof window !== "undefined") {
|
|
266
|
-
window.addEventListener("beforeunload", handleBeforeUnload);
|
|
267
|
-
}
|
|
268
|
-
node.addEventListener("click", handleClick, { capture: true });
|
|
269
|
-
return {
|
|
270
|
-
update(newOptions) {
|
|
271
|
-
isDirty = newOptions.isDirty;
|
|
272
|
-
enabled = newOptions.enabled ?? true;
|
|
273
|
-
onBlocked = newOptions.onBlocked;
|
|
274
|
-
},
|
|
275
|
-
destroy() {
|
|
276
|
-
if (typeof window !== "undefined") {
|
|
277
|
-
window.removeEventListener("beforeunload", handleBeforeUnload);
|
|
278
|
-
}
|
|
279
|
-
node.removeEventListener("click", handleClick, { capture: true });
|
|
280
|
-
}
|
|
281
|
-
};
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
// src/createNavigationGuard.svelte.ts
|
|
285
|
-
import * as $5 from "svelte/internal/client";
|
|
286
|
-
function createNavigationGuard(options) {
|
|
287
|
-
let showConfirm = $5.state(false);
|
|
288
|
-
let pendingUrl = $5.state(null);
|
|
289
|
-
const getIsDirty = () => typeof options.isDirty === "function" ? options.isDirty() : options.isDirty;
|
|
290
|
-
const getEnabled = () => typeof options.enabled === "function" ? options.enabled() : options.enabled ?? true;
|
|
291
|
-
function handleBeforeUnload(e) {
|
|
292
|
-
if (!getEnabled() || !getIsDirty()) return;
|
|
293
|
-
e.preventDefault();
|
|
294
|
-
e.returnValue = "";
|
|
295
|
-
}
|
|
296
|
-
if (typeof window !== "undefined") {
|
|
297
|
-
window.addEventListener("beforeunload", handleBeforeUnload);
|
|
298
|
-
}
|
|
299
|
-
function intercept(url) {
|
|
300
|
-
if (getEnabled() && getIsDirty()) {
|
|
301
|
-
$5.set(pendingUrl, url, true);
|
|
302
|
-
$5.set(showConfirm, true);
|
|
303
|
-
options.onBlocked?.(url);
|
|
304
|
-
return true;
|
|
305
|
-
}
|
|
306
|
-
return false;
|
|
307
|
-
}
|
|
308
|
-
function confirmLeave() {
|
|
309
|
-
$5.set(showConfirm, false);
|
|
310
|
-
const target = $5.get(pendingUrl);
|
|
311
|
-
if (target) {
|
|
312
|
-
if (options.onNavigate) {
|
|
313
|
-
options.onNavigate(target);
|
|
314
|
-
} else if (typeof window !== "undefined") {
|
|
315
|
-
window.location.href = target;
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
function cancelLeave() {
|
|
320
|
-
$5.set(showConfirm, false);
|
|
321
|
-
$5.set(pendingUrl, null);
|
|
322
|
-
}
|
|
323
|
-
function destroy() {
|
|
324
|
-
if (typeof window !== "undefined") {
|
|
325
|
-
window.removeEventListener("beforeunload", handleBeforeUnload);
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
return {
|
|
329
|
-
get showConfirm() {
|
|
330
|
-
return $5.get(showConfirm);
|
|
331
|
-
},
|
|
332
|
-
setShowConfirm(val) {
|
|
333
|
-
$5.set(showConfirm, val, true);
|
|
334
|
-
},
|
|
335
|
-
get pendingUrl() {
|
|
336
|
-
return $5.get(pendingUrl);
|
|
337
|
-
},
|
|
338
|
-
intercept,
|
|
339
|
-
confirmLeave,
|
|
340
|
-
cancelLeave,
|
|
341
|
-
destroy
|
|
342
|
-
};
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
// src/history/history.svelte.ts
|
|
346
|
-
import * as $6 from "svelte/internal/client";
|
|
347
|
-
import { HistoryManager, createHistoryManager } from "@pixerate/editor";
|
|
348
|
-
function createHistory(managerOrOptions) {
|
|
349
|
-
const manager = managerOrOptions instanceof HistoryManager ? managerOrOptions : createHistoryManager(managerOrOptions);
|
|
350
|
-
let state7 = $6.state($6.proxy(manager.getState()));
|
|
351
|
-
manager.subscribe((newState) => {
|
|
352
|
-
$6.set(state7, newState, true);
|
|
353
|
-
});
|
|
354
|
-
return {
|
|
355
|
-
get canUndo() {
|
|
356
|
-
return $6.get(state7).canUndo;
|
|
357
|
-
},
|
|
358
|
-
get canRedo() {
|
|
359
|
-
return $6.get(state7).canRedo;
|
|
360
|
-
},
|
|
361
|
-
get undoName() {
|
|
362
|
-
return $6.get(state7).undoName;
|
|
363
|
-
},
|
|
364
|
-
get redoName() {
|
|
365
|
-
return $6.get(state7).redoName;
|
|
366
|
-
},
|
|
367
|
-
get undoCount() {
|
|
368
|
-
return $6.get(state7).undoCount;
|
|
369
|
-
},
|
|
370
|
-
get redoCount() {
|
|
371
|
-
return $6.get(state7).redoCount;
|
|
372
|
-
},
|
|
373
|
-
get manager() {
|
|
374
|
-
return manager;
|
|
375
|
-
},
|
|
376
|
-
undo: () => manager.undo(),
|
|
377
|
-
redo: () => manager.redo(),
|
|
378
|
-
clear: () => manager.clear(),
|
|
379
|
-
execute: (cmd) => manager.execute(cmd),
|
|
380
|
-
executeMerged: (cmd, opts) => manager.executeMerged(cmd, opts),
|
|
381
|
-
batch: (name, fn) => manager.batch(name, fn),
|
|
382
|
-
subscribe: (run) => manager.subscribe(run)
|
|
383
|
-
};
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
// src/history/createHistoryShortcuts.ts
|
|
387
|
-
function createHistoryShortcuts(manager, options = {}) {
|
|
388
|
-
const {
|
|
389
|
-
enabled = true,
|
|
390
|
-
target,
|
|
391
|
-
ignoreEditableElements = true
|
|
392
|
-
} = options;
|
|
393
|
-
if (!enabled) {
|
|
394
|
-
return { destroy: () => {
|
|
395
|
-
} };
|
|
396
|
-
}
|
|
397
|
-
const eventTarget = target ?? (typeof window !== "undefined" ? window : null);
|
|
398
|
-
if (!eventTarget) {
|
|
399
|
-
return { destroy: () => {
|
|
400
|
-
} };
|
|
401
|
-
}
|
|
402
|
-
const handleKeyDown = (event2) => {
|
|
403
|
-
const e = event2;
|
|
404
|
-
const isMac = typeof navigator !== "undefined" && /Mac|iPod|iPhone|iPad/.test(navigator.platform || navigator.userAgent);
|
|
405
|
-
const modifier = isMac ? e.metaKey : e.ctrlKey;
|
|
406
|
-
if (!modifier) return;
|
|
407
|
-
if (ignoreEditableElements && typeof document !== "undefined") {
|
|
408
|
-
const targetEl = e.target || document.activeElement;
|
|
409
|
-
if (targetEl && targetEl.tagName) {
|
|
410
|
-
const tagName = targetEl.tagName.toLowerCase();
|
|
411
|
-
const isInput = tagName === "input" || tagName === "textarea";
|
|
412
|
-
const isContentEditable = targetEl.isContentEditable || targetEl.getAttribute?.("contenteditable") === "true";
|
|
413
|
-
if (isInput || isContentEditable) {
|
|
414
|
-
return;
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
const key = e.key?.toLowerCase();
|
|
419
|
-
if (key === "z" && !e.shiftKey) {
|
|
420
|
-
if (manager.getState().canUndo) {
|
|
421
|
-
e.preventDefault();
|
|
422
|
-
manager.undo();
|
|
423
|
-
}
|
|
424
|
-
return;
|
|
425
|
-
}
|
|
426
|
-
const isRedoKey = key === "z" && e.shiftKey || !isMac && key === "y" && !e.shiftKey;
|
|
427
|
-
if (isRedoKey) {
|
|
428
|
-
if (manager.getState().canRedo) {
|
|
429
|
-
e.preventDefault();
|
|
430
|
-
manager.redo();
|
|
431
|
-
}
|
|
432
|
-
}
|
|
433
|
-
};
|
|
434
|
-
eventTarget.addEventListener("keydown", handleKeyDown);
|
|
435
|
-
return {
|
|
436
|
-
destroy: () => {
|
|
437
|
-
eventTarget.removeEventListener("keydown", handleKeyDown);
|
|
438
|
-
}
|
|
439
|
-
};
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
// src/index.ts
|
|
443
|
-
import {
|
|
444
|
-
DirtyTracker,
|
|
445
|
-
createDirtyTracker,
|
|
446
|
-
defaultIsEqual,
|
|
447
|
-
HistoryManager as HistoryManager2,
|
|
448
|
-
createHistoryManager as createHistoryManager2
|
|
449
|
-
} from "@pixerate/editor";
|
|
450
|
-
|
|
451
|
-
// src/spreadsheet/SpreadsheetEditor.svelte
|
|
452
|
-
import "svelte/internal/disclose-version";
|
|
453
|
-
import * as $9 from "svelte/internal/client";
|
|
454
|
-
import { indexToColName as indexToColName2 } from "@pixerate/editor";
|
|
455
|
-
|
|
456
|
-
// src/spreadsheet/FormulaBar.svelte
|
|
457
|
-
import "svelte/internal/disclose-version";
|
|
458
|
-
import * as $7 from "svelte/internal/client";
|
|
459
|
-
import { indexToColName } from "@pixerate/editor";
|
|
460
|
-
var root4 = $7.from_html(`<div><div class="flex h-6 min-w-[3rem] items-center justify-center rounded border border-border bg-background px-1.5 font-semibold text-foreground"> </div> <div class="flex items-center text-muted-foreground select-none"><span class="italic font-serif font-bold text-sm text-primary">fx</span></div> <input type="text" class="flex-1 bg-transparent px-2 py-0.5 outline-none font-sans text-xs text-foreground placeholder:text-muted-foreground/60 focus:bg-background focus:ring-1 focus:ring-primary rounded" placeholder="Enter a value or formula (e.g. =SUM(A1:A5))"/></div>`);
|
|
461
|
-
function FormulaBar($$anchor, $$props) {
|
|
462
|
-
$7.push($$props, true);
|
|
463
|
-
let sheetState = $7.prop($$props, "sheetState", 7), activeCoord = $7.prop($$props, "activeCoord", 3, null), value = $7.prop($$props, "value", 15, ""), className = $7.prop($$props, "class", 3, "");
|
|
464
|
-
let effectiveCoord = $7.derived(() => {
|
|
465
|
-
if (sheetState()) return sheetState().activeCell;
|
|
466
|
-
return activeCoord();
|
|
467
|
-
});
|
|
468
|
-
let coordLabel = $7.derived(() => {
|
|
469
|
-
if (!$7.get(effectiveCoord)) return "--";
|
|
470
|
-
const colName = indexToColName($7.get(effectiveCoord).col);
|
|
471
|
-
return `${colName}${$7.get(effectiveCoord).row + 1}`;
|
|
472
|
-
});
|
|
473
|
-
let effectiveValue = $7.derived(() => {
|
|
474
|
-
if (sheetState()) {
|
|
475
|
-
if (sheetState().editingCell) return sheetState().draftValue;
|
|
476
|
-
if (!sheetState().activeCell) return "";
|
|
477
|
-
const row = sheetState().document.rows[sheetState().activeCell.row];
|
|
478
|
-
const col = sheetState().document.columns[sheetState().activeCell.col];
|
|
479
|
-
if (!row || !col) return "";
|
|
480
|
-
return sheetState().getCell(row.id, col.id).raw || "";
|
|
481
|
-
}
|
|
482
|
-
return value();
|
|
483
|
-
});
|
|
484
|
-
function handleKeyDown(e) {
|
|
485
|
-
if (e.key === "Enter") {
|
|
486
|
-
e.preventDefault();
|
|
487
|
-
if (sheetState() && sheetState().activeCell) {
|
|
488
|
-
const row = sheetState().document.rows[sheetState().activeCell.row];
|
|
489
|
-
const col = sheetState().document.columns[sheetState().activeCell.col];
|
|
490
|
-
if (row && col) {
|
|
491
|
-
sheetState().setCellValue(row.id, col.id, $7.get(effectiveValue));
|
|
492
|
-
}
|
|
493
|
-
sheetState().commitEditing();
|
|
494
|
-
}
|
|
495
|
-
$$props.onCommit?.($7.get(effectiveValue));
|
|
496
|
-
} else if (e.key === "Escape") {
|
|
497
|
-
e.preventDefault();
|
|
498
|
-
if (sheetState()) {
|
|
499
|
-
sheetState().cancelEditing();
|
|
500
|
-
}
|
|
501
|
-
$$props.onCancel?.();
|
|
502
|
-
}
|
|
503
|
-
}
|
|
504
|
-
function handleInput(e) {
|
|
505
|
-
const target = e.target;
|
|
506
|
-
if (sheetState()) {
|
|
507
|
-
sheetState().draftValue = target.value;
|
|
508
|
-
if (sheetState().activeCell && !sheetState().editingCell) {
|
|
509
|
-
sheetState().startEditing(sheetState().activeCell.row, sheetState().activeCell.col, target.value);
|
|
510
|
-
}
|
|
511
|
-
} else {
|
|
512
|
-
value(target.value);
|
|
513
|
-
}
|
|
514
|
-
$$props.onChange?.(target.value);
|
|
515
|
-
}
|
|
516
|
-
var div = root4();
|
|
517
|
-
var div_1 = $7.child(div);
|
|
518
|
-
var text = $7.only_child(div_1, true);
|
|
519
|
-
var input = $7.sibling(div_1, 4);
|
|
520
|
-
$7.remove_input_defaults(input);
|
|
521
|
-
$7.reset(div);
|
|
522
|
-
$7.template_effect(() => {
|
|
523
|
-
$7.set_class(div, 1, `flex items-center gap-2 border-b border-border bg-muted/20 px-3 py-1.5 text-xs font-mono ${className() ?? ""}`);
|
|
524
|
-
$7.set_text(text, $7.get(coordLabel));
|
|
525
|
-
$7.set_value(input, $7.get(effectiveValue));
|
|
526
|
-
});
|
|
527
|
-
$7.delegated("input", input, handleInput);
|
|
528
|
-
$7.delegated("keydown", input, handleKeyDown);
|
|
529
|
-
$7.append($$anchor, div);
|
|
530
|
-
$7.pop();
|
|
531
|
-
}
|
|
532
|
-
$7.delegate(["input", "keydown"]);
|
|
533
|
-
|
|
534
|
-
// src/spreadsheet/spreadsheet.svelte.ts
|
|
535
|
-
import * as $8 from "svelte/internal/client";
|
|
536
|
-
import { SpreadsheetController } from "@pixerate/editor";
|
|
537
|
-
function createReactiveSpreadsheet(options = {}) {
|
|
538
|
-
let doc = $8.state($8.proxy({
|
|
539
|
-
id: options.document?.id || `sheet_${Date.now()}`,
|
|
540
|
-
name: options.document?.name || "Sheet 1",
|
|
541
|
-
columns: options.document?.columns || [],
|
|
542
|
-
rows: options.document?.rows || [],
|
|
543
|
-
cells: options.document?.cells || {},
|
|
544
|
-
createdAt: options.document?.createdAt || Date.now(),
|
|
545
|
-
updatedAt: options.document?.updatedAt || Date.now()
|
|
546
|
-
}));
|
|
547
|
-
let activeCell = $8.state(null);
|
|
548
|
-
let selectedRange = $8.state(null);
|
|
549
|
-
let editingCell = $8.state(null);
|
|
550
|
-
let draftValue = $8.state("");
|
|
551
|
-
const controller = new SpreadsheetController({
|
|
552
|
-
...options,
|
|
553
|
-
document: options.document,
|
|
554
|
-
onDocumentChange: (updated) => {
|
|
555
|
-
$8.set(doc, { ...updated }, true);
|
|
556
|
-
options.onDocumentChange?.(updated);
|
|
557
|
-
},
|
|
558
|
-
onSelectionChange: (active, range) => {
|
|
559
|
-
$8.set(activeCell, active, true);
|
|
560
|
-
$8.set(selectedRange, range, true);
|
|
561
|
-
options.onSelectionChange?.(active, range);
|
|
562
|
-
},
|
|
563
|
-
onCellCommit: (rowId, colId, raw, value) => {
|
|
564
|
-
options.onCellCommit?.(rowId, colId, raw, value);
|
|
565
|
-
}
|
|
566
|
-
});
|
|
567
|
-
$8.set(doc, { ...controller.document }, true);
|
|
568
|
-
$8.set(activeCell, controller.activeCell, true);
|
|
569
|
-
$8.set(selectedRange, controller.selectedRange, true);
|
|
570
|
-
return {
|
|
571
|
-
get document() {
|
|
572
|
-
return $8.get(doc);
|
|
573
|
-
},
|
|
574
|
-
get activeCell() {
|
|
575
|
-
return $8.get(activeCell);
|
|
576
|
-
},
|
|
577
|
-
get selectedRange() {
|
|
578
|
-
return $8.get(selectedRange);
|
|
579
|
-
},
|
|
580
|
-
get editingCell() {
|
|
581
|
-
return $8.get(editingCell);
|
|
582
|
-
},
|
|
583
|
-
get draftValue() {
|
|
584
|
-
return $8.get(draftValue);
|
|
585
|
-
},
|
|
586
|
-
set draftValue(val) {
|
|
587
|
-
$8.set(draftValue, val, true);
|
|
588
|
-
controller.draftValue = val;
|
|
589
|
-
},
|
|
590
|
-
controller,
|
|
591
|
-
getCell(rowId, colId) {
|
|
592
|
-
return controller.getCell(rowId, colId);
|
|
593
|
-
},
|
|
594
|
-
setCellValue(rowId, colId, raw) {
|
|
595
|
-
controller.setCellValue(rowId, colId, raw);
|
|
596
|
-
$8.set(doc, { ...controller.document }, true);
|
|
597
|
-
},
|
|
598
|
-
selectCell(row, col, extendSelection = false) {
|
|
599
|
-
controller.selectCell(row, col, extendSelection);
|
|
600
|
-
$8.set(activeCell, controller.activeCell, true);
|
|
601
|
-
$8.set(selectedRange, controller.selectedRange, true);
|
|
602
|
-
},
|
|
603
|
-
selectRange(range) {
|
|
604
|
-
controller.selectRange(range);
|
|
605
|
-
$8.set(selectedRange, controller.selectedRange, true);
|
|
606
|
-
},
|
|
607
|
-
startEditing(row, col, initialVal) {
|
|
608
|
-
controller.startEditing(row, col, initialVal);
|
|
609
|
-
$8.set(activeCell, controller.activeCell, true);
|
|
610
|
-
$8.set(editingCell, controller.editingCell, true);
|
|
611
|
-
$8.set(draftValue, controller.draftValue, true);
|
|
612
|
-
},
|
|
613
|
-
commitEditing(val) {
|
|
614
|
-
controller.commitEditing(val);
|
|
615
|
-
$8.set(editingCell, null);
|
|
616
|
-
$8.set(draftValue, "");
|
|
617
|
-
$8.set(doc, { ...controller.document }, true);
|
|
618
|
-
},
|
|
619
|
-
cancelEditing() {
|
|
620
|
-
controller.cancelEditing();
|
|
621
|
-
$8.set(editingCell, null);
|
|
622
|
-
$8.set(draftValue, "");
|
|
623
|
-
},
|
|
624
|
-
moveCursor(dir, extend = false) {
|
|
625
|
-
controller.moveCursor(dir, extend);
|
|
626
|
-
$8.set(activeCell, controller.activeCell, true);
|
|
627
|
-
$8.set(selectedRange, controller.selectedRange, true);
|
|
628
|
-
},
|
|
629
|
-
insertColumn(index2, config) {
|
|
630
|
-
controller.insertColumn(index2, config);
|
|
631
|
-
$8.set(doc, { ...controller.document }, true);
|
|
632
|
-
},
|
|
633
|
-
deleteColumn(colId) {
|
|
634
|
-
controller.deleteColumn(colId);
|
|
635
|
-
$8.set(doc, { ...controller.document }, true);
|
|
636
|
-
},
|
|
637
|
-
insertRow(index2, config) {
|
|
638
|
-
controller.insertRow(index2, config);
|
|
639
|
-
$8.set(doc, { ...controller.document }, true);
|
|
640
|
-
},
|
|
641
|
-
deleteRow(rowId) {
|
|
642
|
-
controller.deleteRow(rowId);
|
|
643
|
-
$8.set(doc, { ...controller.document }, true);
|
|
644
|
-
},
|
|
645
|
-
setColumnWidth(colId, width) {
|
|
646
|
-
controller.setColumnWidth(colId, width);
|
|
647
|
-
$8.set(doc, { ...controller.document }, true);
|
|
648
|
-
},
|
|
649
|
-
autoFitColumnWidth(colId, customWidth) {
|
|
650
|
-
controller.autoFitColumnWidth(colId, customWidth);
|
|
651
|
-
$8.set(doc, { ...controller.document }, true);
|
|
652
|
-
},
|
|
653
|
-
loadDocument(document2) {
|
|
654
|
-
controller.loadDocument(document2);
|
|
655
|
-
$8.set(doc, { ...controller.document }, true);
|
|
656
|
-
$8.set(activeCell, controller.activeCell, true);
|
|
657
|
-
$8.set(selectedRange, controller.selectedRange, true);
|
|
658
|
-
$8.set(editingCell, controller.editingCell, true);
|
|
659
|
-
$8.set(draftValue, controller.draftValue, true);
|
|
660
|
-
},
|
|
661
|
-
syncWithDataSource() {
|
|
662
|
-
controller.syncWithDataSource();
|
|
663
|
-
controller.recalculateAll();
|
|
664
|
-
$8.set(doc, { ...controller.document }, true);
|
|
665
|
-
},
|
|
666
|
-
registerDataSource(ds) {
|
|
667
|
-
controller.registerDataSource(ds);
|
|
668
|
-
$8.set(doc, { ...controller.document }, true);
|
|
669
|
-
},
|
|
670
|
-
setPrimaryDataSource(id) {
|
|
671
|
-
controller.setPrimaryDataSource(id);
|
|
672
|
-
$8.set(doc, { ...controller.document }, true);
|
|
673
|
-
},
|
|
674
|
-
recalculateAll() {
|
|
675
|
-
controller.recalculateAll();
|
|
676
|
-
$8.set(doc, { ...controller.document }, true);
|
|
677
|
-
},
|
|
678
|
-
exportToTsv() {
|
|
679
|
-
return controller.exportToTsv();
|
|
680
|
-
},
|
|
681
|
-
importFromTsv(data) {
|
|
682
|
-
controller.importFromTsv(data);
|
|
683
|
-
$8.set(doc, { ...controller.document }, true);
|
|
684
|
-
},
|
|
685
|
-
undo() {
|
|
686
|
-
controller.undo();
|
|
687
|
-
$8.set(doc, { ...controller.document }, true);
|
|
688
|
-
},
|
|
689
|
-
redo() {
|
|
690
|
-
controller.redo();
|
|
691
|
-
$8.set(doc, { ...controller.document }, true);
|
|
692
|
-
}
|
|
693
|
-
};
|
|
694
|
-
}
|
|
695
|
-
|
|
696
|
-
// src/spreadsheet/SpreadsheetEditor.svelte
|
|
697
|
-
var root5 = $9.from_html(`<th><div class="flex items-center justify-between gap-1 min-w-0 overflow-hidden truncate"><span class="truncate font-semibold text-foreground text-xs min-w-0"> </span> <span class="text-[10px] text-muted-foreground/70 font-mono font-normal shrink-0"> </span></div> <div class="col-resize-handle svelte-m799ch" style="position: absolute; top: 0; bottom: 0; width: 12px; right: -6px; cursor: col-resize !important; z-index: 20; display: flex; justify-content: center; touch-action: none;" role="separator" aria-orientation="vertical" tabindex="-1"><div class="col-resize-handle-line svelte-m799ch"></div></div></th>`);
|
|
698
|
-
var root_13 = $9.from_html(`<th class="w-10 min-w-[2.5rem] px-1 text-center bg-muted/40 hover:bg-muted cursor-pointer transition-colors svelte-m799ch" title="Add Column"><span class="text-xs font-bold text-muted-foreground">+</span></th>`);
|
|
699
|
-
var root_22 = $9.from_html(`<input type="text" class="absolute inset-0 w-full h-full px-2 py-1 bg-background text-foreground outline-none font-sans text-xs border-2 border-primary z-20"/>`);
|
|
700
|
-
var root_32 = $9.from_html(`<span> </span>`);
|
|
701
|
-
var root_42 = $9.from_html(`<td style="max-width: 0; overflow: hidden;"><!></td>`);
|
|
702
|
-
var root_5 = $9.from_html(`<td class="w-10 min-w-[2.5rem] bg-muted/10 border-r border-border svelte-m799ch"></td>`);
|
|
703
|
-
var root_6 = $9.from_html(`<tr class="border-b border-border hover:bg-muted/10 transition-colors"><td class="w-12 min-w-[3rem] sticky left-0 z-10 bg-muted/50 border-r border-border text-center text-[10px] text-muted-foreground font-mono select-none svelte-m799ch"> </td><!><!><td class="border-b border-border bg-transparent p-0 svelte-m799ch"></td></tr>`);
|
|
704
|
-
var root_7 = $9.from_html(`<div tabindex="0" role="grid" aria-label="Spreadsheet"><!> <div class="relative flex-1 overflow-auto"><table class="border-collapse table-fixed w-max min-w-full svelte-m799ch"><thead><tr class="h-7 bg-muted/60 sticky top-0 z-20 border-b border-border shadow-xs"><th class="w-12 min-w-[3rem] sticky left-0 z-30 bg-muted/90 border-r border-border text-center text-[10px] text-muted-foreground font-medium svelte-m799ch">#</th><!><!><th class="border-b border-border bg-transparent p-0 font-normal svelte-m799ch"></th></tr></thead><tbody></tbody></table></div></div>`);
|
|
705
|
-
function SpreadsheetEditor($$anchor, $$props) {
|
|
706
|
-
$9.push($$props, true);
|
|
707
|
-
let sheetState = $9.prop($$props, "sheetState", 23, createReactiveSpreadsheet), readOnly = $9.prop($$props, "readOnly", 3, false), readonly = $9.prop($$props, "readonly", 3, false), showFormulaBar = $9.prop($$props, "showFormulaBar", 3, true), className = $9.prop($$props, "class", 3, "");
|
|
708
|
-
let isReadOnly = $9.derived(() => readOnly() || readonly());
|
|
709
|
-
let gridContainer = $9.state(null);
|
|
710
|
-
let resizingColId = $9.state(null);
|
|
711
|
-
let hoveredColId = $9.state(null);
|
|
712
|
-
let resizeStartX = $9.state(0);
|
|
713
|
-
let resizeStartWidth = $9.state(0);
|
|
714
|
-
function handleCellClick(rIdx, cIdx, e) {
|
|
715
|
-
if (sheetState().editingCell && (sheetState().editingCell.row !== rIdx || sheetState().editingCell.col !== cIdx)) {
|
|
716
|
-
sheetState().commitEditing();
|
|
717
|
-
}
|
|
718
|
-
sheetState().selectCell(rIdx, cIdx, e.shiftKey);
|
|
719
|
-
}
|
|
720
|
-
function handleCellDblClick(rIdx, cIdx) {
|
|
721
|
-
if ($9.get(isReadOnly)) return;
|
|
722
|
-
const col = sheetState().document.columns[cIdx];
|
|
723
|
-
if (col?.readOnly) return;
|
|
724
|
-
sheetState().startEditing(rIdx, cIdx);
|
|
725
|
-
}
|
|
726
|
-
function handleKeyDown(e) {
|
|
727
|
-
if (sheetState().editingCell) {
|
|
728
|
-
if (e.key === "Escape") {
|
|
729
|
-
sheetState().cancelEditing();
|
|
730
|
-
} else if (e.key === "Enter") {
|
|
731
|
-
sheetState().commitEditing();
|
|
732
|
-
sheetState().moveCursor("down");
|
|
733
|
-
} else if (e.key === "Tab") {
|
|
734
|
-
e.preventDefault();
|
|
735
|
-
sheetState().commitEditing();
|
|
736
|
-
sheetState().moveCursor(e.shiftKey ? "left" : "right");
|
|
737
|
-
}
|
|
738
|
-
return;
|
|
739
|
-
}
|
|
740
|
-
if (!sheetState().activeCell) return;
|
|
741
|
-
if (e.key === "ArrowUp") {
|
|
742
|
-
e.preventDefault();
|
|
743
|
-
sheetState().moveCursor("up", e.shiftKey);
|
|
744
|
-
} else if (e.key === "ArrowDown") {
|
|
745
|
-
e.preventDefault();
|
|
746
|
-
sheetState().moveCursor("down", e.shiftKey);
|
|
747
|
-
} else if (e.key === "ArrowLeft") {
|
|
748
|
-
e.preventDefault();
|
|
749
|
-
sheetState().moveCursor("left", e.shiftKey);
|
|
750
|
-
} else if (e.key === "ArrowRight") {
|
|
751
|
-
e.preventDefault();
|
|
752
|
-
sheetState().moveCursor("right", e.shiftKey);
|
|
753
|
-
} else if (e.key === "Tab") {
|
|
754
|
-
e.preventDefault();
|
|
755
|
-
sheetState().moveCursor(e.shiftKey ? "left" : "right");
|
|
756
|
-
} else if (e.key === "Enter") {
|
|
757
|
-
e.preventDefault();
|
|
758
|
-
const col = sheetState().document.columns[sheetState().activeCell.col];
|
|
759
|
-
if (!$9.get(isReadOnly) && !col?.readOnly) {
|
|
760
|
-
sheetState().startEditing();
|
|
761
|
-
}
|
|
762
|
-
} else if (e.key === "Backspace" || e.key === "Delete") {
|
|
763
|
-
if ($9.get(isReadOnly)) return;
|
|
764
|
-
const row = sheetState().document.rows[sheetState().activeCell.row];
|
|
765
|
-
const col = sheetState().document.columns[sheetState().activeCell.col];
|
|
766
|
-
if (row && col && !col.readOnly) {
|
|
767
|
-
e.preventDefault();
|
|
768
|
-
sheetState().setCellValue(row.id, col.id, "");
|
|
769
|
-
}
|
|
770
|
-
} else if ((e.metaKey || e.ctrlKey) && e.key === "z") {
|
|
771
|
-
e.preventDefault();
|
|
772
|
-
if (e.shiftKey) {
|
|
773
|
-
sheetState().redo();
|
|
774
|
-
} else {
|
|
775
|
-
sheetState().undo();
|
|
776
|
-
}
|
|
777
|
-
} else if ((e.metaKey || e.ctrlKey) && e.key === "c") {
|
|
778
|
-
e.preventDefault();
|
|
779
|
-
const tsv = sheetState().exportToTsv();
|
|
780
|
-
navigator.clipboard?.writeText(tsv);
|
|
781
|
-
} else if (!$9.get(isReadOnly) && e.key.length === 1 && !e.ctrlKey && !e.metaKey && !e.altKey) {
|
|
782
|
-
const col = sheetState().document.columns[sheetState().activeCell.col];
|
|
783
|
-
if (!col?.readOnly) {
|
|
784
|
-
sheetState().startEditing(sheetState().activeCell.row, sheetState().activeCell.col, e.key);
|
|
785
|
-
}
|
|
786
|
-
}
|
|
787
|
-
}
|
|
788
|
-
function handleResizeStart(colId, width, e) {
|
|
789
|
-
e.preventDefault();
|
|
790
|
-
e.stopPropagation();
|
|
791
|
-
$9.set(resizingColId, colId, true);
|
|
792
|
-
$9.set(resizeStartX, e.clientX, true);
|
|
793
|
-
$9.set(resizeStartWidth, width, true);
|
|
794
|
-
if (typeof document !== "undefined") {
|
|
795
|
-
document.body.style.cursor = "col-resize";
|
|
796
|
-
document.body.style.userSelect = "none";
|
|
797
|
-
}
|
|
798
|
-
let rafId = null;
|
|
799
|
-
let pendingWidth = width;
|
|
800
|
-
let hasDragged = false;
|
|
801
|
-
const handleMouseMove = (moveEvent) => {
|
|
802
|
-
if (!$9.get(resizingColId)) return;
|
|
803
|
-
const delta = moveEvent.clientX - $9.get(resizeStartX);
|
|
804
|
-
if (Math.abs(delta) > 2) {
|
|
805
|
-
hasDragged = true;
|
|
806
|
-
}
|
|
807
|
-
pendingWidth = Math.max(30, $9.get(resizeStartWidth) + delta);
|
|
808
|
-
if (rafId === null) {
|
|
809
|
-
rafId = requestAnimationFrame(() => {
|
|
810
|
-
rafId = null;
|
|
811
|
-
if ($9.get(resizingColId)) {
|
|
812
|
-
sheetState().setColumnWidth($9.get(resizingColId), pendingWidth);
|
|
813
|
-
}
|
|
814
|
-
});
|
|
815
|
-
}
|
|
816
|
-
};
|
|
817
|
-
const handleMouseUp = () => {
|
|
818
|
-
if (rafId !== null) {
|
|
819
|
-
cancelAnimationFrame(rafId);
|
|
820
|
-
rafId = null;
|
|
821
|
-
}
|
|
822
|
-
if ($9.get(resizingColId) && hasDragged) {
|
|
823
|
-
sheetState().setColumnWidth($9.get(resizingColId), pendingWidth);
|
|
824
|
-
const col = sheetState().document.columns.find((c) => c.id === $9.get(resizingColId));
|
|
825
|
-
if (col && $$props.onColumnResize) {
|
|
826
|
-
$$props.onColumnResize(col.id, col.width || pendingWidth);
|
|
827
|
-
}
|
|
828
|
-
}
|
|
829
|
-
$9.set(resizingColId, null);
|
|
830
|
-
if (typeof document !== "undefined") {
|
|
831
|
-
document.body.style.cursor = "";
|
|
832
|
-
document.body.style.userSelect = "";
|
|
833
|
-
}
|
|
834
|
-
window.removeEventListener("mousemove", handleMouseMove);
|
|
835
|
-
window.removeEventListener("mouseup", handleMouseUp);
|
|
836
|
-
};
|
|
837
|
-
window.addEventListener("mousemove", handleMouseMove);
|
|
838
|
-
window.addEventListener("mouseup", handleMouseUp);
|
|
839
|
-
}
|
|
840
|
-
function measureElementContentWidth(el, container) {
|
|
841
|
-
if (typeof document === "undefined") return 0;
|
|
842
|
-
let maxW = el.scrollWidth || 0;
|
|
843
|
-
const firstChild = el.firstElementChild;
|
|
844
|
-
if (firstChild && firstChild.scrollWidth > maxW) {
|
|
845
|
-
maxW = firstChild.scrollWidth;
|
|
846
|
-
}
|
|
847
|
-
const truncated = el.querySelectorAll(".truncate, [title], span, div");
|
|
848
|
-
truncated.forEach((node) => {
|
|
849
|
-
if (node.scrollWidth > maxW) {
|
|
850
|
-
maxW = node.scrollWidth;
|
|
851
|
-
}
|
|
852
|
-
});
|
|
853
|
-
try {
|
|
854
|
-
const clone = firstChild ? firstChild.cloneNode(true) : el.cloneNode(true);
|
|
855
|
-
clone.style.cssText = `
|
|
856
|
-
position: absolute !important;
|
|
857
|
-
visibility: hidden !important;
|
|
858
|
-
width: max-content !important;
|
|
859
|
-
min-width: max-content !important;
|
|
860
|
-
max-width: none !important;
|
|
861
|
-
overflow: visible !important;
|
|
862
|
-
white-space: nowrap !important;
|
|
863
|
-
pointer-events: none !important;
|
|
864
|
-
top: -9999px !important;
|
|
865
|
-
left: -9999px !important;
|
|
866
|
-
`;
|
|
867
|
-
const allNodes = clone.querySelectorAll("*");
|
|
868
|
-
allNodes.forEach((node) => {
|
|
869
|
-
node.style.maxWidth = "none";
|
|
870
|
-
node.style.overflow = "visible";
|
|
871
|
-
node.style.textOverflow = "clip";
|
|
872
|
-
node.style.whiteSpace = "nowrap";
|
|
873
|
-
if (node.classList.contains("truncate") || node.classList.contains("min-w-0") || node.classList.contains("w-full") || node.classList.contains("max-w-0") || node.classList.contains("flex-1")) {
|
|
874
|
-
node.style.width = "max-content";
|
|
875
|
-
node.style.minWidth = "max-content";
|
|
876
|
-
}
|
|
877
|
-
});
|
|
878
|
-
container.appendChild(clone);
|
|
879
|
-
const rect = clone.getBoundingClientRect();
|
|
880
|
-
container.removeChild(clone);
|
|
881
|
-
if (rect.width > maxW) {
|
|
882
|
-
maxW = rect.width;
|
|
883
|
-
}
|
|
884
|
-
} catch {
|
|
885
|
-
}
|
|
886
|
-
return maxW;
|
|
887
|
-
}
|
|
888
|
-
function autoFitColumn(colId, colIndex) {
|
|
889
|
-
const col = sheetState().document.columns.find((c) => c.id === colId);
|
|
890
|
-
if (!col) return;
|
|
891
|
-
let calculatedWidth = 0;
|
|
892
|
-
if ($9.get(gridContainer) && typeof document !== "undefined") {
|
|
893
|
-
const table = $9.get(gridContainer).querySelector("table");
|
|
894
|
-
if (table) {
|
|
895
|
-
const thElements = table.querySelectorAll("thead th");
|
|
896
|
-
const th = thElements[colIndex + 1];
|
|
897
|
-
if (th) {
|
|
898
|
-
const headerInner = th.firstElementChild || th;
|
|
899
|
-
const headerW = measureElementContentWidth(headerInner, $9.get(gridContainer));
|
|
900
|
-
calculatedWidth = Math.max(calculatedWidth, headerW + 28);
|
|
901
|
-
}
|
|
902
|
-
const rows = table.querySelectorAll("tbody tr");
|
|
903
|
-
const sampleLimit = Math.min(rows.length, 150);
|
|
904
|
-
for (let r = 0; r < sampleLimit; r++) {
|
|
905
|
-
const tr = rows[r];
|
|
906
|
-
const td = tr.children[colIndex + 1];
|
|
907
|
-
if (td) {
|
|
908
|
-
const cellW = measureElementContentWidth(td, $9.get(gridContainer));
|
|
909
|
-
calculatedWidth = Math.max(calculatedWidth, cellW + 20);
|
|
910
|
-
}
|
|
911
|
-
}
|
|
912
|
-
}
|
|
913
|
-
}
|
|
914
|
-
if (calculatedWidth > 0) {
|
|
915
|
-
const finalWidth = Math.min(600, Math.max(50, Math.ceil(calculatedWidth)));
|
|
916
|
-
sheetState().setColumnWidth(colId, finalWidth);
|
|
917
|
-
} else {
|
|
918
|
-
sheetState().autoFitColumnWidth(colId);
|
|
919
|
-
}
|
|
920
|
-
const updatedCol = sheetState().document.columns.find((c) => c.id === colId);
|
|
921
|
-
if (updatedCol && $$props.onColumnResize) {
|
|
922
|
-
$$props.onColumnResize(updatedCol.id, updatedCol.width || 130);
|
|
923
|
-
}
|
|
924
|
-
}
|
|
925
|
-
function handleResizeDblClick(colId, colIndex, e) {
|
|
926
|
-
e.preventDefault();
|
|
927
|
-
e.stopPropagation();
|
|
928
|
-
autoFitColumn(colId, colIndex);
|
|
929
|
-
}
|
|
930
|
-
function handleHeaderDblClick(colId, colIndex, e) {
|
|
931
|
-
const target = e.currentTarget;
|
|
932
|
-
if (target) {
|
|
933
|
-
const rect = target.getBoundingClientRect();
|
|
934
|
-
if (rect.right - e.clientX <= 12) {
|
|
935
|
-
e.preventDefault();
|
|
936
|
-
e.stopPropagation();
|
|
937
|
-
autoFitColumn(colId, colIndex);
|
|
938
|
-
}
|
|
939
|
-
}
|
|
940
|
-
}
|
|
941
|
-
function isCellSelected(rIdx, cIdx) {
|
|
942
|
-
if (!sheetState().selectedRange) return false;
|
|
943
|
-
const minR = Math.min(sheetState().selectedRange.startRow, sheetState().selectedRange.endRow);
|
|
944
|
-
const maxR = Math.max(sheetState().selectedRange.startRow, sheetState().selectedRange.endRow);
|
|
945
|
-
const minC = Math.min(sheetState().selectedRange.startCol, sheetState().selectedRange.endCol);
|
|
946
|
-
const maxC = Math.max(sheetState().selectedRange.startCol, sheetState().selectedRange.endCol);
|
|
947
|
-
return rIdx >= minR && rIdx <= maxR && cIdx >= minC && cIdx <= maxC;
|
|
948
|
-
}
|
|
949
|
-
function isActiveCell(rIdx, cIdx) {
|
|
950
|
-
return sheetState().activeCell?.row === rIdx && sheetState().activeCell?.col === cIdx;
|
|
951
|
-
}
|
|
952
|
-
var div = root_7();
|
|
953
|
-
var node_1 = $9.child(div);
|
|
954
|
-
{
|
|
955
|
-
var consequent = ($$anchor2) => {
|
|
956
|
-
FormulaBar($$anchor2, {
|
|
957
|
-
get sheetState() {
|
|
958
|
-
return sheetState();
|
|
959
|
-
}
|
|
960
|
-
});
|
|
961
|
-
};
|
|
962
|
-
$9.if(node_1, ($$render) => {
|
|
963
|
-
if (showFormulaBar()) $$render(consequent);
|
|
964
|
-
});
|
|
965
|
-
}
|
|
966
|
-
var div_1 = $9.sibling(node_1, 2);
|
|
967
|
-
var table_1 = $9.child(div_1);
|
|
968
|
-
var thead = $9.child(table_1);
|
|
969
|
-
var tr_1 = $9.child(thead);
|
|
970
|
-
var node_2 = $9.sibling($9.child(tr_1));
|
|
971
|
-
$9.each(node_2, 19, () => sheetState().document.columns, (col) => col.id, ($$anchor2, col, cIdx) => {
|
|
972
|
-
var th_1 = root5();
|
|
973
|
-
var div_2 = $9.child(th_1);
|
|
974
|
-
var span = $9.child(div_2);
|
|
975
|
-
var text = $9.only_child(span, true);
|
|
976
|
-
var span_1 = $9.sibling(span, 2);
|
|
977
|
-
var text_1 = $9.only_child(span_1);
|
|
978
|
-
$9.reset(div_2);
|
|
979
|
-
var div_3 = $9.sibling(div_2, 2);
|
|
980
|
-
var div_4 = $9.only_child(div_3);
|
|
981
|
-
$9.reset(th_1);
|
|
982
|
-
$9.template_effect(() => {
|
|
983
|
-
$9.set_class(th_1, 1, `relative border-r border-border px-2 text-left font-medium text-muted-foreground hover:bg-muted/90 transition-colors group overflow-hidden max-w-0 ${$$props.onColumnHeaderClick ? "cursor-pointer" : "cursor-default"}`, "svelte-m799ch");
|
|
984
|
-
$9.set_style(th_1, `width: ${($9.get(col).width || 130) ?? ""}px; min-width: ${($9.get(col).width || 130) ?? ""}px; max-width: ${($9.get(col).width || 130) ?? ""}px; overflow: hidden;`);
|
|
985
|
-
$9.set_text(text, $9.get(col).title);
|
|
986
|
-
$9.set_text(text_1, `(${$9.get(col).key ?? ""})`);
|
|
987
|
-
$9.set_style(div_4, `width: 2px; height: 100%; pointer-events: none; transition: background-color 150ms ease; background-color: ${$9.get(resizingColId) === $9.get(col).id ? "var(--primary, #6366f1)" : $9.get(hoveredColId) === $9.get(col).id ? "color-mix(in srgb, var(--primary, #6366f1) 75%, transparent)" : "transparent"};`);
|
|
988
|
-
});
|
|
989
|
-
$9.delegated("click", th_1, () => $$props.onColumnHeaderClick?.($9.get(col)));
|
|
990
|
-
$9.delegated("dblclick", th_1, (e) => handleHeaderDblClick($9.get(col).id, $9.get(cIdx), e));
|
|
991
|
-
$9.event("mouseenter", div_3, () => $9.set(hoveredColId, $9.get(col).id, true));
|
|
992
|
-
$9.event("mouseleave", div_3, () => {
|
|
993
|
-
if ($9.get(hoveredColId) === $9.get(col).id) $9.set(hoveredColId, null);
|
|
994
|
-
});
|
|
995
|
-
$9.delegated("mousedown", div_3, (e) => handleResizeStart($9.get(col).id, $9.get(col).width || 130, e));
|
|
996
|
-
$9.delegated("dblclick", div_3, (e) => handleResizeDblClick($9.get(col).id, $9.get(cIdx), e));
|
|
997
|
-
$9.append($$anchor2, th_1);
|
|
998
|
-
});
|
|
999
|
-
var node_3 = $9.sibling(node_2);
|
|
1000
|
-
{
|
|
1001
|
-
var consequent_1 = ($$anchor2) => {
|
|
1002
|
-
var th_2 = root_13();
|
|
1003
|
-
$9.delegated("click", th_2, function(...$$args) {
|
|
1004
|
-
$$props.onAddColumnClick?.apply(this, $$args);
|
|
1005
|
-
});
|
|
1006
|
-
$9.append($$anchor2, th_2);
|
|
1007
|
-
};
|
|
1008
|
-
$9.if(node_3, ($$render) => {
|
|
1009
|
-
if ($$props.onAddColumnClick) $$render(consequent_1);
|
|
1010
|
-
});
|
|
1011
|
-
}
|
|
1012
|
-
$9.next();
|
|
1013
|
-
$9.reset(tr_1);
|
|
1014
|
-
$9.reset(thead);
|
|
1015
|
-
var tbody = $9.sibling(thead);
|
|
1016
|
-
$9.each(tbody, 23, () => sheetState().document.rows, (row) => row.id, ($$anchor2, row, rIdx) => {
|
|
1017
|
-
var tr_2 = root_6();
|
|
1018
|
-
var td_1 = $9.child(tr_2);
|
|
1019
|
-
var text_2 = $9.only_child(td_1, true);
|
|
1020
|
-
var node_4 = $9.sibling(td_1);
|
|
1021
|
-
$9.each(node_4, 19, () => sheetState().document.columns, (col) => col.id, ($$anchor3, col, cIdx) => {
|
|
1022
|
-
const cell = $9.derived(() => sheetState().getCell($9.get(row).id, $9.get(col).id));
|
|
1023
|
-
const selected = $9.derived(() => isCellSelected($9.get(rIdx), $9.get(cIdx)));
|
|
1024
|
-
const active = $9.derived(() => isActiveCell($9.get(rIdx), $9.get(cIdx)));
|
|
1025
|
-
const isEditing = $9.derived(() => sheetState().editingCell?.row === $9.get(rIdx) && sheetState().editingCell?.col === $9.get(cIdx));
|
|
1026
|
-
var td_2 = root_42();
|
|
1027
|
-
var node_5 = $9.child(td_2);
|
|
1028
|
-
{
|
|
1029
|
-
var consequent_2 = ($$anchor4) => {
|
|
1030
|
-
var input = root_22();
|
|
1031
|
-
$9.remove_input_defaults(input);
|
|
1032
|
-
$9.event("blur", input, () => sheetState().commitEditing());
|
|
1033
|
-
$9.bind_value(input, () => sheetState().draftValue, ($$value) => sheetState().draftValue = $$value);
|
|
1034
|
-
$9.append($$anchor4, input);
|
|
1035
|
-
};
|
|
1036
|
-
var consequent_3 = ($$anchor4) => {
|
|
1037
|
-
const cellArg = $9.derived(() => Object.assign({ row: $9.get(row), col: $9.get(col), cell: $9.get(cell) }, $9.get(cell)));
|
|
1038
|
-
var fragment_1 = $9.comment();
|
|
1039
|
-
var node_6 = $9.first_child(fragment_1);
|
|
1040
|
-
$9.snippet(node_6, () => $$props.customCellRenderer, () => $9.get(cellArg), () => $9.get(col), () => $9.get(row));
|
|
1041
|
-
$9.append($$anchor4, fragment_1);
|
|
1042
|
-
};
|
|
1043
|
-
var alternate = ($$anchor4) => {
|
|
1044
|
-
var span_2 = root_32();
|
|
1045
|
-
var text_3 = $9.only_child(span_2, true);
|
|
1046
|
-
$9.template_effect(() => {
|
|
1047
|
-
$9.set_class(span_2, 1, `truncate block max-w-full ${$9.get(cell).error ? "text-destructive font-semibold" : ""}`);
|
|
1048
|
-
$9.set_text(text_3, $9.get(cell).error || ($9.get(cell).value ?? ""));
|
|
1049
|
-
});
|
|
1050
|
-
$9.append($$anchor4, span_2);
|
|
1051
|
-
};
|
|
1052
|
-
$9.if(node_5, ($$render) => {
|
|
1053
|
-
if ($9.get(isEditing)) $$render(consequent_2);
|
|
1054
|
-
else if ($$props.customCellRenderer) $$render(consequent_3, 1);
|
|
1055
|
-
else $$render(alternate, -1);
|
|
1056
|
-
});
|
|
1057
|
-
}
|
|
1058
|
-
$9.reset(td_2);
|
|
1059
|
-
$9.template_effect(() => $9.set_class(td_2, 1, `relative border-r border-border px-2 py-1 truncate max-w-0 text-foreground transition-colors ${$9.get(selected) ? "bg-primary/10" : ""} ${$9.get(active) ? "ring-2 ring-primary ring-inset z-10" : ""}`, "svelte-m799ch"));
|
|
1060
|
-
$9.delegated("click", td_2, (e) => handleCellClick($9.get(rIdx), $9.get(cIdx), e));
|
|
1061
|
-
$9.delegated("dblclick", td_2, () => handleCellDblClick($9.get(rIdx), $9.get(cIdx)));
|
|
1062
|
-
$9.append($$anchor3, td_2);
|
|
1063
|
-
});
|
|
1064
|
-
var node_7 = $9.sibling(node_4);
|
|
1065
|
-
{
|
|
1066
|
-
var consequent_4 = ($$anchor3) => {
|
|
1067
|
-
var td_3 = root_5();
|
|
1068
|
-
$9.append($$anchor3, td_3);
|
|
1069
|
-
};
|
|
1070
|
-
$9.if(node_7, ($$render) => {
|
|
1071
|
-
if ($$props.onAddColumnClick) $$render(consequent_4);
|
|
1072
|
-
});
|
|
1073
|
-
}
|
|
1074
|
-
$9.next();
|
|
1075
|
-
$9.reset(tr_2);
|
|
1076
|
-
$9.template_effect(() => {
|
|
1077
|
-
$9.set_style(tr_2, `height: ${($9.get(row).height || 32) ?? ""}px;`);
|
|
1078
|
-
$9.set_text(text_2, $9.get(rIdx) + 1);
|
|
1079
|
-
});
|
|
1080
|
-
$9.append($$anchor2, tr_2);
|
|
1081
|
-
});
|
|
1082
|
-
$9.reset(tbody);
|
|
1083
|
-
$9.reset(table_1);
|
|
1084
|
-
$9.reset(div_1);
|
|
1085
|
-
$9.reset(div);
|
|
1086
|
-
$9.bind_this(div, ($$value) => $9.set(gridContainer, $$value), () => $9.get(gridContainer));
|
|
1087
|
-
$9.template_effect(() => $9.set_class(div, 1, `flex flex-col h-full w-full overflow-hidden border border-border bg-background select-none outline-none text-foreground font-sans text-xs ${className() ?? ""}`, "svelte-m799ch"));
|
|
1088
|
-
$9.delegated("keydown", div, handleKeyDown);
|
|
1089
|
-
$9.append($$anchor, div);
|
|
1090
|
-
$9.pop();
|
|
1091
|
-
}
|
|
1092
|
-
$9.delegate(["keydown", "click", "dblclick", "mousedown"]);
|
|
1093
|
-
|
|
1094
|
-
// src/index.ts
|
|
1095
|
-
var EditableTextNodeEditor2 = EditableTextNodeEditor;
|
|
1096
|
-
var BubbleMenu2 = BubbleMenu;
|
|
1097
|
-
var TemplateRenderer2 = TemplateRenderer;
|
|
1098
|
-
export {
|
|
1099
|
-
BubbleMenu2 as BubbleMenu,
|
|
1100
|
-
DirtyTracker,
|
|
1101
|
-
EditableTextNodeEditor2 as EditableTextNodeEditor,
|
|
1102
|
-
FormulaBar,
|
|
1103
|
-
HistoryManager2 as HistoryManager,
|
|
1104
|
-
ImageEditor,
|
|
1105
|
-
SpreadsheetEditor,
|
|
1106
|
-
TemplateRenderer2 as TemplateRenderer,
|
|
1107
|
-
createDirtyTracker,
|
|
1108
|
-
createHistory,
|
|
1109
|
-
createHistoryManager2 as createHistoryManager,
|
|
1110
|
-
createHistoryShortcuts,
|
|
1111
|
-
createNavigationGuard,
|
|
1112
|
-
createReactiveEditor,
|
|
1113
|
-
createReactiveImageEditor,
|
|
1114
|
-
createReactiveSpreadsheet,
|
|
1115
|
-
defaultIsEqual,
|
|
1116
|
-
initiateEditor,
|
|
1117
|
-
navigationGuard
|
|
1118
|
-
};
|
|
1119
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
export * from "./editor.svelte.js";
|
|
2
|
+
export * from "./navigationGuard.js";
|
|
3
|
+
export * from "./createNavigationGuard.svelte.js";
|
|
4
|
+
export * from "./history/index.js";
|
|
5
|
+
export { DirtyTracker, createDirtyTracker, defaultIsEqual, HistoryManager, createHistoryManager, } from "@pixerate/editor";
|
|
6
|
+
export { default as EditableTextNodeEditor } from "./EditableTextNodeEditor.svelte";
|
|
7
|
+
export { default as BubbleMenu } from "./BubbleMenu.svelte";
|
|
8
|
+
export { default as TemplateRenderer } from "./TemplateRenderer.svelte";
|
|
9
|
+
export * from "./spreadsheet/index.js";
|
|
10
|
+
export * from "./image-editor/index.js";
|