@fieldnotes/core 0.40.1 → 0.40.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +20 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +20 -10
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -4031,6 +4031,7 @@ var NoteEditor = class {
|
|
|
4031
4031
|
inputHandler = null;
|
|
4032
4032
|
pendingEditId = null;
|
|
4033
4033
|
onStopCallback = null;
|
|
4034
|
+
onInputCallback = null;
|
|
4034
4035
|
beginHistory = null;
|
|
4035
4036
|
commitHistory = null;
|
|
4036
4037
|
toolbar;
|
|
@@ -4048,6 +4049,9 @@ var NoteEditor = class {
|
|
|
4048
4049
|
setOnStop(callback) {
|
|
4049
4050
|
this.onStopCallback = callback;
|
|
4050
4051
|
}
|
|
4052
|
+
setOnInput(callback) {
|
|
4053
|
+
this.onInputCallback = callback;
|
|
4054
|
+
}
|
|
4051
4055
|
setHistoryHooks(begin, commit) {
|
|
4052
4056
|
this.beginHistory = begin;
|
|
4053
4057
|
this.commitHistory = commit;
|
|
@@ -4090,7 +4094,6 @@ var NoteEditor = class {
|
|
|
4090
4094
|
cursor: "default"
|
|
4091
4095
|
});
|
|
4092
4096
|
this.toolbar?.hide();
|
|
4093
|
-
this.beginHistory?.();
|
|
4094
4097
|
if (textChanged) {
|
|
4095
4098
|
store.update(this.editingId, { text });
|
|
4096
4099
|
}
|
|
@@ -4119,6 +4122,7 @@ var NoteEditor = class {
|
|
|
4119
4122
|
activateEditing(node, elementId, store) {
|
|
4120
4123
|
this.editingId = elementId;
|
|
4121
4124
|
this.editingNode = node;
|
|
4125
|
+
this.beginHistory?.();
|
|
4122
4126
|
node.contentEditable = "true";
|
|
4123
4127
|
Object.assign(node.style, {
|
|
4124
4128
|
userSelect: "text",
|
|
@@ -4139,6 +4143,7 @@ var NoteEditor = class {
|
|
|
4139
4143
|
node.setAttribute("data-fn-empty", String(isNodeEmpty(node)));
|
|
4140
4144
|
this.inputHandler = () => {
|
|
4141
4145
|
node.setAttribute("data-fn-empty", String(isNodeEmpty(node)));
|
|
4146
|
+
this.onInputCallback?.(elementId);
|
|
4142
4147
|
};
|
|
4143
4148
|
node.addEventListener("input", this.inputHandler);
|
|
4144
4149
|
this.toolbar?.show(node);
|
|
@@ -6602,6 +6607,16 @@ var ViewportInteractions = class {
|
|
|
6602
6607
|
this.deps.noteEditor.startEditing(node, id, this.deps.store);
|
|
6603
6608
|
}
|
|
6604
6609
|
}
|
|
6610
|
+
liveFitHeight(elementId) {
|
|
6611
|
+
const element = this.deps.store.getById(elementId);
|
|
6612
|
+
if (!element || element.type !== "note" && element.type !== "text") return;
|
|
6613
|
+
const node = this.deps.domNodeManager.getNode(elementId);
|
|
6614
|
+
if (!node) return;
|
|
6615
|
+
const measured = node.scrollHeight;
|
|
6616
|
+
if (measured > 0 && measured !== element.size.h) {
|
|
6617
|
+
this.deps.store.update(elementId, { size: { w: element.size.w, h: measured } });
|
|
6618
|
+
}
|
|
6619
|
+
}
|
|
6605
6620
|
fitNoteHeight(elementId) {
|
|
6606
6621
|
const element = this.deps.store.getById(elementId);
|
|
6607
6622
|
if (!element || element.type !== "note") return;
|
|
@@ -6621,7 +6636,7 @@ var ViewportInteractions = class {
|
|
|
6621
6636
|
this.deps.store.remove(elementId);
|
|
6622
6637
|
return;
|
|
6623
6638
|
}
|
|
6624
|
-
this.
|
|
6639
|
+
this.liveFitHeight(elementId);
|
|
6625
6640
|
return;
|
|
6626
6641
|
}
|
|
6627
6642
|
if (element.type !== "text") return;
|
|
@@ -6629,13 +6644,7 @@ var ViewportInteractions = class {
|
|
|
6629
6644
|
this.deps.store.remove(elementId);
|
|
6630
6645
|
return;
|
|
6631
6646
|
}
|
|
6632
|
-
|
|
6633
|
-
if (node && "size" in element) {
|
|
6634
|
-
const measured = node.scrollHeight;
|
|
6635
|
-
if (measured !== element.size.h) {
|
|
6636
|
-
this.deps.store.update(elementId, { size: { w: element.size.w, h: measured } });
|
|
6637
|
-
}
|
|
6638
|
-
}
|
|
6647
|
+
this.liveFitHeight(elementId);
|
|
6639
6648
|
}
|
|
6640
6649
|
onTapDown = (e) => {
|
|
6641
6650
|
this.tapDownX = e.clientX;
|
|
@@ -6771,6 +6780,7 @@ var Viewport = class {
|
|
|
6771
6780
|
placeholder: options.placeholder
|
|
6772
6781
|
});
|
|
6773
6782
|
this.noteEditor.setOnStop((id) => this.interactions.onTextEditStop(id));
|
|
6783
|
+
this.noteEditor.setOnInput((id) => this.interactions.liveFitHeight(id));
|
|
6774
6784
|
this.arrowLabelEditor = new ArrowLabelEditor();
|
|
6775
6785
|
this.noteEditor.setHistoryHooks(
|
|
6776
6786
|
() => this.historyRecorder.begin(),
|
|
@@ -9737,7 +9747,7 @@ var LaserTool = class {
|
|
|
9737
9747
|
};
|
|
9738
9748
|
|
|
9739
9749
|
// src/index.ts
|
|
9740
|
-
var VERSION = "0.40.
|
|
9750
|
+
var VERSION = "0.40.2";
|
|
9741
9751
|
// Annotate the CommonJS export names for ESM import in node:
|
|
9742
9752
|
0 && (module.exports = {
|
|
9743
9753
|
ArrowTool,
|