@kritzel/engine 0.4.31 → 0.4.33
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/LICENSE.md +49 -49
- package/dist/cjs/{engine.constants-CakmdKMW.js → engine.constants-VyFrUl1W.js} +627 -129
- package/dist/cjs/{index-BbbWU2aN.js → index-BP5Iy6FQ.js} +27 -9
- package/dist/cjs/index.cjs.js +4 -2
- package/dist/cjs/kritzel-awareness-cursors_5.cjs.entry.js +257 -113
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/stencil.cjs.js +3 -3
- package/dist/collection/classes/core/core.class.js +40 -32
- package/dist/collection/classes/core/reviver.class.js +4 -0
- package/dist/collection/classes/core/store.class.js +10 -3
- package/dist/collection/classes/managers/cursor.manager.js +10 -5
- package/dist/collection/classes/objects/dynamic-object.class.js +18 -5
- package/dist/collection/classes/objects/iframe.class.js +447 -0
- package/dist/collection/classes/registries/icon-registry.class.js +100 -67
- package/dist/collection/classes/tools/selection-tool.class.js +3 -3
- package/dist/collection/collection-manifest.json +4 -2
- package/dist/collection/components/kritzel-awareness-cursors/kritzel-awareness-cursors.css +115 -115
- package/dist/collection/components/kritzel-awareness-cursors/kritzel-awareness-cursors.js +1 -1
- package/dist/collection/components/kritzel-cursor-trail/kritzel-cursor-trail.css +10 -10
- package/dist/collection/components/kritzel-cursor-trail/kritzel-cursor-trail.js +1 -1
- package/dist/collection/components/kritzel-engine/kritzel-engine.css +80 -80
- package/dist/collection/components/kritzel-engine/kritzel-engine.js +196 -44
- package/dist/collection/components/kritzel-icon/kritzel-icon.css +18 -18
- package/dist/collection/components/kritzel-icon/kritzel-icon.js +25 -4
- package/dist/collection/components/kritzel-watermark/kritzel-watermark.css +29 -29
- package/dist/collection/components/kritzel-watermark/kritzel-watermark.js +2 -2
- package/dist/collection/constants/version.js +1 -1
- package/dist/collection/helpers/cursor.helper.js +8 -8
- package/dist/collection/helpers/object.helper.js +13 -0
- package/dist/collection/helpers/svg-export.helper.js +55 -41
- package/dist/collection/helpers/wheel.helper.js +1 -7
- package/dist/collection/index.js +3 -0
- package/dist/collection/interfaces/embedded-object.interface.js +1 -0
- package/dist/collection/themes/dark-theme.js +1 -5
- package/dist/collection/themes/light-theme.js +1 -6
- package/dist/components/index.js +7 -7
- package/dist/components/kritzel-awareness-cursors.js +1 -1
- package/dist/components/kritzel-cursor-trail.js +1 -1
- package/dist/components/kritzel-engine.js +755 -161
- package/dist/components/kritzel-icon.js +1 -1
- package/dist/components/kritzel-watermark.js +1 -1
- package/dist/components/{p-B2Htv9ou.js → p-BHVbfJrf.js} +3 -3
- package/dist/components/{p-YP8wAcF4.js → p-BTU9qcSW.js} +2 -2
- package/dist/components/{p-CfSx6HU_.js → p-BWfRbEIq.js} +16 -4
- package/dist/components/p-NAEiq8CK.js +214 -0
- package/dist/components/{p-BvRGQvVI.js → p-k0LxV9Bg.js} +18 -14
- package/dist/esm/{engine.constants-Bl5-pbq-.js → engine.constants-BHTr2qPx.js} +626 -130
- package/dist/esm/{index-BU9Mv7y0.js → index-C8PnHbLt.js} +27 -10
- package/dist/esm/index.js +3 -3
- package/dist/esm/kritzel-awareness-cursors_5.entry.js +257 -113
- package/dist/esm/loader.js +3 -3
- package/dist/esm/stencil.js +4 -4
- package/dist/stencil/index.esm.js +3 -3
- package/dist/stencil/{p-f0a8b7af.entry.js → p-40097a38.entry.js} +257 -113
- package/dist/stencil/{p-Bl5-pbq-.js → p-BHTr2qPx.js} +626 -130
- package/dist/stencil/{p-BU9Mv7y0.js → p-C8PnHbLt.js} +27 -10
- package/dist/stencil/stencil.esm.js +4 -4
- package/dist/types/classes/core/store.class.d.ts +3 -2
- package/dist/types/classes/objects/dynamic-object.class.d.ts +4 -2
- package/dist/types/classes/objects/iframe.class.d.ts +76 -0
- package/dist/types/classes/registries/icon-registry.class.d.ts +75 -6
- package/dist/types/components/kritzel-engine/kritzel-engine.d.ts +14 -1
- package/dist/types/components/kritzel-icon/kritzel-icon.d.ts +5 -1
- package/dist/types/components.d.ts +26 -8
- package/dist/types/constants/version.d.ts +1 -1
- package/dist/types/helpers/cursor.helper.d.ts +2 -1
- package/dist/types/helpers/object.helper.d.ts +2 -0
- package/dist/types/helpers/svg-export.helper.d.ts +1 -0
- package/dist/types/helpers/wheel.helper.d.ts +2 -2
- package/dist/types/index.d.ts +3 -0
- package/dist/types/interfaces/context-menu-item.interface.d.ts +2 -1
- package/dist/types/interfaces/dynamic-object-renderer.interface.d.ts +7 -0
- package/dist/types/interfaces/embedded-object.interface.d.ts +9 -0
- package/dist/types/interfaces/engine-state.interface.d.ts +3 -2
- package/dist/types/interfaces/login-config.interface.d.ts +2 -1
- package/dist/types/interfaces/master-detail.interface.d.ts +2 -1
- package/dist/types/interfaces/menu-item.interface.d.ts +2 -1
- package/dist/types/interfaces/theme.interface.d.ts +6 -7
- package/dist/types/interfaces/tool.interface.d.ts +9 -0
- package/dist/types/interfaces/toolbar-item.interface.d.ts +3 -2
- package/dist/types/stencil-public-runtime.d.ts +61 -55
- package/package.json +3 -1
- package/readme.md +10 -10
- package/dist/components/p-fx6msYHJ.js +0 -167
|
@@ -33,12 +33,26 @@ export class KritzelEngine {
|
|
|
33
33
|
/** Authoritative workspace catalog for this engine instance. When provided, provider-only workspaces are hidden but not deleted. */
|
|
34
34
|
workspaces;
|
|
35
35
|
async onWorkspacesPropChange() {
|
|
36
|
-
|
|
36
|
+
this._workspacesRevision++;
|
|
37
|
+
if (!this._isYjsInitialized || this._syncInitPromise) {
|
|
37
38
|
return;
|
|
38
39
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
const previousReconciliation = this._workspacePropReconciliationPromise;
|
|
41
|
+
const reconciliationPromise = (async () => {
|
|
42
|
+
await previousReconciliation;
|
|
43
|
+
await this.reconcileProvidedWorkspaces();
|
|
44
|
+
await this.ensureActiveWorkspaceIsVisible();
|
|
45
|
+
this.workspacesChange.emit(this.getVisibleWorkspaces());
|
|
46
|
+
})();
|
|
47
|
+
this._workspacePropReconciliationPromise = reconciliationPromise;
|
|
48
|
+
try {
|
|
49
|
+
await reconciliationPromise;
|
|
50
|
+
}
|
|
51
|
+
finally {
|
|
52
|
+
if (this._workspacePropReconciliationPromise === reconciliationPromise) {
|
|
53
|
+
this._workspacePropReconciliationPromise = null;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
42
56
|
}
|
|
43
57
|
/** Optional unique identifier for namespacing storage keys across multiple editor instances. */
|
|
44
58
|
editorId;
|
|
@@ -92,6 +106,12 @@ export class KritzelEngine {
|
|
|
92
106
|
onUserChange(newValue) {
|
|
93
107
|
this.core.setUser(newValue);
|
|
94
108
|
}
|
|
109
|
+
/** Tool definitions to register with this engine instance. */
|
|
110
|
+
tools = [];
|
|
111
|
+
onToolsChange() {
|
|
112
|
+
this._toolsRevision++;
|
|
113
|
+
void this.registerConfiguredTools();
|
|
114
|
+
}
|
|
95
115
|
/** Context menu items shown when right-clicking the canvas background. */
|
|
96
116
|
globalContextMenuItems;
|
|
97
117
|
onGlobalContextMenuItemsChange(newValue) {
|
|
@@ -282,7 +302,7 @@ export class KritzelEngine {
|
|
|
282
302
|
}
|
|
283
303
|
const hoveredObject = this.core.getObjectFromPointerEvent(ev);
|
|
284
304
|
if (hoveredObject &&
|
|
285
|
-
ObjectHelper.
|
|
305
|
+
ObjectHelper.isKritzelEmbeddedObject(hoveredObject) &&
|
|
286
306
|
KritzelWheelHelper.shouldKeepWheelInDynamicObject(ev, hoveredObject)) {
|
|
287
307
|
return;
|
|
288
308
|
}
|
|
@@ -384,7 +404,7 @@ export class KritzelEngine {
|
|
|
384
404
|
return false;
|
|
385
405
|
}
|
|
386
406
|
const object = this.core.store.objects.findById(objectElement.id);
|
|
387
|
-
if (!object || !
|
|
407
|
+
if (!object || !ObjectHelper.isKritzelEmbeddedObject(object)) {
|
|
388
408
|
return false;
|
|
389
409
|
}
|
|
390
410
|
const isSelected = !!this.core.store.selectionGroup?.objects?.some(selectedObject => selectedObject.id === object.id);
|
|
@@ -394,13 +414,7 @@ export class KritzelEngine {
|
|
|
394
414
|
if (object.isInteractive !== true) {
|
|
395
415
|
return false;
|
|
396
416
|
}
|
|
397
|
-
const potentialRoots =
|
|
398
|
-
if (object.element instanceof HTMLElement) {
|
|
399
|
-
potentialRoots.push(object.element);
|
|
400
|
-
}
|
|
401
|
-
if (object.elementRef instanceof HTMLElement) {
|
|
402
|
-
potentialRoots.push(object.elementRef);
|
|
403
|
-
}
|
|
417
|
+
const potentialRoots = object.getEmbeddedContentRoots();
|
|
404
418
|
if (potentialRoots.length === 0) {
|
|
405
419
|
return false;
|
|
406
420
|
}
|
|
@@ -574,7 +588,7 @@ export class KritzelEngine {
|
|
|
574
588
|
* Switches the active drawing tool by its registered name.
|
|
575
589
|
* @param toolName - The name the tool was registered with (e.g., 'brush', 'eraser').
|
|
576
590
|
*/
|
|
577
|
-
async
|
|
591
|
+
async setActiveTool(toolName) {
|
|
578
592
|
const tool = this.core.toolRegistry.getTool(toolName);
|
|
579
593
|
if (!tool) {
|
|
580
594
|
console.warn(`[KritzelEngine] No tool registered with name: ${toolName}`);
|
|
@@ -1880,9 +1894,13 @@ export class KritzelEngine {
|
|
|
1880
1894
|
_stateChangeListenersRegistered = false;
|
|
1881
1895
|
_workspaceInitializationPromise = null;
|
|
1882
1896
|
_workspaceInitializationTargetKey = null;
|
|
1897
|
+
_workspacePropReconciliationPromise = null;
|
|
1883
1898
|
_syncInitPromise = null;
|
|
1899
|
+
_toolsInitPromise = null;
|
|
1900
|
+
_toolsRevision = 0;
|
|
1884
1901
|
_syncConfigRevision = 0;
|
|
1885
1902
|
_assetStorageConfigRevision = 0;
|
|
1903
|
+
_workspacesRevision = 0;
|
|
1886
1904
|
_hasLoggedUnlicensedWelcomeBanner = false;
|
|
1887
1905
|
_previousVisibleDynamicObjects = new Set();
|
|
1888
1906
|
_revealedImageKeys = new Set();
|
|
@@ -1895,6 +1913,37 @@ export class KritzelEngine {
|
|
|
1895
1913
|
undoStackSize: 0,
|
|
1896
1914
|
redoStackSize: 0,
|
|
1897
1915
|
};
|
|
1916
|
+
/** Returns a tool registered in this engine instance. */
|
|
1917
|
+
async getTool(toolName) {
|
|
1918
|
+
await this.registerConfiguredTools();
|
|
1919
|
+
return this.core.toolRegistry.getTool(toolName);
|
|
1920
|
+
}
|
|
1921
|
+
async registerConfiguredTools() {
|
|
1922
|
+
if (this._toolsInitPromise) {
|
|
1923
|
+
return this._toolsInitPromise;
|
|
1924
|
+
}
|
|
1925
|
+
this._toolsInitPromise = (async () => {
|
|
1926
|
+
do {
|
|
1927
|
+
const revision = this._toolsRevision;
|
|
1928
|
+
for (const definition of this.tools) {
|
|
1929
|
+
let toolClass = definition.tool;
|
|
1930
|
+
if (typeof toolClass !== 'function') {
|
|
1931
|
+
toolClass = toolClass.constructor;
|
|
1932
|
+
}
|
|
1933
|
+
await this.registerTool(definition.name, toolClass, definition.config);
|
|
1934
|
+
}
|
|
1935
|
+
if (revision === this._toolsRevision) {
|
|
1936
|
+
break;
|
|
1937
|
+
}
|
|
1938
|
+
} while (true);
|
|
1939
|
+
})();
|
|
1940
|
+
try {
|
|
1941
|
+
await this._toolsInitPromise;
|
|
1942
|
+
}
|
|
1943
|
+
finally {
|
|
1944
|
+
this._toolsInitPromise = null;
|
|
1945
|
+
}
|
|
1946
|
+
}
|
|
1898
1947
|
setLoadingState(isLoading) {
|
|
1899
1948
|
if (this.core.store.state.isLoading === isLoading) {
|
|
1900
1949
|
return;
|
|
@@ -2004,6 +2053,8 @@ export class KritzelEngine {
|
|
|
2004
2053
|
this.core.licenseManager.destroy();
|
|
2005
2054
|
}
|
|
2006
2055
|
componentWillLoad() {
|
|
2056
|
+
this._toolsRevision++;
|
|
2057
|
+
void this.registerConfiguredTools();
|
|
2007
2058
|
this.core.setEditorId(this.editorId);
|
|
2008
2059
|
if (this.themes && this.themes.length > 0) {
|
|
2009
2060
|
this.core.themeManager.registerThemes(this.themes);
|
|
@@ -2043,7 +2094,9 @@ export class KritzelEngine {
|
|
|
2043
2094
|
const editorElement = this.host.closest('kritzel-editor');
|
|
2044
2095
|
this.core.themeManager.setTargetElement(editorElement || this.host);
|
|
2045
2096
|
// Initialize sync config and Yjs
|
|
2097
|
+
await this.registerConfiguredTools();
|
|
2046
2098
|
await this.initializeSyncAndWorkspace();
|
|
2099
|
+
await this.waitForWorkspaceAndSceneReady();
|
|
2047
2100
|
if (this.core.store.state.isReady === false) {
|
|
2048
2101
|
this.core.store.state.isReady = true;
|
|
2049
2102
|
this.logUnlicensedWelcomeBanner();
|
|
@@ -2065,6 +2118,20 @@ export class KritzelEngine {
|
|
|
2065
2118
|
this._syncInitPromise = null;
|
|
2066
2119
|
}
|
|
2067
2120
|
}
|
|
2121
|
+
async waitForSceneRender() {
|
|
2122
|
+
await new Promise(resolve => {
|
|
2123
|
+
requestAnimationFrame(() => requestAnimationFrame(() => resolve()));
|
|
2124
|
+
});
|
|
2125
|
+
}
|
|
2126
|
+
async waitForWorkspaceAndSceneReady() {
|
|
2127
|
+
let observedRevision;
|
|
2128
|
+
do {
|
|
2129
|
+
observedRevision = this._workspacesRevision;
|
|
2130
|
+
await this._workspacePropReconciliationPromise;
|
|
2131
|
+
await this.waitForSceneRender();
|
|
2132
|
+
} while (observedRevision !== this._workspacesRevision ||
|
|
2133
|
+
this._workspacePropReconciliationPromise);
|
|
2134
|
+
}
|
|
2068
2135
|
/**
|
|
2069
2136
|
* Initializes the asset storage layer with the latest config. Mirrors
|
|
2070
2137
|
* the in-flight replay logic of {@link doInitializeSyncAndWorkspace} for
|
|
@@ -2447,7 +2514,7 @@ export class KritzelEngine {
|
|
|
2447
2514
|
if (!KritzelClassHelper.isInstanceOf(object, 'KritzelSelectionGroup')) {
|
|
2448
2515
|
return 'auto';
|
|
2449
2516
|
}
|
|
2450
|
-
if (object.objects.length === 1 &&
|
|
2517
|
+
if (object.objects.length === 1 && ObjectHelper.isKritzelEmbeddedObject(object.objects[0])) {
|
|
2451
2518
|
return 'none';
|
|
2452
2519
|
}
|
|
2453
2520
|
return 'auto';
|
|
@@ -2455,7 +2522,7 @@ export class KritzelEngine {
|
|
|
2455
2522
|
// Track visible dynamic objects and unmount culled ones
|
|
2456
2523
|
const currentVisibleDynamicObjects = new Set();
|
|
2457
2524
|
visibleObjects.forEach(object => {
|
|
2458
|
-
if (
|
|
2525
|
+
if (ObjectHelper.isKritzelEmbeddedObject(object)) {
|
|
2459
2526
|
currentVisibleDynamicObjects.add(object.id);
|
|
2460
2527
|
}
|
|
2461
2528
|
});
|
|
@@ -2463,7 +2530,7 @@ export class KritzelEngine {
|
|
|
2463
2530
|
this._previousVisibleDynamicObjects.forEach(id => {
|
|
2464
2531
|
if (!currentVisibleDynamicObjects.has(id)) {
|
|
2465
2532
|
const object = this.core.store.objects.findById(id);
|
|
2466
|
-
if (object &&
|
|
2533
|
+
if (object && ObjectHelper.isKritzelEmbeddedObject(object)) {
|
|
2467
2534
|
object.unmount();
|
|
2468
2535
|
}
|
|
2469
2536
|
}
|
|
@@ -2556,7 +2623,7 @@ export class KritzelEngine {
|
|
|
2556
2623
|
display: 'flex',
|
|
2557
2624
|
alignItems: 'center',
|
|
2558
2625
|
justifyContent: 'center',
|
|
2559
|
-
} }, h("kritzel-icon", { name: object.loadState === 'error' ? '
|
|
2626
|
+
} }, h("kritzel-icon", { name: object.loadState === 'error' ? 'imageOff' : 'image', size: Math.max(16, Math.min(object.totalWidth, object.totalHeight) * 0.3), style: {
|
|
2560
2627
|
color: KritzelColorHelper.resolveThemeColor({ light: '#9ca3af', dark: '#6b7280' }, currentTheme),
|
|
2561
2628
|
} }))), KritzelClassHelper.isInstanceOf(object, 'KritzelDynamicObject') && (h("div", { ref: el => el && object.mount(el), style: {
|
|
2562
2629
|
position: 'absolute',
|
|
@@ -2575,7 +2642,37 @@ export class KritzelEngine {
|
|
|
2575
2642
|
padding: object.padding + 'px',
|
|
2576
2643
|
overflow: 'visible',
|
|
2577
2644
|
display: 'block',
|
|
2578
|
-
} })), KritzelClassHelper.isInstanceOf(object, '
|
|
2645
|
+
} })), KritzelClassHelper.isInstanceOf(object, 'KritzelIframeObject') && (h("div", { style: {
|
|
2646
|
+
position: 'absolute',
|
|
2647
|
+
left: '0',
|
|
2648
|
+
top: '0',
|
|
2649
|
+
width: object.totalWidth + 'px',
|
|
2650
|
+
height: object.totalHeight + 'px',
|
|
2651
|
+
transform: object.rotationDegrees !== 0 ? `rotate(${object.rotationDegrees}deg)` : undefined,
|
|
2652
|
+
transformOrigin: object.rotationDegrees !== 0 ? `${object.totalWidth / 2}px ${object.totalHeight / 2}px` : undefined,
|
|
2653
|
+
opacity: effectiveOpacityString,
|
|
2654
|
+
backgroundColor: KritzelColorHelper.resolveThemeColor(object.backgroundColor, currentTheme),
|
|
2655
|
+
borderColor: KritzelColorHelper.resolveThemeColor(object.borderColor, currentTheme),
|
|
2656
|
+
borderWidth: object.borderWidth + 'px',
|
|
2657
|
+
borderStyle: 'solid',
|
|
2658
|
+
borderRadius: object.borderRadius !== undefined ? (typeof object.borderRadius === 'number' ? `${object.borderRadius}px` : object.borderRadius) : undefined,
|
|
2659
|
+
boxShadow: object.boxShadow,
|
|
2660
|
+
overflow: 'hidden',
|
|
2661
|
+
display: 'block',
|
|
2662
|
+
pointerEvents: object.markedForRemoval ? 'none' : 'auto',
|
|
2663
|
+
} }, h("iframe", { ref: element => element && object.mount(element), title: object.title, sandbox: object.sandboxAttribute, style: {
|
|
2664
|
+
display: 'block',
|
|
2665
|
+
width: '100%',
|
|
2666
|
+
height: '100%',
|
|
2667
|
+
border: '0',
|
|
2668
|
+
borderRadius: object.borderRadius !== undefined ? (typeof object.borderRadius === 'number' ? `${object.borderRadius}px` : object.borderRadius) : undefined,
|
|
2669
|
+
pointerEvents: object.isInteractive ? 'auto' : 'none',
|
|
2670
|
+
} }), h("div", { style: {
|
|
2671
|
+
position: 'absolute',
|
|
2672
|
+
inset: '0',
|
|
2673
|
+
borderRadius: object.borderRadius !== undefined ? (typeof object.borderRadius === 'number' ? `${object.borderRadius}px` : object.borderRadius) : undefined,
|
|
2674
|
+
pointerEvents: object.isInteractive ? 'none' : 'auto',
|
|
2675
|
+
} }))), KritzelClassHelper.isInstanceOf(object, 'KritzelSelectionGroup') && !this.core.displaySelectionLineUI(object) && (h("div", { ref: el => el && object.mount(el), style: {
|
|
2579
2676
|
position: 'absolute',
|
|
2580
2677
|
left: '0',
|
|
2581
2678
|
top: '0',
|
|
@@ -3036,7 +3133,7 @@ export class KritzelEngine {
|
|
|
3036
3133
|
"optional": true,
|
|
3037
3134
|
"docs": {
|
|
3038
3135
|
"tags": [],
|
|
3039
|
-
"text": "Configuration for binary asset storage (e.g., images).\
|
|
3136
|
+
"text": "Configuration for binary asset storage (e.g., images).\n\nThe Yjs document only persists asset ids; the actual bytes are stored\nby the providers listed here. Defaults to IndexedDB-only storage. To\nsupport cross-device image sync alongside a networked sync provider\n(Hocuspocus, WebSocket), configure at least one remote asset provider\nsuch as `HttpAssetProvider` or `PresignedAssetProvider`."
|
|
3040
3137
|
},
|
|
3041
3138
|
"getter": false,
|
|
3042
3139
|
"setter": false
|
|
@@ -3065,6 +3162,31 @@ export class KritzelEngine {
|
|
|
3065
3162
|
"getter": false,
|
|
3066
3163
|
"setter": false
|
|
3067
3164
|
},
|
|
3165
|
+
"tools": {
|
|
3166
|
+
"type": "unknown",
|
|
3167
|
+
"mutable": false,
|
|
3168
|
+
"complexType": {
|
|
3169
|
+
"original": "KritzelToolDefinition[]",
|
|
3170
|
+
"resolved": "KritzelToolDefinition[]",
|
|
3171
|
+
"references": {
|
|
3172
|
+
"KritzelToolDefinition": {
|
|
3173
|
+
"location": "import",
|
|
3174
|
+
"path": "../../interfaces/tool.interface",
|
|
3175
|
+
"id": "src/interfaces/tool.interface.ts::KritzelToolDefinition",
|
|
3176
|
+
"referenceLocation": "KritzelToolDefinition"
|
|
3177
|
+
}
|
|
3178
|
+
}
|
|
3179
|
+
},
|
|
3180
|
+
"required": false,
|
|
3181
|
+
"optional": false,
|
|
3182
|
+
"docs": {
|
|
3183
|
+
"tags": [],
|
|
3184
|
+
"text": "Tool definitions to register with this engine instance."
|
|
3185
|
+
},
|
|
3186
|
+
"getter": false,
|
|
3187
|
+
"setter": false,
|
|
3188
|
+
"defaultValue": "[]"
|
|
3189
|
+
},
|
|
3068
3190
|
"globalContextMenuItems": {
|
|
3069
3191
|
"type": "unknown",
|
|
3070
3192
|
"mutable": false,
|
|
@@ -3994,7 +4116,7 @@ export class KritzelEngine {
|
|
|
3994
4116
|
}]
|
|
3995
4117
|
}
|
|
3996
4118
|
},
|
|
3997
|
-
"
|
|
4119
|
+
"setActiveTool": {
|
|
3998
4120
|
"complexType": {
|
|
3999
4121
|
"signature": "(toolName: string) => Promise<void>",
|
|
4000
4122
|
"parameters": [{
|
|
@@ -4392,7 +4514,7 @@ export class KritzelEngine {
|
|
|
4392
4514
|
"return": "Promise<void>"
|
|
4393
4515
|
},
|
|
4394
4516
|
"docs": {
|
|
4395
|
-
"text": "Programmatically opens the context menu at a specified world-coordinate position.\
|
|
4517
|
+
"text": "Programmatically opens the context menu at a specified world-coordinate position.\nIf `objectId` is provided and found, the object context menu is shown for that object.\nIf no `objectId` is provided but a selection group already exists, the object context menu is shown.\nOtherwise, the global context menu is shown.",
|
|
4396
4518
|
"tags": [{
|
|
4397
4519
|
"name": "param",
|
|
4398
4520
|
"text": "options.x - The X position in world (canvas) coordinates."
|
|
@@ -4502,7 +4624,7 @@ export class KritzelEngine {
|
|
|
4502
4624
|
"return": "Promise<T[]>"
|
|
4503
4625
|
},
|
|
4504
4626
|
"docs": {
|
|
4505
|
-
"text": "Returns all objects that match the given predicate function.\
|
|
4627
|
+
"text": "Returns all objects that match the given predicate function.\nExcludes internal selection-related objects (selection groups and selection boxes).",
|
|
4506
4628
|
"tags": [{
|
|
4507
4629
|
"name": "param",
|
|
4508
4630
|
"text": "predicate - A filter function called for each object. Return `true` to include."
|
|
@@ -4511,7 +4633,7 @@ export class KritzelEngine {
|
|
|
4511
4633
|
"text": "An array of matching objects."
|
|
4512
4634
|
}, {
|
|
4513
4635
|
"name": "example",
|
|
4514
|
-
"text": "```ts\
|
|
4636
|
+
"text": "```ts\n// Find all text objects\nconst texts = await engine.findObjects(obj => obj.__class__ === 'KritzelText');\n\n// Find objects at a point\nconst hits = await engine.findObjects(obj => obj.hitTest(100, 200));\n\n// Combine criteria\nconst filtered = await engine.findObjects(obj => obj.__class__ === 'KritzelPath' && obj.opacity < 0.5);\n```"
|
|
4515
4637
|
}]
|
|
4516
4638
|
}
|
|
4517
4639
|
},
|
|
@@ -4644,7 +4766,7 @@ export class KritzelEngine {
|
|
|
4644
4766
|
"return": "Promise<T[]>"
|
|
4645
4767
|
},
|
|
4646
4768
|
"docs": {
|
|
4647
|
-
"text": "Adds multiple objects to the canvas in a single batch operation.\
|
|
4769
|
+
"text": "Adds multiple objects to the canvas in a single batch operation.\nAll objects are inserted within one Yjs transaction (single undo step),\ntriggering only one rerender cycle. Intended for programmatic streaming\nscenarios where per-object overhead would cause stutter.",
|
|
4648
4770
|
"tags": [{
|
|
4649
4771
|
"name": "param",
|
|
4650
4772
|
"text": "objects - The object instances to add."
|
|
@@ -4766,7 +4888,7 @@ export class KritzelEngine {
|
|
|
4766
4888
|
"return": "Promise<T[]>"
|
|
4767
4889
|
},
|
|
4768
4890
|
"docs": {
|
|
4769
|
-
"text": "Removes multiple objects from the canvas in a single batch operation.\
|
|
4891
|
+
"text": "Removes multiple objects from the canvas in a single batch operation.\nAll removals happen within one Yjs transaction (single undo step),\ntriggering only one rerender cycle. Intended for programmatic streaming\nscenarios where per-object overhead would cause stutter.",
|
|
4770
4892
|
"tags": [{
|
|
4771
4893
|
"name": "param",
|
|
4772
4894
|
"text": "objects - The objects to remove."
|
|
@@ -4954,7 +5076,7 @@ export class KritzelEngine {
|
|
|
4954
5076
|
"return": "Promise<void>"
|
|
4955
5077
|
},
|
|
4956
5078
|
"docs": {
|
|
4957
|
-
"text": "Pans the viewport to center on the given object without changing the zoom level.\
|
|
5079
|
+
"text": "Pans the viewport to center on the given object without changing the zoom level.\nUnlike `centerObjectInViewport`, this moves the camera \u2014 not the object.",
|
|
4958
5080
|
"tags": [{
|
|
4959
5081
|
"name": "param",
|
|
4960
5082
|
"text": "object - The object whose center the viewport should pan to."
|
|
@@ -4974,7 +5096,7 @@ export class KritzelEngine {
|
|
|
4974
5096
|
"return": "Promise<boolean>"
|
|
4975
5097
|
},
|
|
4976
5098
|
"docs": {
|
|
4977
|
-
"text": "Pans and zooms the viewport to fit the nearest content, with padding.\
|
|
5099
|
+
"text": "Pans and zooms the viewport to fit the nearest content, with padding.\nUseful when the user has panned away from all objects.",
|
|
4978
5100
|
"tags": [{
|
|
4979
5101
|
"name": "returns",
|
|
4980
5102
|
"text": "`true` if content was found and the viewport was adjusted, `false` otherwise."
|
|
@@ -4998,7 +5120,7 @@ export class KritzelEngine {
|
|
|
4998
5120
|
"return": "Promise<boolean>"
|
|
4999
5121
|
},
|
|
5000
5122
|
"docs": {
|
|
5001
|
-
"text": "Pans and zooms the viewport to fit ALL objects on the canvas, including those not currently rendered.\
|
|
5123
|
+
"text": "Pans and zooms the viewport to fit ALL objects on the canvas, including those not currently rendered.\nCalculates the combined bounding box of all objects and centers the viewport to show them.",
|
|
5002
5124
|
"tags": [{
|
|
5003
5125
|
"name": "param",
|
|
5004
5126
|
"text": "animate - Whether to animate the viewport transition (default: true)."
|
|
@@ -5035,7 +5157,7 @@ export class KritzelEngine {
|
|
|
5035
5157
|
"return": "Promise<boolean>"
|
|
5036
5158
|
},
|
|
5037
5159
|
"docs": {
|
|
5038
|
-
"text": "Pans and zooms the viewport to fit the provided objects.\
|
|
5160
|
+
"text": "Pans and zooms the viewport to fit the provided objects.\nCalculates the combined bounding box of the given objects and centers the viewport to show them.",
|
|
5039
5161
|
"tags": [{
|
|
5040
5162
|
"name": "param",
|
|
5041
5163
|
"text": "objects - The objects to center and fit in the viewport."
|
|
@@ -5142,7 +5264,7 @@ export class KritzelEngine {
|
|
|
5142
5264
|
"return": "Promise<void>"
|
|
5143
5265
|
},
|
|
5144
5266
|
"docs": {
|
|
5145
|
-
"text": "Zooms the viewport to the given scale level.\
|
|
5267
|
+
"text": "Zooms the viewport to the given scale level.\nOptionally centers on a world point; if omitted, zooms around the viewport center.",
|
|
5146
5268
|
"tags": [{
|
|
5147
5269
|
"name": "param",
|
|
5148
5270
|
"text": "scale - Target scale level."
|
|
@@ -5430,7 +5552,7 @@ export class KritzelEngine {
|
|
|
5430
5552
|
"return": "Promise<KritzelObjectExportFormat[]>"
|
|
5431
5553
|
},
|
|
5432
5554
|
"docs": {
|
|
5433
|
-
"text": "Returns export formats supported by the currently selected object.\
|
|
5555
|
+
"text": "Returns export formats supported by the currently selected object.\nOnly returns formats when exactly one object is selected.",
|
|
5434
5556
|
"tags": []
|
|
5435
5557
|
}
|
|
5436
5558
|
},
|
|
@@ -5457,7 +5579,7 @@ export class KritzelEngine {
|
|
|
5457
5579
|
"return": "Promise<boolean>"
|
|
5458
5580
|
},
|
|
5459
5581
|
"docs": {
|
|
5460
|
-
"text": "Checks whether the currently selected object supports a specific export format.\
|
|
5582
|
+
"text": "Checks whether the currently selected object supports a specific export format.\nReturns false when none or multiple objects are selected.",
|
|
5461
5583
|
"tags": []
|
|
5462
5584
|
}
|
|
5463
5585
|
},
|
|
@@ -5484,7 +5606,7 @@ export class KritzelEngine {
|
|
|
5484
5606
|
"return": "Promise<void>"
|
|
5485
5607
|
},
|
|
5486
5608
|
"docs": {
|
|
5487
|
-
"text": "Exports the currently selected object in the requested format and triggers a file download.\
|
|
5609
|
+
"text": "Exports the currently selected object in the requested format and triggers a file download.\nOnly supports single selection.",
|
|
5488
5610
|
"tags": []
|
|
5489
5611
|
}
|
|
5490
5612
|
},
|
|
@@ -5505,7 +5627,7 @@ export class KritzelEngine {
|
|
|
5505
5627
|
"return": "Promise<string>"
|
|
5506
5628
|
},
|
|
5507
5629
|
"docs": {
|
|
5508
|
-
"text": "Exports the current workspace and all its objects as a JSON string.\
|
|
5630
|
+
"text": "Exports the current workspace and all its objects as a JSON string.\nThe exported data includes workspace metadata (id, name, viewport) and all canvas objects.",
|
|
5509
5631
|
"tags": [{
|
|
5510
5632
|
"name": "returns",
|
|
5511
5633
|
"text": "A JSON string representing the complete workspace state."
|
|
@@ -5539,7 +5661,7 @@ export class KritzelEngine {
|
|
|
5539
5661
|
"return": "Promise<void>"
|
|
5540
5662
|
},
|
|
5541
5663
|
"docs": {
|
|
5542
|
-
"text": "Imports a workspace from a JSON string into a new workspace.\
|
|
5664
|
+
"text": "Imports a workspace from a JSON string into a new workspace.\nCreates a new workspace with the imported data and automatically switches to it.",
|
|
5543
5665
|
"tags": [{
|
|
5544
5666
|
"name": "param",
|
|
5545
5667
|
"text": "json - A JSON string containing workspace data (from exportAsJson)."
|
|
@@ -5576,7 +5698,7 @@ export class KritzelEngine {
|
|
|
5576
5698
|
"return": "Promise<number>"
|
|
5577
5699
|
},
|
|
5578
5700
|
"docs": {
|
|
5579
|
-
"text": "Loads objects from a workspace JSON string into the current workspace.\
|
|
5701
|
+
"text": "Loads objects from a workspace JSON string into the current workspace.\nUnlike importFromJson, this does not create a new workspace - it adds objects to the existing one.\nUseful for initializing a workspace with pre-existing content after the editor is ready.",
|
|
5580
5702
|
"tags": [{
|
|
5581
5703
|
"name": "param",
|
|
5582
5704
|
"text": "json - A JSON string containing workspace data (from exportAsJson)."
|
|
@@ -5636,7 +5758,7 @@ export class KritzelEngine {
|
|
|
5636
5758
|
"return": "Promise<void>"
|
|
5637
5759
|
},
|
|
5638
5760
|
"docs": {
|
|
5639
|
-
"text": "Opens a file picker dialog and imports the selected JSON file into the workspace.\
|
|
5761
|
+
"text": "Opens a file picker dialog and imports the selected JSON file into the workspace.\nThis method creates a hidden file input, triggers the browser's file chooser,\nreads the selected JSON file, and imports it using importFromJson.",
|
|
5640
5762
|
"tags": [{
|
|
5641
5763
|
"name": "returns",
|
|
5642
5764
|
"text": "A promise that resolves when the import is complete or rejects on error/cancel."
|
|
@@ -5707,7 +5829,7 @@ export class KritzelEngine {
|
|
|
5707
5829
|
"return": "Promise<KritzelWorkspace>"
|
|
5708
5830
|
},
|
|
5709
5831
|
"docs": {
|
|
5710
|
-
"text": "Creates a new workspace and emits a `workspacesChange` event.\
|
|
5832
|
+
"text": "Creates a new workspace and emits a `workspacesChange` event.\nEmits `activeWorkspaceChange` if the created workspace is activated.",
|
|
5711
5833
|
"tags": [{
|
|
5712
5834
|
"name": "param",
|
|
5713
5835
|
"text": "workspace - The workspace instance to create."
|
|
@@ -5740,7 +5862,7 @@ export class KritzelEngine {
|
|
|
5740
5862
|
"return": "Promise<void>"
|
|
5741
5863
|
},
|
|
5742
5864
|
"docs": {
|
|
5743
|
-
"text": "Applies a workspace as declared and emits a `workspacesChange` event.\
|
|
5865
|
+
"text": "Applies a workspace as declared and emits a `workspacesChange` event.\nMetadata and viewport are always applied. When `workspace.objects` is set it is treated as the\ncomplete desired object set (`undefined` leaves objects untouched, `[]` removes them all);\nupdating objects of a non-active workspace requires a configured sync provider.",
|
|
5744
5866
|
"tags": [{
|
|
5745
5867
|
"name": "param",
|
|
5746
5868
|
"text": "workspace - The workspace describing the desired state."
|
|
@@ -5860,7 +5982,7 @@ export class KritzelEngine {
|
|
|
5860
5982
|
"return": "Promise<void>"
|
|
5861
5983
|
},
|
|
5862
5984
|
"docs": {
|
|
5863
|
-
"text": "Loads a shared workspace by token.\
|
|
5985
|
+
"text": "Loads a shared workspace by token.\nIf the workspace exists locally, it switches to it.\nIf it doesn't exist, it adds it to the local workspaces list and then switches to it.",
|
|
5864
5986
|
"tags": [{
|
|
5865
5987
|
"name": "param",
|
|
5866
5988
|
"text": "token - The connection token identifying the shared workspace"
|
|
@@ -5880,7 +6002,7 @@ export class KritzelEngine {
|
|
|
5880
6002
|
"return": "Promise<void>"
|
|
5881
6003
|
},
|
|
5882
6004
|
"docs": {
|
|
5883
|
-
"text": "Reinitializes sync by performing a full teardown and re-initialization.\
|
|
6005
|
+
"text": "Reinitializes sync by performing a full teardown and re-initialization.\nDestroys the current Yjs documents and providers, then rebuilds everything\nfrom the current syncConfig. Data reloads from IndexedDB nearly instantly.\nCall this after updating the syncConfig prop (e.g. after authentication state changes).",
|
|
5884
6006
|
"tags": []
|
|
5885
6007
|
}
|
|
5886
6008
|
},
|
|
@@ -5997,7 +6119,7 @@ export class KritzelEngine {
|
|
|
5997
6119
|
"return": "Promise<void>"
|
|
5998
6120
|
},
|
|
5999
6121
|
"docs": {
|
|
6000
|
-
"text": "Declaratively configures the full locale catalog, replacing the available\
|
|
6122
|
+
"text": "Declaratively configures the full locale catalog, replacing the available\nlocale set. Pass `undefined` to restore the built-in locales (en/de/fr).",
|
|
6001
6123
|
"tags": [{
|
|
6002
6124
|
"name": "param",
|
|
6003
6125
|
"text": "locales - The full locale catalog, or `undefined` for built-ins."
|
|
@@ -6173,7 +6295,34 @@ export class KritzelEngine {
|
|
|
6173
6295
|
"return": "Promise<Partial<Record<keyof KritzelTerms, string>>>"
|
|
6174
6296
|
},
|
|
6175
6297
|
"docs": {
|
|
6176
|
-
"text": "Resolves every known term key for the active locale into a flat map.\
|
|
6298
|
+
"text": "Resolves every known term key for the active locale into a flat map.\nUseful for UI layers that need to localize many strings at once.",
|
|
6299
|
+
"tags": []
|
|
6300
|
+
}
|
|
6301
|
+
},
|
|
6302
|
+
"getTool": {
|
|
6303
|
+
"complexType": {
|
|
6304
|
+
"signature": "(toolName: string) => Promise<KritzelBaseTool | null>",
|
|
6305
|
+
"parameters": [{
|
|
6306
|
+
"name": "toolName",
|
|
6307
|
+
"type": "string",
|
|
6308
|
+
"docs": ""
|
|
6309
|
+
}],
|
|
6310
|
+
"references": {
|
|
6311
|
+
"Promise": {
|
|
6312
|
+
"location": "global",
|
|
6313
|
+
"id": "global::Promise"
|
|
6314
|
+
},
|
|
6315
|
+
"KritzelBaseTool": {
|
|
6316
|
+
"location": "import",
|
|
6317
|
+
"path": "../../classes/tools/base-tool.class",
|
|
6318
|
+
"id": "src/classes/tools/base-tool.class.ts::KritzelBaseTool",
|
|
6319
|
+
"referenceLocation": "KritzelBaseTool"
|
|
6320
|
+
}
|
|
6321
|
+
},
|
|
6322
|
+
"return": "Promise<KritzelBaseTool>"
|
|
6323
|
+
},
|
|
6324
|
+
"docs": {
|
|
6325
|
+
"text": "Returns a tool registered in this engine instance.",
|
|
6177
6326
|
"tags": []
|
|
6178
6327
|
}
|
|
6179
6328
|
}
|
|
@@ -6196,6 +6345,9 @@ export class KritzelEngine {
|
|
|
6196
6345
|
}, {
|
|
6197
6346
|
"propName": "user",
|
|
6198
6347
|
"methodName": "onUserChange"
|
|
6348
|
+
}, {
|
|
6349
|
+
"propName": "tools",
|
|
6350
|
+
"methodName": "onToolsChange"
|
|
6199
6351
|
}, {
|
|
6200
6352
|
"propName": "globalContextMenuItems",
|
|
6201
6353
|
"methodName": "onGlobalContextMenuItemsChange"
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
:host {
|
|
2
|
-
display: inline-flex; /* Changed from block to inline-flex for better alignment */
|
|
3
|
-
justify-content: center; /* Center content horizontally */
|
|
4
|
-
align-items: center; /* Center content vertically */
|
|
5
|
-
color: var(--kritzel-icon-color, inherited);
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
span {
|
|
9
|
-
display: flex;
|
|
10
|
-
align-items: center;
|
|
11
|
-
width: 100%; /* Make span fill host width */
|
|
12
|
-
height: 100%; /* Make span fill host height */
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
span > svg { /* Ensure SVG scales within the span */
|
|
16
|
-
width: 100%;
|
|
17
|
-
height: 100%;
|
|
18
|
-
}
|
|
1
|
+
:host {
|
|
2
|
+
display: inline-flex; /* Changed from block to inline-flex for better alignment */
|
|
3
|
+
justify-content: center; /* Center content horizontally */
|
|
4
|
+
align-items: center; /* Center content vertically */
|
|
5
|
+
color: var(--kritzel-icon-color, inherited);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
span {
|
|
9
|
+
display: flex;
|
|
10
|
+
align-items: center;
|
|
11
|
+
width: 100%; /* Make span fill host width */
|
|
12
|
+
height: 100%; /* Make span fill host height */
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
span > svg { /* Ensure SVG scales within the span */
|
|
16
|
+
width: 100%;
|
|
17
|
+
height: 100%;
|
|
18
|
+
}
|
|
@@ -1,9 +1,23 @@
|
|
|
1
|
-
import { h, Host } from "@stencil/core";
|
|
1
|
+
import { h, Host, forceUpdate } from "@stencil/core";
|
|
2
2
|
import { KritzelIconRegistry } from "../../classes/registries/icon-registry.class";
|
|
3
3
|
export class KritzelIcon {
|
|
4
4
|
name;
|
|
5
5
|
label;
|
|
6
6
|
size = 24;
|
|
7
|
+
unsubscribe;
|
|
8
|
+
connectedCallback() {
|
|
9
|
+
this.unsubscribe?.();
|
|
10
|
+
this.unsubscribe = KritzelIconRegistry.subscribe(name => {
|
|
11
|
+
if (name === this.name) {
|
|
12
|
+
forceUpdate(this);
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
forceUpdate(this);
|
|
16
|
+
}
|
|
17
|
+
disconnectedCallback() {
|
|
18
|
+
this.unsubscribe?.();
|
|
19
|
+
this.unsubscribe = undefined;
|
|
20
|
+
}
|
|
7
21
|
render() {
|
|
8
22
|
const svgContent = KritzelIconRegistry.get(this.name);
|
|
9
23
|
if (!svgContent) {
|
|
@@ -34,9 +48,16 @@ export class KritzelIcon {
|
|
|
34
48
|
"type": "string",
|
|
35
49
|
"mutable": false,
|
|
36
50
|
"complexType": {
|
|
37
|
-
"original": "
|
|
38
|
-
"resolved": "string",
|
|
39
|
-
"references": {
|
|
51
|
+
"original": "KritzelIconName",
|
|
52
|
+
"resolved": "\"align\" | \"alignCenterHorizontal\" | \"alignCenterVertical\" | \"alignEndHorizontal\" | \"alignEndVertical\" | \"alignStartHorizontal\" | \"alignStartVertical\" | \"arrow\" | \"arrowDownFromDot\" | \"arrowUpFromDot\" | \"braces\" | \"bringToFront\" | \"check\" | \"chevronDown\" | \"chevronLeft\" | \"chevronRight\" | \"chevronUp\" | \"chevronsLeft\" | \"command\" | \"copy\" | \"cursor\" | \"cut\" | \"delete\" | \"download\" | \"ellipsisVertical\" | \"eraser\" | \"facebook\" | \"github\" | \"google\" | \"group\" | \"hand\" | \"handGrab\" | \"heart\" | \"highlighter\" | \"image\" | \"imageOff\" | \"info\" | \"layoutTemplate\" | \"logOut\" | \"minus\" | \"mousePointer\" | \"moveVertical\" | \"ordering\" | \"palette\" | \"paste\" | \"pen\" | \"plus\" | \"pointer\" | \"redo\" | \"selectAll\" | \"sendToBack\" | \"settings\" | \"shapeEllipse\" | \"shapeRectangle\" | \"shapeTriangle\" | \"shapes\" | \"share\" | \"type\" | \"undo\" | \"ungroup\" | \"upload\" | \"usersRound\" | \"viewport\" | \"x\" | string & {}",
|
|
53
|
+
"references": {
|
|
54
|
+
"KritzelIconName": {
|
|
55
|
+
"location": "import",
|
|
56
|
+
"path": "../../classes/registries/icon-registry.class",
|
|
57
|
+
"id": "src/classes/registries/icon-registry.class.ts::KritzelIconName",
|
|
58
|
+
"referenceLocation": "KritzelIconName"
|
|
59
|
+
}
|
|
60
|
+
}
|
|
40
61
|
},
|
|
41
62
|
"required": false,
|
|
42
63
|
"optional": false,
|