@fieldnotes/core 0.49.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 +20 -12
- 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 -12
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1123,6 +1123,6 @@ declare class LaserTool implements Tool {
|
|
|
1123
1123
|
private notifyOptionsChange;
|
|
1124
1124
|
}
|
|
1125
1125
|
|
|
1126
|
-
declare const VERSION = "0.
|
|
1126
|
+
declare const VERSION = "0.50.1";
|
|
1127
1127
|
|
|
1128
1128
|
export { type ActiveFormats, type AlignEdge, type ArrowElement, type ArrowStrokeStyle, ArrowTool, type ArrowToolOptions, AutoSave, type AutoSaveOptions, type BackgroundOptions, type BackgroundPattern, type Binding, type Bounds, Camera, type CameraChangeInfo, type CameraOptions, type CanvasElement, type CanvasState, type Command, DEFAULT_NOTE_FONT_SIZE, type DistributeAxis, type ElementChangeMeta, ElementStore, type ElementStyle, type ElementType, type ElementUpdateEvent, EraserTool, type EraserToolOptions, type ExportImageOptions, type ExportSvgOptions, type FontSizePreset, type GridElement, type GridInfo, HandTool, type HexOrientation, HistoryStack, type HistoryStackOptions, type HtmlElement, type ImageElement, ImageTool, type ImageToolOptions, IndexedDBAdapter, type IndexedDBAdapterOptions, LaserTool, type LaserToolOptions, type Layer, LayerManager, LocalStorageAdapter, MeasureTool, type MeasureToolOptions, type Measurement, MemoryAdapter, type NoteElement, NoteTool, type NoteToolOptions, PencilTool, type PencilToolOptions, type Point, type PointerState, type RenderStatsSnapshot, type RotateDirection, SelectTool, type ShapeElement, type ShapeKind, ShapeTool, type ShapeToolOptions, type ShortcutBindings, type ShortcutOptions, type ShortcutsApi, type Size, type StorageAdapter, type StrokeElement, type StrokePoint, type TemplateElement, type TemplateRenderStyle, type TemplateShape, TemplateTool, type TemplateToolOptions, type TextElement, TextTool, type TextToolOptions, type Tool, type ToolContext, ToolManager, type ToolName, VERSION, Viewport, type ViewportOptions, boundsIntersect, createArrow, createGrid, createHtmlElement, createImage, createNote, createShape, createStroke, createTemplate, createText, drawHexPath, exportImage, exportSvg, getActiveFormats, getArrowBounds, getArrowControlPoint, getArrowMidpoint, getArrowTangentAngle, getBendFromPoint, getElementBounds, getElementStyle, getElementsBoundingBox, getHexCellsInCone, getHexCellsInLine, getHexCellsInRadius, getHexCellsInRectangle, getHexCellsInSquare, getHexDistance, isNearBezier, setFontSize, smartSnap, snapPoint, snapToHexCenter, styleToPatch, toggleBold, toggleItalic, toggleStrikethrough, toggleUnderline };
|
package/dist/index.d.ts
CHANGED
|
@@ -1123,6 +1123,6 @@ declare class LaserTool implements Tool {
|
|
|
1123
1123
|
private notifyOptionsChange;
|
|
1124
1124
|
}
|
|
1125
1125
|
|
|
1126
|
-
declare const VERSION = "0.
|
|
1126
|
+
declare const VERSION = "0.50.1";
|
|
1127
1127
|
|
|
1128
1128
|
export { type ActiveFormats, type AlignEdge, type ArrowElement, type ArrowStrokeStyle, ArrowTool, type ArrowToolOptions, AutoSave, type AutoSaveOptions, type BackgroundOptions, type BackgroundPattern, type Binding, type Bounds, Camera, type CameraChangeInfo, type CameraOptions, type CanvasElement, type CanvasState, type Command, DEFAULT_NOTE_FONT_SIZE, type DistributeAxis, type ElementChangeMeta, ElementStore, type ElementStyle, type ElementType, type ElementUpdateEvent, EraserTool, type EraserToolOptions, type ExportImageOptions, type ExportSvgOptions, type FontSizePreset, type GridElement, type GridInfo, HandTool, type HexOrientation, HistoryStack, type HistoryStackOptions, type HtmlElement, type ImageElement, ImageTool, type ImageToolOptions, IndexedDBAdapter, type IndexedDBAdapterOptions, LaserTool, type LaserToolOptions, type Layer, LayerManager, LocalStorageAdapter, MeasureTool, type MeasureToolOptions, type Measurement, MemoryAdapter, type NoteElement, NoteTool, type NoteToolOptions, PencilTool, type PencilToolOptions, type Point, type PointerState, type RenderStatsSnapshot, type RotateDirection, SelectTool, type ShapeElement, type ShapeKind, ShapeTool, type ShapeToolOptions, type ShortcutBindings, type ShortcutOptions, type ShortcutsApi, type Size, type StorageAdapter, type StrokeElement, type StrokePoint, type TemplateElement, type TemplateRenderStyle, type TemplateShape, TemplateTool, type TemplateToolOptions, type TextElement, TextTool, type TextToolOptions, type Tool, type ToolContext, ToolManager, type ToolName, VERSION, Viewport, type ViewportOptions, boundsIntersect, createArrow, createGrid, createHtmlElement, createImage, createNote, createShape, createStroke, createTemplate, createText, drawHexPath, exportImage, exportSvg, getActiveFormats, getArrowBounds, getArrowControlPoint, getArrowMidpoint, getArrowTangentAngle, getBendFromPoint, getElementBounds, getElementStyle, getElementsBoundingBox, getHexCellsInCone, getHexCellsInLine, getHexCellsInRadius, getHexCellsInRectangle, getHexCellsInSquare, getHexDistance, isNearBezier, setFontSize, smartSnap, snapPoint, snapToHexCenter, styleToPatch, toggleBold, toggleItalic, toggleStrikethrough, toggleUnderline };
|
package/dist/index.js
CHANGED
|
@@ -280,7 +280,7 @@ function migrateElement(obj) {
|
|
|
280
280
|
if (obj["type"] === "note" && typeof obj["textColor"] !== "string") {
|
|
281
281
|
obj["textColor"] = "#000000";
|
|
282
282
|
}
|
|
283
|
-
if (obj["type"] === "note" && typeof obj["text"] === "string") {
|
|
283
|
+
if ((obj["type"] === "note" || obj["type"] === "text") && typeof obj["text"] === "string") {
|
|
284
284
|
obj["text"] = sanitizeNoteHtml(obj["text"]);
|
|
285
285
|
}
|
|
286
286
|
}
|
|
@@ -2493,6 +2493,11 @@ function transferStrokeRenderData(prev, next) {
|
|
|
2493
2493
|
}
|
|
2494
2494
|
|
|
2495
2495
|
// src/elements/element-store.ts
|
|
2496
|
+
function sanitizeRichText(element) {
|
|
2497
|
+
if (element.type !== "note" && element.type !== "text") return element;
|
|
2498
|
+
const text = sanitizeNoteHtml(element.text);
|
|
2499
|
+
return text === element.text ? element : { ...element, text };
|
|
2500
|
+
}
|
|
2496
2501
|
var ElementStore = class {
|
|
2497
2502
|
elements = /* @__PURE__ */ new Map();
|
|
2498
2503
|
bus = new EventBus();
|
|
@@ -2537,6 +2542,7 @@ var ElementStore = class {
|
|
|
2537
2542
|
return angle === 0 ? bounds : rotatedAABB(bounds, angle);
|
|
2538
2543
|
}
|
|
2539
2544
|
add(element, meta) {
|
|
2545
|
+
element = sanitizeRichText(element);
|
|
2540
2546
|
this.sortedCache = null;
|
|
2541
2547
|
this._versions.set(element.id, 0);
|
|
2542
2548
|
this.elements.set(element.id, element);
|
|
@@ -2563,7 +2569,7 @@ var ElementStore = class {
|
|
|
2563
2569
|
const arrow = updated;
|
|
2564
2570
|
arrow.cachedControlPoint = getArrowControlPoint(arrow.from, arrow.to, arrow.bend);
|
|
2565
2571
|
}
|
|
2566
|
-
if (updated.type === "note" && "text" in partial) {
|
|
2572
|
+
if ((updated.type === "note" || updated.type === "text") && "text" in partial) {
|
|
2567
2573
|
updated.text = sanitizeNoteHtml(updated.text);
|
|
2568
2574
|
}
|
|
2569
2575
|
this.elements.set(id, updated);
|
|
@@ -2593,11 +2599,12 @@ var ElementStore = class {
|
|
|
2593
2599
|
return this.getAll().map((el) => ({ ...el }));
|
|
2594
2600
|
}
|
|
2595
2601
|
loadSnapshot(elements, meta) {
|
|
2602
|
+
const sanitizedElements = elements.map(sanitizeRichText);
|
|
2596
2603
|
this.sortedCache = null;
|
|
2597
2604
|
this._versions.clear();
|
|
2598
2605
|
this.elements.clear();
|
|
2599
2606
|
this.spatialIndex.clear();
|
|
2600
|
-
for (const el of
|
|
2607
|
+
for (const el of sanitizedElements) {
|
|
2601
2608
|
this.elements.set(el.id, el);
|
|
2602
2609
|
this._versions.set(el.id, 0);
|
|
2603
2610
|
const bounds = this.indexBounds(el);
|
|
@@ -2610,7 +2617,7 @@ var ElementStore = class {
|
|
|
2610
2617
|
}
|
|
2611
2618
|
}
|
|
2612
2619
|
this.bus.emit("clear", null, meta);
|
|
2613
|
-
for (const el of
|
|
2620
|
+
for (const el of sanitizedElements) {
|
|
2614
2621
|
this.bus.emit("add", el, meta);
|
|
2615
2622
|
}
|
|
2616
2623
|
}
|
|
@@ -4025,7 +4032,7 @@ function createText(input) {
|
|
|
4025
4032
|
locked: input.locked ?? false,
|
|
4026
4033
|
layerId: input.layerId ?? "",
|
|
4027
4034
|
size: input.size ?? { w: 200, h: 28 },
|
|
4028
|
-
text: input.text ?? "",
|
|
4035
|
+
text: sanitizeNoteHtml(input.text ?? ""),
|
|
4029
4036
|
fontSize: input.fontSize ?? 16,
|
|
4030
4037
|
color: input.color ?? "#1a1a1a",
|
|
4031
4038
|
textAlign: input.textAlign ?? "left"
|
|
@@ -8878,7 +8885,7 @@ function anchorOffset(handle, w, h) {
|
|
|
8878
8885
|
return { x: 0, y: 0 };
|
|
8879
8886
|
}
|
|
8880
8887
|
}
|
|
8881
|
-
function computeResize(el, handle, world, lastWorld, aspectRatio,
|
|
8888
|
+
function computeResize(el, handle, world, lastWorld, aspectRatio, lockAspect) {
|
|
8882
8889
|
const dx = world.x - lastWorld.x;
|
|
8883
8890
|
const dy = world.y - lastWorld.y;
|
|
8884
8891
|
let { x, y, w, h } = { x: el.position.x, y: el.position.y, w: el.size.w, h: el.size.h };
|
|
@@ -8904,7 +8911,7 @@ function computeResize(el, handle, world, lastWorld, aspectRatio, shiftKey) {
|
|
|
8904
8911
|
h -= dy;
|
|
8905
8912
|
break;
|
|
8906
8913
|
}
|
|
8907
|
-
if (
|
|
8914
|
+
if (lockAspect && aspectRatio > 0) {
|
|
8908
8915
|
const absDw = Math.abs(w - el.size.w);
|
|
8909
8916
|
const absDh = Math.abs(h - el.size.h);
|
|
8910
8917
|
if (absDw >= absDh) {
|
|
@@ -8929,7 +8936,7 @@ function computeResize(el, handle, world, lastWorld, aspectRatio, shiftKey) {
|
|
|
8929
8936
|
}
|
|
8930
8937
|
return { position: { x, y }, size: { w, h } };
|
|
8931
8938
|
}
|
|
8932
|
-
function computeRotatedResize(el, handle, angle, world, lastWorld, aspectRatio,
|
|
8939
|
+
function computeRotatedResize(el, handle, angle, world, lastWorld, aspectRatio, lockAspect) {
|
|
8933
8940
|
const wdx = world.x - lastWorld.x;
|
|
8934
8941
|
const wdy = world.y - lastWorld.y;
|
|
8935
8942
|
const cosN = Math.cos(-angle);
|
|
@@ -8956,7 +8963,7 @@ function computeRotatedResize(el, handle, angle, world, lastWorld, aspectRatio,
|
|
|
8956
8963
|
h -= ldy;
|
|
8957
8964
|
break;
|
|
8958
8965
|
}
|
|
8959
|
-
if (
|
|
8966
|
+
if (lockAspect && aspectRatio > 0) {
|
|
8960
8967
|
const absDw = Math.abs(w - el.size.w);
|
|
8961
8968
|
const absDh = Math.abs(h - el.size.h);
|
|
8962
8969
|
if (absDw >= absDh) h = w / aspectRatio;
|
|
@@ -9486,6 +9493,7 @@ var SelectTool = class {
|
|
|
9486
9493
|
if (this.mode.type !== "resizing") return;
|
|
9487
9494
|
const el = ctx.store.getById(this.mode.elementId);
|
|
9488
9495
|
if (!el || !("size" in el) || el.locked) return;
|
|
9496
|
+
const lockAspect = shiftKey !== (el.type === "image");
|
|
9489
9497
|
const angle = el.rotation ?? 0;
|
|
9490
9498
|
const patch = angle !== 0 ? computeRotatedResize(
|
|
9491
9499
|
el,
|
|
@@ -9494,14 +9502,14 @@ var SelectTool = class {
|
|
|
9494
9502
|
world,
|
|
9495
9503
|
this.lastWorld,
|
|
9496
9504
|
this.resizeAspectRatio,
|
|
9497
|
-
|
|
9505
|
+
lockAspect
|
|
9498
9506
|
) : computeResize(
|
|
9499
9507
|
el,
|
|
9500
9508
|
this.mode.handle,
|
|
9501
9509
|
world,
|
|
9502
9510
|
this.lastWorld,
|
|
9503
9511
|
this.resizeAspectRatio,
|
|
9504
|
-
|
|
9512
|
+
lockAspect
|
|
9505
9513
|
);
|
|
9506
9514
|
this.lastWorld = world;
|
|
9507
9515
|
ctx.store.update(this.mode.elementId, patch);
|
|
@@ -10526,7 +10534,7 @@ var LaserTool = class {
|
|
|
10526
10534
|
};
|
|
10527
10535
|
|
|
10528
10536
|
// src/index.ts
|
|
10529
|
-
var VERSION = "0.
|
|
10537
|
+
var VERSION = "0.50.1";
|
|
10530
10538
|
export {
|
|
10531
10539
|
ArrowTool,
|
|
10532
10540
|
AutoSave,
|