@fieldnotes/core 0.50.0 → 0.50.1
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 +13 -6
- 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 +13 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -367,7 +367,7 @@ function migrateElement(obj) {
|
|
|
367
367
|
if (obj["type"] === "note" && typeof obj["textColor"] !== "string") {
|
|
368
368
|
obj["textColor"] = "#000000";
|
|
369
369
|
}
|
|
370
|
-
if (obj["type"] === "note" && typeof obj["text"] === "string") {
|
|
370
|
+
if ((obj["type"] === "note" || obj["type"] === "text") && typeof obj["text"] === "string") {
|
|
371
371
|
obj["text"] = sanitizeNoteHtml(obj["text"]);
|
|
372
372
|
}
|
|
373
373
|
}
|
|
@@ -2580,6 +2580,11 @@ function transferStrokeRenderData(prev, next) {
|
|
|
2580
2580
|
}
|
|
2581
2581
|
|
|
2582
2582
|
// src/elements/element-store.ts
|
|
2583
|
+
function sanitizeRichText(element) {
|
|
2584
|
+
if (element.type !== "note" && element.type !== "text") return element;
|
|
2585
|
+
const text = sanitizeNoteHtml(element.text);
|
|
2586
|
+
return text === element.text ? element : { ...element, text };
|
|
2587
|
+
}
|
|
2583
2588
|
var ElementStore = class {
|
|
2584
2589
|
elements = /* @__PURE__ */ new Map();
|
|
2585
2590
|
bus = new EventBus();
|
|
@@ -2624,6 +2629,7 @@ var ElementStore = class {
|
|
|
2624
2629
|
return angle === 0 ? bounds : rotatedAABB(bounds, angle);
|
|
2625
2630
|
}
|
|
2626
2631
|
add(element, meta) {
|
|
2632
|
+
element = sanitizeRichText(element);
|
|
2627
2633
|
this.sortedCache = null;
|
|
2628
2634
|
this._versions.set(element.id, 0);
|
|
2629
2635
|
this.elements.set(element.id, element);
|
|
@@ -2650,7 +2656,7 @@ var ElementStore = class {
|
|
|
2650
2656
|
const arrow = updated;
|
|
2651
2657
|
arrow.cachedControlPoint = getArrowControlPoint(arrow.from, arrow.to, arrow.bend);
|
|
2652
2658
|
}
|
|
2653
|
-
if (updated.type === "note" && "text" in partial) {
|
|
2659
|
+
if ((updated.type === "note" || updated.type === "text") && "text" in partial) {
|
|
2654
2660
|
updated.text = sanitizeNoteHtml(updated.text);
|
|
2655
2661
|
}
|
|
2656
2662
|
this.elements.set(id, updated);
|
|
@@ -2680,11 +2686,12 @@ var ElementStore = class {
|
|
|
2680
2686
|
return this.getAll().map((el) => ({ ...el }));
|
|
2681
2687
|
}
|
|
2682
2688
|
loadSnapshot(elements, meta) {
|
|
2689
|
+
const sanitizedElements = elements.map(sanitizeRichText);
|
|
2683
2690
|
this.sortedCache = null;
|
|
2684
2691
|
this._versions.clear();
|
|
2685
2692
|
this.elements.clear();
|
|
2686
2693
|
this.spatialIndex.clear();
|
|
2687
|
-
for (const el of
|
|
2694
|
+
for (const el of sanitizedElements) {
|
|
2688
2695
|
this.elements.set(el.id, el);
|
|
2689
2696
|
this._versions.set(el.id, 0);
|
|
2690
2697
|
const bounds = this.indexBounds(el);
|
|
@@ -2697,7 +2704,7 @@ var ElementStore = class {
|
|
|
2697
2704
|
}
|
|
2698
2705
|
}
|
|
2699
2706
|
this.bus.emit("clear", null, meta);
|
|
2700
|
-
for (const el of
|
|
2707
|
+
for (const el of sanitizedElements) {
|
|
2701
2708
|
this.bus.emit("add", el, meta);
|
|
2702
2709
|
}
|
|
2703
2710
|
}
|
|
@@ -4112,7 +4119,7 @@ function createText(input) {
|
|
|
4112
4119
|
locked: input.locked ?? false,
|
|
4113
4120
|
layerId: input.layerId ?? "",
|
|
4114
4121
|
size: input.size ?? { w: 200, h: 28 },
|
|
4115
|
-
text: input.text ?? "",
|
|
4122
|
+
text: sanitizeNoteHtml(input.text ?? ""),
|
|
4116
4123
|
fontSize: input.fontSize ?? 16,
|
|
4117
4124
|
color: input.color ?? "#1a1a1a",
|
|
4118
4125
|
textAlign: input.textAlign ?? "left"
|
|
@@ -10614,7 +10621,7 @@ var LaserTool = class {
|
|
|
10614
10621
|
};
|
|
10615
10622
|
|
|
10616
10623
|
// src/index.ts
|
|
10617
|
-
var VERSION = "0.50.
|
|
10624
|
+
var VERSION = "0.50.1";
|
|
10618
10625
|
// Annotate the CommonJS export names for ESM import in node:
|
|
10619
10626
|
0 && (module.exports = {
|
|
10620
10627
|
ArrowTool,
|