kritzel-stencil 0.0.145 → 0.0.146
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/{default-text-tool.config-D2dP2xyB.js → default-text-tool.config-C0W0noF9.js} +54 -34
- package/dist/cjs/default-text-tool.config-C0W0noF9.js.map +1 -0
- package/dist/cjs/index.cjs.js +1 -1
- package/dist/cjs/kritzel-color_22.cjs.entry.js +11 -37
- package/dist/collection/classes/objects/text.class.js +23 -23
- package/dist/collection/classes/objects/text.class.js.map +1 -1
- package/dist/collection/classes/tools/text-tool.class.js +3 -10
- package/dist/collection/classes/tools/text-tool.class.js.map +1 -1
- package/dist/components/index.js +3 -3
- package/dist/components/kritzel-controls.js +1 -1
- package/dist/components/kritzel-editor.js +3 -3
- package/dist/components/kritzel-engine.js +1 -1
- package/dist/components/{p-ByRC-aCs.js → p-CwHz5s2a.js} +3 -3
- package/dist/components/{p-ByRC-aCs.js.map → p-CwHz5s2a.js.map} +1 -1
- package/dist/components/{p-BgRGxOIE.js → p-DPN0PZvw.js} +3 -3
- package/dist/components/{p-BgRGxOIE.js.map → p-DPN0PZvw.js.map} +1 -1
- package/dist/components/{p-COGwCbe1.js → p-G2HGJcNm.js} +28 -34
- package/dist/components/p-G2HGJcNm.js.map +1 -0
- package/dist/esm/{default-text-tool.config-CsZAW1Cu.js → default-text-tool.config-nXXHSTK9.js} +54 -35
- package/dist/esm/default-text-tool.config-nXXHSTK9.js.map +1 -0
- package/dist/esm/index.js +2 -2
- package/dist/esm/kritzel-color_22.entry.js +1 -27
- package/dist/stencil/index.esm.js +1 -1
- package/dist/stencil/p-f8a8a8d7.entry.js +2 -0
- package/dist/stencil/p-f8a8a8d7.entry.js.map +1 -0
- package/dist/stencil/p-nXXHSTK9.js +2 -0
- package/dist/stencil/p-nXXHSTK9.js.map +1 -0
- package/dist/stencil/stencil.esm.js +1 -1
- package/dist/types/classes/objects/text.class.d.ts +1 -0
- package/package.json +15 -14
- package/dist/cjs/default-text-tool.config-D2dP2xyB.js.map +0 -1
- package/dist/components/p-COGwCbe1.js.map +0 -1
- package/dist/esm/default-text-tool.config-CsZAW1Cu.js.map +0 -1
- package/dist/stencil/p-27adbf9d.entry.js +0 -2
- package/dist/stencil/p-27adbf9d.entry.js.map +0 -1
- package/dist/stencil/p-CsZAW1Cu.js +0 -2
- package/dist/stencil/p-CsZAW1Cu.js.map +0 -1
package/dist/cjs/{default-text-tool.config-D2dP2xyB.js → default-text-tool.config-C0W0noF9.js}
RENAMED
|
@@ -355,6 +355,32 @@ class KritzelKeyboardHelper {
|
|
|
355
355
|
}
|
|
356
356
|
}
|
|
357
357
|
|
|
358
|
+
class KritzelDevicesHelper {
|
|
359
|
+
static isTouchDevice() {
|
|
360
|
+
return window.matchMedia('(any-pointer: coarse)').matches;
|
|
361
|
+
}
|
|
362
|
+
static isAndroid() {
|
|
363
|
+
return /android/i.test(navigator.userAgent);
|
|
364
|
+
}
|
|
365
|
+
static isIOS() {
|
|
366
|
+
return /iPad|iPhone|iPod/.test(navigator.userAgent);
|
|
367
|
+
}
|
|
368
|
+
static detectOS() {
|
|
369
|
+
if (this.isIOS()) {
|
|
370
|
+
return 'iOS';
|
|
371
|
+
}
|
|
372
|
+
else if (this.isAndroid()) {
|
|
373
|
+
return 'Android';
|
|
374
|
+
}
|
|
375
|
+
else {
|
|
376
|
+
return 'Other';
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
static isFirefox() {
|
|
380
|
+
return /firefox/i.test(navigator.userAgent);
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
|
|
358
384
|
// ::- Persistent data structure representing an ordered mapping from
|
|
359
385
|
// strings to values, with some convenient update methods.
|
|
360
386
|
function OrderedMap(content) {
|
|
@@ -13908,17 +13934,12 @@ class KritzelText extends KritzelBaseObject {
|
|
|
13908
13934
|
}),
|
|
13909
13935
|
editable: () => false,
|
|
13910
13936
|
dispatchTransaction: transaction => {
|
|
13911
|
-
// Apply the transaction to get the new state
|
|
13912
13937
|
const newState = this.editor.state.apply(transaction);
|
|
13913
|
-
// Update the editor state first
|
|
13914
13938
|
this.editor.updateState(newState);
|
|
13915
|
-
// Only update content and adjust size if the document actually changed
|
|
13916
|
-
// AND it's not from a remote source (to prevent infinite loops)
|
|
13917
13939
|
if (transaction.docChanged) {
|
|
13918
13940
|
this.content = newState.doc.toJSON();
|
|
13919
13941
|
this.adjustSizeOnInput();
|
|
13920
13942
|
if (!transaction.getMeta('fromRemote')) {
|
|
13921
|
-
// Mark updates as temporary while editing - they'll be consolidated on save
|
|
13922
13943
|
this._core.store.state.objectsMap.update(this, { temporary: true });
|
|
13923
13944
|
}
|
|
13924
13945
|
}
|
|
@@ -13930,7 +13951,6 @@ class KritzelText extends KritzelBaseObject {
|
|
|
13930
13951
|
if (this.editor && content) {
|
|
13931
13952
|
const newDoc = this.editor.state.schema.nodeFromJSON(content);
|
|
13932
13953
|
const tr = this.editor.state.tr.replaceWith(0, this.editor.state.doc.content.size, newDoc.content);
|
|
13933
|
-
// Mark this transaction as coming from remote/external source
|
|
13934
13954
|
tr.setMeta('fromRemote', true);
|
|
13935
13955
|
this.editor.dispatch(tr);
|
|
13936
13956
|
}
|
|
@@ -13978,39 +13998,46 @@ class KritzelText extends KritzelBaseObject {
|
|
|
13978
13998
|
focus(coords) {
|
|
13979
13999
|
if (this.editor) {
|
|
13980
14000
|
const doc = this.editor.state.doc;
|
|
13981
|
-
if (coords) {
|
|
14001
|
+
if (coords.x && coords.y) {
|
|
13982
14002
|
const pos = this.editor.posAtCoords({ left: coords.x, top: coords.y });
|
|
13983
14003
|
if (pos) {
|
|
13984
14004
|
this.editor.dispatch(this.editor.state.tr.setSelection(TextSelection.create(doc, pos.pos)));
|
|
13985
14005
|
this.editor.focus();
|
|
14006
|
+
if (KritzelDevicesHelper.isIOS()) {
|
|
14007
|
+
this.scrollIntoViewOnIOS();
|
|
14008
|
+
}
|
|
13986
14009
|
return;
|
|
13987
14010
|
}
|
|
13988
14011
|
}
|
|
13989
14012
|
const end = Math.max(1, doc.content.size - 1);
|
|
13990
14013
|
this.editor.dispatch(this.editor.state.tr.setSelection(TextSelection.create(doc, end)));
|
|
13991
14014
|
this.editor.focus();
|
|
14015
|
+
if (KritzelDevicesHelper.isIOS()) {
|
|
14016
|
+
this.scrollIntoViewOnIOS();
|
|
14017
|
+
}
|
|
13992
14018
|
}
|
|
13993
14019
|
}
|
|
14020
|
+
scrollIntoViewOnIOS() {
|
|
14021
|
+
setTimeout(() => {
|
|
14022
|
+
if (this.editor && this.editor.dom) {
|
|
14023
|
+
this.editor.dom.scrollIntoView({
|
|
14024
|
+
behavior: 'smooth',
|
|
14025
|
+
block: 'center',
|
|
14026
|
+
inline: 'nearest'
|
|
14027
|
+
});
|
|
14028
|
+
}
|
|
14029
|
+
}, 300);
|
|
14030
|
+
}
|
|
13994
14031
|
edit(event) {
|
|
13995
14032
|
KritzelKeyboardHelper.disableInteractiveWidget();
|
|
13996
14033
|
this.uneditedObject = this.clone();
|
|
13997
14034
|
this._core.store.setState('activeTool', KritzelToolRegistry.getTool('text'));
|
|
13998
|
-
|
|
13999
|
-
this.editor.setProps({ editable: () => true });
|
|
14000
|
-
}
|
|
14035
|
+
this.editor.setProps({ editable: () => true });
|
|
14001
14036
|
this.isEditing = true;
|
|
14002
14037
|
this._core.rerender();
|
|
14003
|
-
|
|
14004
|
-
|
|
14005
|
-
|
|
14006
|
-
if (event) {
|
|
14007
|
-
this.focus({ x: event.clientX, y: event.clientY });
|
|
14008
|
-
}
|
|
14009
|
-
else {
|
|
14010
|
-
this.focus();
|
|
14011
|
-
}
|
|
14012
|
-
KritzelKeyboardHelper.enableInteractiveWidget();
|
|
14013
|
-
});
|
|
14038
|
+
this.adjustSizeOnInput();
|
|
14039
|
+
this.focus({ x: event?.clientX, y: event?.clientY });
|
|
14040
|
+
KritzelKeyboardHelper.enableInteractiveWidget();
|
|
14014
14041
|
}
|
|
14015
14042
|
save() {
|
|
14016
14043
|
requestAnimationFrame(() => this.adjustSizeOnInput());
|
|
@@ -14018,9 +14045,7 @@ class KritzelText extends KritzelBaseObject {
|
|
|
14018
14045
|
this.editor.setProps({ editable: () => false });
|
|
14019
14046
|
this.editor.dom.blur();
|
|
14020
14047
|
this.isEditing = false;
|
|
14021
|
-
// Consolidate all temporary keystrokes into a single undo item
|
|
14022
14048
|
this._core.store.state.objectsMap.consolidateTemporaryItems();
|
|
14023
|
-
// Final update with normal origin
|
|
14024
14049
|
this._core.store.state.objectsMap.update(this);
|
|
14025
14050
|
}
|
|
14026
14051
|
handlePointerDown(event) {
|
|
@@ -14862,7 +14887,7 @@ class KritzelTextTool extends KritzelBaseTool {
|
|
|
14862
14887
|
text.zIndex = this._core.store.currentZIndex;
|
|
14863
14888
|
this._core.store.state.objectsMap.insert(text);
|
|
14864
14889
|
this._core.rerender();
|
|
14865
|
-
|
|
14890
|
+
text.edit(event);
|
|
14866
14891
|
}
|
|
14867
14892
|
if (event.pointerType === 'touch') {
|
|
14868
14893
|
const activePointers = Array.from(this._core.store.state.pointers.values());
|
|
@@ -14887,7 +14912,6 @@ class KritzelTextTool extends KritzelBaseTool {
|
|
|
14887
14912
|
if (activePointers.length > 1) {
|
|
14888
14913
|
return;
|
|
14889
14914
|
}
|
|
14890
|
-
KritzelKeyboardHelper.disableInteractiveWidget();
|
|
14891
14915
|
const clientX = Math.round(activePointers[0].clientX - this._core.store.offsetX);
|
|
14892
14916
|
const clientY = Math.round(activePointers[0].clientY - this._core.store.offsetY);
|
|
14893
14917
|
const text = KritzelText.create(this._core, this.fontSize, this.fontFamily);
|
|
@@ -14897,19 +14921,14 @@ class KritzelTextTool extends KritzelBaseTool {
|
|
|
14897
14921
|
text.zIndex = this._core.store.currentZIndex;
|
|
14898
14922
|
this._core.store.state.objectsMap.insert(text);
|
|
14899
14923
|
this._core.rerender();
|
|
14924
|
+
text.edit(event);
|
|
14900
14925
|
}
|
|
14901
14926
|
}
|
|
14902
14927
|
handlePointerUp(event) {
|
|
14903
14928
|
if (event.cancelable) {
|
|
14904
14929
|
event.preventDefault();
|
|
14905
14930
|
}
|
|
14906
|
-
|
|
14907
|
-
this._core.store.activeText?.edit(event);
|
|
14908
|
-
}
|
|
14909
|
-
if (event.pointerType === 'touch') {
|
|
14910
|
-
this._core.store.activeText?.edit(event);
|
|
14911
|
-
KritzelKeyboardHelper.enableInteractiveWidget();
|
|
14912
|
-
}
|
|
14931
|
+
this._core.store.activeText?.edit(event);
|
|
14913
14932
|
}
|
|
14914
14933
|
}
|
|
14915
14934
|
|
|
@@ -31260,6 +31279,7 @@ exports.KritzelBaseHandler = KritzelBaseHandler;
|
|
|
31260
31279
|
exports.KritzelBaseObject = KritzelBaseObject;
|
|
31261
31280
|
exports.KritzelBaseTool = KritzelBaseTool;
|
|
31262
31281
|
exports.KritzelBrushTool = KritzelBrushTool;
|
|
31282
|
+
exports.KritzelDevicesHelper = KritzelDevicesHelper;
|
|
31263
31283
|
exports.KritzelEraserTool = KritzelEraserTool;
|
|
31264
31284
|
exports.KritzelEventHelper = KritzelEventHelper;
|
|
31265
31285
|
exports.KritzelImage = KritzelImage;
|
|
@@ -31305,6 +31325,6 @@ exports.varStorage = varStorage;
|
|
|
31305
31325
|
exports.writeVarString = writeVarString$2;
|
|
31306
31326
|
exports.writeVarUint = writeVarUint$2;
|
|
31307
31327
|
exports.writeVarUint8Array = writeVarUint8Array$2;
|
|
31308
|
-
//# sourceMappingURL=default-text-tool.config-
|
|
31328
|
+
//# sourceMappingURL=default-text-tool.config-C0W0noF9.js.map
|
|
31309
31329
|
|
|
31310
|
-
//# sourceMappingURL=default-text-tool.config-
|
|
31330
|
+
//# sourceMappingURL=default-text-tool.config-C0W0noF9.js.map
|