@templatical/core 0.0.6 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs DELETED
@@ -1,548 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/index.ts
21
- var index_exports = {};
22
- __export(index_exports, {
23
- useAutoSave: () => useAutoSave,
24
- useBlockActions: () => useBlockActions,
25
- useConditionPreview: () => useConditionPreview,
26
- useDataSourceFetch: () => useDataSourceFetch,
27
- useEditor: () => useEditor,
28
- useHistory: () => useHistory,
29
- useHistoryInterceptor: () => useHistoryInterceptor
30
- });
31
- module.exports = __toCommonJS(index_exports);
32
-
33
- // src/editor.ts
34
- var import_types = require("@templatical/types");
35
- var import_reactivity = require("@vue/reactivity");
36
- function useEditor(options) {
37
- const state = (0, import_reactivity.reactive)({
38
- content: options.content ?? (0, import_types.createDefaultTemplateContent)(
39
- options.defaultFontFamily,
40
- options.templateDefaults
41
- ),
42
- selectedBlockId: null,
43
- viewport: "desktop",
44
- darkMode: false,
45
- previewMode: false,
46
- isDirty: false,
47
- uiTheme: "auto"
48
- });
49
- const content = (0, import_reactivity.computed)({
50
- get: () => state.content,
51
- set: (value) => {
52
- state.content = value;
53
- state.isDirty = true;
54
- }
55
- });
56
- const selectedBlock = (0, import_reactivity.computed)(() => {
57
- if (!state.selectedBlockId) return null;
58
- return findBlockById(state.content.blocks, state.selectedBlockId);
59
- });
60
- function findBlockById(blocks, id) {
61
- for (const block of blocks) {
62
- if (block.id === id) return block;
63
- if (block.type === "section") {
64
- for (const column of block.children) {
65
- const found = findBlockById(column, id);
66
- if (found) return found;
67
- }
68
- }
69
- }
70
- return null;
71
- }
72
- function findBlockParent(blocks, id, parent = { blocks }) {
73
- for (let i = 0; i < blocks.length; i++) {
74
- const block = blocks[i];
75
- if (block.id === id) return parent;
76
- if (block.type === "section") {
77
- for (let colIdx = 0; colIdx < block.children.length; colIdx++) {
78
- const result = findBlockParent(block.children[colIdx], id, {
79
- blocks: block.children[colIdx],
80
- sectionId: block.id,
81
- columnIndex: colIdx
82
- });
83
- if (result) return result;
84
- }
85
- }
86
- }
87
- return null;
88
- }
89
- function isBlockLocked(blockId) {
90
- return options.lockedBlocks?.value.has(blockId) ?? false;
91
- }
92
- function setContent(newContent, markDirty2 = true) {
93
- state.content = newContent;
94
- if (markDirty2) {
95
- state.isDirty = true;
96
- }
97
- }
98
- function selectBlock(blockId) {
99
- if (blockId && isBlockLocked(blockId)) {
100
- return;
101
- }
102
- state.selectedBlockId = blockId;
103
- }
104
- function setViewport(viewport) {
105
- state.viewport = viewport;
106
- }
107
- function setDarkMode(darkMode) {
108
- state.darkMode = darkMode;
109
- }
110
- function setUiTheme(theme) {
111
- state.uiTheme = theme;
112
- }
113
- function setPreviewMode(previewMode) {
114
- state.previewMode = previewMode;
115
- if (previewMode) {
116
- state.selectedBlockId = null;
117
- }
118
- }
119
- function updateBlock(blockId, updates) {
120
- if (isBlockLocked(blockId)) {
121
- return;
122
- }
123
- const block = findBlockById(state.content.blocks, blockId);
124
- if (block) {
125
- Object.assign(block, updates);
126
- state.isDirty = true;
127
- }
128
- }
129
- function updateSettings(updates) {
130
- state.content.settings = { ...state.content.settings, ...updates };
131
- state.isDirty = true;
132
- }
133
- function addBlock(block, targetSectionId, columnIndex = 0, index) {
134
- if (targetSectionId) {
135
- const section = findBlockById(state.content.blocks, targetSectionId);
136
- if (section && section.type === "section") {
137
- section.children[columnIndex] = section.children[columnIndex] || [];
138
- const targetArray = section.children[columnIndex];
139
- if (index !== void 0 && index < targetArray.length) {
140
- targetArray.splice(index, 0, block);
141
- } else {
142
- targetArray.push(block);
143
- }
144
- }
145
- } else {
146
- if (index !== void 0 && index < state.content.blocks.length) {
147
- state.content.blocks.splice(index, 0, block);
148
- } else {
149
- state.content.blocks.push(block);
150
- }
151
- }
152
- state.isDirty = true;
153
- }
154
- function removeBlock(blockId) {
155
- if (isBlockLocked(blockId)) {
156
- return;
157
- }
158
- const parent = findBlockParent(state.content.blocks, blockId);
159
- if (parent) {
160
- const index = parent.blocks.findIndex((b) => b.id === blockId);
161
- if (index !== -1) {
162
- parent.blocks.splice(index, 1);
163
- if (state.selectedBlockId === blockId) {
164
- state.selectedBlockId = null;
165
- }
166
- state.isDirty = true;
167
- }
168
- }
169
- }
170
- function moveBlock(blockId, newIndex, targetSectionId, columnIndex = 0) {
171
- const parent = findBlockParent(state.content.blocks, blockId);
172
- if (!parent) return;
173
- const oldIndex = parent.blocks.findIndex((b) => b.id === blockId);
174
- if (oldIndex === -1) return;
175
- const [block] = parent.blocks.splice(oldIndex, 1);
176
- if (targetSectionId) {
177
- const section = findBlockById(state.content.blocks, targetSectionId);
178
- if (section && section.type === "section") {
179
- section.children[columnIndex] = section.children[columnIndex] || [];
180
- section.children[columnIndex].splice(newIndex, 0, block);
181
- }
182
- } else {
183
- state.content.blocks.splice(newIndex, 0, block);
184
- }
185
- state.isDirty = true;
186
- }
187
- function markDirty() {
188
- state.isDirty = true;
189
- }
190
- return {
191
- state: (0, import_reactivity.readonly)(state),
192
- content,
193
- selectedBlock,
194
- isBlockLocked,
195
- setContent,
196
- selectBlock,
197
- setViewport,
198
- setDarkMode,
199
- setUiTheme,
200
- setPreviewMode,
201
- updateBlock,
202
- updateSettings,
203
- addBlock,
204
- removeBlock,
205
- moveBlock,
206
- markDirty
207
- };
208
- }
209
-
210
- // src/history.ts
211
- var import_reactivity2 = require("@vue/reactivity");
212
- var MAX_STACK_SIZE = 50;
213
- var DEBOUNCE_MS = 300;
214
- var NAVIGATE_IDLE_MS = 1500;
215
- function useHistory(options) {
216
- const {
217
- content,
218
- setContent,
219
- isRemoteOperation,
220
- maxSize = MAX_STACK_SIZE
221
- } = options;
222
- const undoStack = (0, import_reactivity2.ref)([]);
223
- const redoStack = (0, import_reactivity2.ref)([]);
224
- const isNavigating = (0, import_reactivity2.ref)(false);
225
- let navigatingTimeoutId = null;
226
- let pendingDebounce = null;
227
- const canUndo = (0, import_reactivity2.computed)(() => undoStack.value.length > 0);
228
- const canRedo = (0, import_reactivity2.computed)(() => redoStack.value.length > 0);
229
- function cloneContent() {
230
- return JSON.parse(JSON.stringify(content.value));
231
- }
232
- function pushToUndoStack(snapshot) {
233
- undoStack.value.push(snapshot);
234
- if (undoStack.value.length > maxSize) {
235
- undoStack.value.splice(0, undoStack.value.length - maxSize);
236
- }
237
- }
238
- function flushPendingDebounce() {
239
- if (pendingDebounce) {
240
- clearTimeout(pendingDebounce.timeoutId);
241
- pendingDebounce = null;
242
- }
243
- }
244
- function record() {
245
- if (isRemoteOperation?.()) {
246
- return;
247
- }
248
- flushPendingDebounce();
249
- pushToUndoStack(cloneContent());
250
- redoStack.value = [];
251
- }
252
- function recordDebounced(blockId) {
253
- if (isRemoteOperation?.()) {
254
- return;
255
- }
256
- if (pendingDebounce && pendingDebounce.blockId === blockId) {
257
- clearTimeout(pendingDebounce.timeoutId);
258
- pendingDebounce.timeoutId = setTimeout(() => {
259
- pendingDebounce = null;
260
- }, DEBOUNCE_MS);
261
- return;
262
- }
263
- flushPendingDebounce();
264
- pushToUndoStack(cloneContent());
265
- redoStack.value = [];
266
- pendingDebounce = {
267
- blockId,
268
- timeoutId: setTimeout(() => {
269
- pendingDebounce = null;
270
- }, DEBOUNCE_MS)
271
- };
272
- }
273
- function setNavigating() {
274
- isNavigating.value = true;
275
- if (navigatingTimeoutId) {
276
- clearTimeout(navigatingTimeoutId);
277
- }
278
- navigatingTimeoutId = setTimeout(() => {
279
- isNavigating.value = false;
280
- navigatingTimeoutId = null;
281
- }, NAVIGATE_IDLE_MS);
282
- }
283
- function undo() {
284
- if (undoStack.value.length === 0) {
285
- return;
286
- }
287
- flushPendingDebounce();
288
- const snapshot = undoStack.value.pop();
289
- redoStack.value.push(cloneContent());
290
- setContent(snapshot, true);
291
- setNavigating();
292
- }
293
- function redo() {
294
- if (redoStack.value.length === 0) {
295
- return;
296
- }
297
- flushPendingDebounce();
298
- const snapshot = redoStack.value.pop();
299
- undoStack.value.push(cloneContent());
300
- setContent(snapshot, true);
301
- setNavigating();
302
- }
303
- function clear() {
304
- undoStack.value = [];
305
- redoStack.value = [];
306
- flushPendingDebounce();
307
- }
308
- function destroy() {
309
- clear();
310
- if (navigatingTimeoutId) {
311
- clearTimeout(navigatingTimeoutId);
312
- navigatingTimeoutId = null;
313
- }
314
- }
315
- return {
316
- canUndo,
317
- canRedo,
318
- isNavigating,
319
- undo,
320
- redo,
321
- record,
322
- recordDebounced,
323
- clear,
324
- destroy
325
- };
326
- }
327
-
328
- // src/block-actions.ts
329
- var import_types2 = require("@templatical/types");
330
- function useBlockActions(options) {
331
- const { addBlock, removeBlock, updateBlock, selectBlock } = options;
332
- function createAndAddBlock(type, targetSectionId, columnIndex) {
333
- const block = (0, import_types2.createBlock)(type, options.blockDefaults);
334
- addBlock(block, targetSectionId, columnIndex);
335
- selectBlock(block.id);
336
- return block;
337
- }
338
- function duplicateBlock(block, targetSectionId, columnIndex) {
339
- const cloned = JSON.parse(JSON.stringify(block));
340
- cloned.id = (0, import_types2.generateId)();
341
- if (cloned.type === "section") {
342
- cloned.children = cloned.children.map(
343
- (column) => column.map((child) => {
344
- const clonedChild = JSON.parse(JSON.stringify(child));
345
- clonedChild.id = (0, import_types2.generateId)();
346
- return clonedChild;
347
- })
348
- );
349
- }
350
- addBlock(cloned, targetSectionId, columnIndex);
351
- selectBlock(cloned.id);
352
- return cloned;
353
- }
354
- function deleteBlock(blockId) {
355
- removeBlock(blockId);
356
- }
357
- function updateBlockProperty(blockId, key, value) {
358
- updateBlock(blockId, { [key]: value });
359
- }
360
- return {
361
- createAndAddBlock,
362
- duplicateBlock,
363
- deleteBlock,
364
- updateBlockProperty
365
- };
366
- }
367
-
368
- // src/auto-save.ts
369
- var import_reactivity3 = require("@vue/reactivity");
370
- function useAutoSave(options) {
371
- const {
372
- content,
373
- isDirty,
374
- onChange,
375
- debounce = 1e3,
376
- enabled = true
377
- } = options;
378
- let timeoutId = null;
379
- let paused = false;
380
- function isEnabled() {
381
- return typeof enabled === "function" ? enabled() : enabled;
382
- }
383
- function pause() {
384
- paused = true;
385
- cancel();
386
- }
387
- function resume() {
388
- paused = false;
389
- }
390
- function cancel() {
391
- if (timeoutId) {
392
- clearTimeout(timeoutId);
393
- timeoutId = null;
394
- }
395
- }
396
- function flush() {
397
- cancel();
398
- if (isDirty()) {
399
- onChange(JSON.parse(JSON.stringify(content.value)));
400
- }
401
- }
402
- function scheduleOnChange() {
403
- if (!isEnabled() || paused) return;
404
- cancel();
405
- timeoutId = setTimeout(() => {
406
- timeoutId = null;
407
- if (isDirty()) {
408
- onChange(JSON.parse(JSON.stringify(content.value)));
409
- }
410
- }, debounce);
411
- }
412
- const stopWatch = (0, import_reactivity3.watch)(
413
- content,
414
- () => {
415
- if (isEnabled() && !paused && isDirty()) {
416
- scheduleOnChange();
417
- }
418
- },
419
- { deep: true }
420
- );
421
- function destroy() {
422
- stopWatch();
423
- cancel();
424
- }
425
- return {
426
- flush,
427
- cancel,
428
- pause,
429
- resume,
430
- destroy
431
- };
432
- }
433
-
434
- // src/condition-preview.ts
435
- var import_reactivity4 = require("@vue/reactivity");
436
- function useConditionPreview(editor) {
437
- const hiddenBlockIds = (0, import_reactivity4.reactive)(/* @__PURE__ */ new Set());
438
- const hasHiddenBlocks = (0, import_reactivity4.computed)(() => hiddenBlockIds.size > 0);
439
- function isHidden(blockId) {
440
- return hiddenBlockIds.has(blockId);
441
- }
442
- function toggleBlock(blockId) {
443
- if (hiddenBlockIds.has(blockId)) {
444
- hiddenBlockIds.delete(blockId);
445
- } else {
446
- hiddenBlockIds.add(blockId);
447
- if (editor.state.selectedBlockId === blockId) {
448
- editor.selectBlock(null);
449
- }
450
- }
451
- }
452
- function reset() {
453
- hiddenBlockIds.clear();
454
- }
455
- return {
456
- isHidden,
457
- toggleBlock,
458
- reset,
459
- hasHiddenBlocks
460
- };
461
- }
462
-
463
- // src/data-source-fetch.ts
464
- var import_reactivity5 = require("@vue/reactivity");
465
- function useDataSourceFetch(options) {
466
- const isFetching = (0, import_reactivity5.ref)(false);
467
- const fetchError = (0, import_reactivity5.ref)(false);
468
- const hasDataSource = (0, import_reactivity5.computed)(() => !!options.definition.value?.dataSource);
469
- const needsFetch = (0, import_reactivity5.computed)(
470
- () => hasDataSource.value && !options.block.value.dataSourceFetched
471
- );
472
- async function fetch() {
473
- const def = options.definition.value;
474
- if (!def?.dataSource) {
475
- return;
476
- }
477
- isFetching.value = true;
478
- fetchError.value = false;
479
- try {
480
- const result = await def.dataSource.onFetch({
481
- fieldValues: { ...options.block.value.fieldValues },
482
- blockId: options.block.value.id
483
- });
484
- if (result == null) {
485
- return;
486
- }
487
- const merged = { ...options.block.value.fieldValues };
488
- for (const key of Object.keys(merged)) {
489
- if (key in result) {
490
- merged[key] = result[key];
491
- }
492
- }
493
- options.onUpdate(merged, true);
494
- } catch (error) {
495
- console.warn("[Templatical] Data source fetch error:", error);
496
- fetchError.value = true;
497
- } finally {
498
- isFetching.value = false;
499
- }
500
- }
501
- return {
502
- isFetching,
503
- fetchError,
504
- fetch,
505
- hasDataSource,
506
- needsFetch
507
- };
508
- }
509
-
510
- // src/history-interceptor.ts
511
- function useHistoryInterceptor(editor, history) {
512
- const originalAddBlock = editor.addBlock;
513
- const originalRemoveBlock = editor.removeBlock;
514
- const originalMoveBlock = editor.moveBlock;
515
- const originalUpdateBlock = editor.updateBlock;
516
- const originalUpdateSettings = editor.updateSettings;
517
- editor.addBlock = (block, targetSectionId, columnIndex, index) => {
518
- history.record();
519
- originalAddBlock(block, targetSectionId, columnIndex, index);
520
- };
521
- editor.removeBlock = (blockId) => {
522
- history.record();
523
- originalRemoveBlock(blockId);
524
- };
525
- editor.moveBlock = (blockId, newIndex, targetSectionId, columnIndex) => {
526
- history.record();
527
- originalMoveBlock(blockId, newIndex, targetSectionId, columnIndex);
528
- };
529
- editor.updateBlock = (blockId, updates) => {
530
- history.recordDebounced(blockId);
531
- originalUpdateBlock(blockId, updates);
532
- };
533
- editor.updateSettings = (updates) => {
534
- history.record();
535
- originalUpdateSettings(updates);
536
- };
537
- }
538
- // Annotate the CommonJS export names for ESM import in node:
539
- 0 && (module.exports = {
540
- useAutoSave,
541
- useBlockActions,
542
- useConditionPreview,
543
- useDataSourceFetch,
544
- useEditor,
545
- useHistory,
546
- useHistoryInterceptor
547
- });
548
- //# sourceMappingURL=index.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/index.ts","../src/editor.ts","../src/history.ts","../src/block-actions.ts","../src/auto-save.ts","../src/condition-preview.ts","../src/data-source-fetch.ts","../src/history-interceptor.ts"],"sourcesContent":["// Editor state\nexport { useEditor } from \"./editor\";\nexport type { EditorState, UseEditorOptions, UseEditorReturn } from \"./editor\";\n\n// History (undo/redo)\nexport { useHistory } from \"./history\";\nexport type { UseHistoryOptions, UseHistoryReturn } from \"./history\";\n\n// Block actions\nexport { useBlockActions } from \"./block-actions\";\nexport type {\n UseBlockActionsOptions,\n UseBlockActionsReturn,\n} from \"./block-actions\";\n\n// Auto-save\nexport { useAutoSave } from \"./auto-save\";\nexport type { UseAutoSaveOptions, UseAutoSaveReturn } from \"./auto-save\";\n\n// Display condition preview\nexport { useConditionPreview } from \"./condition-preview\";\nexport type { UseConditionPreviewReturn } from \"./condition-preview\";\n\n// Custom block data source fetching\nexport { useDataSourceFetch } from \"./data-source-fetch\";\n\n// History interceptor\nexport { useHistoryInterceptor } from \"./history-interceptor\";\n","import type {\n Block,\n TemplateContent,\n TemplateDefaults,\n TemplateSettings,\n UiTheme,\n ViewportSize,\n} from \"@templatical/types\";\nimport { createDefaultTemplateContent } from \"@templatical/types\";\nimport {\n computed,\n reactive,\n readonly,\n type DeepReadonly,\n type Ref,\n} from \"@vue/reactivity\";\n\nexport interface EditorState {\n content: TemplateContent;\n selectedBlockId: string | null;\n viewport: ViewportSize;\n darkMode: boolean;\n previewMode: boolean;\n isDirty: boolean;\n uiTheme: UiTheme;\n}\n\nexport interface UseEditorOptions {\n content: TemplateContent;\n defaultFontFamily?: string;\n templateDefaults?: TemplateDefaults;\n lockedBlocks?: Ref<Map<string, unknown>>;\n}\n\nexport interface UseEditorReturn {\n state: DeepReadonly<EditorState>;\n content: Ref<TemplateContent>;\n selectedBlock: Ref<Block | null>;\n setContent: (content: TemplateContent, markDirty?: boolean) => void;\n selectBlock: (blockId: string | null) => void;\n setViewport: (viewport: ViewportSize) => void;\n setDarkMode: (darkMode: boolean) => void;\n setPreviewMode: (previewMode: boolean) => void;\n setUiTheme: (theme: UiTheme) => void;\n updateBlock: (blockId: string, updates: Partial<Block>) => void;\n updateSettings: (updates: Partial<TemplateSettings>) => void;\n addBlock: (\n block: Block,\n targetSectionId?: string,\n columnIndex?: number,\n index?: number,\n ) => void;\n removeBlock: (blockId: string) => void;\n moveBlock: (\n blockId: string,\n newIndex: number,\n targetSectionId?: string,\n columnIndex?: number,\n ) => void;\n isBlockLocked: (blockId: string) => boolean;\n markDirty: () => void;\n}\n\nexport function useEditor(options: UseEditorOptions): UseEditorReturn {\n const state = reactive<EditorState>({\n content:\n options.content ??\n createDefaultTemplateContent(\n options.defaultFontFamily,\n options.templateDefaults,\n ),\n selectedBlockId: null,\n viewport: \"desktop\",\n darkMode: false,\n previewMode: false,\n isDirty: false,\n uiTheme: \"auto\",\n });\n\n const content = computed({\n get: () => state.content,\n set: (value: TemplateContent) => {\n state.content = value;\n state.isDirty = true;\n },\n });\n\n const selectedBlock = computed(() => {\n if (!state.selectedBlockId) return null;\n return findBlockById(state.content.blocks, state.selectedBlockId);\n });\n\n function findBlockById(blocks: Block[], id: string): Block | null {\n for (const block of blocks) {\n if (block.id === id) return block;\n if (block.type === \"section\") {\n for (const column of block.children) {\n const found = findBlockById(column, id);\n if (found) return found;\n }\n }\n }\n return null;\n }\n\n function findBlockParent(\n blocks: Block[],\n id: string,\n parent: {\n blocks: Block[];\n sectionId?: string;\n columnIndex?: number;\n } = { blocks },\n ): { blocks: Block[]; sectionId?: string; columnIndex?: number } | null {\n for (let i = 0; i < blocks.length; i++) {\n const block = blocks[i];\n if (block.id === id) return parent;\n if (block.type === \"section\") {\n for (let colIdx = 0; colIdx < block.children.length; colIdx++) {\n const result = findBlockParent(block.children[colIdx], id, {\n blocks: block.children[colIdx],\n sectionId: block.id,\n columnIndex: colIdx,\n });\n if (result) return result;\n }\n }\n }\n return null;\n }\n\n function isBlockLocked(blockId: string): boolean {\n return options.lockedBlocks?.value.has(blockId) ?? false;\n }\n\n function setContent(newContent: TemplateContent, markDirty = true): void {\n state.content = newContent;\n if (markDirty) {\n state.isDirty = true;\n }\n }\n\n function selectBlock(blockId: string | null): void {\n if (blockId && isBlockLocked(blockId)) {\n return;\n }\n state.selectedBlockId = blockId;\n }\n\n function setViewport(viewport: ViewportSize): void {\n state.viewport = viewport;\n }\n\n function setDarkMode(darkMode: boolean): void {\n state.darkMode = darkMode;\n }\n\n function setUiTheme(theme: UiTheme): void {\n state.uiTheme = theme;\n }\n\n function setPreviewMode(previewMode: boolean): void {\n state.previewMode = previewMode;\n if (previewMode) {\n state.selectedBlockId = null;\n }\n }\n\n function updateBlock(blockId: string, updates: Partial<Block>): void {\n if (isBlockLocked(blockId)) {\n return;\n }\n const block = findBlockById(state.content.blocks, blockId);\n if (block) {\n Object.assign(block, updates);\n state.isDirty = true;\n }\n }\n\n function updateSettings(updates: Partial<TemplateSettings>): void {\n state.content.settings = { ...state.content.settings, ...updates };\n state.isDirty = true;\n }\n\n function addBlock(\n block: Block,\n targetSectionId?: string,\n columnIndex = 0,\n index?: number,\n ): void {\n if (targetSectionId) {\n const section = findBlockById(state.content.blocks, targetSectionId);\n if (section && section.type === \"section\") {\n section.children[columnIndex] = section.children[columnIndex] || [];\n const targetArray = section.children[columnIndex];\n if (index !== undefined && index < targetArray.length) {\n targetArray.splice(index, 0, block);\n } else {\n targetArray.push(block);\n }\n }\n } else {\n if (index !== undefined && index < state.content.blocks.length) {\n state.content.blocks.splice(index, 0, block);\n } else {\n state.content.blocks.push(block);\n }\n }\n state.isDirty = true;\n }\n\n function removeBlock(blockId: string): void {\n if (isBlockLocked(blockId)) {\n return;\n }\n const parent = findBlockParent(state.content.blocks, blockId);\n if (parent) {\n const index = parent.blocks.findIndex((b) => b.id === blockId);\n if (index !== -1) {\n parent.blocks.splice(index, 1);\n if (state.selectedBlockId === blockId) {\n state.selectedBlockId = null;\n }\n state.isDirty = true;\n }\n }\n }\n\n function moveBlock(\n blockId: string,\n newIndex: number,\n targetSectionId?: string,\n columnIndex = 0,\n ): void {\n const parent = findBlockParent(state.content.blocks, blockId);\n if (!parent) return;\n\n const oldIndex = parent.blocks.findIndex((b) => b.id === blockId);\n if (oldIndex === -1) return;\n\n const [block] = parent.blocks.splice(oldIndex, 1);\n\n if (targetSectionId) {\n const section = findBlockById(state.content.blocks, targetSectionId);\n if (section && section.type === \"section\") {\n section.children[columnIndex] = section.children[columnIndex] || [];\n section.children[columnIndex].splice(newIndex, 0, block);\n }\n } else {\n state.content.blocks.splice(newIndex, 0, block);\n }\n\n state.isDirty = true;\n }\n\n function markDirty(): void {\n state.isDirty = true;\n }\n\n return {\n state: readonly(state),\n content,\n selectedBlock,\n isBlockLocked,\n setContent,\n selectBlock,\n setViewport,\n setDarkMode,\n setUiTheme,\n setPreviewMode,\n updateBlock,\n updateSettings,\n addBlock,\n removeBlock,\n moveBlock,\n markDirty,\n };\n}\n","import type { TemplateContent } from \"@templatical/types\";\nimport { computed, ref, type ComputedRef, type Ref } from \"@vue/reactivity\";\n\nexport interface UseHistoryOptions {\n content: Ref<TemplateContent>;\n setContent: (content: TemplateContent, markDirty?: boolean) => void;\n isRemoteOperation?: () => boolean;\n maxSize?: number;\n}\n\nexport interface UseHistoryReturn {\n canUndo: ComputedRef<boolean>;\n canRedo: ComputedRef<boolean>;\n isNavigating: Ref<boolean>;\n undo: () => void;\n redo: () => void;\n record: () => void;\n recordDebounced: (blockId: string) => void;\n clear: () => void;\n destroy: () => void;\n}\n\ninterface DebouncedSnapshot {\n blockId: string;\n timeoutId: ReturnType<typeof setTimeout>;\n}\n\nconst MAX_STACK_SIZE = 50;\nconst DEBOUNCE_MS = 300;\nconst NAVIGATE_IDLE_MS = 1500;\n\nexport function useHistory(options: UseHistoryOptions): UseHistoryReturn {\n const {\n content,\n setContent,\n isRemoteOperation,\n maxSize = MAX_STACK_SIZE,\n } = options;\n\n const undoStack = ref<TemplateContent[]>([]);\n const redoStack = ref<TemplateContent[]>([]);\n const isNavigating = ref(false);\n let navigatingTimeoutId: ReturnType<typeof setTimeout> | null = null;\n let pendingDebounce: DebouncedSnapshot | null = null;\n\n const canUndo = computed(() => undoStack.value.length > 0);\n const canRedo = computed(() => redoStack.value.length > 0);\n\n function cloneContent(): TemplateContent {\n return JSON.parse(JSON.stringify(content.value)) as TemplateContent;\n }\n\n function pushToUndoStack(snapshot: TemplateContent): void {\n undoStack.value.push(snapshot);\n if (undoStack.value.length > maxSize) {\n undoStack.value.splice(0, undoStack.value.length - maxSize);\n }\n }\n\n function flushPendingDebounce(): void {\n if (pendingDebounce) {\n clearTimeout(pendingDebounce.timeoutId);\n pendingDebounce = null;\n }\n }\n\n function record(): void {\n if (isRemoteOperation?.()) {\n return;\n }\n\n flushPendingDebounce();\n pushToUndoStack(cloneContent());\n redoStack.value = [];\n }\n\n function recordDebounced(blockId: string): void {\n if (isRemoteOperation?.()) {\n return;\n }\n\n if (pendingDebounce && pendingDebounce.blockId === blockId) {\n clearTimeout(pendingDebounce.timeoutId);\n pendingDebounce.timeoutId = setTimeout(() => {\n pendingDebounce = null;\n }, DEBOUNCE_MS);\n return;\n }\n\n flushPendingDebounce();\n\n pushToUndoStack(cloneContent());\n redoStack.value = [];\n\n pendingDebounce = {\n blockId,\n timeoutId: setTimeout(() => {\n pendingDebounce = null;\n }, DEBOUNCE_MS),\n };\n }\n\n function setNavigating(): void {\n isNavigating.value = true;\n if (navigatingTimeoutId) {\n clearTimeout(navigatingTimeoutId);\n }\n navigatingTimeoutId = setTimeout(() => {\n isNavigating.value = false;\n navigatingTimeoutId = null;\n }, NAVIGATE_IDLE_MS);\n }\n\n function undo(): void {\n if (undoStack.value.length === 0) {\n return;\n }\n\n flushPendingDebounce();\n\n const snapshot = undoStack.value.pop()!;\n redoStack.value.push(cloneContent());\n setContent(snapshot, true);\n setNavigating();\n }\n\n function redo(): void {\n if (redoStack.value.length === 0) {\n return;\n }\n\n flushPendingDebounce();\n\n const snapshot = redoStack.value.pop()!;\n undoStack.value.push(cloneContent());\n setContent(snapshot, true);\n setNavigating();\n }\n\n function clear(): void {\n undoStack.value = [];\n redoStack.value = [];\n flushPendingDebounce();\n }\n\n function destroy(): void {\n clear();\n if (navigatingTimeoutId) {\n clearTimeout(navigatingTimeoutId);\n navigatingTimeoutId = null;\n }\n }\n\n return {\n canUndo,\n canRedo,\n isNavigating,\n undo,\n redo,\n record,\n recordDebounced,\n clear,\n destroy,\n };\n}\n","import type { Block, BlockDefaults, BlockType } from \"@templatical/types\";\nimport { createBlock, generateId } from \"@templatical/types\";\n\nexport interface UseBlockActionsOptions {\n addBlock: (\n block: Block,\n targetSectionId?: string,\n columnIndex?: number,\n ) => void;\n removeBlock: (blockId: string) => void;\n updateBlock: (blockId: string, updates: Partial<Block>) => void;\n selectBlock: (blockId: string | null) => void;\n blockDefaults?: BlockDefaults;\n}\n\nexport interface UseBlockActionsReturn {\n createAndAddBlock: (\n type: BlockType,\n targetSectionId?: string,\n columnIndex?: number,\n ) => Block;\n duplicateBlock: (\n block: Block,\n targetSectionId?: string,\n columnIndex?: number,\n ) => Block;\n deleteBlock: (blockId: string) => void;\n updateBlockProperty: <K extends keyof Block>(\n blockId: string,\n key: K,\n value: Block[K],\n ) => void;\n}\n\nexport function useBlockActions(\n options: UseBlockActionsOptions,\n): UseBlockActionsReturn {\n const { addBlock, removeBlock, updateBlock, selectBlock } = options;\n\n function createAndAddBlock(\n type: BlockType,\n targetSectionId?: string,\n columnIndex?: number,\n ): Block {\n const block = createBlock(type, options.blockDefaults);\n addBlock(block, targetSectionId, columnIndex);\n selectBlock(block.id);\n return block;\n }\n\n function duplicateBlock(\n block: Block,\n targetSectionId?: string,\n columnIndex?: number,\n ): Block {\n const cloned = JSON.parse(JSON.stringify(block)) as Block;\n cloned.id = generateId();\n\n if (cloned.type === \"section\") {\n cloned.children = cloned.children.map((column) =>\n column.map((child) => {\n const clonedChild = JSON.parse(JSON.stringify(child)) as Block;\n clonedChild.id = generateId();\n return clonedChild;\n }),\n );\n }\n\n addBlock(cloned, targetSectionId, columnIndex);\n selectBlock(cloned.id);\n return cloned;\n }\n\n function deleteBlock(blockId: string): void {\n removeBlock(blockId);\n }\n\n function updateBlockProperty<K extends keyof Block>(\n blockId: string,\n key: K,\n value: Block[K],\n ): void {\n updateBlock(blockId, { [key]: value } as Partial<Block>);\n }\n\n return {\n createAndAddBlock,\n duplicateBlock,\n deleteBlock,\n updateBlockProperty,\n };\n}\n","import type { TemplateContent } from \"@templatical/types\";\nimport { watch, type Ref } from \"@vue/reactivity\";\n\nexport interface UseAutoSaveOptions {\n content: Ref<TemplateContent>;\n isDirty: () => boolean;\n onChange: (content: TemplateContent) => void;\n debounce?: number;\n enabled?: boolean | (() => boolean);\n}\n\nexport interface UseAutoSaveReturn {\n flush: () => void;\n cancel: () => void;\n pause: () => void;\n resume: () => void;\n destroy: () => void;\n}\n\nexport function useAutoSave(options: UseAutoSaveOptions): UseAutoSaveReturn {\n const {\n content,\n isDirty,\n onChange,\n debounce = 1000,\n enabled = true,\n } = options;\n\n let timeoutId: ReturnType<typeof setTimeout> | null = null;\n let paused = false;\n\n function isEnabled(): boolean {\n return typeof enabled === \"function\" ? enabled() : enabled;\n }\n\n function pause(): void {\n paused = true;\n cancel();\n }\n\n function resume(): void {\n paused = false;\n }\n\n function cancel(): void {\n if (timeoutId) {\n clearTimeout(timeoutId);\n timeoutId = null;\n }\n }\n\n function flush(): void {\n cancel();\n if (isDirty()) {\n onChange(JSON.parse(JSON.stringify(content.value)));\n }\n }\n\n function scheduleOnChange(): void {\n if (!isEnabled() || paused) return;\n\n cancel();\n timeoutId = setTimeout(() => {\n timeoutId = null;\n if (isDirty()) {\n onChange(JSON.parse(JSON.stringify(content.value)));\n }\n }, debounce);\n }\n\n const stopWatch = watch(\n content,\n () => {\n if (isEnabled() && !paused && isDirty()) {\n scheduleOnChange();\n }\n },\n { deep: true },\n );\n\n function destroy(): void {\n stopWatch();\n cancel();\n }\n\n return {\n flush,\n cancel,\n pause,\n resume,\n destroy,\n };\n}\n","import type { UseEditorReturn } from \"./editor\";\nimport { computed, reactive, type ComputedRef } from \"@vue/reactivity\";\n\nexport interface UseConditionPreviewReturn {\n isHidden: (blockId: string) => boolean;\n toggleBlock: (blockId: string) => void;\n reset: () => void;\n hasHiddenBlocks: ComputedRef<boolean>;\n}\n\nexport function useConditionPreview(\n editor: UseEditorReturn,\n): UseConditionPreviewReturn {\n const hiddenBlockIds = reactive(new Set<string>());\n\n const hasHiddenBlocks = computed(() => hiddenBlockIds.size > 0);\n\n function isHidden(blockId: string): boolean {\n return hiddenBlockIds.has(blockId);\n }\n\n function toggleBlock(blockId: string): void {\n if (hiddenBlockIds.has(blockId)) {\n hiddenBlockIds.delete(blockId);\n } else {\n hiddenBlockIds.add(blockId);\n\n if (editor.state.selectedBlockId === blockId) {\n editor.selectBlock(null);\n }\n }\n }\n\n function reset(): void {\n hiddenBlockIds.clear();\n }\n\n return {\n isHidden,\n toggleBlock,\n reset,\n hasHiddenBlocks,\n };\n}\n","import type { CustomBlock, CustomBlockDefinition } from \"@templatical/types\";\nimport type { ComputedRef, Ref } from \"@vue/reactivity\";\nimport { computed, ref } from \"@vue/reactivity\";\n\nexport function useDataSourceFetch(options: {\n definition: ComputedRef<CustomBlockDefinition | undefined>;\n block: ComputedRef<CustomBlock>;\n onUpdate: (fieldValues: Record<string, unknown>, fetched: boolean) => void;\n}): {\n isFetching: Ref<boolean>;\n fetchError: Ref<boolean>;\n fetch: () => Promise<void>;\n hasDataSource: ComputedRef<boolean>;\n needsFetch: ComputedRef<boolean>;\n} {\n const isFetching = ref(false);\n const fetchError = ref(false);\n\n const hasDataSource = computed(() => !!options.definition.value?.dataSource);\n\n const needsFetch = computed(\n () => hasDataSource.value && !options.block.value.dataSourceFetched,\n );\n\n async function fetch(): Promise<void> {\n const def = options.definition.value;\n if (!def?.dataSource) {\n return;\n }\n\n isFetching.value = true;\n fetchError.value = false;\n\n try {\n const result = await def.dataSource.onFetch({\n fieldValues: { ...options.block.value.fieldValues },\n blockId: options.block.value.id,\n });\n\n if (result == null) {\n return;\n }\n\n const merged = { ...options.block.value.fieldValues };\n for (const key of Object.keys(merged)) {\n if (key in result) {\n merged[key] = result[key];\n }\n }\n\n options.onUpdate(merged, true);\n } catch (error) {\n console.warn(\"[Templatical] Data source fetch error:\", error);\n fetchError.value = true;\n } finally {\n isFetching.value = false;\n }\n }\n\n return {\n isFetching,\n fetchError,\n fetch,\n hasDataSource,\n needsFetch,\n };\n}\n","import type { UseEditorReturn } from \"./editor\";\nimport type { UseHistoryReturn } from \"./history\";\n\n/**\n * Wraps editor mutation methods to record history snapshots before each\n * operation. Mutates the editor object in place.\n *\n * Must be applied **after** any collaboration broadcast wrapping so the\n * call chain is: history.record() → broadcast → original mutation.\n */\nexport function useHistoryInterceptor(\n editor: UseEditorReturn,\n history: UseHistoryReturn,\n): void {\n const originalAddBlock = editor.addBlock;\n const originalRemoveBlock = editor.removeBlock;\n const originalMoveBlock = editor.moveBlock;\n const originalUpdateBlock = editor.updateBlock;\n const originalUpdateSettings = editor.updateSettings;\n\n editor.addBlock = (block, targetSectionId?, columnIndex?, index?) => {\n history.record();\n originalAddBlock(block, targetSectionId, columnIndex, index);\n };\n\n editor.removeBlock = (blockId) => {\n history.record();\n originalRemoveBlock(blockId);\n };\n\n editor.moveBlock = (blockId, newIndex, targetSectionId?, columnIndex?) => {\n history.record();\n originalMoveBlock(blockId, newIndex, targetSectionId, columnIndex);\n };\n\n editor.updateBlock = (blockId, updates) => {\n history.recordDebounced(blockId);\n originalUpdateBlock(blockId, updates);\n };\n\n editor.updateSettings = (updates) => {\n history.record();\n originalUpdateSettings(updates);\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACQA,mBAA6C;AAC7C,wBAMO;AAgDA,SAAS,UAAU,SAA4C;AACpE,QAAM,YAAQ,4BAAsB;AAAA,IAClC,SACE,QAAQ,eACR;AAAA,MACE,QAAQ;AAAA,MACR,QAAQ;AAAA,IACV;AAAA,IACF,iBAAiB;AAAA,IACjB,UAAU;AAAA,IACV,UAAU;AAAA,IACV,aAAa;AAAA,IACb,SAAS;AAAA,IACT,SAAS;AAAA,EACX,CAAC;AAED,QAAM,cAAU,4BAAS;AAAA,IACvB,KAAK,MAAM,MAAM;AAAA,IACjB,KAAK,CAAC,UAA2B;AAC/B,YAAM,UAAU;AAChB,YAAM,UAAU;AAAA,IAClB;AAAA,EACF,CAAC;AAED,QAAM,oBAAgB,4BAAS,MAAM;AACnC,QAAI,CAAC,MAAM,gBAAiB,QAAO;AACnC,WAAO,cAAc,MAAM,QAAQ,QAAQ,MAAM,eAAe;AAAA,EAClE,CAAC;AAED,WAAS,cAAc,QAAiB,IAA0B;AAChE,eAAW,SAAS,QAAQ;AAC1B,UAAI,MAAM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D;AAEA,SAAO,cAAc,CAAC,YAAY;AAChC,YAAQ,OAAO;AACf,wBAAoB,OAAO;AAAA,EAC7B;AAEA,SAAO,YAAY,CAAC,SAAS,UAAU,iBAAkB,gBAAiB;AACxE,YAAQ,OAAO;AACf,sBAAkB,SAAS,UAAU,iBAAiB,WAAW;AAAA,EACnE;AAEA,SAAO,cAAc,CAAC,SAAS,YAAY;AACzC,YAAQ,gBAAgB,OAAO;AAC/B,wBAAoB,SAAS,OAAO;AAAA,EACtC;AAEA,SAAO,iBAAiB,CAAC,YAAY;AACnC,YAAQ,OAAO;AACf,2BAAuB,OAAO;AAAA,EAChC;AACF;","names":["markDirty","import_reactivity","import_types","import_reactivity","import_reactivity","import_reactivity"]}