@fieldnotes/core 0.7.1 → 0.8.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 +263 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -2
- package/dist/index.d.ts +11 -2
- package/dist/index.js +262 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -393,6 +393,14 @@ declare class InputHandler {
|
|
|
393
393
|
private cancelToolIfActive;
|
|
394
394
|
}
|
|
395
395
|
|
|
396
|
+
interface ExportImageOptions {
|
|
397
|
+
scale?: number;
|
|
398
|
+
padding?: number;
|
|
399
|
+
background?: string;
|
|
400
|
+
filter?: (element: CanvasElement) => boolean;
|
|
401
|
+
}
|
|
402
|
+
declare function exportImage(store: ElementStore, options?: ExportImageOptions, layerManager?: LayerManager): Promise<Blob | null>;
|
|
403
|
+
|
|
396
404
|
interface ViewportOptions {
|
|
397
405
|
camera?: CameraOptions;
|
|
398
406
|
background?: BackgroundOptions;
|
|
@@ -430,6 +438,7 @@ declare class Viewport {
|
|
|
430
438
|
requestRender(): void;
|
|
431
439
|
exportState(): CanvasState;
|
|
432
440
|
exportJSON(): string;
|
|
441
|
+
exportImage(options?: ExportImageOptions): Promise<Blob | null>;
|
|
433
442
|
loadState(state: CanvasState): void;
|
|
434
443
|
loadJSON(json: string): void;
|
|
435
444
|
undo(): boolean;
|
|
@@ -861,6 +870,6 @@ declare class UpdateLayerCommand implements Command {
|
|
|
861
870
|
undo(_store: ElementStore): void;
|
|
862
871
|
}
|
|
863
872
|
|
|
864
|
-
declare const VERSION = "0.
|
|
873
|
+
declare const VERSION = "0.8.1";
|
|
865
874
|
|
|
866
|
-
export { AddElementCommand, type ArrowElement, ArrowTool, type ArrowToolOptions, AutoSave, type AutoSaveOptions, Background, type BackgroundOptions, type BackgroundPattern, BatchCommand, type Binding, type Bounds, Camera, type CameraOptions, type CanvasElement, type CanvasState, type Command, CreateLayerCommand, ElementRenderer, ElementStore, type ElementType, type ElementUpdateEvent, EraserTool, type EraserToolOptions, EventBus, type GridElement, HandTool, type HexOrientation, HistoryRecorder, HistoryStack, type HistoryStackOptions, type HtmlElement, type ImageElement, ImageTool, type ImageToolOptions, InputHandler, type Layer, LayerManager, NoteEditor, type NoteElement, NoteTool, type NoteToolOptions, PencilTool, type PencilToolOptions, type Point, type PointerState, RemoveElementCommand, RemoveLayerCommand, SelectTool, type ShapeElement, type ShapeKind, ShapeTool, type ShapeToolOptions, type Size, type StrokeElement, type StrokePoint, type TextElement, TextTool, type TextToolOptions, type Tool, type ToolContext, ToolManager, type ToolName, UpdateElementCommand, UpdateLayerCommand, VERSION, Viewport, type ViewportOptions, clearStaleBindings, createArrow, createGrid, createHtmlElement, createId, createImage, createNote, createShape, createStroke, createText, exportState, findBindTarget, findBoundArrows, getArrowBounds, getArrowControlPoint, getArrowMidpoint, getArrowTangentAngle, getBendFromPoint, getEdgeIntersection, getElementBounds, getElementCenter, isBindable, isNearBezier, parseState, snapPoint, unbindArrow, updateBoundArrow };
|
|
875
|
+
export { AddElementCommand, type ArrowElement, ArrowTool, type ArrowToolOptions, AutoSave, type AutoSaveOptions, Background, type BackgroundOptions, type BackgroundPattern, BatchCommand, type Binding, type Bounds, Camera, type CameraOptions, type CanvasElement, type CanvasState, type Command, CreateLayerCommand, ElementRenderer, ElementStore, type ElementType, type ElementUpdateEvent, EraserTool, type EraserToolOptions, EventBus, type ExportImageOptions, type GridElement, HandTool, type HexOrientation, HistoryRecorder, HistoryStack, type HistoryStackOptions, type HtmlElement, type ImageElement, ImageTool, type ImageToolOptions, InputHandler, type Layer, LayerManager, NoteEditor, type NoteElement, NoteTool, type NoteToolOptions, PencilTool, type PencilToolOptions, type Point, type PointerState, RemoveElementCommand, RemoveLayerCommand, SelectTool, type ShapeElement, type ShapeKind, ShapeTool, type ShapeToolOptions, type Size, type StrokeElement, type StrokePoint, type TextElement, TextTool, type TextToolOptions, type Tool, type ToolContext, ToolManager, type ToolName, UpdateElementCommand, UpdateLayerCommand, VERSION, Viewport, type ViewportOptions, clearStaleBindings, createArrow, createGrid, createHtmlElement, createId, createImage, createNote, createShape, createStroke, createText, exportImage, exportState, findBindTarget, findBoundArrows, getArrowBounds, getArrowControlPoint, getArrowMidpoint, getArrowTangentAngle, getBendFromPoint, getEdgeIntersection, getElementBounds, getElementCenter, isBindable, isNearBezier, parseState, snapPoint, unbindArrow, updateBoundArrow };
|
package/dist/index.d.ts
CHANGED
|
@@ -393,6 +393,14 @@ declare class InputHandler {
|
|
|
393
393
|
private cancelToolIfActive;
|
|
394
394
|
}
|
|
395
395
|
|
|
396
|
+
interface ExportImageOptions {
|
|
397
|
+
scale?: number;
|
|
398
|
+
padding?: number;
|
|
399
|
+
background?: string;
|
|
400
|
+
filter?: (element: CanvasElement) => boolean;
|
|
401
|
+
}
|
|
402
|
+
declare function exportImage(store: ElementStore, options?: ExportImageOptions, layerManager?: LayerManager): Promise<Blob | null>;
|
|
403
|
+
|
|
396
404
|
interface ViewportOptions {
|
|
397
405
|
camera?: CameraOptions;
|
|
398
406
|
background?: BackgroundOptions;
|
|
@@ -430,6 +438,7 @@ declare class Viewport {
|
|
|
430
438
|
requestRender(): void;
|
|
431
439
|
exportState(): CanvasState;
|
|
432
440
|
exportJSON(): string;
|
|
441
|
+
exportImage(options?: ExportImageOptions): Promise<Blob | null>;
|
|
433
442
|
loadState(state: CanvasState): void;
|
|
434
443
|
loadJSON(json: string): void;
|
|
435
444
|
undo(): boolean;
|
|
@@ -861,6 +870,6 @@ declare class UpdateLayerCommand implements Command {
|
|
|
861
870
|
undo(_store: ElementStore): void;
|
|
862
871
|
}
|
|
863
872
|
|
|
864
|
-
declare const VERSION = "0.
|
|
873
|
+
declare const VERSION = "0.8.1";
|
|
865
874
|
|
|
866
|
-
export { AddElementCommand, type ArrowElement, ArrowTool, type ArrowToolOptions, AutoSave, type AutoSaveOptions, Background, type BackgroundOptions, type BackgroundPattern, BatchCommand, type Binding, type Bounds, Camera, type CameraOptions, type CanvasElement, type CanvasState, type Command, CreateLayerCommand, ElementRenderer, ElementStore, type ElementType, type ElementUpdateEvent, EraserTool, type EraserToolOptions, EventBus, type GridElement, HandTool, type HexOrientation, HistoryRecorder, HistoryStack, type HistoryStackOptions, type HtmlElement, type ImageElement, ImageTool, type ImageToolOptions, InputHandler, type Layer, LayerManager, NoteEditor, type NoteElement, NoteTool, type NoteToolOptions, PencilTool, type PencilToolOptions, type Point, type PointerState, RemoveElementCommand, RemoveLayerCommand, SelectTool, type ShapeElement, type ShapeKind, ShapeTool, type ShapeToolOptions, type Size, type StrokeElement, type StrokePoint, type TextElement, TextTool, type TextToolOptions, type Tool, type ToolContext, ToolManager, type ToolName, UpdateElementCommand, UpdateLayerCommand, VERSION, Viewport, type ViewportOptions, clearStaleBindings, createArrow, createGrid, createHtmlElement, createId, createImage, createNote, createShape, createStroke, createText, exportState, findBindTarget, findBoundArrows, getArrowBounds, getArrowControlPoint, getArrowMidpoint, getArrowTangentAngle, getBendFromPoint, getEdgeIntersection, getElementBounds, getElementCenter, isBindable, isNearBezier, parseState, snapPoint, unbindArrow, updateBoundArrow };
|
|
875
|
+
export { AddElementCommand, type ArrowElement, ArrowTool, type ArrowToolOptions, AutoSave, type AutoSaveOptions, Background, type BackgroundOptions, type BackgroundPattern, BatchCommand, type Binding, type Bounds, Camera, type CameraOptions, type CanvasElement, type CanvasState, type Command, CreateLayerCommand, ElementRenderer, ElementStore, type ElementType, type ElementUpdateEvent, EraserTool, type EraserToolOptions, EventBus, type ExportImageOptions, type GridElement, HandTool, type HexOrientation, HistoryRecorder, HistoryStack, type HistoryStackOptions, type HtmlElement, type ImageElement, ImageTool, type ImageToolOptions, InputHandler, type Layer, LayerManager, NoteEditor, type NoteElement, NoteTool, type NoteToolOptions, PencilTool, type PencilToolOptions, type Point, type PointerState, RemoveElementCommand, RemoveLayerCommand, SelectTool, type ShapeElement, type ShapeKind, ShapeTool, type ShapeToolOptions, type Size, type StrokeElement, type StrokePoint, type TextElement, TextTool, type TextToolOptions, type Tool, type ToolContext, ToolManager, type ToolName, UpdateElementCommand, UpdateLayerCommand, VERSION, Viewport, type ViewportOptions, clearStaleBindings, createArrow, createGrid, createHtmlElement, createId, createImage, createNote, createShape, createStroke, createText, exportImage, exportState, findBindTarget, findBoundArrows, getArrowBounds, getArrowControlPoint, getArrowMidpoint, getArrowTangentAngle, getBendFromPoint, getEdgeIntersection, getElementBounds, getElementCenter, isBindable, isNearBezier, parseState, snapPoint, unbindArrow, updateBoundArrow };
|
package/dist/index.js
CHANGED
|
@@ -1746,6 +1746,257 @@ function createText(input) {
|
|
|
1746
1746
|
};
|
|
1747
1747
|
}
|
|
1748
1748
|
|
|
1749
|
+
// src/canvas/export-image.ts
|
|
1750
|
+
function getStrokeBounds(el) {
|
|
1751
|
+
if (el.type !== "stroke") return null;
|
|
1752
|
+
if (el.points.length === 0) return null;
|
|
1753
|
+
let minX = Infinity;
|
|
1754
|
+
let minY = Infinity;
|
|
1755
|
+
let maxX = -Infinity;
|
|
1756
|
+
let maxY = -Infinity;
|
|
1757
|
+
for (const p of el.points) {
|
|
1758
|
+
const px = el.position.x + p.x;
|
|
1759
|
+
const py = el.position.y + p.y;
|
|
1760
|
+
minX = Math.min(minX, px);
|
|
1761
|
+
minY = Math.min(minY, py);
|
|
1762
|
+
maxX = Math.max(maxX, px);
|
|
1763
|
+
maxY = Math.max(maxY, py);
|
|
1764
|
+
}
|
|
1765
|
+
const pad = el.width / 2;
|
|
1766
|
+
return {
|
|
1767
|
+
x: minX - pad,
|
|
1768
|
+
y: minY - pad,
|
|
1769
|
+
w: maxX - minX + el.width,
|
|
1770
|
+
h: maxY - minY + el.width
|
|
1771
|
+
};
|
|
1772
|
+
}
|
|
1773
|
+
function getElementRect(el) {
|
|
1774
|
+
switch (el.type) {
|
|
1775
|
+
case "stroke":
|
|
1776
|
+
return getStrokeBounds(el);
|
|
1777
|
+
case "arrow": {
|
|
1778
|
+
const b = getArrowBounds(el.from, el.to, el.bend);
|
|
1779
|
+
const pad = el.width / 2 + 14;
|
|
1780
|
+
return { x: b.x - pad, y: b.y - pad, w: b.w + pad * 2, h: b.h + pad * 2 };
|
|
1781
|
+
}
|
|
1782
|
+
case "grid":
|
|
1783
|
+
return null;
|
|
1784
|
+
case "note":
|
|
1785
|
+
case "image":
|
|
1786
|
+
case "html":
|
|
1787
|
+
case "text":
|
|
1788
|
+
case "shape":
|
|
1789
|
+
if ("size" in el) {
|
|
1790
|
+
return { x: el.position.x, y: el.position.y, w: el.size.w, h: el.size.h };
|
|
1791
|
+
}
|
|
1792
|
+
return null;
|
|
1793
|
+
default:
|
|
1794
|
+
return null;
|
|
1795
|
+
}
|
|
1796
|
+
}
|
|
1797
|
+
function computeBounds(elements, padding) {
|
|
1798
|
+
let minX = Infinity;
|
|
1799
|
+
let minY = Infinity;
|
|
1800
|
+
let maxX = -Infinity;
|
|
1801
|
+
let maxY = -Infinity;
|
|
1802
|
+
let found = false;
|
|
1803
|
+
for (const el of elements) {
|
|
1804
|
+
const rect = getElementRect(el);
|
|
1805
|
+
if (!rect) continue;
|
|
1806
|
+
found = true;
|
|
1807
|
+
minX = Math.min(minX, rect.x);
|
|
1808
|
+
minY = Math.min(minY, rect.y);
|
|
1809
|
+
maxX = Math.max(maxX, rect.x + rect.w);
|
|
1810
|
+
maxY = Math.max(maxY, rect.y + rect.h);
|
|
1811
|
+
}
|
|
1812
|
+
if (!found) return null;
|
|
1813
|
+
return {
|
|
1814
|
+
x: minX - padding,
|
|
1815
|
+
y: minY - padding,
|
|
1816
|
+
w: maxX - minX + padding * 2,
|
|
1817
|
+
h: maxY - minY + padding * 2
|
|
1818
|
+
};
|
|
1819
|
+
}
|
|
1820
|
+
function renderNoteOnCanvas(ctx, note) {
|
|
1821
|
+
const { x, y } = note.position;
|
|
1822
|
+
const { w, h } = note.size;
|
|
1823
|
+
const r = 4;
|
|
1824
|
+
const pad = 8;
|
|
1825
|
+
ctx.save();
|
|
1826
|
+
ctx.fillStyle = note.backgroundColor;
|
|
1827
|
+
ctx.beginPath();
|
|
1828
|
+
ctx.moveTo(x + r, y);
|
|
1829
|
+
ctx.lineTo(x + w - r, y);
|
|
1830
|
+
ctx.arcTo(x + w, y, x + w, y + r, r);
|
|
1831
|
+
ctx.lineTo(x + w, y + h - r);
|
|
1832
|
+
ctx.arcTo(x + w, y + h, x + w - r, y + h, r);
|
|
1833
|
+
ctx.lineTo(x + r, y + h);
|
|
1834
|
+
ctx.arcTo(x, y + h, x, y + h - r, r);
|
|
1835
|
+
ctx.lineTo(x, y + r);
|
|
1836
|
+
ctx.arcTo(x, y, x + r, y, r);
|
|
1837
|
+
ctx.closePath();
|
|
1838
|
+
ctx.fill();
|
|
1839
|
+
if (note.text) {
|
|
1840
|
+
ctx.fillStyle = note.textColor;
|
|
1841
|
+
ctx.font = "14px system-ui, sans-serif";
|
|
1842
|
+
ctx.textBaseline = "top";
|
|
1843
|
+
wrapText(ctx, note.text, x + pad, y + pad, w - pad * 2, 18);
|
|
1844
|
+
}
|
|
1845
|
+
ctx.restore();
|
|
1846
|
+
}
|
|
1847
|
+
function renderTextOnCanvas(ctx, text) {
|
|
1848
|
+
if (!text.text) return;
|
|
1849
|
+
ctx.save();
|
|
1850
|
+
ctx.fillStyle = text.color;
|
|
1851
|
+
ctx.font = `${text.fontSize}px system-ui, sans-serif`;
|
|
1852
|
+
ctx.textBaseline = "top";
|
|
1853
|
+
ctx.textAlign = text.textAlign;
|
|
1854
|
+
const pad = 2;
|
|
1855
|
+
let textX = text.position.x + pad;
|
|
1856
|
+
if (text.textAlign === "center") {
|
|
1857
|
+
textX = text.position.x + text.size.w / 2;
|
|
1858
|
+
} else if (text.textAlign === "right") {
|
|
1859
|
+
textX = text.position.x + text.size.w - pad;
|
|
1860
|
+
}
|
|
1861
|
+
const lineHeight = text.fontSize * 1.4;
|
|
1862
|
+
const lines = text.text.split("\n");
|
|
1863
|
+
for (let i = 0; i < lines.length; i++) {
|
|
1864
|
+
const line = lines[i];
|
|
1865
|
+
if (line !== void 0) {
|
|
1866
|
+
ctx.fillText(line, textX, text.position.y + pad + i * lineHeight);
|
|
1867
|
+
}
|
|
1868
|
+
}
|
|
1869
|
+
ctx.restore();
|
|
1870
|
+
}
|
|
1871
|
+
function wrapText(ctx, text, x, y, maxWidth, lineHeight) {
|
|
1872
|
+
const words = text.split(" ");
|
|
1873
|
+
let line = "";
|
|
1874
|
+
let offsetY = 0;
|
|
1875
|
+
for (const word of words) {
|
|
1876
|
+
const testLine = line ? `${line} ${word}` : word;
|
|
1877
|
+
const metrics = ctx.measureText(testLine);
|
|
1878
|
+
if (metrics.width > maxWidth && line) {
|
|
1879
|
+
ctx.fillText(line, x, y + offsetY);
|
|
1880
|
+
line = word;
|
|
1881
|
+
offsetY += lineHeight;
|
|
1882
|
+
} else {
|
|
1883
|
+
line = testLine;
|
|
1884
|
+
}
|
|
1885
|
+
}
|
|
1886
|
+
if (line) {
|
|
1887
|
+
ctx.fillText(line, x, y + offsetY);
|
|
1888
|
+
}
|
|
1889
|
+
}
|
|
1890
|
+
function renderGridForBounds(ctx, grid, bounds) {
|
|
1891
|
+
const visibleBounds = {
|
|
1892
|
+
minX: bounds.x,
|
|
1893
|
+
minY: bounds.y,
|
|
1894
|
+
maxX: bounds.x + bounds.w,
|
|
1895
|
+
maxY: bounds.y + bounds.h
|
|
1896
|
+
};
|
|
1897
|
+
if (grid.gridType === "hex") {
|
|
1898
|
+
renderHexGrid(
|
|
1899
|
+
ctx,
|
|
1900
|
+
visibleBounds,
|
|
1901
|
+
grid.cellSize,
|
|
1902
|
+
grid.hexOrientation,
|
|
1903
|
+
grid.strokeColor,
|
|
1904
|
+
grid.strokeWidth,
|
|
1905
|
+
grid.opacity
|
|
1906
|
+
);
|
|
1907
|
+
} else {
|
|
1908
|
+
renderSquareGrid(
|
|
1909
|
+
ctx,
|
|
1910
|
+
visibleBounds,
|
|
1911
|
+
grid.cellSize,
|
|
1912
|
+
grid.strokeColor,
|
|
1913
|
+
grid.strokeWidth,
|
|
1914
|
+
grid.opacity
|
|
1915
|
+
);
|
|
1916
|
+
}
|
|
1917
|
+
}
|
|
1918
|
+
function loadImages(elements) {
|
|
1919
|
+
const imageElements = elements.filter(
|
|
1920
|
+
(el) => el.type === "image" && "src" in el
|
|
1921
|
+
);
|
|
1922
|
+
const cache = /* @__PURE__ */ new Map();
|
|
1923
|
+
if (imageElements.length === 0) return Promise.resolve(cache);
|
|
1924
|
+
return new Promise((resolve) => {
|
|
1925
|
+
let remaining = imageElements.length;
|
|
1926
|
+
const done = () => {
|
|
1927
|
+
remaining--;
|
|
1928
|
+
if (remaining <= 0) resolve(cache);
|
|
1929
|
+
};
|
|
1930
|
+
for (const el of imageElements) {
|
|
1931
|
+
const img = new Image();
|
|
1932
|
+
img.crossOrigin = "anonymous";
|
|
1933
|
+
img.onload = () => {
|
|
1934
|
+
cache.set(el.id, img);
|
|
1935
|
+
done();
|
|
1936
|
+
};
|
|
1937
|
+
img.onerror = done;
|
|
1938
|
+
img.src = el.src;
|
|
1939
|
+
}
|
|
1940
|
+
});
|
|
1941
|
+
}
|
|
1942
|
+
async function exportImage(store, options = {}, layerManager) {
|
|
1943
|
+
const scale = options.scale ?? 2;
|
|
1944
|
+
const padding = options.padding ?? 0;
|
|
1945
|
+
const background = options.background ?? "#ffffff";
|
|
1946
|
+
const filter = options.filter;
|
|
1947
|
+
const allElements = store.getAll();
|
|
1948
|
+
let visibleElements = layerManager ? allElements.filter((el) => layerManager.isLayerVisible(el.layerId)) : allElements;
|
|
1949
|
+
if (filter) {
|
|
1950
|
+
visibleElements = visibleElements.filter(filter);
|
|
1951
|
+
}
|
|
1952
|
+
const bounds = computeBounds(visibleElements, padding);
|
|
1953
|
+
if (!bounds) return null;
|
|
1954
|
+
const imageCache = await loadImages(visibleElements);
|
|
1955
|
+
const canvas = document.createElement("canvas");
|
|
1956
|
+
canvas.width = Math.ceil(bounds.w * scale);
|
|
1957
|
+
canvas.height = Math.ceil(bounds.h * scale);
|
|
1958
|
+
const ctx = canvas.getContext("2d");
|
|
1959
|
+
if (!ctx) return null;
|
|
1960
|
+
ctx.scale(scale, scale);
|
|
1961
|
+
ctx.translate(-bounds.x, -bounds.y);
|
|
1962
|
+
ctx.fillStyle = background;
|
|
1963
|
+
ctx.fillRect(bounds.x, bounds.y, bounds.w, bounds.h);
|
|
1964
|
+
const renderer = new ElementRenderer();
|
|
1965
|
+
renderer.setStore(store);
|
|
1966
|
+
const grids = [];
|
|
1967
|
+
for (const el of visibleElements) {
|
|
1968
|
+
if (el.type === "grid") {
|
|
1969
|
+
grids.push(el);
|
|
1970
|
+
continue;
|
|
1971
|
+
}
|
|
1972
|
+
if (el.type === "note") {
|
|
1973
|
+
renderNoteOnCanvas(ctx, el);
|
|
1974
|
+
continue;
|
|
1975
|
+
}
|
|
1976
|
+
if (el.type === "text") {
|
|
1977
|
+
renderTextOnCanvas(ctx, el);
|
|
1978
|
+
continue;
|
|
1979
|
+
}
|
|
1980
|
+
if (el.type === "html") {
|
|
1981
|
+
continue;
|
|
1982
|
+
}
|
|
1983
|
+
if (el.type === "image") {
|
|
1984
|
+
const img = imageCache.get(el.id);
|
|
1985
|
+
if (img) {
|
|
1986
|
+
ctx.drawImage(img, el.position.x, el.position.y, el.size.w, el.size.h);
|
|
1987
|
+
}
|
|
1988
|
+
continue;
|
|
1989
|
+
}
|
|
1990
|
+
renderer.renderCanvasElement(ctx, el);
|
|
1991
|
+
}
|
|
1992
|
+
for (const grid of grids) {
|
|
1993
|
+
renderGridForBounds(ctx, grid, bounds);
|
|
1994
|
+
}
|
|
1995
|
+
return new Promise((resolve) => {
|
|
1996
|
+
canvas.toBlob((blob) => resolve(blob), "image/png");
|
|
1997
|
+
});
|
|
1998
|
+
}
|
|
1999
|
+
|
|
1749
2000
|
// src/layers/layer-manager.ts
|
|
1750
2001
|
var LayerManager = class {
|
|
1751
2002
|
constructor(store) {
|
|
@@ -2007,6 +2258,9 @@ var Viewport = class {
|
|
|
2007
2258
|
exportJSON() {
|
|
2008
2259
|
return JSON.stringify(this.exportState());
|
|
2009
2260
|
}
|
|
2261
|
+
async exportImage(options) {
|
|
2262
|
+
return exportImage(this.store, options, this.layerManager);
|
|
2263
|
+
}
|
|
2010
2264
|
loadState(state) {
|
|
2011
2265
|
this.historyRecorder.pause();
|
|
2012
2266
|
this.noteEditor.destroy(this.store);
|
|
@@ -2048,7 +2302,12 @@ var Viewport = class {
|
|
|
2048
2302
|
}
|
|
2049
2303
|
addHtmlElement(dom, position, size = { w: 200, h: 150 }) {
|
|
2050
2304
|
const domId = dom.id || void 0;
|
|
2051
|
-
const el = createHtmlElement({
|
|
2305
|
+
const el = createHtmlElement({
|
|
2306
|
+
position,
|
|
2307
|
+
size,
|
|
2308
|
+
domId,
|
|
2309
|
+
layerId: this.layerManager.activeLayerId
|
|
2310
|
+
});
|
|
2052
2311
|
this.htmlContent.set(el.id, dom);
|
|
2053
2312
|
this.historyRecorder.begin();
|
|
2054
2313
|
this.store.add(el);
|
|
@@ -3585,7 +3844,7 @@ var UpdateLayerCommand = class {
|
|
|
3585
3844
|
};
|
|
3586
3845
|
|
|
3587
3846
|
// src/index.ts
|
|
3588
|
-
var VERSION = "0.
|
|
3847
|
+
var VERSION = "0.8.1";
|
|
3589
3848
|
export {
|
|
3590
3849
|
AddElementCommand,
|
|
3591
3850
|
ArrowTool,
|
|
@@ -3627,6 +3886,7 @@ export {
|
|
|
3627
3886
|
createShape,
|
|
3628
3887
|
createStroke,
|
|
3629
3888
|
createText,
|
|
3889
|
+
exportImage,
|
|
3630
3890
|
exportState,
|
|
3631
3891
|
findBindTarget,
|
|
3632
3892
|
findBoundArrows,
|