@ibodr/editor 0.1.4 → 0.1.5
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.mjs +22 -10
- package/dist/index.mjs.map +1 -1
- package/editor.css +1 -0
- package/package.json +7 -7
package/dist/index.mjs
CHANGED
|
@@ -1646,6 +1646,9 @@ function useScreenBounds(ref) {
|
|
|
1646
1646
|
trailing: true
|
|
1647
1647
|
}
|
|
1648
1648
|
);
|
|
1649
|
+
if (ref.current) {
|
|
1650
|
+
editor.updateViewportScreenBounds(ref.current);
|
|
1651
|
+
}
|
|
1649
1652
|
const interval = editor.timers.setInterval(updateBounds, 1e3);
|
|
1650
1653
|
const win = editor.getContainerWindow();
|
|
1651
1654
|
win.addEventListener("resize", updateBounds);
|
|
@@ -3796,25 +3799,35 @@ var CanvasOverlays = memo(function CanvasOverlays2() {
|
|
|
3796
3799
|
() => {
|
|
3797
3800
|
const instance = editor.getInstanceState();
|
|
3798
3801
|
const camera = editor.getCamera();
|
|
3802
|
+
const pageState = editor.getCurrentPageState();
|
|
3799
3803
|
return {
|
|
3800
3804
|
dpr: instance.devicePixelRatio,
|
|
3801
3805
|
w: instance.screenBounds.w,
|
|
3802
3806
|
h: instance.screenBounds.h,
|
|
3803
3807
|
cx: camera.x,
|
|
3804
3808
|
cy: camera.y,
|
|
3805
|
-
zoom: camera.z
|
|
3809
|
+
zoom: camera.z,
|
|
3810
|
+
overlayStateKey: [
|
|
3811
|
+
editor.getPath(),
|
|
3812
|
+
pageState.selectedShapeIds.join("\0"),
|
|
3813
|
+
pageState.hoveredShapeId ?? "",
|
|
3814
|
+
pageState.editingShapeId ?? "",
|
|
3815
|
+
instance.isChangingStyle ? "1" : "0",
|
|
3816
|
+
editor.getHintingShapeIds().join("\0")
|
|
3817
|
+
].join("|")
|
|
3806
3818
|
};
|
|
3807
3819
|
},
|
|
3808
3820
|
{
|
|
3809
|
-
isEqual: (a, b) => a.dpr === b.dpr && a.w === b.w && a.h === b.h && a.cx === b.cx && a.cy === b.cy && a.zoom === b.zoom
|
|
3821
|
+
isEqual: (a, b) => a.dpr === b.dpr && a.w === b.w && a.h === b.h && a.cx === b.cx && a.cy === b.cy && a.zoom === b.zoom && a.overlayStateKey === b.overlayStateKey
|
|
3810
3822
|
}
|
|
3811
3823
|
);
|
|
3812
3824
|
const scheduler = new EffectScheduler("canvas overlays render", () => {
|
|
3825
|
+
const { dpr, w, h, cx, cy, zoom } = renderInputs$.get();
|
|
3826
|
+
const overlayEntries = editor.overlays.getActiveOverlayEntries();
|
|
3813
3827
|
const canvas = canvasRef.current;
|
|
3814
3828
|
if (!canvas) return;
|
|
3815
3829
|
const ctx = canvas.getContext("2d");
|
|
3816
3830
|
if (!ctx) return;
|
|
3817
|
-
const { dpr, w, h, cx, cy, zoom } = renderInputs$.get();
|
|
3818
3831
|
const canvasWidth = Math.ceil(w * dpr);
|
|
3819
3832
|
const canvasHeight = Math.ceil(h * dpr);
|
|
3820
3833
|
if (canvas.width !== canvasWidth || canvas.height !== canvasHeight) {
|
|
@@ -3827,7 +3840,7 @@ var CanvasOverlays = memo(function CanvasOverlays2() {
|
|
|
3827
3840
|
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
3828
3841
|
const s = dpr * zoom;
|
|
3829
3842
|
ctx.setTransform(s, 0, 0, s, s * cx, s * cy);
|
|
3830
|
-
for (const { util, overlays } of
|
|
3843
|
+
for (const { util, overlays } of overlayEntries) {
|
|
3831
3844
|
ctx.save();
|
|
3832
3845
|
util.render(ctx, overlays);
|
|
3833
3846
|
ctx.restore();
|
|
@@ -3880,7 +3893,7 @@ var CanvasOverlays = memo(function CanvasOverlays2() {
|
|
|
3880
3893
|
ctx.strokeStyle = "magenta";
|
|
3881
3894
|
ctx.fillStyle = "rgba(255, 0, 255, 0.1)";
|
|
3882
3895
|
ctx.lineWidth = 1 / zoom;
|
|
3883
|
-
for (const { overlays } of
|
|
3896
|
+
for (const { overlays } of overlayEntries) {
|
|
3884
3897
|
for (const overlay of overlays) {
|
|
3885
3898
|
const geometry = editor.overlays.getOverlayGeometry(overlay);
|
|
3886
3899
|
if (!geometry) continue;
|
|
@@ -4038,7 +4051,7 @@ function DefaultCanvas({ className }) {
|
|
|
4038
4051
|
] }) }),
|
|
4039
4052
|
Background && /* @__PURE__ */ jsx("div", { className: "dr-background__wrapper", children: /* @__PURE__ */ jsx(Background, {}) }),
|
|
4040
4053
|
isGridMode && Grid && /* @__PURE__ */ jsx(GridWrapper, {}),
|
|
4041
|
-
/* @__PURE__ */ jsxs("div", { ref: rHtmlLayer, className: "dr-html-layer
|
|
4054
|
+
/* @__PURE__ */ jsxs("div", { ref: rHtmlLayer, className: "dr-html-layer dr-shapes", draggable: false, children: [
|
|
4042
4055
|
/* @__PURE__ */ jsx(OnTheCanvasWrapper, {}),
|
|
4043
4056
|
SelectionBackground && /* @__PURE__ */ jsx(SelectionBackgroundWrapper, {}),
|
|
4044
4057
|
hideShapes ? null : /* @__PURE__ */ jsx(ShapesLayer, { canvasRef: rCanvas })
|
|
@@ -24523,7 +24536,6 @@ function DrawEditorWithReadyStore({
|
|
|
24523
24536
|
const { ErrorFallback } = useEditorComponents();
|
|
24524
24537
|
const container = useContainer();
|
|
24525
24538
|
const [editor, setEditor] = useRefState(null);
|
|
24526
|
-
const canvasRef = useRef(null);
|
|
24527
24539
|
const _deepLinks = options?.deepLinks;
|
|
24528
24540
|
const deepLinks = useShallowObjectIdentity(_deepLinks === true ? {} : _deepLinks);
|
|
24529
24541
|
const editorOptionsRef = useRef({
|
|
@@ -24579,7 +24591,7 @@ function DrawEditorWithReadyStore({
|
|
|
24579
24591
|
themes: themes2,
|
|
24580
24592
|
initialTheme: initialTheme2
|
|
24581
24593
|
});
|
|
24582
|
-
editor2.updateViewportScreenBounds(
|
|
24594
|
+
editor2.updateViewportScreenBounds(container);
|
|
24583
24595
|
if (deepLinks2) {
|
|
24584
24596
|
if (!deepLinks2?.getUrl) {
|
|
24585
24597
|
editor2.navigateToDeepLink(deepLinks2);
|
|
@@ -24694,7 +24706,7 @@ function DrawEditorWithReadyStore({
|
|
|
24694
24706
|
if (!editor || !fontLoadingState?.isLoaded) {
|
|
24695
24707
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
24696
24708
|
LoadingScreen2 && /* @__PURE__ */ jsx(LoadingScreen2, {}),
|
|
24697
|
-
/* @__PURE__ */ jsx("div", { className: "dr-canvas"
|
|
24709
|
+
/* @__PURE__ */ jsx("div", { className: "dr-canvas" })
|
|
24698
24710
|
] });
|
|
24699
24711
|
}
|
|
24700
24712
|
return (
|
|
@@ -24832,7 +24844,7 @@ function getFontsFromRichText(editor, richText, initialState2) {
|
|
|
24832
24844
|
// src/index.ts
|
|
24833
24845
|
registerDrawLibraryVersion(
|
|
24834
24846
|
"@ibodr/editor",
|
|
24835
|
-
"0.1.
|
|
24847
|
+
"0.1.5",
|
|
24836
24848
|
"esm"
|
|
24837
24849
|
);
|
|
24838
24850
|
/*!
|