kritzel-stencil 0.1.80 → 0.1.82
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/cjs/index.cjs.js +1 -1
- package/dist/cjs/kritzel-active-users_42.cjs.entry.js +30 -37
- package/dist/cjs/{workspace.migrations-DUXtSb7C.js → workspace.migrations-4HATwIMK.js} +46 -58
- package/dist/collection/classes/core/core.class.js +6 -6
- package/dist/collection/classes/core/store.class.js +0 -12
- package/dist/collection/classes/objects/base-object.class.js +1 -1
- package/dist/collection/classes/objects/custom-element.class.js +1 -1
- package/dist/collection/classes/objects/group.class.js +1 -1
- package/dist/collection/classes/objects/image.class.js +1 -1
- package/dist/collection/classes/objects/line.class.js +1 -1
- package/dist/collection/classes/objects/path.class.js +1 -1
- package/dist/collection/classes/objects/selection-box.class.js +1 -1
- package/dist/collection/classes/objects/selection-group.class.js +1 -1
- package/dist/collection/classes/objects/shape.class.js +15 -21
- package/dist/collection/classes/objects/text.class.js +24 -30
- package/dist/collection/components/core/kritzel-engine/kritzel-engine.js +21 -16
- package/dist/collection/constants/version.js +1 -1
- package/dist/components/index.js +1 -1
- package/dist/components/kritzel-awareness-cursors.js +1 -1
- package/dist/components/kritzel-controls.js +1 -1
- package/dist/components/kritzel-editor.js +1 -1
- package/dist/components/kritzel-engine.js +1 -1
- package/dist/components/kritzel-settings.js +1 -1
- package/dist/components/kritzel-tool-config.js +1 -1
- package/dist/components/{p-xYCbKFih.js → p-B4h_tGG1.js} +1 -1
- package/dist/components/{p-BcwZ36sO.js → p-BPQOTise.js} +1 -1
- package/dist/components/{p-B-Gej_Ak.js → p-C35iuSnC.js} +1 -1
- package/dist/components/{p-BzQmBVwr.js → p-CgtykATT.js} +2 -2
- package/dist/components/{p-C_fSm7T4.js → p-DK_d3fKa.js} +1 -1
- package/dist/components/p-DQK_4lkI.js +1 -0
- package/dist/components/{p-CvyE2Wg-.js → p-DsfD4pGR.js} +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/kritzel-active-users_42.entry.js +30 -37
- package/dist/esm/{workspace.migrations-OzSSw5kt.js → workspace.migrations-Be65cOkQ.js} +46 -58
- package/dist/stencil/index.esm.js +1 -1
- package/dist/stencil/p-Be65cOkQ.js +1 -0
- package/dist/stencil/p-f318b7d5.entry.js +9 -0
- package/dist/stencil/stencil.esm.js +1 -1
- package/dist/types/classes/core/store.class.d.ts +0 -8
- package/dist/types/classes/objects/shape.class.d.ts +0 -1
- package/dist/types/classes/objects/text.class.d.ts +0 -1
- package/dist/types/components/core/kritzel-engine/kritzel-engine.d.ts +1 -0
- package/dist/types/constants/version.d.ts +1 -1
- package/package.json +1 -1
- package/dist/components/p-C8WnYSHi.js +0 -1
- package/dist/stencil/p-OzSSw5kt.js +0 -1
- package/dist/stencil/p-f7be06a8.entry.js +0 -9
package/dist/cjs/index.cjs.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var index = require('./index-CFnj_FXt.js');
|
|
4
|
-
var workspace_migrations = require('./workspace.migrations-
|
|
4
|
+
var workspace_migrations = require('./workspace.migrations-4HATwIMK.js');
|
|
5
5
|
var Y = require('yjs');
|
|
6
6
|
require('y-websocket');
|
|
7
7
|
require('y-indexeddb');
|
|
@@ -20759,7 +20759,7 @@ class KritzelCustomElement extends workspace_migrations.KritzelBaseObject {
|
|
|
20759
20759
|
const object = new KritzelCustomElement(config);
|
|
20760
20760
|
object._core = core;
|
|
20761
20761
|
object.id = object.generateId();
|
|
20762
|
-
object.workspaceId = core.store.activeWorkspace.id;
|
|
20762
|
+
object.workspaceId = core.store.state.activeWorkspace.id;
|
|
20763
20763
|
object.userId = core.user?.id;
|
|
20764
20764
|
return object;
|
|
20765
20765
|
}
|
|
@@ -22287,18 +22287,6 @@ class KritzelStore {
|
|
|
22287
22287
|
}
|
|
22288
22288
|
return this._state.objects;
|
|
22289
22289
|
}
|
|
22290
|
-
/**
|
|
22291
|
-
* Gets the currently active workspace.
|
|
22292
|
-
* Throws an error if no active workspace is set, as it is required for workspace-bound operations.
|
|
22293
|
-
* @returns The current active KritzelWorkspace
|
|
22294
|
-
* @throws Error if no active workspace is set in the state
|
|
22295
|
-
*/
|
|
22296
|
-
get activeWorkspace() {
|
|
22297
|
-
if (!this._state.activeWorkspace) {
|
|
22298
|
-
throw new Error('Active workspace is not set.');
|
|
22299
|
-
}
|
|
22300
|
-
return this._state.activeWorkspace;
|
|
22301
|
-
}
|
|
22302
22290
|
/**
|
|
22303
22291
|
* Gets the host element for the Kritzel editor.
|
|
22304
22292
|
* Throws an error if the host is not set, as it is required for many operations.
|
|
@@ -23481,7 +23469,7 @@ class KritzelCore {
|
|
|
23481
23469
|
workspace.updatedAt = new Date();
|
|
23482
23470
|
this.saveWorkspaceToAppState(workspace);
|
|
23483
23471
|
// Keep metadata map in sync when the active workspace's name changes
|
|
23484
|
-
if (this._store.activeWorkspace?.id === workspace.id) {
|
|
23472
|
+
if (this._store.state.activeWorkspace?.id === workspace.id) {
|
|
23485
23473
|
this._store.objects?.setWorkspaceName(workspace.name);
|
|
23486
23474
|
}
|
|
23487
23475
|
const workspaces = this._store.state.workspaces;
|
|
@@ -23499,7 +23487,7 @@ class KritzelCore {
|
|
|
23499
23487
|
*/
|
|
23500
23488
|
deleteWorkspace(workspace) {
|
|
23501
23489
|
// If deleting the active workspace, need to handle ObjectMap cleanup
|
|
23502
|
-
if (this._store.activeWorkspace?.id === workspace.id) {
|
|
23490
|
+
if (this._store.state.activeWorkspace?.id === workspace.id) {
|
|
23503
23491
|
this.engine.viewport?.cancelPendingUpdates();
|
|
23504
23492
|
this._store.objects?.destroy();
|
|
23505
23493
|
}
|
|
@@ -23520,7 +23508,7 @@ class KritzelCore {
|
|
|
23520
23508
|
* @param scale - The zoom scale of the viewport
|
|
23521
23509
|
*/
|
|
23522
23510
|
updateWorkspaceViewport(translateX, translateY, scale) {
|
|
23523
|
-
const activeWorkspace = this._store.activeWorkspace;
|
|
23511
|
+
const activeWorkspace = this._store.state.activeWorkspace;
|
|
23524
23512
|
if (!activeWorkspace) {
|
|
23525
23513
|
return;
|
|
23526
23514
|
}
|
|
@@ -23543,7 +23531,7 @@ class KritzelCore {
|
|
|
23543
23531
|
* @returns True if the workspace is public, false otherwise
|
|
23544
23532
|
*/
|
|
23545
23533
|
getIsPublic() {
|
|
23546
|
-
return this._store.activeWorkspace?.isPublic ?? false;
|
|
23534
|
+
return this._store.state.activeWorkspace?.isPublic ?? false;
|
|
23547
23535
|
}
|
|
23548
23536
|
// ═══════════════════════════════════════════════════════════════════════════
|
|
23549
23537
|
// Object Management Methods
|
|
@@ -23735,7 +23723,7 @@ class KritzelCore {
|
|
|
23735
23723
|
if (!copiedObjects || copiedObjects.length === 0) {
|
|
23736
23724
|
return;
|
|
23737
23725
|
}
|
|
23738
|
-
const activeWorkspace = this._store.activeWorkspace;
|
|
23726
|
+
const activeWorkspace = this._store.state.activeWorkspace;
|
|
23739
23727
|
const originalIdMapping = this._store.state.copiedObjectIdMapping;
|
|
23740
23728
|
// Check if we're pasting from a different workspace
|
|
23741
23729
|
const isDifferentWorkspace = copiedObjects.some(obj => obj.workspaceId !== activeWorkspace.id);
|
|
@@ -24251,7 +24239,7 @@ class KritzelCore {
|
|
|
24251
24239
|
// saving the old workspace's viewport to the new workspace
|
|
24252
24240
|
this._kritzelEngine.viewport?.cancelPendingUpdates();
|
|
24253
24241
|
// Immediately save the current workspace's viewport before switching
|
|
24254
|
-
const currentWorkspace = this._store.activeWorkspace;
|
|
24242
|
+
const currentWorkspace = this._store.state.activeWorkspace;
|
|
24255
24243
|
if (currentWorkspace) {
|
|
24256
24244
|
this.updateWorkspaceViewport(this._store.state.translateX, this._store.state.translateY, this._store.state.scale);
|
|
24257
24245
|
}
|
|
@@ -25606,13 +25594,13 @@ const KritzelEngine = class {
|
|
|
25606
25594
|
}
|
|
25607
25595
|
// Let batched prop updates settle, then perform an idempotent re-check.
|
|
25608
25596
|
await Promise.resolve();
|
|
25609
|
-
const currentWorkspaceId = this.core.store.activeWorkspace?.id;
|
|
25597
|
+
const currentWorkspaceId = this.core.store.state.activeWorkspace?.id;
|
|
25610
25598
|
if (currentWorkspaceId === newWorkspaceId) {
|
|
25611
25599
|
return;
|
|
25612
25600
|
}
|
|
25613
25601
|
this.core.beforeWorkspaceChange();
|
|
25614
25602
|
await this.initializeWorkspaceIfNeeded(newWorkspace);
|
|
25615
|
-
this.activeWorkspaceChange.emit(this.core.store.activeWorkspace);
|
|
25603
|
+
this.activeWorkspaceChange.emit(this.core.store.state.activeWorkspace);
|
|
25616
25604
|
}
|
|
25617
25605
|
/** Optional unique identifier for namespacing storage keys across multiple editor instances. */
|
|
25618
25606
|
editorId;
|
|
@@ -25630,8 +25618,11 @@ const KritzelEngine = class {
|
|
|
25630
25618
|
this._syncConfigRevision++;
|
|
25631
25619
|
// Keep core config in sync immediately so late prop updates are not lost.
|
|
25632
25620
|
this.core.setSyncConfig(newValue);
|
|
25633
|
-
// If syncConfig arrives after componentDidLoad, initialize Yjs now
|
|
25634
|
-
|
|
25621
|
+
// If syncConfig arrives after componentDidLoad, initialize Yjs now.
|
|
25622
|
+
// Guard on _isViewportReady to avoid restoring viewport state before
|
|
25623
|
+
// viewportWidth/viewportHeight are set (they default to 0 until the
|
|
25624
|
+
// KritzelViewport constructor runs inside componentDidLoad's timeout).
|
|
25625
|
+
if (newValue && !this._isYjsInitialized && this._isViewportReady) {
|
|
25635
25626
|
await this.initializeSyncAndWorkspace();
|
|
25636
25627
|
}
|
|
25637
25628
|
}
|
|
@@ -26064,7 +26055,7 @@ const KritzelEngine = class {
|
|
|
26064
26055
|
object._core = this.core;
|
|
26065
26056
|
object.scale = this.core.store.state.scale;
|
|
26066
26057
|
object.zIndex = this.core.store.currentZIndex;
|
|
26067
|
-
object.workspaceId = this.core.store.activeWorkspace.id;
|
|
26058
|
+
object.workspaceId = this.core.store.state.activeWorkspace.id;
|
|
26068
26059
|
// Handle KritzelText: recreate the editor now that _core is available
|
|
26069
26060
|
// The editor's dispatchTransaction callback needs _core for persisting changes
|
|
26070
26061
|
if (workspace_migrations.KritzelClassHelper.isInstanceOf(object, 'KritzelText')) {
|
|
@@ -26085,7 +26076,7 @@ const KritzelEngine = class {
|
|
|
26085
26076
|
child._core = this.core;
|
|
26086
26077
|
child.scale = this.core.store.state.scale;
|
|
26087
26078
|
child.zIndex = this.core.store.currentZIndex;
|
|
26088
|
-
child.workspaceId = this.core.store.activeWorkspace.id;
|
|
26079
|
+
child.workspaceId = this.core.store.state.activeWorkspace.id;
|
|
26089
26080
|
idRemapping.set(oldId, child.id);
|
|
26090
26081
|
object.childIds.push(child.id);
|
|
26091
26082
|
});
|
|
@@ -26286,7 +26277,7 @@ const KritzelEngine = class {
|
|
|
26286
26277
|
// Save critical state before screenshot to restore after
|
|
26287
26278
|
const savedState = {
|
|
26288
26279
|
objects: this.core.store.objects,
|
|
26289
|
-
activeWorkspace: this.core.store.activeWorkspace,
|
|
26280
|
+
activeWorkspace: this.core.store.state.activeWorkspace,
|
|
26290
26281
|
workspaces: this.core.store.state.workspaces,
|
|
26291
26282
|
activeTool: this.core.store.state.activeTool,
|
|
26292
26283
|
isReady: this.core.store.state.isReady,
|
|
@@ -26484,7 +26475,7 @@ const KritzelEngine = class {
|
|
|
26484
26475
|
* @returns A JSON string representing the complete workspace state.
|
|
26485
26476
|
*/
|
|
26486
26477
|
async exportAsJson() {
|
|
26487
|
-
const workspace = this.core.store.activeWorkspace;
|
|
26478
|
+
const workspace = this.core.store.state.activeWorkspace;
|
|
26488
26479
|
if (!workspace) {
|
|
26489
26480
|
throw new Error('Cannot export workspace: no active workspace is loaded');
|
|
26490
26481
|
}
|
|
@@ -26560,7 +26551,7 @@ const KritzelEngine = class {
|
|
|
26560
26551
|
if (data.version && data.version !== workspace_migrations.WORKSPACE_EXPORT_VERSION) {
|
|
26561
26552
|
console.warn(`Workspace version mismatch: expected ${workspace_migrations.WORKSPACE_EXPORT_VERSION}, got ${data.version}`);
|
|
26562
26553
|
}
|
|
26563
|
-
const activeWorkspace = this.core.store.activeWorkspace;
|
|
26554
|
+
const activeWorkspace = this.core.store.state.activeWorkspace;
|
|
26564
26555
|
if (!activeWorkspace) {
|
|
26565
26556
|
throw new Error('Cannot load objects: no active workspace is loaded');
|
|
26566
26557
|
}
|
|
@@ -26700,7 +26691,7 @@ const KritzelEngine = class {
|
|
|
26700
26691
|
}
|
|
26701
26692
|
/** Returns the currently active workspace. */
|
|
26702
26693
|
async getActiveWorkspace() {
|
|
26703
|
-
const activeWorkspace = this.core.store.activeWorkspace;
|
|
26694
|
+
const activeWorkspace = this.core.store.state.activeWorkspace;
|
|
26704
26695
|
if (!activeWorkspace) {
|
|
26705
26696
|
throw new Error('No active workspace is loaded');
|
|
26706
26697
|
}
|
|
@@ -26733,7 +26724,7 @@ const KritzelEngine = class {
|
|
|
26733
26724
|
this.workspacesChange.emit(this.core.store.state.workspaces);
|
|
26734
26725
|
this.core.beforeWorkspaceChange();
|
|
26735
26726
|
await this.initializeWorkspaceIfNeeded(workspace);
|
|
26736
|
-
this.activeWorkspaceChange.emit(this.core.store.activeWorkspace);
|
|
26727
|
+
this.activeWorkspaceChange.emit(this.core.store.state.activeWorkspace);
|
|
26737
26728
|
}
|
|
26738
26729
|
/**
|
|
26739
26730
|
* Reinitializes sync by performing a full teardown and re-initialization.
|
|
@@ -26755,6 +26746,7 @@ const KritzelEngine = class {
|
|
|
26755
26746
|
keyHandler;
|
|
26756
26747
|
contextMenuElement = null;
|
|
26757
26748
|
_lastHadSelectionGroup = false;
|
|
26749
|
+
_isViewportReady = false;
|
|
26758
26750
|
_isYjsInitialized = false;
|
|
26759
26751
|
_isResolvingActiveWorkspaceId = false;
|
|
26760
26752
|
_stateChangeListenersRegistered = false;
|
|
@@ -26828,6 +26820,7 @@ const KritzelEngine = class {
|
|
|
26828
26820
|
this.contextMenuHandler = new KritzelContextMenuHandler(this.core, this.globalContextMenuItems, this.objectContextMenuItems);
|
|
26829
26821
|
this.keyHandler = new KritzelKeyHandler(this.core);
|
|
26830
26822
|
this.viewport = new KritzelViewport(this.core, this.host);
|
|
26823
|
+
this._isViewportReady = true;
|
|
26831
26824
|
// Initialize cursor manager with target element and shadow root
|
|
26832
26825
|
this.core.cursorManager.setTargetElement(this.cursorTarget || document.body);
|
|
26833
26826
|
if (this.host.shadowRoot) {
|
|
@@ -26893,7 +26886,7 @@ const KritzelEngine = class {
|
|
|
26893
26886
|
await this.initializeWorkspaceIfNeeded(startupWorkspace);
|
|
26894
26887
|
}
|
|
26895
26888
|
// Emit initial active workspace once startup initialization has completed
|
|
26896
|
-
const initialActiveWorkspace = this.core.store.activeWorkspace;
|
|
26889
|
+
const initialActiveWorkspace = this.core.store.state.activeWorkspace;
|
|
26897
26890
|
if (initialActiveWorkspace) {
|
|
26898
26891
|
this.activeWorkspaceChange.emit(initialActiveWorkspace);
|
|
26899
26892
|
}
|
|
@@ -26922,7 +26915,7 @@ const KritzelEngine = class {
|
|
|
26922
26915
|
if (!this.activeWorkspaceId || this._isResolvingActiveWorkspaceId) {
|
|
26923
26916
|
return;
|
|
26924
26917
|
}
|
|
26925
|
-
if (this.core.store.activeWorkspace?.id === this.activeWorkspaceId) {
|
|
26918
|
+
if (this.core.store.state.activeWorkspace?.id === this.activeWorkspaceId) {
|
|
26926
26919
|
return;
|
|
26927
26920
|
}
|
|
26928
26921
|
this._isResolvingActiveWorkspaceId = true;
|
|
@@ -26938,17 +26931,17 @@ const KritzelEngine = class {
|
|
|
26938
26931
|
}
|
|
26939
26932
|
return;
|
|
26940
26933
|
}
|
|
26941
|
-
if (this.core.store.activeWorkspace?.id === workspace.id) {
|
|
26934
|
+
if (this.core.store.state.activeWorkspace?.id === workspace.id) {
|
|
26942
26935
|
return;
|
|
26943
26936
|
}
|
|
26944
26937
|
this.core.beforeWorkspaceChange();
|
|
26945
26938
|
await this.initializeWorkspaceIfNeeded(workspace);
|
|
26946
|
-
this.activeWorkspaceChange.emit(this.core.store.activeWorkspace);
|
|
26939
|
+
this.activeWorkspaceChange.emit(this.core.store.state.activeWorkspace);
|
|
26947
26940
|
}
|
|
26948
26941
|
async initializeWorkspaceIfNeeded(workspace, options) {
|
|
26949
26942
|
const targetWorkspaceId = workspace?.id ?? null;
|
|
26950
26943
|
const targetKey = targetWorkspaceId ?? (options?.skipFallbackCreation ? '__NO_FALLBACK__' : '__AUTO__');
|
|
26951
|
-
if (targetWorkspaceId && this.core.store.activeWorkspace?.id === targetWorkspaceId) {
|
|
26944
|
+
if (targetWorkspaceId && this.core.store.state.activeWorkspace?.id === targetWorkspaceId) {
|
|
26952
26945
|
return;
|
|
26953
26946
|
}
|
|
26954
26947
|
if (this._workspaceInitializationPromise && this._workspaceInitializationTargetKey === targetKey) {
|
|
@@ -28715,7 +28708,7 @@ const KritzelPortal = class {
|
|
|
28715
28708
|
* This file is auto-generated by the version bump scripts.
|
|
28716
28709
|
* Do not modify manually.
|
|
28717
28710
|
*/
|
|
28718
|
-
const KRITZEL_VERSION = '0.1.
|
|
28711
|
+
const KRITZEL_VERSION = '0.1.82';
|
|
28719
28712
|
|
|
28720
28713
|
const kritzelSettingsCss = () => `:host{display:contents}kritzel-dialog{--kritzel-dialog-body-padding:0;--kritzel-dialog-width-large:800px;--kritzel-dialog-height-large:500px}.footer-button{padding:8px 16px;border-radius:6px;cursor:pointer;font-size:14px}.cancel-button{border:1px solid #ebebeb;background:#fff;color:inherit}.cancel-button:hover{background:#f5f5f5}.settings-content{padding:0}.settings-content h3{margin:0 0 16px 0;font-size:18px;font-weight:600;color:var(--kritzel-settings-content-heading-color, #333333)}.settings-content p{margin:0;font-size:14px;color:var(--kritzel-settings-content-text-color, #666666);line-height:1.5}.settings-group{display:flex;flex-direction:column;gap:24px}.settings-item{display:flex;flex-direction:column;gap:8px}.settings-row{display:flex;align-items:center;justify-content:space-between;gap:16px}.settings-label{font-size:14px;font-weight:600;color:var(--kritzel-settings-label-color, #333333);margin:0 0 4px 0}.settings-description{font-size:12px;color:var(--kritzel-settings-description-color, #888888);margin:0;line-height:1.4}.shortcuts-list{display:flex;flex-direction:column;gap:24px}.shortcuts-category{display:flex;flex-direction:column;gap:8px}.shortcuts-category-title{font-size:14px;font-weight:600;color:var(--kritzel-settings-label-color, #333333);margin:0 0 4px 0}.shortcuts-group{display:flex;flex-direction:column;gap:4px}.shortcut-item{display:flex;justify-content:space-between;align-items:center;padding:6px 8px;border-radius:4px;background:var(--kritzel-settings-shortcut-item-bg, rgba(0, 0, 0, 0.02))}.shortcut-label{font-size:14px;color:var(--kritzel-settings-content-text-color, #666666)}.shortcut-key{font-family:monospace;font-size:12px;padding:2px 8px;border-radius:4px;background:var(--kritzel-settings-shortcut-key-bg, #f0f0f0);color:var(--kritzel-settings-shortcut-key-color, #333333);border:1px solid var(--kritzel-settings-shortcut-key-border, #ddd)}`;
|
|
28721
28714
|
|
|
@@ -446,7 +446,7 @@ class KritzelBaseObject {
|
|
|
446
446
|
const object = new KritzelBaseObject();
|
|
447
447
|
object._core = core;
|
|
448
448
|
object.zIndex = core.store.currentZIndex;
|
|
449
|
-
object.workspaceId = core.store.activeWorkspace.id;
|
|
449
|
+
object.workspaceId = core.store.state.activeWorkspace.id;
|
|
450
450
|
object.userId = core.user?.id;
|
|
451
451
|
return object;
|
|
452
452
|
}
|
|
@@ -15250,12 +15250,6 @@ class KritzelText extends KritzelBaseObject {
|
|
|
15250
15250
|
isEditing = false;
|
|
15251
15251
|
editor = null;
|
|
15252
15252
|
content = null;
|
|
15253
|
-
get _editor() {
|
|
15254
|
-
if (!this._editor) {
|
|
15255
|
-
throw new Error('KritzelShape: editor is not initialized');
|
|
15256
|
-
}
|
|
15257
|
-
return this._editor;
|
|
15258
|
-
}
|
|
15259
15253
|
_schema = new Schema({
|
|
15260
15254
|
nodes: addListNodes(schema.spec.nodes, 'paragraph block*', 'block'),
|
|
15261
15255
|
marks: schema.spec.marks,
|
|
@@ -15267,10 +15261,10 @@ class KritzelText extends KritzelBaseObject {
|
|
|
15267
15261
|
* @returns `true` if the editor is empty or contains only whitespace, `false` otherwise.
|
|
15268
15262
|
*/
|
|
15269
15263
|
get isEmpty() {
|
|
15270
|
-
if (!this.
|
|
15264
|
+
if (!this.editor) {
|
|
15271
15265
|
return true;
|
|
15272
15266
|
}
|
|
15273
|
-
const doc = this.
|
|
15267
|
+
const doc = this.editor.state.doc;
|
|
15274
15268
|
if (doc.content.size === 0) {
|
|
15275
15269
|
return true;
|
|
15276
15270
|
}
|
|
@@ -15343,7 +15337,7 @@ class KritzelText extends KritzelBaseObject {
|
|
|
15343
15337
|
const object = new KritzelText();
|
|
15344
15338
|
object._core = core;
|
|
15345
15339
|
object.id = object.generateId();
|
|
15346
|
-
object.workspaceId = core.store.activeWorkspace.id;
|
|
15340
|
+
object.workspaceId = core.store.state.activeWorkspace.id;
|
|
15347
15341
|
object.userId = core.user?.id;
|
|
15348
15342
|
object.fontSize = fontSize || 8;
|
|
15349
15343
|
object.fontFamily = fontFamily || 'Arial';
|
|
@@ -15374,7 +15368,7 @@ class KritzelText extends KritzelBaseObject {
|
|
|
15374
15368
|
element.style.fontFamily = this.fontFamily;
|
|
15375
15369
|
element.style.fontSize = `${this.fontSize}pt`;
|
|
15376
15370
|
element.style.color = KritzelColorHelper.resolveThemeColor(this.fontColor);
|
|
15377
|
-
if (this.isMounted && this.elementRef === element && this.
|
|
15371
|
+
if (this.isMounted && this.elementRef === element && this.editor.dom.parentElement === element) {
|
|
15378
15372
|
if (!this._core.store.state.isScaling && !this._core.store.state.isPanning) {
|
|
15379
15373
|
requestAnimationFrame(() => this.adjustSizeOnInput());
|
|
15380
15374
|
}
|
|
@@ -15384,7 +15378,7 @@ class KritzelText extends KritzelBaseObject {
|
|
|
15384
15378
|
this.elementRef.style.whiteSpace = 'pre-wrap';
|
|
15385
15379
|
this.elementRef.style.wordWrap = 'break-word';
|
|
15386
15380
|
this.elementRef.innerHTML = '';
|
|
15387
|
-
this.elementRef.appendChild(this.
|
|
15381
|
+
this.elementRef.appendChild(this.editor.dom);
|
|
15388
15382
|
this.isMounted = true;
|
|
15389
15383
|
requestAnimationFrame(() => this.adjustSizeOnInput());
|
|
15390
15384
|
}
|
|
@@ -15402,8 +15396,8 @@ class KritzelText extends KritzelBaseObject {
|
|
|
15402
15396
|
}),
|
|
15403
15397
|
editable: () => false,
|
|
15404
15398
|
dispatchTransaction: transaction => {
|
|
15405
|
-
const newState = this.
|
|
15406
|
-
this.
|
|
15399
|
+
const newState = this.editor.state.apply(transaction);
|
|
15400
|
+
this.editor.updateState(newState);
|
|
15407
15401
|
if (transaction.docChanged) {
|
|
15408
15402
|
this.content = newState.doc.toJSON();
|
|
15409
15403
|
this.adjustSizeOnInput();
|
|
@@ -15421,11 +15415,11 @@ class KritzelText extends KritzelBaseObject {
|
|
|
15421
15415
|
*/
|
|
15422
15416
|
setContent(content) {
|
|
15423
15417
|
this.content = content;
|
|
15424
|
-
if (this.
|
|
15425
|
-
const newDoc = this.
|
|
15426
|
-
const tr = this.
|
|
15418
|
+
if (this.editor && content) {
|
|
15419
|
+
const newDoc = this.editor.state.schema.nodeFromJSON(content);
|
|
15420
|
+
const tr = this.editor.state.tr.replaceWith(0, this.editor.state.doc.content.size, newDoc.content);
|
|
15427
15421
|
tr.setMeta('fromRemote', true);
|
|
15428
|
-
this.
|
|
15422
|
+
this.editor.dispatch(tr);
|
|
15429
15423
|
}
|
|
15430
15424
|
}
|
|
15431
15425
|
/**
|
|
@@ -15490,13 +15484,13 @@ class KritzelText extends KritzelBaseObject {
|
|
|
15490
15484
|
* @param coords.y - Y coordinate for cursor placement.
|
|
15491
15485
|
*/
|
|
15492
15486
|
focus(coords) {
|
|
15493
|
-
if (this.
|
|
15494
|
-
const doc = this.
|
|
15487
|
+
if (this.editor) {
|
|
15488
|
+
const doc = this.editor.state.doc;
|
|
15495
15489
|
if (coords.x && coords.y && !this.isEmpty) {
|
|
15496
|
-
const pos = this.
|
|
15490
|
+
const pos = this.editor.posAtCoords({ left: coords.x, top: coords.y });
|
|
15497
15491
|
if (pos) {
|
|
15498
|
-
this.
|
|
15499
|
-
this.
|
|
15492
|
+
this.editor.dispatch(this.editor.state.tr.setSelection(TextSelection.create(doc, pos.pos)));
|
|
15493
|
+
this.editor.focus();
|
|
15500
15494
|
if (KritzelDevicesHelper.isIOS()) {
|
|
15501
15495
|
this.scrollIntoViewOnIOS();
|
|
15502
15496
|
}
|
|
@@ -15504,8 +15498,8 @@ class KritzelText extends KritzelBaseObject {
|
|
|
15504
15498
|
}
|
|
15505
15499
|
}
|
|
15506
15500
|
const end = Math.max(1, doc.content.size - 1);
|
|
15507
|
-
this.
|
|
15508
|
-
this.
|
|
15501
|
+
this.editor.dispatch(this.editor.state.tr.setSelection(TextSelection.create(doc, end)));
|
|
15502
|
+
this.editor.focus();
|
|
15509
15503
|
if (KritzelDevicesHelper.isIOS()) {
|
|
15510
15504
|
this.scrollIntoViewOnIOS();
|
|
15511
15505
|
}
|
|
@@ -15517,8 +15511,8 @@ class KritzelText extends KritzelBaseObject {
|
|
|
15517
15511
|
*/
|
|
15518
15512
|
scrollIntoViewOnIOS() {
|
|
15519
15513
|
setTimeout(() => {
|
|
15520
|
-
if (this.
|
|
15521
|
-
this.
|
|
15514
|
+
if (this.editor && this.editor.dom) {
|
|
15515
|
+
this.editor.dom.scrollIntoView({
|
|
15522
15516
|
behavior: 'smooth',
|
|
15523
15517
|
block: 'center',
|
|
15524
15518
|
inline: 'nearest',
|
|
@@ -15536,7 +15530,7 @@ class KritzelText extends KritzelBaseObject {
|
|
|
15536
15530
|
KritzelKeyboardHelper.disableInteractiveWidget();
|
|
15537
15531
|
this.uneditedObject = this.clone();
|
|
15538
15532
|
this._core.store.setState('activeTool', KritzelToolRegistry.getTool('text'));
|
|
15539
|
-
this.
|
|
15533
|
+
this.editor.setProps({ editable: () => true });
|
|
15540
15534
|
this.isEditing = true;
|
|
15541
15535
|
this._core.rerender();
|
|
15542
15536
|
this.adjustSizeOnInput();
|
|
@@ -15552,9 +15546,9 @@ class KritzelText extends KritzelBaseObject {
|
|
|
15552
15546
|
*/
|
|
15553
15547
|
save() {
|
|
15554
15548
|
requestAnimationFrame(() => this.adjustSizeOnInput());
|
|
15555
|
-
this.content = this.
|
|
15556
|
-
this.
|
|
15557
|
-
this.
|
|
15549
|
+
this.content = this.editor.state.doc.toJSON();
|
|
15550
|
+
this.editor.setProps({ editable: () => false });
|
|
15551
|
+
this.editor.dom.blur();
|
|
15558
15552
|
this.isEditing = false;
|
|
15559
15553
|
this._core.store.objects.consolidateTemporaryItems();
|
|
15560
15554
|
this._core.store.objects.update(this);
|
|
@@ -15735,7 +15729,7 @@ class KritzelPath extends KritzelBaseObject {
|
|
|
15735
15729
|
const object = new KritzelPath();
|
|
15736
15730
|
object._core = core;
|
|
15737
15731
|
object.id = object.generateId();
|
|
15738
|
-
object.workspaceId = core.store.activeWorkspace.id;
|
|
15732
|
+
object.workspaceId = core.store.state.activeWorkspace.id;
|
|
15739
15733
|
object.userId = core.user?.id;
|
|
15740
15734
|
object.options = options;
|
|
15741
15735
|
object.points = options?.points ?? [];
|
|
@@ -16237,7 +16231,7 @@ class KritzelImage extends KritzelBaseObject {
|
|
|
16237
16231
|
const object = new KritzelImage();
|
|
16238
16232
|
object._core = core;
|
|
16239
16233
|
object.id = object.generateId();
|
|
16240
|
-
object.workspaceId = core.store.activeWorkspace.id;
|
|
16234
|
+
object.workspaceId = core.store.state.activeWorkspace.id;
|
|
16241
16235
|
object.userId = core.user?.id;
|
|
16242
16236
|
object.x = 0;
|
|
16243
16237
|
object.y = 0;
|
|
@@ -16388,7 +16382,7 @@ class KritzelLine extends KritzelBaseObject {
|
|
|
16388
16382
|
const object = new KritzelLine();
|
|
16389
16383
|
object._core = core;
|
|
16390
16384
|
object.id = object.generateId();
|
|
16391
|
-
object.workspaceId = core.store.activeWorkspace.id;
|
|
16385
|
+
object.workspaceId = core.store.state.activeWorkspace.id;
|
|
16392
16386
|
object.userId = core.user?.id;
|
|
16393
16387
|
object.options = options;
|
|
16394
16388
|
object.startX = options?.startX ?? 0;
|
|
@@ -17148,7 +17142,7 @@ class KritzelGroup extends KritzelBaseObject {
|
|
|
17148
17142
|
const group = new KritzelGroup();
|
|
17149
17143
|
group._core = core;
|
|
17150
17144
|
group.id = group.generateId();
|
|
17151
|
-
group.workspaceId = core.store.activeWorkspace.id;
|
|
17145
|
+
group.workspaceId = core.store.state.activeWorkspace.id;
|
|
17152
17146
|
group.userId = core.user?.id;
|
|
17153
17147
|
group.scale = core.store.state.scale;
|
|
17154
17148
|
group.zIndex = core.store.currentZIndex;
|
|
@@ -17645,12 +17639,6 @@ class KritzelShape extends KritzelBaseObject {
|
|
|
17645
17639
|
get viewBox() {
|
|
17646
17640
|
return `${this.x} ${this.y} ${this.width} ${this.height}`;
|
|
17647
17641
|
}
|
|
17648
|
-
get _editor() {
|
|
17649
|
-
if (!this.editor) {
|
|
17650
|
-
throw new Error('KritzelShape: editor is not initialized');
|
|
17651
|
-
}
|
|
17652
|
-
return this.editor;
|
|
17653
|
-
}
|
|
17654
17642
|
/**
|
|
17655
17643
|
* Creates a new KritzelShape instance with optional configuration.
|
|
17656
17644
|
* This constructor initializes the shape with default values that can be
|
|
@@ -17706,7 +17694,7 @@ class KritzelShape extends KritzelBaseObject {
|
|
|
17706
17694
|
const object = new KritzelShape();
|
|
17707
17695
|
object._core = core;
|
|
17708
17696
|
object.id = object.generateId();
|
|
17709
|
-
object.workspaceId = core.store.activeWorkspace.id;
|
|
17697
|
+
object.workspaceId = core.store.state.activeWorkspace.id;
|
|
17710
17698
|
object.userId = core.user?.id;
|
|
17711
17699
|
object.x = config?.x ?? 0;
|
|
17712
17700
|
object.y = config?.y ?? 0;
|
|
@@ -17758,7 +17746,7 @@ class KritzelShape extends KritzelBaseObject {
|
|
|
17758
17746
|
if (element === null || this.isInViewport() === false) {
|
|
17759
17747
|
return;
|
|
17760
17748
|
}
|
|
17761
|
-
if (this.isMounted && this.elementRef === element && this.
|
|
17749
|
+
if (this.isMounted && this.elementRef === element && this.editor.dom.parentElement === element) {
|
|
17762
17750
|
return;
|
|
17763
17751
|
}
|
|
17764
17752
|
this.elementRef = element;
|
|
@@ -17774,7 +17762,7 @@ class KritzelShape extends KritzelBaseObject {
|
|
|
17774
17762
|
* @returns void
|
|
17775
17763
|
*/
|
|
17776
17764
|
mountTextEditor(element) {
|
|
17777
|
-
if (element === null
|
|
17765
|
+
if (element === null) {
|
|
17778
17766
|
return;
|
|
17779
17767
|
}
|
|
17780
17768
|
element.style.fontFamily = this.fontFamily;
|
|
@@ -17805,8 +17793,8 @@ class KritzelShape extends KritzelBaseObject {
|
|
|
17805
17793
|
}),
|
|
17806
17794
|
editable: () => false,
|
|
17807
17795
|
dispatchTransaction: transaction => {
|
|
17808
|
-
const newState = this.
|
|
17809
|
-
this.
|
|
17796
|
+
const newState = this.editor.state.apply(transaction);
|
|
17797
|
+
this.editor.updateState(newState);
|
|
17810
17798
|
if (transaction.docChanged) {
|
|
17811
17799
|
this.content = newState.doc.toJSON();
|
|
17812
17800
|
if (!transaction.getMeta('fromRemote')) {
|
|
@@ -17868,12 +17856,12 @@ class KritzelShape extends KritzelBaseObject {
|
|
|
17868
17856
|
* @returns void
|
|
17869
17857
|
*/
|
|
17870
17858
|
focus(coords) {
|
|
17871
|
-
const doc = this.
|
|
17859
|
+
const doc = this.editor.state.doc;
|
|
17872
17860
|
if (coords?.x && coords?.y) {
|
|
17873
|
-
const pos = this.
|
|
17861
|
+
const pos = this.editor.posAtCoords({ left: coords.x, top: coords.y });
|
|
17874
17862
|
if (pos) {
|
|
17875
|
-
this.
|
|
17876
|
-
this.
|
|
17863
|
+
this.editor.dispatch(this.editor.state.tr.setSelection(TextSelection.create(doc, pos.pos)));
|
|
17864
|
+
this.editor.focus();
|
|
17877
17865
|
if (KritzelDevicesHelper.isIOS()) {
|
|
17878
17866
|
this.scrollIntoViewOnIOS();
|
|
17879
17867
|
}
|
|
@@ -17881,8 +17869,8 @@ class KritzelShape extends KritzelBaseObject {
|
|
|
17881
17869
|
}
|
|
17882
17870
|
}
|
|
17883
17871
|
const end = Math.max(1, doc.content.size - 1);
|
|
17884
|
-
this.
|
|
17885
|
-
this.
|
|
17872
|
+
this.editor.dispatch(this.editor.state.tr.setSelection(TextSelection.create(doc, end)));
|
|
17873
|
+
this.editor.focus();
|
|
17886
17874
|
if (KritzelDevicesHelper.isIOS()) {
|
|
17887
17875
|
this.scrollIntoViewOnIOS();
|
|
17888
17876
|
}
|
|
@@ -17920,7 +17908,7 @@ class KritzelShape extends KritzelBaseObject {
|
|
|
17920
17908
|
KritzelKeyboardHelper.disableInteractiveWidget();
|
|
17921
17909
|
this.uneditedObject = this.clone();
|
|
17922
17910
|
this._core.store.setState('activeTool', KritzelToolRegistry.getTool('shape'));
|
|
17923
|
-
this.
|
|
17911
|
+
this.editor.setProps({ editable: () => true });
|
|
17924
17912
|
this.isEditing = true;
|
|
17925
17913
|
this._core.rerender();
|
|
17926
17914
|
if (event?.clientX && event?.clientY) {
|
|
@@ -17937,9 +17925,9 @@ class KritzelShape extends KritzelBaseObject {
|
|
|
17937
17925
|
* @returns void
|
|
17938
17926
|
*/
|
|
17939
17927
|
save() {
|
|
17940
|
-
this.content = this.
|
|
17941
|
-
this.
|
|
17942
|
-
this.
|
|
17928
|
+
this.content = this.editor.state.doc.toJSON();
|
|
17929
|
+
this.editor.setProps({ editable: () => false });
|
|
17930
|
+
this.editor.dom.blur();
|
|
17943
17931
|
this.isEditing = false;
|
|
17944
17932
|
this._core.store.objects.consolidateTemporaryItems();
|
|
17945
17933
|
this._core.store.objects.update(this);
|
|
@@ -18617,7 +18605,7 @@ class KritzelSelectionGroup extends KritzelBaseObject {
|
|
|
18617
18605
|
const object = new KritzelSelectionGroup();
|
|
18618
18606
|
object._core = core;
|
|
18619
18607
|
object.id = object.generateId();
|
|
18620
|
-
object.workspaceId = core.store.activeWorkspace.id;
|
|
18608
|
+
object.workspaceId = core.store.state.activeWorkspace.id;
|
|
18621
18609
|
object.userId = core.user?.id;
|
|
18622
18610
|
object.clientId = core.store.objects?.localClientId ?? undefined;
|
|
18623
18611
|
object.scale = core.store.state.scale;
|
|
@@ -20944,7 +20932,7 @@ class KritzelSelectionBox extends KritzelBaseObject {
|
|
|
20944
20932
|
const object = new KritzelSelectionBox();
|
|
20945
20933
|
object._core = core;
|
|
20946
20934
|
object.id = object.generateId();
|
|
20947
|
-
object.workspaceId = core.store.activeWorkspace.id;
|
|
20935
|
+
object.workspaceId = core.store.state.activeWorkspace.id;
|
|
20948
20936
|
object.userId = core.user?.id;
|
|
20949
20937
|
object.scale = core.store.state.scale;
|
|
20950
20938
|
object.zIndex = 99999;
|
|
@@ -358,7 +358,7 @@ export class KritzelCore {
|
|
|
358
358
|
workspace.updatedAt = new Date();
|
|
359
359
|
this.saveWorkspaceToAppState(workspace);
|
|
360
360
|
// Keep metadata map in sync when the active workspace's name changes
|
|
361
|
-
if (this._store.activeWorkspace?.id === workspace.id) {
|
|
361
|
+
if (this._store.state.activeWorkspace?.id === workspace.id) {
|
|
362
362
|
this._store.objects?.setWorkspaceName(workspace.name);
|
|
363
363
|
}
|
|
364
364
|
const workspaces = this._store.state.workspaces;
|
|
@@ -376,7 +376,7 @@ export class KritzelCore {
|
|
|
376
376
|
*/
|
|
377
377
|
deleteWorkspace(workspace) {
|
|
378
378
|
// If deleting the active workspace, need to handle ObjectMap cleanup
|
|
379
|
-
if (this._store.activeWorkspace?.id === workspace.id) {
|
|
379
|
+
if (this._store.state.activeWorkspace?.id === workspace.id) {
|
|
380
380
|
this.engine.viewport?.cancelPendingUpdates();
|
|
381
381
|
this._store.objects?.destroy();
|
|
382
382
|
}
|
|
@@ -397,7 +397,7 @@ export class KritzelCore {
|
|
|
397
397
|
* @param scale - The zoom scale of the viewport
|
|
398
398
|
*/
|
|
399
399
|
updateWorkspaceViewport(translateX, translateY, scale) {
|
|
400
|
-
const activeWorkspace = this._store.activeWorkspace;
|
|
400
|
+
const activeWorkspace = this._store.state.activeWorkspace;
|
|
401
401
|
if (!activeWorkspace) {
|
|
402
402
|
return;
|
|
403
403
|
}
|
|
@@ -420,7 +420,7 @@ export class KritzelCore {
|
|
|
420
420
|
* @returns True if the workspace is public, false otherwise
|
|
421
421
|
*/
|
|
422
422
|
getIsPublic() {
|
|
423
|
-
return this._store.activeWorkspace?.isPublic ?? false;
|
|
423
|
+
return this._store.state.activeWorkspace?.isPublic ?? false;
|
|
424
424
|
}
|
|
425
425
|
// ═══════════════════════════════════════════════════════════════════════════
|
|
426
426
|
// Object Management Methods
|
|
@@ -612,7 +612,7 @@ export class KritzelCore {
|
|
|
612
612
|
if (!copiedObjects || copiedObjects.length === 0) {
|
|
613
613
|
return;
|
|
614
614
|
}
|
|
615
|
-
const activeWorkspace = this._store.activeWorkspace;
|
|
615
|
+
const activeWorkspace = this._store.state.activeWorkspace;
|
|
616
616
|
const originalIdMapping = this._store.state.copiedObjectIdMapping;
|
|
617
617
|
// Check if we're pasting from a different workspace
|
|
618
618
|
const isDifferentWorkspace = copiedObjects.some(obj => obj.workspaceId !== activeWorkspace.id);
|
|
@@ -1128,7 +1128,7 @@ export class KritzelCore {
|
|
|
1128
1128
|
// saving the old workspace's viewport to the new workspace
|
|
1129
1129
|
this._kritzelEngine.viewport?.cancelPendingUpdates();
|
|
1130
1130
|
// Immediately save the current workspace's viewport before switching
|
|
1131
|
-
const currentWorkspace = this._store.activeWorkspace;
|
|
1131
|
+
const currentWorkspace = this._store.state.activeWorkspace;
|
|
1132
1132
|
if (currentWorkspace) {
|
|
1133
1133
|
this.updateWorkspaceViewport(this._store.state.translateX, this._store.state.translateY, this._store.state.scale);
|
|
1134
1134
|
}
|
|
@@ -40,18 +40,6 @@ export class KritzelStore {
|
|
|
40
40
|
}
|
|
41
41
|
return this._state.objects;
|
|
42
42
|
}
|
|
43
|
-
/**
|
|
44
|
-
* Gets the currently active workspace.
|
|
45
|
-
* Throws an error if no active workspace is set, as it is required for workspace-bound operations.
|
|
46
|
-
* @returns The current active KritzelWorkspace
|
|
47
|
-
* @throws Error if no active workspace is set in the state
|
|
48
|
-
*/
|
|
49
|
-
get activeWorkspace() {
|
|
50
|
-
if (!this._state.activeWorkspace) {
|
|
51
|
-
throw new Error('Active workspace is not set.');
|
|
52
|
-
}
|
|
53
|
-
return this._state.activeWorkspace;
|
|
54
|
-
}
|
|
55
43
|
/**
|
|
56
44
|
* Gets the host element for the Kritzel editor.
|
|
57
45
|
* Throws an error if the host is not set, as it is required for many operations.
|
|
@@ -208,7 +208,7 @@ export class KritzelBaseObject {
|
|
|
208
208
|
const object = new KritzelBaseObject();
|
|
209
209
|
object._core = core;
|
|
210
210
|
object.zIndex = core.store.currentZIndex;
|
|
211
|
-
object.workspaceId = core.store.activeWorkspace.id;
|
|
211
|
+
object.workspaceId = core.store.state.activeWorkspace.id;
|
|
212
212
|
object.userId = core.user?.id;
|
|
213
213
|
return object;
|
|
214
214
|
}
|
|
@@ -48,7 +48,7 @@ export class KritzelCustomElement extends KritzelBaseObject {
|
|
|
48
48
|
const object = new KritzelCustomElement(config);
|
|
49
49
|
object._core = core;
|
|
50
50
|
object.id = object.generateId();
|
|
51
|
-
object.workspaceId = core.store.activeWorkspace.id;
|
|
51
|
+
object.workspaceId = core.store.state.activeWorkspace.id;
|
|
52
52
|
object.userId = core.user?.id;
|
|
53
53
|
return object;
|
|
54
54
|
}
|
|
@@ -69,7 +69,7 @@ export class KritzelGroup extends KritzelBaseObject {
|
|
|
69
69
|
const group = new KritzelGroup();
|
|
70
70
|
group._core = core;
|
|
71
71
|
group.id = group.generateId();
|
|
72
|
-
group.workspaceId = core.store.activeWorkspace.id;
|
|
72
|
+
group.workspaceId = core.store.state.activeWorkspace.id;
|
|
73
73
|
group.userId = core.user?.id;
|
|
74
74
|
group.scale = core.store.state.scale;
|
|
75
75
|
group.zIndex = core.store.currentZIndex;
|