@templatical/core 0.48.0 → 0.50.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/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@templatical/core",
3
3
  "description": "Framework-agnostic editor logic for Templatical email editor",
4
- "version": "0.48.0",
4
+ "version": "0.50.0",
5
5
  "bugs": "https://github.com/templatical/sdk/issues",
6
6
  "dependencies": {
7
- "@templatical/types": "0.48.0",
7
+ "@templatical/types": "0.50.0",
8
8
  "@vue/reactivity": "^3.5.44"
9
9
  },
10
10
  "devDependencies": {
11
11
  "pusher-js": "^8.6.0",
12
12
  "typescript": "^6.0.3",
13
- "vitest": "^5.0.4",
13
+ "vitest": "^5.0.5",
14
14
  "vue": "^3.5.44"
15
15
  },
16
16
  "exports": {
@@ -1,105 +0,0 @@
1
- import { Block, Template, TemplateContent, TemplateDefaults, TemplateSaveTrigger, TemplateSettings, TemplatesProvider, UiTheme, ViewportSize } from "@templatical/types";
2
- import { DeepReadonly, Ref } from "@vue/reactivity";
3
- //#region src/editor.d.ts
4
- interface EditorState {
5
- /**
6
- * The template currently being edited, as the store last returned it — `null`
7
- * until `create()` or `load()` resolves, and always `null` without a
8
- * {@link TemplatesProvider}.
9
- *
10
- * Carries identity and name only for practical purposes: its `content` is the
11
- * store's copy from the last round-trip, whereas `state.content` is what the
12
- * user is editing.
13
- */
14
- template: Template | null;
15
- content: TemplateContent;
16
- selectedBlockId: string | null;
17
- viewport: ViewportSize;
18
- darkMode: boolean;
19
- previewMode: boolean;
20
- isDirty: boolean;
21
- /** True for the duration of a `save()` call. */
22
- isSaving: boolean;
23
- /** True for the duration of a `create()` or `load()` call. */
24
- isLoading: boolean;
25
- uiTheme: UiTheme;
26
- }
27
- interface UseEditorOptions {
28
- content: TemplateContent;
29
- defaultFontFamily?: string;
30
- templateDefaults?: TemplateDefaults;
31
- lockedBlocks?: Ref<Map<string, unknown>>;
32
- /**
33
- * Storage backend for the template's save/load lifecycle. Omit it and
34
- * `create()` / `load()` / `save()` reject — the editor keeps working as a
35
- * purely local editing surface.
36
- */
37
- templates?: TemplatesProvider;
38
- /**
39
- * Called with any error a provider call rejects with, before the rejection is
40
- * re-thrown to the caller.
41
- */
42
- onError?: (error: Error) => void;
43
- }
44
- interface UseEditorReturn {
45
- state: DeepReadonly<EditorState>;
46
- content: Ref<TemplateContent>;
47
- selectedBlock: Ref<Block | null>;
48
- setContent: (content: TemplateContent, markDirty?: boolean) => void;
49
- selectBlock: (blockId: string | null) => void;
50
- setViewport: (viewport: ViewportSize) => void;
51
- setDarkMode: (darkMode: boolean) => void;
52
- setPreviewMode: (previewMode: boolean) => void;
53
- setUiTheme: (theme: UiTheme) => void;
54
- updateBlock: (blockId: string, updates: Partial<Block>) => void;
55
- updateSettings: (updates: Partial<TemplateSettings>) => void;
56
- addBlock: (block: Block, targetSectionId?: string, columnIndex?: number, index?: number) => void;
57
- removeBlock: (blockId: string) => void;
58
- moveBlock: (blockId: string, newIndex: number, targetSectionId?: string, columnIndex?: number) => void;
59
- isBlockLocked: (blockId: string) => boolean;
60
- markDirty: () => void;
61
- findBlockLocation: (blockId: string) => {
62
- targetSectionId?: string;
63
- columnIndex?: number;
64
- index: number;
65
- } | null;
66
- /**
67
- * Rename the loaded template locally and mark the editor dirty. The new name
68
- * reaches the store on the next `save()`, in the same patch as the content —
69
- * a rename is an ordinary unsaved change, not a side channel.
70
- *
71
- * This method only stages it. The editor's inline rename field commits by
72
- * calling `setName()` and then saving immediately, because a rename reads as a
73
- * discrete action rather than an edit to be batched — so in the editor the
74
- * "next `save()`" is usually the one it triggers itself. A headless caller
75
- * decides its own moment.
76
- *
77
- * No-op when no template is loaded: there is nothing to name.
78
- */
79
- setName: (name: string) => void;
80
- /**
81
- * Persist the current content as a new template. `input.content`, when given,
82
- * replaces the editor's content first — so `create({ content })` both loads
83
- * and stores in one step.
84
- */
85
- create: (input?: {
86
- name?: string;
87
- content?: TemplateContent;
88
- }) => Promise<Template>;
89
- /** Fetch a template and make it the editor's content. */
90
- load: (templateId: string) => Promise<Template>;
91
- /**
92
- * Persist the loaded template's name + content as a patch.
93
- *
94
- * `trigger` is passed through to `TemplatesOptions.onSaved`. It defaults to
95
- * `"api"`, which is the honest answer for a direct call — the editor package
96
- * passes the value matching whichever affordance fired.
97
- */
98
- save: (trigger?: TemplateSaveTrigger) => Promise<Template>;
99
- /** Whether a template has been created or loaded. */
100
- hasTemplate: () => boolean;
101
- }
102
- declare function useEditor(options: UseEditorOptions): UseEditorReturn;
103
- //#endregion
104
- export { useEditor as i, UseEditorOptions as n, UseEditorReturn as r, EditorState as t };
105
- //# sourceMappingURL=editor-Bl4WsPU3.d.ts.map