@templatical/core 0.0.1

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 ADDED
@@ -0,0 +1,512 @@
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
+ });
30
+ module.exports = __toCommonJS(index_exports);
31
+
32
+ // src/editor.ts
33
+ var import_types = require("@templatical/types");
34
+ var import_reactivity = require("@vue/reactivity");
35
+ function useEditor(options) {
36
+ const state = (0, import_reactivity.reactive)({
37
+ content: options.content ?? (0, import_types.createDefaultTemplateContent)(
38
+ options.defaultFontFamily,
39
+ options.templateDefaults
40
+ ),
41
+ selectedBlockId: null,
42
+ viewport: "desktop",
43
+ darkMode: false,
44
+ previewMode: false,
45
+ isDirty: false
46
+ });
47
+ const content = (0, import_reactivity.computed)({
48
+ get: () => state.content,
49
+ set: (value) => {
50
+ state.content = value;
51
+ state.isDirty = true;
52
+ }
53
+ });
54
+ const selectedBlock = (0, import_reactivity.computed)(() => {
55
+ if (!state.selectedBlockId) return null;
56
+ return findBlockById(state.content.blocks, state.selectedBlockId);
57
+ });
58
+ function findBlockById(blocks, id) {
59
+ for (const block of blocks) {
60
+ if (block.id === id) return block;
61
+ if (block.type === "section") {
62
+ for (const column of block.children) {
63
+ const found = findBlockById(column, id);
64
+ if (found) return found;
65
+ }
66
+ }
67
+ }
68
+ return null;
69
+ }
70
+ function findBlockParent(blocks, id, parent = { blocks }) {
71
+ for (let i = 0; i < blocks.length; i++) {
72
+ const block = blocks[i];
73
+ if (block.id === id) return parent;
74
+ if (block.type === "section") {
75
+ for (let colIdx = 0; colIdx < block.children.length; colIdx++) {
76
+ const result = findBlockParent(block.children[colIdx], id, {
77
+ blocks: block.children[colIdx],
78
+ sectionId: block.id,
79
+ columnIndex: colIdx
80
+ });
81
+ if (result) return result;
82
+ }
83
+ }
84
+ }
85
+ return null;
86
+ }
87
+ function isBlockLocked(blockId) {
88
+ return options.lockedBlocks?.value.has(blockId) ?? false;
89
+ }
90
+ function setContent(newContent, markDirty2 = true) {
91
+ state.content = newContent;
92
+ if (markDirty2) {
93
+ state.isDirty = true;
94
+ }
95
+ }
96
+ function selectBlock(blockId) {
97
+ if (blockId && isBlockLocked(blockId)) {
98
+ return;
99
+ }
100
+ state.selectedBlockId = blockId;
101
+ }
102
+ function setViewport(viewport) {
103
+ state.viewport = viewport;
104
+ }
105
+ function setDarkMode(darkMode) {
106
+ state.darkMode = darkMode;
107
+ }
108
+ function setPreviewMode(previewMode) {
109
+ state.previewMode = previewMode;
110
+ if (previewMode) {
111
+ state.selectedBlockId = null;
112
+ }
113
+ }
114
+ function updateBlock(blockId, updates) {
115
+ if (isBlockLocked(blockId)) {
116
+ return;
117
+ }
118
+ const block = findBlockById(state.content.blocks, blockId);
119
+ if (block) {
120
+ Object.assign(block, updates);
121
+ state.isDirty = true;
122
+ }
123
+ }
124
+ function updateSettings(updates) {
125
+ state.content.settings = { ...state.content.settings, ...updates };
126
+ state.isDirty = true;
127
+ }
128
+ function addBlock(block, targetSectionId, columnIndex = 0, index) {
129
+ if (targetSectionId) {
130
+ const section = findBlockById(state.content.blocks, targetSectionId);
131
+ if (section && section.type === "section") {
132
+ section.children[columnIndex] = section.children[columnIndex] || [];
133
+ const targetArray = section.children[columnIndex];
134
+ if (index !== void 0 && index < targetArray.length) {
135
+ targetArray.splice(index, 0, block);
136
+ } else {
137
+ targetArray.push(block);
138
+ }
139
+ }
140
+ } else {
141
+ if (index !== void 0 && index < state.content.blocks.length) {
142
+ state.content.blocks.splice(index, 0, block);
143
+ } else {
144
+ state.content.blocks.push(block);
145
+ }
146
+ }
147
+ state.isDirty = true;
148
+ }
149
+ function removeBlock(blockId) {
150
+ if (isBlockLocked(blockId)) {
151
+ return;
152
+ }
153
+ const parent = findBlockParent(state.content.blocks, blockId);
154
+ if (parent) {
155
+ const index = parent.blocks.findIndex((b) => b.id === blockId);
156
+ if (index !== -1) {
157
+ parent.blocks.splice(index, 1);
158
+ if (state.selectedBlockId === blockId) {
159
+ state.selectedBlockId = null;
160
+ }
161
+ state.isDirty = true;
162
+ }
163
+ }
164
+ }
165
+ function moveBlock(blockId, newIndex, targetSectionId, columnIndex = 0) {
166
+ const parent = findBlockParent(state.content.blocks, blockId);
167
+ if (!parent) return;
168
+ const oldIndex = parent.blocks.findIndex((b) => b.id === blockId);
169
+ if (oldIndex === -1) return;
170
+ const [block] = parent.blocks.splice(oldIndex, 1);
171
+ if (targetSectionId) {
172
+ const section = findBlockById(state.content.blocks, targetSectionId);
173
+ if (section && section.type === "section") {
174
+ section.children[columnIndex] = section.children[columnIndex] || [];
175
+ section.children[columnIndex].splice(newIndex, 0, block);
176
+ }
177
+ } else {
178
+ state.content.blocks.splice(newIndex, 0, block);
179
+ }
180
+ state.isDirty = true;
181
+ }
182
+ function markDirty() {
183
+ state.isDirty = true;
184
+ }
185
+ return {
186
+ state: (0, import_reactivity.readonly)(state),
187
+ content,
188
+ selectedBlock,
189
+ isBlockLocked,
190
+ setContent,
191
+ selectBlock,
192
+ setViewport,
193
+ setDarkMode,
194
+ setPreviewMode,
195
+ updateBlock,
196
+ updateSettings,
197
+ addBlock,
198
+ removeBlock,
199
+ moveBlock,
200
+ markDirty
201
+ };
202
+ }
203
+
204
+ // src/history.ts
205
+ var import_reactivity2 = require("@vue/reactivity");
206
+ var MAX_STACK_SIZE = 50;
207
+ var DEBOUNCE_MS = 300;
208
+ var NAVIGATE_IDLE_MS = 1500;
209
+ function useHistory(options) {
210
+ const {
211
+ content,
212
+ setContent,
213
+ isRemoteOperation,
214
+ maxSize = MAX_STACK_SIZE
215
+ } = options;
216
+ const undoStack = (0, import_reactivity2.ref)([]);
217
+ const redoStack = (0, import_reactivity2.ref)([]);
218
+ const isNavigating = (0, import_reactivity2.ref)(false);
219
+ let navigatingTimeoutId = null;
220
+ let pendingDebounce = null;
221
+ const canUndo = (0, import_reactivity2.computed)(() => undoStack.value.length > 0);
222
+ const canRedo = (0, import_reactivity2.computed)(() => redoStack.value.length > 0);
223
+ function cloneContent() {
224
+ return JSON.parse(JSON.stringify(content.value));
225
+ }
226
+ function pushToUndoStack(snapshot) {
227
+ undoStack.value.push(snapshot);
228
+ if (undoStack.value.length > maxSize) {
229
+ undoStack.value.splice(0, undoStack.value.length - maxSize);
230
+ }
231
+ }
232
+ function flushPendingDebounce() {
233
+ if (pendingDebounce) {
234
+ clearTimeout(pendingDebounce.timeoutId);
235
+ pendingDebounce = null;
236
+ }
237
+ }
238
+ function record() {
239
+ if (isRemoteOperation?.()) {
240
+ return;
241
+ }
242
+ flushPendingDebounce();
243
+ pushToUndoStack(cloneContent());
244
+ redoStack.value = [];
245
+ }
246
+ function recordDebounced(blockId) {
247
+ if (isRemoteOperation?.()) {
248
+ return;
249
+ }
250
+ if (pendingDebounce && pendingDebounce.blockId === blockId) {
251
+ clearTimeout(pendingDebounce.timeoutId);
252
+ pendingDebounce.timeoutId = setTimeout(() => {
253
+ pendingDebounce = null;
254
+ }, DEBOUNCE_MS);
255
+ return;
256
+ }
257
+ flushPendingDebounce();
258
+ pushToUndoStack(cloneContent());
259
+ redoStack.value = [];
260
+ pendingDebounce = {
261
+ blockId,
262
+ timeoutId: setTimeout(() => {
263
+ pendingDebounce = null;
264
+ }, DEBOUNCE_MS)
265
+ };
266
+ }
267
+ function setNavigating() {
268
+ isNavigating.value = true;
269
+ if (navigatingTimeoutId) {
270
+ clearTimeout(navigatingTimeoutId);
271
+ }
272
+ navigatingTimeoutId = setTimeout(() => {
273
+ isNavigating.value = false;
274
+ navigatingTimeoutId = null;
275
+ }, NAVIGATE_IDLE_MS);
276
+ }
277
+ function undo() {
278
+ if (undoStack.value.length === 0) {
279
+ return;
280
+ }
281
+ flushPendingDebounce();
282
+ const snapshot = undoStack.value.pop();
283
+ redoStack.value.push(cloneContent());
284
+ setContent(snapshot, true);
285
+ setNavigating();
286
+ }
287
+ function redo() {
288
+ if (redoStack.value.length === 0) {
289
+ return;
290
+ }
291
+ flushPendingDebounce();
292
+ const snapshot = redoStack.value.pop();
293
+ undoStack.value.push(cloneContent());
294
+ setContent(snapshot, true);
295
+ setNavigating();
296
+ }
297
+ function clear() {
298
+ undoStack.value = [];
299
+ redoStack.value = [];
300
+ flushPendingDebounce();
301
+ }
302
+ function destroy() {
303
+ clear();
304
+ if (navigatingTimeoutId) {
305
+ clearTimeout(navigatingTimeoutId);
306
+ navigatingTimeoutId = null;
307
+ }
308
+ }
309
+ return {
310
+ canUndo,
311
+ canRedo,
312
+ isNavigating,
313
+ undo,
314
+ redo,
315
+ record,
316
+ recordDebounced,
317
+ clear,
318
+ destroy
319
+ };
320
+ }
321
+
322
+ // src/block-actions.ts
323
+ var import_types2 = require("@templatical/types");
324
+ function useBlockActions(options) {
325
+ const { addBlock, removeBlock, updateBlock, selectBlock } = options;
326
+ function createAndAddBlock(type, targetSectionId, columnIndex) {
327
+ const block = (0, import_types2.createBlock)(type, options.blockDefaults);
328
+ addBlock(block, targetSectionId, columnIndex);
329
+ selectBlock(block.id);
330
+ return block;
331
+ }
332
+ function duplicateBlock(block, targetSectionId, columnIndex) {
333
+ const cloned = JSON.parse(JSON.stringify(block));
334
+ cloned.id = (0, import_types2.generateId)();
335
+ if (cloned.type === "section") {
336
+ cloned.children = cloned.children.map(
337
+ (column) => column.map((child) => {
338
+ const clonedChild = JSON.parse(JSON.stringify(child));
339
+ clonedChild.id = (0, import_types2.generateId)();
340
+ return clonedChild;
341
+ })
342
+ );
343
+ }
344
+ addBlock(cloned, targetSectionId, columnIndex);
345
+ selectBlock(cloned.id);
346
+ return cloned;
347
+ }
348
+ function deleteBlock(blockId) {
349
+ removeBlock(blockId);
350
+ }
351
+ function updateBlockProperty(blockId, key, value) {
352
+ updateBlock(blockId, { [key]: value });
353
+ }
354
+ return {
355
+ createAndAddBlock,
356
+ duplicateBlock,
357
+ deleteBlock,
358
+ updateBlockProperty
359
+ };
360
+ }
361
+
362
+ // src/auto-save.ts
363
+ var import_reactivity3 = require("@vue/reactivity");
364
+ function useAutoSave(options) {
365
+ const {
366
+ content,
367
+ isDirty,
368
+ onChange,
369
+ debounce = 1e3,
370
+ enabled = true
371
+ } = options;
372
+ let timeoutId = null;
373
+ let paused = false;
374
+ function isEnabled() {
375
+ return typeof enabled === "function" ? enabled() : enabled;
376
+ }
377
+ function pause() {
378
+ paused = true;
379
+ cancel();
380
+ }
381
+ function resume() {
382
+ paused = false;
383
+ }
384
+ function cancel() {
385
+ if (timeoutId) {
386
+ clearTimeout(timeoutId);
387
+ timeoutId = null;
388
+ }
389
+ }
390
+ function flush() {
391
+ cancel();
392
+ if (isDirty()) {
393
+ onChange(JSON.parse(JSON.stringify(content.value)));
394
+ }
395
+ }
396
+ function scheduleOnChange() {
397
+ if (!isEnabled() || paused) return;
398
+ cancel();
399
+ timeoutId = setTimeout(() => {
400
+ timeoutId = null;
401
+ if (isDirty()) {
402
+ onChange(JSON.parse(JSON.stringify(content.value)));
403
+ }
404
+ }, debounce);
405
+ }
406
+ const stopWatch = (0, import_reactivity3.watch)(
407
+ content,
408
+ () => {
409
+ if (isEnabled() && !paused && isDirty()) {
410
+ scheduleOnChange();
411
+ }
412
+ },
413
+ { deep: true }
414
+ );
415
+ function destroy() {
416
+ stopWatch();
417
+ cancel();
418
+ }
419
+ return {
420
+ flush,
421
+ cancel,
422
+ pause,
423
+ resume,
424
+ destroy
425
+ };
426
+ }
427
+
428
+ // src/condition-preview.ts
429
+ var import_reactivity4 = require("@vue/reactivity");
430
+ function useConditionPreview(editor) {
431
+ const hiddenBlockIds = (0, import_reactivity4.reactive)(/* @__PURE__ */ new Set());
432
+ const hasHiddenBlocks = (0, import_reactivity4.computed)(() => hiddenBlockIds.size > 0);
433
+ function isHidden(blockId) {
434
+ return hiddenBlockIds.has(blockId);
435
+ }
436
+ function toggleBlock(blockId) {
437
+ if (hiddenBlockIds.has(blockId)) {
438
+ hiddenBlockIds.delete(blockId);
439
+ } else {
440
+ hiddenBlockIds.add(blockId);
441
+ if (editor.state.selectedBlockId === blockId) {
442
+ editor.selectBlock(null);
443
+ }
444
+ }
445
+ }
446
+ function reset() {
447
+ hiddenBlockIds.clear();
448
+ }
449
+ return {
450
+ isHidden,
451
+ toggleBlock,
452
+ reset,
453
+ hasHiddenBlocks
454
+ };
455
+ }
456
+
457
+ // src/data-source-fetch.ts
458
+ var import_reactivity5 = require("@vue/reactivity");
459
+ function useDataSourceFetch(options) {
460
+ const isFetching = (0, import_reactivity5.ref)(false);
461
+ const fetchError = (0, import_reactivity5.ref)(false);
462
+ const hasDataSource = (0, import_reactivity5.computed)(() => !!options.definition.value?.dataSource);
463
+ const needsFetch = (0, import_reactivity5.computed)(
464
+ () => hasDataSource.value && !options.block.value.dataSourceFetched
465
+ );
466
+ async function fetch() {
467
+ const def = options.definition.value;
468
+ if (!def?.dataSource) {
469
+ return;
470
+ }
471
+ isFetching.value = true;
472
+ fetchError.value = false;
473
+ try {
474
+ const result = await def.dataSource.onFetch({
475
+ fieldValues: { ...options.block.value.fieldValues },
476
+ blockId: options.block.value.id
477
+ });
478
+ if (result === null || result === void 0) {
479
+ return;
480
+ }
481
+ const merged = { ...options.block.value.fieldValues };
482
+ for (const key of Object.keys(merged)) {
483
+ if (key in result) {
484
+ merged[key] = result[key];
485
+ }
486
+ }
487
+ options.onUpdate(merged, true);
488
+ } catch (error) {
489
+ console.warn("[Templatical] Data source fetch error:", error);
490
+ fetchError.value = true;
491
+ } finally {
492
+ isFetching.value = false;
493
+ }
494
+ }
495
+ return {
496
+ isFetching,
497
+ fetchError,
498
+ fetch,
499
+ hasDataSource,
500
+ needsFetch
501
+ };
502
+ }
503
+ // Annotate the CommonJS export names for ESM import in node:
504
+ 0 && (module.exports = {
505
+ useAutoSave,
506
+ useBlockActions,
507
+ useConditionPreview,
508
+ useDataSourceFetch,
509
+ useEditor,
510
+ useHistory
511
+ });
512
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
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"],"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// Plugin system\nexport type {\n BlockContextAction,\n EditorPlugin,\n EditorPluginContext,\n SidebarPanel,\n ToolbarAction,\n} from \"./plugins\";\n","import type {\n Block,\n TemplateContent,\n TemplateDefaults,\n TemplateSettings,\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}\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 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 });\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 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 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 || result === undefined) {\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"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACOA,mBAA6C;AAC7C,wBAMO;AA8CA,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,EACX,CAAC;AAED,QAAM,cAAU,4BAAS;AAAA,IACvB,KAAK,MAAM,MAAM;AAAA,IACjB,KAAK,CAAC,UA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