@baasix/lexical 0.0.4 → 0.0.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/{ExcalidrawComponent-GZYLHNOY.js → ExcalidrawComponent-MA23PUNN.js} +113 -12
- package/dist/ExcalidrawComponent-MA23PUNN.js.map +1 -0
- package/dist/{chunk-N22RKA5D.js → chunk-RIV43XYA.js} +15 -14
- package/dist/chunk-RIV43XYA.js.map +1 -0
- package/dist/index.css +107 -0
- package/dist/index.css.map +1 -1
- package/dist/index.js +15 -10
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/ExcalidrawComponent-GZYLHNOY.js.map +0 -1
- package/dist/chunk-N22RKA5D.js.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
$isExcalidrawNode,
|
|
3
3
|
ExcalidrawModal
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-RIV43XYA.js";
|
|
5
5
|
import {
|
|
6
6
|
ImageResizer
|
|
7
7
|
} from "./chunk-FJ6COZ4H.js";
|
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
isDOMNode
|
|
21
21
|
} from "lexical";
|
|
22
22
|
import { useCallback, useEffect as useEffect2, useMemo, useRef, useState as useState2 } from "react";
|
|
23
|
+
import { createPortal } from "react-dom";
|
|
23
24
|
|
|
24
25
|
// src/nodes/ExcalidrawNode/ExcalidrawImage.tsx
|
|
25
26
|
import { useEffect, useState } from "react";
|
|
@@ -65,6 +66,8 @@ function ExcalidrawImage({
|
|
|
65
66
|
const containerStyle = {};
|
|
66
67
|
if (width !== "inherit") {
|
|
67
68
|
containerStyle.width = `${width}px`;
|
|
69
|
+
} else {
|
|
70
|
+
containerStyle.width = "100%";
|
|
68
71
|
}
|
|
69
72
|
if (height !== "inherit") {
|
|
70
73
|
containerStyle.height = `${height}px`;
|
|
@@ -88,6 +91,65 @@ function ExcalidrawImage({
|
|
|
88
91
|
|
|
89
92
|
// src/nodes/ExcalidrawNode/ExcalidrawComponent.tsx
|
|
90
93
|
import { Fragment, jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
94
|
+
function parseDimension(val) {
|
|
95
|
+
const trimmed = val.trim();
|
|
96
|
+
if (!trimmed || trimmed === "inherit" || trimmed === "100%" || trimmed === "auto") {
|
|
97
|
+
return "inherit";
|
|
98
|
+
}
|
|
99
|
+
const num = parseInt(trimmed.replace(/px$/i, ""), 10);
|
|
100
|
+
return isNaN(num) || num <= 0 ? "inherit" : num;
|
|
101
|
+
}
|
|
102
|
+
function dimensionToString(d) {
|
|
103
|
+
return d === "inherit" ? "" : String(d);
|
|
104
|
+
}
|
|
105
|
+
function ExcalidrawResizeDialog({
|
|
106
|
+
width,
|
|
107
|
+
height,
|
|
108
|
+
onSave,
|
|
109
|
+
onClose
|
|
110
|
+
}) {
|
|
111
|
+
const [widthVal, setWidthVal] = useState2(dimensionToString(width));
|
|
112
|
+
const [heightVal, setHeightVal] = useState2(dimensionToString(height));
|
|
113
|
+
const handleSave = () => {
|
|
114
|
+
onSave(parseDimension(widthVal), parseDimension(heightVal));
|
|
115
|
+
};
|
|
116
|
+
return /* @__PURE__ */ jsx2("div", { className: "excalidraw-resize-overlay", children: /* @__PURE__ */ jsxs("div", { className: "excalidraw-resize-dialog", children: [
|
|
117
|
+
/* @__PURE__ */ jsx2("div", { className: "excalidraw-resize-dialog__title", children: "Resize Diagram" }),
|
|
118
|
+
/* @__PURE__ */ jsxs("div", { className: "excalidraw-resize-dialog__fields", children: [
|
|
119
|
+
/* @__PURE__ */ jsxs("label", { className: "excalidraw-resize-dialog__label", children: [
|
|
120
|
+
"Width",
|
|
121
|
+
/* @__PURE__ */ jsx2(
|
|
122
|
+
"input",
|
|
123
|
+
{
|
|
124
|
+
className: "excalidraw-resize-dialog__input",
|
|
125
|
+
type: "text",
|
|
126
|
+
value: widthVal,
|
|
127
|
+
onChange: (e) => setWidthVal(e.target.value),
|
|
128
|
+
placeholder: "auto (full width)"
|
|
129
|
+
}
|
|
130
|
+
)
|
|
131
|
+
] }),
|
|
132
|
+
/* @__PURE__ */ jsxs("label", { className: "excalidraw-resize-dialog__label", children: [
|
|
133
|
+
"Height",
|
|
134
|
+
/* @__PURE__ */ jsx2(
|
|
135
|
+
"input",
|
|
136
|
+
{
|
|
137
|
+
className: "excalidraw-resize-dialog__input",
|
|
138
|
+
type: "text",
|
|
139
|
+
value: heightVal,
|
|
140
|
+
onChange: (e) => setHeightVal(e.target.value),
|
|
141
|
+
placeholder: "auto"
|
|
142
|
+
}
|
|
143
|
+
)
|
|
144
|
+
] })
|
|
145
|
+
] }),
|
|
146
|
+
/* @__PURE__ */ jsx2("div", { className: "excalidraw-resize-dialog__hint", children: "Enter a number in pixels (e.g. 400) or leave empty for auto." }),
|
|
147
|
+
/* @__PURE__ */ jsxs("div", { className: "excalidraw-resize-dialog__actions", children: [
|
|
148
|
+
/* @__PURE__ */ jsx2("button", { type: "button", className: "excalidraw-resize-dialog__btn excalidraw-resize-dialog__btn--cancel", onClick: onClose, children: "Cancel" }),
|
|
149
|
+
/* @__PURE__ */ jsx2("button", { type: "button", className: "excalidraw-resize-dialog__btn excalidraw-resize-dialog__btn--save", onClick: handleSave, children: "Apply" })
|
|
150
|
+
] })
|
|
151
|
+
] }) });
|
|
152
|
+
}
|
|
91
153
|
function ExcalidrawComponent({
|
|
92
154
|
nodeKey,
|
|
93
155
|
data,
|
|
@@ -99,6 +161,7 @@ function ExcalidrawComponent({
|
|
|
99
161
|
const [isModalOpen, setModalOpen] = useState2(
|
|
100
162
|
data === "[]" && editor.isEditable()
|
|
101
163
|
);
|
|
164
|
+
const [isResizeDialogOpen, setResizeDialogOpen] = useState2(false);
|
|
102
165
|
const imageContainerRef = useRef(null);
|
|
103
166
|
const buttonRef = useRef(null);
|
|
104
167
|
const captionButtonRef = useRef(null);
|
|
@@ -181,6 +244,19 @@ function ExcalidrawComponent({
|
|
|
181
244
|
const openModal = useCallback(() => {
|
|
182
245
|
setModalOpen(true);
|
|
183
246
|
}, []);
|
|
247
|
+
const handleResizeSave = useCallback(
|
|
248
|
+
(newWidth, newHeight) => {
|
|
249
|
+
editor.update(() => {
|
|
250
|
+
const node = $getNodeByKey(nodeKey);
|
|
251
|
+
if ($isExcalidrawNode(node)) {
|
|
252
|
+
node.setWidth(newWidth);
|
|
253
|
+
node.setHeight(newHeight);
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
setResizeDialogOpen(false);
|
|
257
|
+
},
|
|
258
|
+
[editor, nodeKey]
|
|
259
|
+
);
|
|
184
260
|
const {
|
|
185
261
|
elements = [],
|
|
186
262
|
files = {},
|
|
@@ -220,6 +296,7 @@ function ExcalidrawComponent({
|
|
|
220
296
|
type: "button",
|
|
221
297
|
ref: buttonRef,
|
|
222
298
|
className: `excalidraw-button ${isSelected ? "selected" : ""}`,
|
|
299
|
+
style: { width: width === "inherit" ? "100%" : `${width}px` },
|
|
223
300
|
children: [
|
|
224
301
|
/* @__PURE__ */ jsx2(
|
|
225
302
|
ExcalidrawImage,
|
|
@@ -233,16 +310,28 @@ function ExcalidrawComponent({
|
|
|
233
310
|
height
|
|
234
311
|
}
|
|
235
312
|
),
|
|
236
|
-
isSelected && isEditable && /* @__PURE__ */
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
313
|
+
isSelected && isEditable && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
314
|
+
/* @__PURE__ */ jsx2(
|
|
315
|
+
"div",
|
|
316
|
+
{
|
|
317
|
+
className: "image-edit-button",
|
|
318
|
+
role: "button",
|
|
319
|
+
tabIndex: 0,
|
|
320
|
+
onMouseDown: (event) => event.preventDefault(),
|
|
321
|
+
onClick: openModal
|
|
322
|
+
}
|
|
323
|
+
),
|
|
324
|
+
/* @__PURE__ */ jsx2(
|
|
325
|
+
"div",
|
|
326
|
+
{
|
|
327
|
+
className: "image-resize-button",
|
|
328
|
+
role: "button",
|
|
329
|
+
tabIndex: 0,
|
|
330
|
+
onMouseDown: (event) => event.preventDefault(),
|
|
331
|
+
onClick: () => setResizeDialogOpen(true)
|
|
332
|
+
}
|
|
333
|
+
)
|
|
334
|
+
] }),
|
|
246
335
|
(isSelected || isResizing) && isEditable && /* @__PURE__ */ jsx2(
|
|
247
336
|
ImageResizer,
|
|
248
337
|
{
|
|
@@ -258,10 +347,22 @@ function ExcalidrawComponent({
|
|
|
258
347
|
)
|
|
259
348
|
]
|
|
260
349
|
}
|
|
350
|
+
),
|
|
351
|
+
isResizeDialogOpen && isEditable && createPortal(
|
|
352
|
+
/* @__PURE__ */ jsx2(
|
|
353
|
+
ExcalidrawResizeDialog,
|
|
354
|
+
{
|
|
355
|
+
width,
|
|
356
|
+
height,
|
|
357
|
+
onSave: handleResizeSave,
|
|
358
|
+
onClose: () => setResizeDialogOpen(false)
|
|
359
|
+
}
|
|
360
|
+
),
|
|
361
|
+
document.body
|
|
261
362
|
)
|
|
262
363
|
] });
|
|
263
364
|
}
|
|
264
365
|
export {
|
|
265
366
|
ExcalidrawComponent as default
|
|
266
367
|
};
|
|
267
|
-
//# sourceMappingURL=ExcalidrawComponent-
|
|
368
|
+
//# sourceMappingURL=ExcalidrawComponent-MA23PUNN.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/nodes/ExcalidrawNode/ExcalidrawComponent.tsx","../src/nodes/ExcalidrawNode/ExcalidrawImage.tsx"],"sourcesContent":["/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport type {ExcalidrawInitialElements} from '../../ui/ExcalidrawModal';\nimport type {AppState, BinaryFiles} from '@excalidraw/excalidraw/types';\nimport type {NodeKey} from 'lexical';\nimport type {JSX} from 'react';\n\nimport {useLexicalComposerContext} from '@lexical/react/LexicalComposerContext';\nimport {useLexicalEditable} from '@lexical/react/useLexicalEditable';\nimport {useLexicalNodeSelection} from '@lexical/react/useLexicalNodeSelection';\nimport {mergeRegister} from '@lexical/utils';\nimport {\n $getNodeByKey,\n CLICK_COMMAND,\n COMMAND_PRIORITY_LOW,\n isDOMNode,\n} from 'lexical';\nimport {useCallback, useEffect, useMemo, useRef, useState} from 'react';\nimport * as React from 'react';\nimport {createPortal} from 'react-dom';\n\nimport ExcalidrawModal from '../../ui/ExcalidrawModal';\nimport ImageResizer from '../../ui/ImageResizer';\nimport {$isExcalidrawNode} from '.';\nimport ExcalidrawImage from './ExcalidrawImage';\n\ntype Dimension = 'inherit' | number;\n\nfunction parseDimension(val: string): Dimension {\n const trimmed = val.trim();\n if (!trimmed || trimmed === 'inherit' || trimmed === '100%' || trimmed === 'auto') {\n return 'inherit';\n }\n // Strip \"px\" suffix if present\n const num = parseInt(trimmed.replace(/px$/i, ''), 10);\n return isNaN(num) || num <= 0 ? 'inherit' : num;\n}\n\nfunction dimensionToString(d: Dimension): string {\n return d === 'inherit' ? '' : String(d);\n}\n\nfunction ExcalidrawResizeDialog({\n width,\n height,\n onSave,\n onClose,\n}: {\n width: Dimension;\n height: Dimension;\n onSave: (w: Dimension, h: Dimension) => void;\n onClose: () => void;\n}): JSX.Element {\n const [widthVal, setWidthVal] = useState(dimensionToString(width));\n const [heightVal, setHeightVal] = useState(dimensionToString(height));\n\n const handleSave = () => {\n onSave(parseDimension(widthVal), parseDimension(heightVal));\n };\n\n return (\n <div className=\"excalidraw-resize-overlay\">\n <div className=\"excalidraw-resize-dialog\">\n <div className=\"excalidraw-resize-dialog__title\">Resize Diagram</div>\n <div className=\"excalidraw-resize-dialog__fields\">\n <label className=\"excalidraw-resize-dialog__label\">\n Width\n <input\n className=\"excalidraw-resize-dialog__input\"\n type=\"text\"\n value={widthVal}\n onChange={(e) => setWidthVal(e.target.value)}\n placeholder=\"auto (full width)\"\n />\n </label>\n <label className=\"excalidraw-resize-dialog__label\">\n Height\n <input\n className=\"excalidraw-resize-dialog__input\"\n type=\"text\"\n value={heightVal}\n onChange={(e) => setHeightVal(e.target.value)}\n placeholder=\"auto\"\n />\n </label>\n </div>\n <div className=\"excalidraw-resize-dialog__hint\">\n Enter a number in pixels (e.g. 400) or leave empty for auto.\n </div>\n <div className=\"excalidraw-resize-dialog__actions\">\n <button type=\"button\" className=\"excalidraw-resize-dialog__btn excalidraw-resize-dialog__btn--cancel\" onClick={onClose}>\n Cancel\n </button>\n <button type=\"button\" className=\"excalidraw-resize-dialog__btn excalidraw-resize-dialog__btn--save\" onClick={handleSave}>\n Apply\n </button>\n </div>\n </div>\n </div>\n );\n}\n\nexport default function ExcalidrawComponent({\n nodeKey,\n data,\n width,\n height,\n}: {\n data: string;\n nodeKey: NodeKey;\n width: 'inherit' | number;\n height: 'inherit' | number;\n}): JSX.Element {\n const [editor] = useLexicalComposerContext();\n const isEditable = useLexicalEditable();\n const [isModalOpen, setModalOpen] = useState<boolean>(\n data === '[]' && editor.isEditable(),\n );\n const [isResizeDialogOpen, setResizeDialogOpen] = useState(false);\n const imageContainerRef = useRef<HTMLDivElement | null>(null);\n const buttonRef = useRef<HTMLButtonElement | null>(null);\n const captionButtonRef = useRef<HTMLButtonElement | null>(null);\n const [isSelected, setSelected, clearSelection] =\n useLexicalNodeSelection(nodeKey);\n const [isResizing, setIsResizing] = useState<boolean>(false);\n\n useEffect(() => {\n if (!isEditable) {\n if (isSelected) {\n clearSelection();\n }\n return;\n }\n return mergeRegister(\n editor.registerCommand(\n CLICK_COMMAND,\n (event: MouseEvent) => {\n const buttonElem = buttonRef.current;\n const eventTarget = event.target;\n\n if (isResizing) {\n return true;\n }\n\n if (\n buttonElem !== null &&\n isDOMNode(eventTarget) &&\n buttonElem.contains(eventTarget)\n ) {\n if (!event.shiftKey) {\n clearSelection();\n }\n setSelected(!isSelected);\n if (event.detail > 1) {\n setModalOpen(true);\n }\n return true;\n }\n\n return false;\n },\n COMMAND_PRIORITY_LOW,\n ),\n );\n }, [clearSelection, editor, isSelected, isResizing, setSelected, isEditable]);\n\n const deleteNode = useCallback(() => {\n setModalOpen(false);\n return editor.update(() => {\n const node = $getNodeByKey(nodeKey);\n if (node) {\n node.remove();\n }\n });\n }, [editor, nodeKey]);\n\n const setData = (\n els: ExcalidrawInitialElements,\n aps: Partial<AppState>,\n fls: BinaryFiles,\n ) => {\n return editor.update(() => {\n const node = $getNodeByKey(nodeKey);\n if ($isExcalidrawNode(node)) {\n if ((els && els.length > 0) || Object.keys(fls).length > 0) {\n node.setData(\n JSON.stringify({\n appState: aps,\n elements: els,\n files: fls,\n }),\n );\n } else {\n node.remove();\n }\n }\n });\n };\n\n const onResizeStart = () => {\n setIsResizing(true);\n };\n\n const onResizeEnd = (\n nextWidth: 'inherit' | number,\n nextHeight: 'inherit' | number,\n ) => {\n // Delay hiding the resize bars for click case\n setTimeout(() => {\n setIsResizing(false);\n }, 200);\n\n editor.update(() => {\n const node = $getNodeByKey(nodeKey);\n\n if ($isExcalidrawNode(node)) {\n node.setWidth(nextWidth);\n node.setHeight(nextHeight);\n }\n });\n };\n\n const openModal = useCallback(() => {\n setModalOpen(true);\n }, []);\n\n const handleResizeSave = useCallback(\n (newWidth: Dimension, newHeight: Dimension) => {\n editor.update(() => {\n const node = $getNodeByKey(nodeKey);\n if ($isExcalidrawNode(node)) {\n node.setWidth(newWidth);\n node.setHeight(newHeight);\n }\n });\n setResizeDialogOpen(false);\n },\n [editor, nodeKey],\n );\n\n const {\n elements = [],\n files = {},\n appState = {},\n } = useMemo(() => JSON.parse(data), [data]);\n\n const closeModal = useCallback(() => {\n setModalOpen(false);\n if (elements.length === 0) {\n editor.update(() => {\n const node = $getNodeByKey(nodeKey);\n if (node) {\n node.remove();\n }\n });\n }\n }, [editor, nodeKey, elements.length]);\n\n return (\n <>\n {isEditable && isModalOpen && (\n <ExcalidrawModal\n initialElements={elements}\n initialFiles={files}\n initialAppState={appState}\n isShown={isModalOpen}\n onDelete={deleteNode}\n onClose={closeModal}\n onSave={(els, aps, fls) => {\n setData(els, aps, fls);\n setModalOpen(false);\n }}\n closeOnClickOutside={false}\n />\n )}\n {elements.length > 0 && (\n <button type=\"button\"\n ref={buttonRef}\n className={`excalidraw-button ${isSelected ? 'selected' : ''}`}\n style={{width: width === 'inherit' ? '100%' : `${width}px`}}>\n <ExcalidrawImage\n imageContainerRef={imageContainerRef}\n className=\"image\"\n elements={elements}\n files={files}\n appState={appState}\n width={width}\n height={height}\n />\n {isSelected && isEditable && (\n <>\n <div\n className=\"image-edit-button\"\n role=\"button\"\n tabIndex={0}\n onMouseDown={(event) => event.preventDefault()}\n onClick={openModal}\n />\n <div\n className=\"image-resize-button\"\n role=\"button\"\n tabIndex={0}\n onMouseDown={(event) => event.preventDefault()}\n onClick={() => setResizeDialogOpen(true)}\n />\n </>\n )}\n {(isSelected || isResizing) && isEditable && (\n <ImageResizer\n buttonRef={captionButtonRef}\n showCaption={true}\n setShowCaption={() => null}\n imageRef={imageContainerRef}\n editor={editor}\n onResizeStart={onResizeStart}\n onResizeEnd={onResizeEnd}\n captionsEnabled={true}\n />\n )}\n </button>\n )}\n {isResizeDialogOpen && isEditable &&\n createPortal(\n <ExcalidrawResizeDialog\n width={width}\n height={height}\n onSave={handleResizeSave}\n onClose={() => setResizeDialogOpen(false)}\n />,\n document.body,\n )}\n </>\n );\n}\n","/**\r\n * Copyright (c) Meta Platforms, Inc. and affiliates.\r\n *\r\n * This source code is licensed under the MIT license found in the\r\n * LICENSE file in the root directory of this source tree.\r\n *\r\n */\r\n\r\nimport type {\r\n ExcalidrawElement,\r\n NonDeleted,\r\n} from '@excalidraw/excalidraw/element/types';\r\nimport type {AppState, BinaryFiles} from '@excalidraw/excalidraw/types';\r\nimport type {JSX} from 'react';\r\n\r\nimport * as React from 'react';\r\nimport {useEffect, useState} from 'react';\r\n\r\ntype ImageType = 'svg' | 'canvas';\r\n\r\ntype Dimension = 'inherit' | number;\r\n\r\ntype Props = {\r\n /**\r\n * Configures the export setting for SVG/Canvas\r\n */\r\n appState: AppState;\r\n /**\r\n * The css class applied to image to be rendered\r\n */\r\n className?: string;\r\n /**\r\n * The Excalidraw elements to be rendered as an image\r\n */\r\n elements: NonDeleted<ExcalidrawElement>[];\r\n /**\r\n * The Excalidraw files associated with the elements\r\n */\r\n files: BinaryFiles;\r\n /**\r\n * The height of the image to be rendered\r\n */\r\n height?: Dimension;\r\n /**\r\n * The ref object to be used to render the image\r\n */\r\n imageContainerRef: React.RefObject<HTMLDivElement | null>;\r\n /**\r\n * The type of image to be rendered\r\n */\r\n imageType?: ImageType;\r\n /**\r\n * The css class applied to the root element of this component\r\n */\r\n rootClassName?: string | null;\r\n /**\r\n * The width of the image to be rendered\r\n */\r\n width?: Dimension;\r\n};\r\n\r\n// exportToSvg has fonts from excalidraw.com\r\n// We don't want them to be used in open source\r\nconst removeStyleFromSvg_HACK = (svg: SVGElement) => {\r\n const styleTag = svg?.firstElementChild?.firstElementChild;\r\n\r\n // Generated SVG is getting double-sized by height and width attributes\r\n // We want to match the real size of the SVG element\r\n const viewBox = svg.getAttribute('viewBox');\r\n if (viewBox != null) {\r\n const viewBoxDimensions = viewBox.split(' ');\r\n svg.setAttribute('width', viewBoxDimensions[2]);\r\n svg.setAttribute('height', viewBoxDimensions[3]);\r\n }\r\n\r\n if (styleTag && styleTag.tagName === 'style') {\r\n styleTag.remove();\r\n }\r\n};\r\n\r\n/**\r\n * @explorer-desc\r\n * A component for rendering Excalidraw elements as a static image\r\n */\r\nexport default function ExcalidrawImage({\r\n elements,\r\n files,\r\n imageContainerRef,\r\n appState,\r\n rootClassName = null,\r\n width = 'inherit',\r\n height = 'inherit',\r\n}: Props): JSX.Element {\r\n const [Svg, setSvg] = useState<SVGElement | null>(null);\r\n\r\n useEffect(() => {\r\n const setContent = async () => {\r\n const {exportToSvg} = await import('@excalidraw/excalidraw');\r\n const svg: SVGElement = await exportToSvg({\r\n appState,\r\n elements,\r\n files,\r\n });\r\n removeStyleFromSvg_HACK(svg);\r\n\r\n svg.setAttribute('width', '100%');\r\n svg.setAttribute('height', '100%');\r\n svg.setAttribute('display', 'block');\r\n\r\n setSvg(svg);\r\n };\r\n setContent();\r\n }, [elements, files, appState]);\r\n\r\n const containerStyle: React.CSSProperties = {};\r\n if (width !== 'inherit') {\r\n containerStyle.width = `${width}px`;\r\n } else {\r\n containerStyle.width = '100%';\r\n }\r\n if (height !== 'inherit') {\r\n containerStyle.height = `${height}px`;\r\n }\r\n\r\n return (\r\n <div\r\n ref={(node) => {\r\n if (node) {\r\n if (imageContainerRef) {\r\n (imageContainerRef as React.MutableRefObject<HTMLDivElement | null>).current = node;\r\n }\r\n }\r\n }}\r\n className={rootClassName ?? ''}\r\n style={containerStyle}\r\n dangerouslySetInnerHTML={{__html: Svg?.outerHTML ?? ''}}\r\n />\r\n );\r\n}\r\n"],"mappings":";;;;;;;;;;;AAaA,SAAQ,iCAAgC;AACxC,SAAQ,0BAAyB;AACjC,SAAQ,+BAA8B;AACtC,SAAQ,qBAAoB;AAC5B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAQ,aAAa,aAAAA,YAAW,SAAS,QAAQ,YAAAC,iBAAe;AAEhE,SAAQ,oBAAmB;;;ACT3B,SAAQ,WAAW,gBAAe;AA6G9B;AA9DJ,IAAM,0BAA0B,CAAC,QAAoB;AACnD,QAAM,WAAW,KAAK,mBAAmB;AAIzC,QAAM,UAAU,IAAI,aAAa,SAAS;AAC1C,MAAI,WAAW,MAAM;AACnB,UAAM,oBAAoB,QAAQ,MAAM,GAAG;AAC3C,QAAI,aAAa,SAAS,kBAAkB,CAAC,CAAC;AAC9C,QAAI,aAAa,UAAU,kBAAkB,CAAC,CAAC;AAAA,EACjD;AAEA,MAAI,YAAY,SAAS,YAAY,SAAS;AAC5C,aAAS,OAAO;AAAA,EAClB;AACF;AAMe,SAAR,gBAAiC;AAAA,EACtC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,gBAAgB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AAa,CAAC,UAAU,MAAM,eAAe;AAAA,gBAC7C,SAAS;AAAA;AAAA,YACX;AAAA,YACA,gBAAAA;AAAA,cAAC;AAAA;AAAA,gBACC,WAAU;AAAA,gBACV,MAAK;AAAA,gBACL,UAAU;AAAA,gBACV,aAAa,CAAC,UAAU,MAAM,eAAe;AAAA,gBAC7C,SAAS,MAAM,oBAAoB,IAAI;AAAA;AAAA,YACzC;AAAA,aACF;AAAA,WAEA,cAAc,eAAe,cAC7B,gBAAAA;AAAA,YAAC;AAAA;AAAA,cACC,WAAW;AAAA,cACX,aAAa;AAAA,cACb,gBAAgB,MAAM;AAAA,cACtB,UAAU;AAAA,cACV;AAAA,cACA;AAAA,cACA;AAAA,cACA,iBAAiB;AAAA;AAAA,UACnB;AAAA;AAAA;AAAA,IAEJ;AAAA,IAED,sBAAsB,cACrB;AAAA,MACE,gBAAAA;AAAA,QAAC;AAAA;AAAA,UACC;AAAA,UACA;AAAA,UACA,QAAQ;AAAA,UACR,SAAS,MAAM,oBAAoB,KAAK;AAAA;AAAA,MAC1C;AAAA,MACA,SAAS;AAAA,IACX;AAAA,KACJ;AAEJ;","names":["useEffect","useState","jsx","useState","useEffect"]}
|
|
@@ -262,16 +262,19 @@ function ExcalidrawModal({
|
|
|
262
262
|
import { DecoratorNode } from "lexical";
|
|
263
263
|
import * as React from "react";
|
|
264
264
|
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
265
|
-
var ExcalidrawComponent2 = React.lazy(() => import("./ExcalidrawComponent-
|
|
265
|
+
var ExcalidrawComponent2 = React.lazy(() => import("./ExcalidrawComponent-MA23PUNN.js"));
|
|
266
266
|
function $convertExcalidrawElement(domNode) {
|
|
267
267
|
const excalidrawData = domNode.getAttribute("data-lexical-excalidraw-json");
|
|
268
|
-
const
|
|
269
|
-
const heightStr =
|
|
270
|
-
const
|
|
271
|
-
const height = !heightStr || heightStr === "inherit" ? "inherit" : parseInt(heightStr, 10);
|
|
272
|
-
const width = !widthStr || widthStr === "inherit" ? "inherit" : parseInt(widthStr, 10);
|
|
268
|
+
const widthStr = domNode.style.width;
|
|
269
|
+
const heightStr = domNode.style.height;
|
|
270
|
+
const width = !widthStr || widthStr === "100%" || widthStr === "auto" || widthStr === "inherit" ? "inherit" : parseInt(widthStr, 10);
|
|
271
|
+
const height = !heightStr || heightStr === "auto" || heightStr === "inherit" ? "inherit" : parseInt(heightStr, 10);
|
|
273
272
|
if (excalidrawData) {
|
|
274
|
-
const node = $createExcalidrawNode(
|
|
273
|
+
const node = $createExcalidrawNode(
|
|
274
|
+
excalidrawData,
|
|
275
|
+
isNaN(width) ? "inherit" : width,
|
|
276
|
+
isNaN(height) ? "inherit" : height
|
|
277
|
+
);
|
|
275
278
|
return {
|
|
276
279
|
node
|
|
277
280
|
};
|
|
@@ -319,9 +322,7 @@ var ExcalidrawNode = class _ExcalidrawNode extends DecoratorNode {
|
|
|
319
322
|
const span = document.createElement("span");
|
|
320
323
|
const theme = config.theme;
|
|
321
324
|
const className = theme.image;
|
|
322
|
-
|
|
323
|
-
span.className = className;
|
|
324
|
-
}
|
|
325
|
+
span.className = `${className ?? ""} editor-excalidraw`.trim();
|
|
325
326
|
return span;
|
|
326
327
|
}
|
|
327
328
|
updateDOM() {
|
|
@@ -342,7 +343,7 @@ var ExcalidrawNode = class _ExcalidrawNode extends DecoratorNode {
|
|
|
342
343
|
}
|
|
343
344
|
exportDOM(editor) {
|
|
344
345
|
const element = document.createElement("span");
|
|
345
|
-
element.style.display = "
|
|
346
|
+
element.style.display = "block";
|
|
346
347
|
const content = editor.getElementByKey(this.getKey());
|
|
347
348
|
if (content !== null) {
|
|
348
349
|
const svg = content.querySelector("svg");
|
|
@@ -350,8 +351,8 @@ var ExcalidrawNode = class _ExcalidrawNode extends DecoratorNode {
|
|
|
350
351
|
element.innerHTML = svg.outerHTML;
|
|
351
352
|
}
|
|
352
353
|
}
|
|
353
|
-
element.style.width = this.__width === "inherit" ? "
|
|
354
|
-
element.style.height = this.__height === "inherit" ? "
|
|
354
|
+
element.style.width = this.__width === "inherit" ? "100%" : `${this.__width}px`;
|
|
355
|
+
element.style.height = this.__height === "inherit" ? "auto" : `${this.__height}px`;
|
|
355
356
|
element.setAttribute("data-lexical-excalidraw-json", this.__data);
|
|
356
357
|
return { element };
|
|
357
358
|
}
|
|
@@ -399,4 +400,4 @@ export {
|
|
|
399
400
|
$createExcalidrawNode,
|
|
400
401
|
$isExcalidrawNode
|
|
401
402
|
};
|
|
402
|
-
//# sourceMappingURL=chunk-
|
|
403
|
+
//# sourceMappingURL=chunk-RIV43XYA.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/ui/ExcalidrawModal.tsx","../src/ui/Modal.tsx","../src/nodes/ExcalidrawNode/index.tsx"],"sourcesContent":["/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport type {\n AppState,\n BinaryFiles,\n ExcalidrawImperativeAPI,\n ExcalidrawInitialDataState,\n} from '@excalidraw/excalidraw/types';\nimport type {JSX} from 'react';\n\nimport './ExcalidrawModal.css';\n\nimport {isDOMNode} from 'lexical';\nimport * as React from 'react';\nimport {ReactPortal, lazy, Suspense, useEffect, useLayoutEffect, useRef, useState} from 'react';\nimport {createPortal} from 'react-dom';\n\nimport Button from './Button';\nimport Modal from './Modal';\n\nconst ExcalidrawComponent = lazy(() =>\n import('@excalidraw/excalidraw').then((mod) => ({default: mod.Excalidraw})),\n);\n\nexport type ExcalidrawInitialElements = ExcalidrawInitialDataState['elements'];\n\ntype Props = {\n closeOnClickOutside?: boolean;\n /**\n * The initial set of elements to draw into the scene\n */\n initialElements: ExcalidrawInitialElements;\n /**\n * The initial set of elements to draw into the scene\n */\n initialAppState: AppState;\n /**\n * The initial set of elements to draw into the scene\n */\n initialFiles: BinaryFiles;\n /**\n * Controls the visibility of the modal\n */\n isShown?: boolean;\n /**\n * Callback when closing and discarding the new changes\n */\n onClose: () => void;\n /**\n * Completely remove Excalidraw component\n */\n onDelete: () => void;\n /**\n * Callback when the save button is clicked\n */\n onSave: (\n elements: ExcalidrawInitialElements,\n appState: Partial<AppState>,\n files: BinaryFiles,\n ) => void;\n};\n\n/**\n * @explorer-desc\n * A component which renders a modal with Excalidraw (a painting app)\n * which can be used to export an editable image\n */\nexport default function ExcalidrawModal({\n closeOnClickOutside = false,\n onSave,\n initialElements,\n initialAppState,\n initialFiles,\n isShown = false,\n onDelete,\n onClose,\n}: Props): ReactPortal | null {\n const excaliDrawModelRef = useRef<HTMLDivElement | null>(null);\n const [excalidrawAPI, setExcalidrawAPI] =\n useState<ExcalidrawImperativeAPI | null>(null);\n const [discardModalOpen, setDiscardModalOpen] = useState(false);\n const [elements, setElements] =\n useState<ExcalidrawInitialElements>(initialElements);\n const [files, setFiles] = useState<BinaryFiles>(initialFiles);\n\n useEffect(() => {\n excaliDrawModelRef.current?.focus();\n }, []);\n\n // Excalidraw registers a document-level wheel handler that calls preventDefault(),\n // which blocks scrolling inside its own modal dialogs (Help, etc.).\n // Watch for the modal container and stop wheel propagation so scroll works.\n useEffect(() => {\n const onWheel = (e: Event) => {\n e.stopPropagation();\n };\n\n const observer = new MutationObserver(() => {\n const container = document.querySelector('.excalidraw-modal-container') as HTMLElement | null;\n if (container && !container.hasAttribute('data-wheel-fixed')) {\n container.setAttribute('data-wheel-fixed', 'true');\n container.addEventListener('wheel', onWheel, {passive: false});\n }\n });\n\n observer.observe(document.body, {childList: true});\n\n return () => {\n observer.disconnect();\n const container = document.querySelector('.excalidraw-modal-container') as HTMLElement | null;\n if (container) {\n container.removeEventListener('wheel', onWheel);\n }\n };\n }, []);\n\n useEffect(() => {\n let modalOverlayElement: HTMLElement | null = null;\n\n const clickOutsideHandler = (event: MouseEvent) => {\n const target = event.target;\n if (\n excaliDrawModelRef.current !== null &&\n isDOMNode(target) &&\n !excaliDrawModelRef.current.contains(target) &&\n closeOnClickOutside\n ) {\n onDelete();\n }\n };\n\n if (excaliDrawModelRef.current !== null) {\n modalOverlayElement = excaliDrawModelRef.current?.parentElement;\n modalOverlayElement?.addEventListener('click', clickOutsideHandler);\n }\n\n return () => {\n modalOverlayElement?.removeEventListener('click', clickOutsideHandler);\n };\n }, [closeOnClickOutside, onDelete]);\n\n useLayoutEffect(() => {\n const currentModalRef = excaliDrawModelRef.current;\n\n const onKeyDown = (event: KeyboardEvent) => {\n if (event.key === 'Escape') {\n onDelete();\n }\n };\n\n currentModalRef?.addEventListener('keydown', onKeyDown);\n\n return () => {\n currentModalRef?.removeEventListener('keydown', onKeyDown);\n };\n }, [elements, files, onDelete]);\n\n const save = () => {\n if (elements?.some((el: Record<string, unknown>) => !el.isDeleted)) {\n const appState = excalidrawAPI?.getAppState();\n // We only need a subset of the state\n const partialState: Partial<AppState> = {\n exportBackground: appState?.exportBackground,\n exportScale: appState?.exportScale,\n exportWithDarkMode: appState?.theme === 'dark',\n isBindingEnabled: appState?.isBindingEnabled,\n isLoading: appState?.isLoading,\n name: appState?.name,\n theme: appState?.theme,\n viewBackgroundColor: appState?.viewBackgroundColor,\n viewModeEnabled: appState?.viewModeEnabled,\n zenModeEnabled: appState?.zenModeEnabled,\n zoom: appState?.zoom,\n };\n onSave(elements, partialState, files);\n } else {\n // delete node if the scene is clear\n onDelete();\n }\n };\n\n const discard = () => {\n setDiscardModalOpen(true);\n };\n\n function ShowDiscardDialog(): JSX.Element {\n return (\n <Modal\n title=\"Discard\"\n onClose={() => {\n setDiscardModalOpen(false);\n }}\n closeOnClickOutside={false}>\n Are you sure you want to discard the changes?\n <div className=\"ExcalidrawModal__discardModal\">\n <Button\n onClick={() => {\n setDiscardModalOpen(false);\n onClose();\n }}>\n Discard\n </Button>{' '}\n <Button\n onClick={() => {\n setDiscardModalOpen(false);\n }}>\n Cancel\n </Button>\n </div>\n </Modal>\n );\n }\n\n if (isShown === false) {\n return null;\n }\n\n const onChange = (\n els: ExcalidrawInitialElements,\n _: AppState,\n fls: BinaryFiles,\n ) => {\n setElements(els);\n setFiles(fls);\n };\n\n return createPortal(\n <div className=\"ExcalidrawModal__overlay\" role=\"dialog\">\n <div\n className=\"ExcalidrawModal__modal\"\n ref={excaliDrawModelRef}\n tabIndex={-1}>\n <div className=\"ExcalidrawModal__row\">\n {discardModalOpen && <ShowDiscardDialog />}\n <Suspense fallback={<div style={{padding: 20}}>Loading Excalidraw...</div>}>\n <ExcalidrawComponent\n onChange={onChange}\n excalidrawAPI={setExcalidrawAPI}\n initialData={{\n appState: initialAppState || {isLoading: false},\n elements: initialElements,\n files: initialFiles,\n }}\n />\n </Suspense>\n <div className=\"ExcalidrawModal__actions\">\n <button type=\"button\" className=\"action-button\" onClick={discard}>\n Discard\n </button>\n <button type=\"button\" className=\"action-button\" onClick={save}>\n Save\n </button>\n </div>\n </div>\n </div>\n </div>,\n document.body,\n );\n}\n","/**\r\n * Copyright (c) Meta Platforms, Inc. and affiliates.\r\n *\r\n * This source code is licensed under the MIT license found in the\r\n * LICENSE file in the root directory of this source tree.\r\n *\r\n */\r\n\r\nimport type {JSX} from 'react';\r\n\r\nimport './Modal.css';\r\n\r\nimport {isDOMNode} from 'lexical';\r\nimport * as React from 'react';\r\nimport {ReactNode, useEffect, useRef} from 'react';\r\nimport {createPortal} from 'react-dom';\r\n\r\nfunction PortalImpl({\r\n onClose,\r\n children,\r\n title,\r\n closeOnClickOutside,\r\n}: {\r\n children: ReactNode;\r\n closeOnClickOutside: boolean;\r\n onClose: () => void;\r\n title: string;\r\n}) {\r\n const modalRef = useRef<HTMLDivElement>(null);\r\n\r\n useEffect(() => {\r\n if (modalRef.current !== null) {\r\n modalRef.current.focus();\r\n }\r\n }, []);\r\n\r\n useEffect(() => {\r\n let modalOverlayElement: HTMLElement | null = null;\r\n const handler = (event: KeyboardEvent) => {\r\n if (event.key === 'Escape') {\r\n onClose();\r\n }\r\n };\r\n const clickOutsideHandler = (event: MouseEvent) => {\r\n const target = event.target;\r\n if (\r\n modalRef.current !== null &&\r\n isDOMNode(target) &&\r\n !modalRef.current.contains(target) &&\r\n closeOnClickOutside\r\n ) {\r\n onClose();\r\n }\r\n };\r\n const modelElement = modalRef.current;\r\n if (modelElement !== null) {\r\n modalOverlayElement = modelElement.parentElement;\r\n if (modalOverlayElement !== null) {\r\n modalOverlayElement.addEventListener('click', clickOutsideHandler);\r\n }\r\n }\r\n\r\n window.addEventListener('keydown', handler);\r\n\r\n return () => {\r\n window.removeEventListener('keydown', handler);\r\n if (modalOverlayElement !== null) {\r\n modalOverlayElement?.removeEventListener('click', clickOutsideHandler);\r\n }\r\n };\r\n }, [closeOnClickOutside, onClose]);\r\n\r\n return (\r\n <div className=\"Modal__overlay\" role=\"dialog\">\r\n <div className=\"Modal__modal\" tabIndex={-1} ref={modalRef}>\r\n <h2 className=\"Modal__title\">{title}</h2>\r\n <button\r\n className=\"Modal__closeButton\"\r\n aria-label=\"Close modal\"\r\n type=\"button\"\r\n onClick={onClose}>\r\n X\r\n </button>\r\n <div className=\"Modal__content\">{children}</div>\r\n </div>\r\n </div>\r\n );\r\n}\r\n\r\nexport default function Modal({\r\n onClose,\r\n children,\r\n title,\r\n closeOnClickOutside = false,\r\n}: {\r\n children: ReactNode;\r\n closeOnClickOutside?: boolean;\r\n onClose: () => void;\r\n title: string;\r\n}): JSX.Element {\r\n return createPortal(\r\n <PortalImpl\r\n onClose={onClose}\r\n title={title}\r\n closeOnClickOutside={closeOnClickOutside}>\r\n {children}\r\n </PortalImpl>,\r\n document.body,\r\n );\r\n}\r\n","/**\r\n * Copyright (c) Meta Platforms, Inc. and affiliates.\r\n *\r\n * This source code is licensed under the MIT license found in the\r\n * LICENSE file in the root directory of this source tree.\r\n *\r\n */\r\n\r\nimport type {\r\n DOMConversionMap,\r\n DOMConversionOutput,\r\n DOMExportOutput,\r\n EditorConfig,\r\n LexicalEditor,\r\n LexicalNode,\r\n NodeKey,\r\n SerializedLexicalNode,\r\n Spread,\r\n} from 'lexical';\r\nimport type {JSX} from 'react';\r\n\r\nimport {DecoratorNode} from 'lexical';\r\nimport * as React from 'react';\r\n\r\ntype Dimension = number | 'inherit';\r\n\r\nconst ExcalidrawComponent = React.lazy(() => import('./ExcalidrawComponent'));\r\n\r\nexport type SerializedExcalidrawNode = Spread<\r\n {\r\n data: string;\r\n width?: Dimension;\r\n height?: Dimension;\r\n },\r\n SerializedLexicalNode\r\n>;\r\n\r\nfunction $convertExcalidrawElement(\r\n domNode: HTMLElement,\r\n): DOMConversionOutput | null {\r\n const excalidrawData = domNode.getAttribute('data-lexical-excalidraw-json');\r\n // Read from inline style (not getComputedStyle) because during\r\n // $generateNodesFromDOM the element is detached and computed styles are empty.\r\n const widthStr = domNode.style.width;\r\n const heightStr = domNode.style.height;\r\n const width =\r\n !widthStr || widthStr === '100%' || widthStr === 'auto' || widthStr === 'inherit'\r\n ? 'inherit'\r\n : parseInt(widthStr, 10);\r\n const height =\r\n !heightStr || heightStr === 'auto' || heightStr === 'inherit'\r\n ? 'inherit'\r\n : parseInt(heightStr, 10);\r\n\r\n if (excalidrawData) {\r\n const node = $createExcalidrawNode(\r\n excalidrawData,\r\n isNaN(width as number) ? 'inherit' : width,\r\n isNaN(height as number) ? 'inherit' : height,\r\n );\r\n return {\r\n node,\r\n };\r\n }\r\n return null;\r\n}\r\n\r\nexport class ExcalidrawNode extends DecoratorNode<JSX.Element> {\r\n __data: string;\r\n __width: Dimension;\r\n __height: Dimension;\r\n\r\n static getType(): string {\r\n return 'excalidraw';\r\n }\r\n\r\n static clone(node: ExcalidrawNode): ExcalidrawNode {\r\n return new ExcalidrawNode(\r\n node.__data,\r\n node.__width,\r\n node.__height,\r\n node.__key,\r\n );\r\n }\r\n\r\n static importJSON(serializedNode: SerializedExcalidrawNode): ExcalidrawNode {\r\n return new ExcalidrawNode(\r\n serializedNode.data,\r\n serializedNode.width ?? 'inherit',\r\n serializedNode.height ?? 'inherit',\r\n ).updateFromJSON(serializedNode);\r\n }\r\n\r\n exportJSON(): SerializedExcalidrawNode {\r\n return {\r\n ...super.exportJSON(),\r\n data: this.__data,\r\n height: this.__height === 'inherit' ? undefined : this.__height,\r\n width: this.__width === 'inherit' ? undefined : this.__width,\r\n };\r\n }\r\n\r\n constructor(\r\n data = '[]',\r\n width: Dimension = 'inherit',\r\n height: Dimension = 'inherit',\r\n key?: NodeKey,\r\n ) {\r\n super(key);\r\n this.__data = data;\r\n this.__width = width;\r\n this.__height = height;\r\n }\r\n\r\n // View\r\n createDOM(config: EditorConfig): HTMLElement {\r\n const span = document.createElement('span');\r\n const theme = config.theme;\r\n const className = theme.image;\r\n span.className = `${className ?? ''} editor-excalidraw`.trim();\r\n return span;\r\n }\r\n\r\n updateDOM(): false {\r\n return false;\r\n }\r\n\r\n static importDOM(): DOMConversionMap<HTMLSpanElement> | null {\r\n return {\r\n span: (domNode: HTMLSpanElement) => {\r\n if (!domNode.hasAttribute('data-lexical-excalidraw-json')) {\r\n return null;\r\n }\r\n return {\r\n conversion: $convertExcalidrawElement,\r\n priority: 1,\r\n };\r\n },\r\n };\r\n }\r\n\r\n exportDOM(editor: LexicalEditor): DOMExportOutput {\r\n const element = document.createElement('span');\r\n\r\n element.style.display = 'block';\r\n\r\n const content = editor.getElementByKey(this.getKey());\r\n if (content !== null) {\r\n const svg = content.querySelector('svg');\r\n if (svg !== null) {\r\n element.innerHTML = svg.outerHTML;\r\n }\r\n }\r\n\r\n element.style.width =\r\n this.__width === 'inherit' ? '100%' : `${this.__width}px`;\r\n element.style.height =\r\n this.__height === 'inherit' ? 'auto' : `${this.__height}px`;\r\n\r\n element.setAttribute('data-lexical-excalidraw-json', this.__data);\r\n return {element};\r\n }\r\n\r\n setData(data: string): void {\r\n const self = this.getWritable();\r\n self.__data = data;\r\n }\r\n\r\n getWidth(): Dimension {\r\n return this.getLatest().__width;\r\n }\r\n\r\n setWidth(width: Dimension): void {\r\n const self = this.getWritable();\r\n self.__width = width;\r\n }\r\n\r\n getHeight(): Dimension {\r\n return this.getLatest().__height;\r\n }\r\n\r\n setHeight(height: Dimension): void {\r\n const self = this.getWritable();\r\n self.__height = height;\r\n }\r\n\r\n decorate(editor: LexicalEditor, config: EditorConfig): JSX.Element {\r\n return (\r\n <ExcalidrawComponent\r\n nodeKey={this.getKey()}\r\n data={this.__data}\r\n width={this.__width}\r\n height={this.__height}\r\n />\r\n );\r\n }\r\n}\r\n\r\nexport function $createExcalidrawNode(\r\n data: string = '[]',\r\n width: Dimension = 'inherit',\r\n height: Dimension = 'inherit',\r\n): ExcalidrawNode {\r\n return new ExcalidrawNode(data, width, height);\r\n}\r\n\r\nexport function $isExcalidrawNode(\r\n node: LexicalNode | null | undefined,\r\n): node is ExcalidrawNode {\r\n return node instanceof ExcalidrawNode;\r\n}\r\n"],"mappings":";;;;;AAkBA,SAAQ,aAAAA,kBAAgB;AAExB,SAAqB,MAAM,UAAU,aAAAC,YAAW,iBAAiB,UAAAC,SAAQ,gBAAe;AACxF,SAAQ,gBAAAC,qBAAmB;;;ACT3B,SAAQ,iBAAgB;AAExB,SAAmB,WAAW,cAAa;AAC3C,SAAQ,oBAAmB;AA2DrB,SACE,KADF;AAzDN,SAAS,WAAW;AAAA,EAClB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAKG;AACD,QAAM,WAAW,OAAuB,IAAI;AAE5C,YAAU,MAAM;AACd,QAAI,SAAS,YAAY,MAAM;AAC7B,eAAS,QAAQ,MAAM;AAAA,IACzB;AAAA,EACF,GAAG,CAAC,CAAC;AAEL,YAAU,MAAM;AACd,QAAI,sBAA0C;AAC9C,UAAM,UAAU,CAAC,UAAyB;AACxC,UAAI,MAAM,QAAQ,UAAU;AAC1B,gBAAQ;AAAA,MACV;AAAA,IACF;AACA,UAAM,sBAAsB,CAAC,UAAsB;AACjD,YAAM,SAAS,MAAM;AACrB,UACE,SAAS,YAAY,QACrB,UAAU,MAAM,KAChB,CAAC,SAAS,QAAQ,SAAS,MAAM,KACjC,qBACA;AACA,gBAAQ;AAAA,MACV;AAAA,IACF;AACA,UAAM,eAAe,SAAS;AAC9B,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wB;AAC/B,UAAM,OAAO,KAAK,YAAY;AAC9B,SAAK,UAAU;AAAA,EACjB;AAAA,EAEA,YAAuB;AACrB,WAAO,KAAK,UAAU,EAAE;AAAA,EAC1B;AAAA,EAEA,UAAU,QAAyB;AACjC,UAAM,OAAO,KAAK,YAAY;AAC9B,SAAK,WAAW;AAAA,EAClB;AAAA,EAEA,SAAS,QAAuB,QAAmC;AACjE,WACE,gBAAAD;AAAA,MAACC;AAAA,MAAA;AAAA,QACC,SAAS,KAAK,OAAO;AAAA,QACrB,MAAM,KAAK;AAAA,QACX,OAAO,KAAK;AAAA,QACZ,QAAQ,KAAK;AAAA;AAAA,IACf;AAAA,EAEJ;AACF;AAEO,SAAS,sBACd,OAAe,MACf,QAAmB,WACnB,SAAoB,WACJ;AAChB,SAAO,IAAI,eAAe,MAAM,OAAO,MAAM;AAC/C;AAEO,SAAS,kBACd,MACwB;AACxB,SAAO,gBAAgB;AACzB;","names":["isDOMNode","useEffect","useRef","createPortal","jsx","jsxs","useRef","useEffect","isDOMNode","createPortal","jsx","ExcalidrawComponent"]}
|
package/dist/index.css
CHANGED
|
@@ -1250,6 +1250,106 @@ i.page-break,
|
|
|
1250
1250
|
.editor-shell .editor-image .image-edit-button:hover {
|
|
1251
1251
|
background-color: rgba(60, 132, 244, 0.1);
|
|
1252
1252
|
}
|
|
1253
|
+
.editor-shell .editor-image .image-resize-button {
|
|
1254
|
+
border: 1px solid rgba(0, 0, 0, 0.3);
|
|
1255
|
+
border-radius: 5px;
|
|
1256
|
+
background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16">%0A <path fill-rule="evenodd" d="M5.828 10.172a.5.5 0 0 0-.707 0l-4.096 4.096V11.5a.5.5 0 0 0-1 0v3.975a.5.5 0 0 0 .5.5H4.5a.5.5 0 0 0 0-1H1.732l4.096-4.096a.5.5 0 0 0 0-.707m4.344-4.344a.5.5 0 0 0 .707 0l4.096-4.096V4.5a.5.5 0 1 0 1 0V.525a.5.5 0 0 0-.5-.5H11.5a.5.5 0 0 0 0 1h2.768l-4.096 4.096a.5.5 0 0 0 0 .707"/>%0A</svg>%0A');
|
|
1257
|
+
background-size: 16px;
|
|
1258
|
+
background-position: center;
|
|
1259
|
+
background-repeat: no-repeat;
|
|
1260
|
+
width: 35px;
|
|
1261
|
+
height: 35px;
|
|
1262
|
+
vertical-align: -0.25em;
|
|
1263
|
+
position: absolute;
|
|
1264
|
+
right: 44px;
|
|
1265
|
+
top: 4px;
|
|
1266
|
+
cursor: pointer;
|
|
1267
|
+
user-select: none;
|
|
1268
|
+
}
|
|
1269
|
+
.editor-shell .editor-image .image-resize-button:hover {
|
|
1270
|
+
background-color: rgba(60, 132, 244, 0.1);
|
|
1271
|
+
}
|
|
1272
|
+
.excalidraw-resize-overlay {
|
|
1273
|
+
position: fixed;
|
|
1274
|
+
inset: 0;
|
|
1275
|
+
z-index: 10001;
|
|
1276
|
+
background: rgba(0, 0, 0, 0.3);
|
|
1277
|
+
display: flex;
|
|
1278
|
+
align-items: center;
|
|
1279
|
+
justify-content: center;
|
|
1280
|
+
pointer-events: auto;
|
|
1281
|
+
}
|
|
1282
|
+
.excalidraw-resize-dialog {
|
|
1283
|
+
background: #fff;
|
|
1284
|
+
border-radius: 8px;
|
|
1285
|
+
padding: 20px 24px;
|
|
1286
|
+
min-width: 300px;
|
|
1287
|
+
box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
|
|
1288
|
+
}
|
|
1289
|
+
.excalidraw-resize-dialog__title {
|
|
1290
|
+
font-size: 16px;
|
|
1291
|
+
font-weight: 600;
|
|
1292
|
+
margin-bottom: 16px;
|
|
1293
|
+
color: #1a1a1a;
|
|
1294
|
+
}
|
|
1295
|
+
.excalidraw-resize-dialog__fields {
|
|
1296
|
+
display: flex;
|
|
1297
|
+
gap: 12px;
|
|
1298
|
+
margin-bottom: 8px;
|
|
1299
|
+
}
|
|
1300
|
+
.excalidraw-resize-dialog__label {
|
|
1301
|
+
display: flex;
|
|
1302
|
+
flex-direction: column;
|
|
1303
|
+
gap: 4px;
|
|
1304
|
+
font-size: 13px;
|
|
1305
|
+
font-weight: 500;
|
|
1306
|
+
color: #555;
|
|
1307
|
+
flex: 1;
|
|
1308
|
+
}
|
|
1309
|
+
.excalidraw-resize-dialog__input {
|
|
1310
|
+
padding: 6px 10px;
|
|
1311
|
+
border: 1px solid #d1d5db;
|
|
1312
|
+
border-radius: 6px;
|
|
1313
|
+
font-size: 14px;
|
|
1314
|
+
outline: none;
|
|
1315
|
+
transition: border-color 0.15s;
|
|
1316
|
+
}
|
|
1317
|
+
.excalidraw-resize-dialog__input:focus {
|
|
1318
|
+
border-color: rgb(60, 132, 244);
|
|
1319
|
+
box-shadow: 0 0 0 2px rgba(60, 132, 244, 0.15);
|
|
1320
|
+
}
|
|
1321
|
+
.excalidraw-resize-dialog__hint {
|
|
1322
|
+
font-size: 12px;
|
|
1323
|
+
color: #888;
|
|
1324
|
+
margin-bottom: 16px;
|
|
1325
|
+
}
|
|
1326
|
+
.excalidraw-resize-dialog__actions {
|
|
1327
|
+
display: flex;
|
|
1328
|
+
justify-content: flex-end;
|
|
1329
|
+
gap: 8px;
|
|
1330
|
+
}
|
|
1331
|
+
.excalidraw-resize-dialog__btn {
|
|
1332
|
+
padding: 6px 16px;
|
|
1333
|
+
border-radius: 6px;
|
|
1334
|
+
font-size: 13px;
|
|
1335
|
+
font-weight: 500;
|
|
1336
|
+
cursor: pointer;
|
|
1337
|
+
border: 1px solid #d1d5db;
|
|
1338
|
+
background: #fff;
|
|
1339
|
+
color: #333;
|
|
1340
|
+
transition: background-color 0.15s;
|
|
1341
|
+
}
|
|
1342
|
+
.excalidraw-resize-dialog__btn:hover {
|
|
1343
|
+
background: #f5f5f5;
|
|
1344
|
+
}
|
|
1345
|
+
.excalidraw-resize-dialog__btn--save {
|
|
1346
|
+
background: rgb(60, 132, 244);
|
|
1347
|
+
color: #fff;
|
|
1348
|
+
border-color: rgb(60, 132, 244);
|
|
1349
|
+
}
|
|
1350
|
+
.excalidraw-resize-dialog__btn--save:hover {
|
|
1351
|
+
background: rgb(45, 115, 225);
|
|
1352
|
+
}
|
|
1253
1353
|
.editor-shell .editor-image .image-resizer {
|
|
1254
1354
|
display: block;
|
|
1255
1355
|
width: 7px;
|
|
@@ -1765,11 +1865,18 @@ button.toolbar-item.active i {
|
|
|
1765
1865
|
height: 12px;
|
|
1766
1866
|
background-size: contain;
|
|
1767
1867
|
}
|
|
1868
|
+
.editor-shell span.editor-excalidraw {
|
|
1869
|
+
display: block;
|
|
1870
|
+
width: 100%;
|
|
1871
|
+
}
|
|
1768
1872
|
.excalidraw-button {
|
|
1769
1873
|
border: 0;
|
|
1770
1874
|
padding: 0;
|
|
1771
1875
|
margin: 0;
|
|
1772
1876
|
background-color: transparent;
|
|
1877
|
+
display: block;
|
|
1878
|
+
cursor: default;
|
|
1879
|
+
position: relative;
|
|
1773
1880
|
}
|
|
1774
1881
|
.excalidraw-button.selected {
|
|
1775
1882
|
outline: 2px solid rgb(60, 132, 244);
|