@fieldnotes/core 0.50.0 → 0.50.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 +92 -30
- 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 +92 -30
- 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.50.
|
|
1126
|
+
declare const VERSION = "0.50.2";
|
|
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.50.
|
|
1126
|
+
declare const VERSION = "0.50.2";
|
|
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
|
}
|
|
@@ -3586,7 +3593,7 @@ function renderSquareGrid(ctx, bounds, cellSize, strokeColor, strokeWidth, opaci
|
|
|
3586
3593
|
ctx.save();
|
|
3587
3594
|
ctx.strokeStyle = strokeColor;
|
|
3588
3595
|
ctx.lineWidth = strokeWidth;
|
|
3589
|
-
ctx.globalAlpha
|
|
3596
|
+
ctx.globalAlpha *= opacity;
|
|
3590
3597
|
ctx.beginPath();
|
|
3591
3598
|
for (const x of verticals) {
|
|
3592
3599
|
ctx.moveTo(x, bounds.minY);
|
|
@@ -3617,7 +3624,7 @@ function renderHexGrid(ctx, bounds, cellSize, orientation, strokeColor, strokeWi
|
|
|
3617
3624
|
ctx.save();
|
|
3618
3625
|
ctx.strokeStyle = strokeColor;
|
|
3619
3626
|
ctx.lineWidth = strokeWidth;
|
|
3620
|
-
ctx.globalAlpha
|
|
3627
|
+
ctx.globalAlpha *= opacity;
|
|
3621
3628
|
ctx.beginPath();
|
|
3622
3629
|
if (orientation === "pointy") {
|
|
3623
3630
|
const hexW = Math.sqrt(3) * cellSize;
|
|
@@ -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"
|
|
@@ -5377,41 +5384,70 @@ async function exportImage(store, options = {}, layerManager) {
|
|
|
5377
5384
|
const renderer = new ElementRenderer();
|
|
5378
5385
|
renderer.setStore(store);
|
|
5379
5386
|
const grids = [];
|
|
5380
|
-
|
|
5381
|
-
if (el.type === "grid") {
|
|
5382
|
-
grids.push(el);
|
|
5383
|
-
continue;
|
|
5384
|
-
}
|
|
5387
|
+
const renderElement = (target, el) => {
|
|
5385
5388
|
if (el.type === "note") {
|
|
5386
5389
|
const b = getElementBounds(el);
|
|
5387
|
-
withRotation(
|
|
5388
|
-
|
|
5390
|
+
withRotation(target, el, b ? center(b) : el.position, () => renderNoteOnCanvas(target, el));
|
|
5391
|
+
return;
|
|
5389
5392
|
}
|
|
5390
5393
|
if (el.type === "text") {
|
|
5391
5394
|
const b = getElementBounds(el);
|
|
5392
|
-
withRotation(
|
|
5393
|
-
|
|
5395
|
+
withRotation(target, el, b ? center(b) : el.position, () => renderTextOnCanvas(target, el));
|
|
5396
|
+
return;
|
|
5394
5397
|
}
|
|
5395
5398
|
if (el.type === "html") {
|
|
5396
|
-
|
|
5399
|
+
return;
|
|
5397
5400
|
}
|
|
5398
5401
|
if (el.type === "image") {
|
|
5399
5402
|
const img = imageCache.get(el.id);
|
|
5400
5403
|
if (img) {
|
|
5401
5404
|
const b = getElementBounds(el);
|
|
5402
5405
|
withRotation(
|
|
5403
|
-
|
|
5406
|
+
target,
|
|
5404
5407
|
el,
|
|
5405
5408
|
b ? center(b) : el.position,
|
|
5406
|
-
() =>
|
|
5409
|
+
() => target.drawImage(img, el.position.x, el.position.y, el.size.w, el.size.h)
|
|
5407
5410
|
);
|
|
5408
5411
|
}
|
|
5412
|
+
return;
|
|
5413
|
+
}
|
|
5414
|
+
renderer.renderCanvasElement(target, el);
|
|
5415
|
+
};
|
|
5416
|
+
const layerGroups = /* @__PURE__ */ new Map();
|
|
5417
|
+
for (const el of visibleElements) {
|
|
5418
|
+
if (el.type === "grid") {
|
|
5419
|
+
grids.push(el);
|
|
5420
|
+
continue;
|
|
5421
|
+
}
|
|
5422
|
+
const group = layerGroups.get(el.layerId) ?? [];
|
|
5423
|
+
group.push(el);
|
|
5424
|
+
layerGroups.set(el.layerId, group);
|
|
5425
|
+
}
|
|
5426
|
+
for (const [layerId, elements] of layerGroups) {
|
|
5427
|
+
const opacity = layerManager?.getLayer?.(layerId)?.opacity ?? 1;
|
|
5428
|
+
if (opacity === 1) {
|
|
5429
|
+
for (const el of elements) renderElement(ctx, el);
|
|
5409
5430
|
continue;
|
|
5410
5431
|
}
|
|
5411
|
-
|
|
5432
|
+
const layerCanvas = document.createElement("canvas");
|
|
5433
|
+
layerCanvas.width = canvas.width;
|
|
5434
|
+
layerCanvas.height = canvas.height;
|
|
5435
|
+
const layerCtx = layerCanvas.getContext("2d");
|
|
5436
|
+
if (!layerCtx) continue;
|
|
5437
|
+
layerCtx.scale(scale, scale);
|
|
5438
|
+
layerCtx.translate(-bounds.x, -bounds.y);
|
|
5439
|
+
for (const el of elements) renderElement(layerCtx, el);
|
|
5440
|
+
ctx.save();
|
|
5441
|
+
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
|
5442
|
+
ctx.globalAlpha = opacity;
|
|
5443
|
+
ctx.drawImage(layerCanvas, 0, 0);
|
|
5444
|
+
ctx.restore();
|
|
5412
5445
|
}
|
|
5413
5446
|
for (const grid of grids) {
|
|
5447
|
+
ctx.save();
|
|
5448
|
+
ctx.globalAlpha = layerManager?.getLayer?.(grid.layerId)?.opacity ?? 1;
|
|
5414
5449
|
renderGridForBounds(ctx, grid, bounds);
|
|
5450
|
+
ctx.restore();
|
|
5415
5451
|
}
|
|
5416
5452
|
return new Promise((resolve) => {
|
|
5417
5453
|
canvas.toBlob((blob) => resolve(blob), "image/png");
|
|
@@ -5731,11 +5767,19 @@ async function exportSvg(store, options = {}, layerManager) {
|
|
|
5731
5767
|
if (options.background) {
|
|
5732
5768
|
body += `<rect x="${n(bounds.x)}" y="${n(bounds.y)}" width="${n(bounds.w)}" height="${n(bounds.h)}" fill="${esc(options.background)}" />`;
|
|
5733
5769
|
}
|
|
5770
|
+
const layerBodies = /* @__PURE__ */ new Map();
|
|
5734
5771
|
for (const el of visibleElements) {
|
|
5735
|
-
|
|
5772
|
+
const emitted = emitElement(el, imageDataUris, rasterScale, firstGrid, store);
|
|
5773
|
+
layerBodies.set(el.layerId, (layerBodies.get(el.layerId) ?? "") + emitted);
|
|
5774
|
+
}
|
|
5775
|
+
for (const [layerId, emitted] of layerBodies) {
|
|
5776
|
+
const opacity = layerManager?.getLayer?.(layerId)?.opacity ?? 1;
|
|
5777
|
+
body += opacity === 1 || emitted === "" ? emitted : `<g opacity="${n(opacity)}">${emitted}</g>`;
|
|
5736
5778
|
}
|
|
5737
5779
|
for (const grid of grids) {
|
|
5738
|
-
|
|
5780
|
+
const emitted = emitGrid(grid, bounds);
|
|
5781
|
+
const opacity = layerManager?.getLayer?.(grid.layerId)?.opacity ?? 1;
|
|
5782
|
+
body += opacity === 1 ? emitted : `<g opacity="${n(opacity)}">${emitted}</g>`;
|
|
5739
5783
|
}
|
|
5740
5784
|
return `<svg xmlns="http://www.w3.org/2000/svg" width="${n(bounds.w)}" height="${n(bounds.h)}" viewBox="${n(bounds.x)} ${n(bounds.y)} ${n(bounds.w)} ${n(bounds.h)}">${body}</svg>`;
|
|
5741
5785
|
}
|
|
@@ -6054,6 +6098,7 @@ var DomNodeManager = class {
|
|
|
6054
6098
|
getVersion;
|
|
6055
6099
|
lastSyncedVersion = /* @__PURE__ */ new Map();
|
|
6056
6100
|
lastSyncedZIndex = /* @__PURE__ */ new Map();
|
|
6101
|
+
lastSyncedOpacity = /* @__PURE__ */ new Map();
|
|
6057
6102
|
constructor(deps) {
|
|
6058
6103
|
this.domLayer = deps.domLayer;
|
|
6059
6104
|
this.onEditRequest = deps.onEditRequest;
|
|
@@ -6073,6 +6118,7 @@ var DomNodeManager = class {
|
|
|
6073
6118
|
this.htmlContent.delete(elementId);
|
|
6074
6119
|
this.lastSyncedVersion.delete(elementId);
|
|
6075
6120
|
this.lastSyncedZIndex.delete(elementId);
|
|
6121
|
+
this.lastSyncedOpacity.delete(elementId);
|
|
6076
6122
|
const node = this.domNodes.get(elementId);
|
|
6077
6123
|
if (!node) return;
|
|
6078
6124
|
while (node.firstChild) {
|
|
@@ -6080,7 +6126,7 @@ var DomNodeManager = class {
|
|
|
6080
6126
|
}
|
|
6081
6127
|
delete node.dataset["initialized"];
|
|
6082
6128
|
}
|
|
6083
|
-
syncDomNode(element, zIndex = 0) {
|
|
6129
|
+
syncDomNode(element, zIndex = 0, opacity = 1) {
|
|
6084
6130
|
let node = this.domNodes.get(element.id);
|
|
6085
6131
|
if (!node) {
|
|
6086
6132
|
node = document.createElement("div");
|
|
@@ -6095,13 +6141,15 @@ var DomNodeManager = class {
|
|
|
6095
6141
|
const currentVersion = this.getVersion(element.id);
|
|
6096
6142
|
const lastVersion = this.lastSyncedVersion.get(element.id);
|
|
6097
6143
|
const lastZ = this.lastSyncedZIndex.get(element.id);
|
|
6098
|
-
|
|
6144
|
+
const lastOpacity = this.lastSyncedOpacity.get(element.id);
|
|
6145
|
+
if (lastVersion === currentVersion && lastZ === zIndex && lastOpacity === opacity) {
|
|
6099
6146
|
return;
|
|
6100
6147
|
}
|
|
6101
6148
|
}
|
|
6102
6149
|
if (this.getVersion) {
|
|
6103
6150
|
this.lastSyncedVersion.set(element.id, this.getVersion(element.id));
|
|
6104
6151
|
this.lastSyncedZIndex.set(element.id, zIndex);
|
|
6152
|
+
this.lastSyncedOpacity.set(element.id, opacity);
|
|
6105
6153
|
}
|
|
6106
6154
|
const size = "size" in element ? element.size : null;
|
|
6107
6155
|
Object.assign(node.style, {
|
|
@@ -6111,6 +6159,7 @@ var DomNodeManager = class {
|
|
|
6111
6159
|
width: size ? `${size.w}px` : "auto",
|
|
6112
6160
|
height: size ? `${size.h}px` : "auto",
|
|
6113
6161
|
zIndex: String(zIndex),
|
|
6162
|
+
opacity: String(opacity),
|
|
6114
6163
|
transform: element.rotation ? `rotate(${element.rotation}rad)` : "",
|
|
6115
6164
|
transformOrigin: "50% 50%"
|
|
6116
6165
|
});
|
|
@@ -6124,6 +6173,7 @@ var DomNodeManager = class {
|
|
|
6124
6173
|
this.htmlContent.delete(id);
|
|
6125
6174
|
this.lastSyncedVersion.delete(id);
|
|
6126
6175
|
this.lastSyncedZIndex.delete(id);
|
|
6176
|
+
this.lastSyncedOpacity.delete(id);
|
|
6127
6177
|
const node = this.domNodes.get(id);
|
|
6128
6178
|
if (node) {
|
|
6129
6179
|
node.remove();
|
|
@@ -6136,6 +6186,7 @@ var DomNodeManager = class {
|
|
|
6136
6186
|
this.htmlContent.clear();
|
|
6137
6187
|
this.lastSyncedVersion.clear();
|
|
6138
6188
|
this.lastSyncedZIndex.clear();
|
|
6189
|
+
this.lastSyncedOpacity.clear();
|
|
6139
6190
|
}
|
|
6140
6191
|
reattachHtmlContent(store) {
|
|
6141
6192
|
for (const el of store.getElementsByType("html")) {
|
|
@@ -6374,11 +6425,12 @@ var RenderLoop = class {
|
|
|
6374
6425
|
}
|
|
6375
6426
|
markAllLayersDirty() {
|
|
6376
6427
|
this.layerCache.markAllDirty();
|
|
6428
|
+
this.gridCacheDirty = true;
|
|
6377
6429
|
}
|
|
6378
6430
|
getStats() {
|
|
6379
6431
|
return this.stats.getSnapshot();
|
|
6380
6432
|
}
|
|
6381
|
-
compositeLayerCache(ctx, layerId) {
|
|
6433
|
+
compositeLayerCache(ctx, layerId, opacity) {
|
|
6382
6434
|
const cached = this.layerCache.getCanvas(layerId);
|
|
6383
6435
|
const offset = this.marginViewport.compositeOffset(
|
|
6384
6436
|
this.camera.position.x,
|
|
@@ -6386,6 +6438,7 @@ var RenderLoop = class {
|
|
|
6386
6438
|
);
|
|
6387
6439
|
ctx.save();
|
|
6388
6440
|
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
|
6441
|
+
ctx.globalAlpha = opacity;
|
|
6389
6442
|
ctx.drawImage(cached, offset.x, offset.y);
|
|
6390
6443
|
ctx.restore();
|
|
6391
6444
|
}
|
|
@@ -6465,11 +6518,12 @@ var RenderLoop = class {
|
|
|
6465
6518
|
continue;
|
|
6466
6519
|
}
|
|
6467
6520
|
if (this.renderer.isDomElement(element)) {
|
|
6521
|
+
const layerOpacity = this.layerManager.getLayer?.(element.layerId)?.opacity ?? 1;
|
|
6468
6522
|
const elBounds = getElementBounds(element);
|
|
6469
6523
|
if (elBounds && !boundsIntersect(elBounds, cullingRect)) {
|
|
6470
6524
|
this.domNodeManager.hideDomNode(element.id);
|
|
6471
6525
|
} else {
|
|
6472
|
-
this.domNodeManager.syncDomNode(element, domZIndex
|
|
6526
|
+
this.domNodeManager.syncDomNode(element, domZIndex++, layerOpacity);
|
|
6473
6527
|
}
|
|
6474
6528
|
continue;
|
|
6475
6529
|
}
|
|
@@ -6486,15 +6540,16 @@ var RenderLoop = class {
|
|
|
6486
6540
|
}
|
|
6487
6541
|
for (const [layerId, elements] of this.layerGroups) {
|
|
6488
6542
|
const isActiveDrawingLayer = layerId === this.activeDrawingLayerId;
|
|
6543
|
+
const layerOpacity = this.layerManager.getLayer?.(layerId)?.opacity ?? 1;
|
|
6489
6544
|
if (!this.layerCache.isDirty(layerId)) {
|
|
6490
6545
|
const compT0 = performance.now();
|
|
6491
|
-
this.compositeLayerCache(ctx, layerId);
|
|
6546
|
+
this.compositeLayerCache(ctx, layerId, layerOpacity);
|
|
6492
6547
|
compositeMs += performance.now() - compT0;
|
|
6493
6548
|
continue;
|
|
6494
6549
|
}
|
|
6495
6550
|
if (isActiveDrawingLayer) {
|
|
6496
6551
|
const compT0 = performance.now();
|
|
6497
|
-
this.compositeLayerCache(ctx, layerId);
|
|
6552
|
+
this.compositeLayerCache(ctx, layerId, layerOpacity);
|
|
6498
6553
|
compositeMs += performance.now() - compT0;
|
|
6499
6554
|
continue;
|
|
6500
6555
|
}
|
|
@@ -6514,7 +6569,7 @@ var RenderLoop = class {
|
|
|
6514
6569
|
this.layerCache.markClean(layerId);
|
|
6515
6570
|
layersMs += performance.now() - layerT0;
|
|
6516
6571
|
const compT0 = performance.now();
|
|
6517
|
-
this.compositeLayerCache(ctx, layerId);
|
|
6572
|
+
this.compositeLayerCache(ctx, layerId, layerOpacity);
|
|
6518
6573
|
compositeMs += performance.now() - compT0;
|
|
6519
6574
|
}
|
|
6520
6575
|
}
|
|
@@ -6538,7 +6593,10 @@ var RenderLoop = class {
|
|
|
6538
6593
|
this.marginViewport.applyRenderTransform(gc);
|
|
6539
6594
|
try {
|
|
6540
6595
|
for (const grid of gridElements) {
|
|
6596
|
+
gc.save();
|
|
6597
|
+
gc.globalAlpha = this.layerManager.getLayer?.(grid.layerId)?.opacity ?? 1;
|
|
6541
6598
|
this.renderer.renderCanvasElement(gc, grid);
|
|
6599
|
+
gc.restore();
|
|
6542
6600
|
}
|
|
6543
6601
|
} finally {
|
|
6544
6602
|
gc.restore();
|
|
@@ -6559,7 +6617,10 @@ var RenderLoop = class {
|
|
|
6559
6617
|
ctx.restore();
|
|
6560
6618
|
} else {
|
|
6561
6619
|
for (const grid of gridElements) {
|
|
6620
|
+
ctx.save();
|
|
6621
|
+
ctx.globalAlpha = this.layerManager.getLayer?.(grid.layerId)?.opacity ?? 1;
|
|
6562
6622
|
this.renderer.renderCanvasElement(ctx, grid);
|
|
6623
|
+
ctx.restore();
|
|
6563
6624
|
}
|
|
6564
6625
|
}
|
|
6565
6626
|
gridMs = performance.now() - gridT0;
|
|
@@ -7464,6 +7525,7 @@ var Viewport = class {
|
|
|
7464
7525
|
];
|
|
7465
7526
|
this.layerManager.on("change", () => {
|
|
7466
7527
|
this.toolContext.activeLayerId = this.layerManager.activeLayerId;
|
|
7528
|
+
this.renderLoop.markAllLayersDirty();
|
|
7467
7529
|
this.minimap?.scheduleDraw();
|
|
7468
7530
|
this.requestRender();
|
|
7469
7531
|
});
|
|
@@ -10527,7 +10589,7 @@ var LaserTool = class {
|
|
|
10527
10589
|
};
|
|
10528
10590
|
|
|
10529
10591
|
// src/index.ts
|
|
10530
|
-
var VERSION = "0.50.
|
|
10592
|
+
var VERSION = "0.50.2";
|
|
10531
10593
|
export {
|
|
10532
10594
|
ArrowTool,
|
|
10533
10595
|
AutoSave,
|