@ibodr/editor 0.1.4 → 0.1.6
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.d.ts +2 -1
- package/dist/index.mjs +22 -12
- package/dist/index.mjs.map +1 -1
- package/editor.css +1 -0
- package/package.json +7 -7
package/dist/index.d.ts
CHANGED
|
@@ -9094,8 +9094,9 @@ interface DrEditorComponents {
|
|
|
9094
9094
|
ErrorFallback?: DrErrorFallbackComponent;
|
|
9095
9095
|
ShapeErrorFallback?: DrShapeErrorFallbackComponent;
|
|
9096
9096
|
}
|
|
9097
|
+
type RequiredDrEditorComponents = Required<Omit<DrEditorComponents, 'CollaboratorCursor' | 'CollaboratorCursors'>> & Pick<DrEditorComponents, 'CollaboratorCursor' | 'CollaboratorCursors'>;
|
|
9097
9098
|
/** @public */
|
|
9098
|
-
declare function useEditorComponents():
|
|
9099
|
+
declare function useEditorComponents(): RequiredDrEditorComponents;
|
|
9099
9100
|
|
|
9100
9101
|
/**
|
|
9101
9102
|
* Allows you to define event handlers that can read the latest props/state but has a stable
|
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 })
|
|
@@ -23227,8 +23240,6 @@ function EditorComponentsProvider({
|
|
|
23227
23240
|
ShapeWrapper: DefaultShapeWrapper,
|
|
23228
23241
|
Spinner: DefaultSpinner,
|
|
23229
23242
|
SvgDefs: DefaultSvgDefs,
|
|
23230
|
-
CollaboratorCursor: null,
|
|
23231
|
-
CollaboratorCursors: null,
|
|
23232
23243
|
ErrorFallback: DefaultErrorFallback,
|
|
23233
23244
|
ShapeErrorFallback: DefaultShapeErrorFallback,
|
|
23234
23245
|
..._overrides
|
|
@@ -24523,7 +24534,6 @@ function DrawEditorWithReadyStore({
|
|
|
24523
24534
|
const { ErrorFallback } = useEditorComponents();
|
|
24524
24535
|
const container = useContainer();
|
|
24525
24536
|
const [editor, setEditor] = useRefState(null);
|
|
24526
|
-
const canvasRef = useRef(null);
|
|
24527
24537
|
const _deepLinks = options?.deepLinks;
|
|
24528
24538
|
const deepLinks = useShallowObjectIdentity(_deepLinks === true ? {} : _deepLinks);
|
|
24529
24539
|
const editorOptionsRef = useRef({
|
|
@@ -24579,7 +24589,7 @@ function DrawEditorWithReadyStore({
|
|
|
24579
24589
|
themes: themes2,
|
|
24580
24590
|
initialTheme: initialTheme2
|
|
24581
24591
|
});
|
|
24582
|
-
editor2.updateViewportScreenBounds(
|
|
24592
|
+
editor2.updateViewportScreenBounds(container);
|
|
24583
24593
|
if (deepLinks2) {
|
|
24584
24594
|
if (!deepLinks2?.getUrl) {
|
|
24585
24595
|
editor2.navigateToDeepLink(deepLinks2);
|
|
@@ -24694,7 +24704,7 @@ function DrawEditorWithReadyStore({
|
|
|
24694
24704
|
if (!editor || !fontLoadingState?.isLoaded) {
|
|
24695
24705
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
24696
24706
|
LoadingScreen2 && /* @__PURE__ */ jsx(LoadingScreen2, {}),
|
|
24697
|
-
/* @__PURE__ */ jsx("div", { className: "dr-canvas"
|
|
24707
|
+
/* @__PURE__ */ jsx("div", { className: "dr-canvas" })
|
|
24698
24708
|
] });
|
|
24699
24709
|
}
|
|
24700
24710
|
return (
|
|
@@ -24832,7 +24842,7 @@ function getFontsFromRichText(editor, richText, initialState2) {
|
|
|
24832
24842
|
// src/index.ts
|
|
24833
24843
|
registerDrawLibraryVersion(
|
|
24834
24844
|
"@ibodr/editor",
|
|
24835
|
-
"0.1.
|
|
24845
|
+
"0.1.6",
|
|
24836
24846
|
"esm"
|
|
24837
24847
|
);
|
|
24838
24848
|
/*!
|