@excalidraw/excalidraw 0.17.1-7500-ac247a0 → 0.17.1-b7babe5
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/CHANGELOG.md +56 -2
- package/dist/browser/dev/excalidraw-assets-dev/{chunk-2W5GQUR4.js → chunk-6NMK7JTV.js} +13 -6
- package/dist/browser/dev/excalidraw-assets-dev/chunk-6NMK7JTV.js.map +7 -0
- package/dist/browser/dev/excalidraw-assets-dev/chunk-CX3RATXT.js +20324 -0
- package/dist/browser/dev/excalidraw-assets-dev/chunk-CX3RATXT.js.map +7 -0
- package/dist/browser/dev/excalidraw-assets-dev/{en-OC6JWP3X.js → en-BZY7JRTM.js} +4 -2
- package/dist/browser/dev/excalidraw-assets-dev/{image-5TVMINCA.js → image-CVN3YKRW.js} +2 -4
- package/dist/browser/dev/excalidraw-assets-dev/image-LK4UNFRZ.css +6 -0
- package/dist/browser/dev/excalidraw-assets-dev/image-LK4UNFRZ.css.map +7 -0
- package/dist/browser/dev/excalidraw-assets-dev/roundRect-T5BX56ZF.js +161 -0
- package/dist/browser/dev/excalidraw-assets-dev/roundRect-T5BX56ZF.js.map +7 -0
- package/dist/browser/dev/index.css +189 -129
- package/dist/browser/dev/index.css.map +3 -3
- package/dist/browser/dev/index.js +34964 -37
- package/dist/browser/dev/index.js.map +4 -4
- package/dist/browser/prod/excalidraw-assets/chunk-VJAIK3AX.js +55 -0
- package/dist/browser/prod/excalidraw-assets/chunk-YYO5DFUW.js +11 -0
- package/dist/browser/prod/excalidraw-assets/en-O2YCQM2W.js +1 -0
- package/dist/browser/prod/excalidraw-assets/image-6FKY54X5.js +1 -0
- package/dist/browser/prod/excalidraw-assets/image-X66R2EM5.css +1 -0
- package/dist/browser/prod/excalidraw-assets/roundRect-2ACQK4DA.js +1 -0
- package/dist/browser/prod/index.css +1 -1
- package/dist/browser/prod/index.js +203 -1
- package/dist/{prod/en-RLIAOBCI.json → dev/en-EY7E2L5O.json} +10 -5
- package/dist/dev/index.css +189 -129
- package/dist/dev/index.css.map +3 -3
- package/dist/dev/index.js +38702 -39409
- package/dist/dev/index.js.map +4 -4
- package/dist/excalidraw/actions/actionAddToLibrary.d.ts +15 -15
- package/dist/excalidraw/actions/actionAlign.d.ts +6 -6
- package/dist/excalidraw/actions/actionAlign.js +2 -1
- package/dist/excalidraw/actions/actionBoundText.d.ts +10 -10
- package/dist/excalidraw/actions/actionBoundText.js +8 -8
- package/dist/excalidraw/actions/actionCanvas.d.ts +58 -58
- package/dist/excalidraw/actions/actionClipboard.d.ts +34 -34
- package/dist/excalidraw/actions/actionClipboard.js +9 -2
- package/dist/excalidraw/actions/actionDeleteSelected.d.ts +15 -15
- package/dist/excalidraw/actions/actionDeleteSelected.js +3 -2
- package/dist/excalidraw/actions/actionDistribute.d.ts +2 -2
- package/dist/excalidraw/actions/actionDistribute.js +1 -1
- package/dist/excalidraw/actions/actionDuplicateSelection.d.ts +1 -1
- package/dist/excalidraw/actions/actionDuplicateSelection.js +4 -3
- package/dist/excalidraw/actions/actionElementLock.d.ts +10 -10
- package/dist/excalidraw/actions/actionExport.d.ts +43 -43
- package/dist/excalidraw/actions/actionExport.js +4 -4
- package/dist/excalidraw/actions/actionFinalize.d.ts +9 -9
- package/dist/excalidraw/actions/actionFinalize.js +7 -6
- package/dist/excalidraw/actions/actionFlip.d.ts +2 -2
- package/dist/excalidraw/actions/actionFlip.js +11 -11
- package/dist/excalidraw/actions/actionFrame.d.ts +16 -16
- package/dist/excalidraw/actions/actionFrame.js +1 -1
- package/dist/excalidraw/actions/actionGroup.d.ts +10 -10
- package/dist/excalidraw/actions/actionGroup.js +3 -2
- package/dist/excalidraw/actions/actionLinearEditor.d.ts +5 -5
- package/dist/excalidraw/actions/actionLinearEditor.js +1 -1
- package/dist/excalidraw/{element/Hyperlink.d.ts → actions/actionLink.d.ts} +29 -51
- package/dist/excalidraw/actions/actionLink.js +40 -0
- package/dist/excalidraw/actions/actionMenu.d.ts +13 -13
- package/dist/excalidraw/actions/actionNavigate.d.ts +10 -10
- package/dist/excalidraw/actions/actionNavigate.js +1 -1
- package/dist/excalidraw/actions/actionProperties.d.ts +77 -77
- package/dist/excalidraw/actions/actionProperties.js +32 -27
- package/dist/excalidraw/actions/actionSelectAll.d.ts +5 -5
- package/dist/excalidraw/actions/actionSelectAll.js +1 -1
- package/dist/excalidraw/actions/actionStyles.d.ts +7 -7
- package/dist/excalidraw/actions/actionStyles.js +4 -4
- package/dist/excalidraw/actions/actionToggleGridMode.d.ts +5 -5
- package/dist/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +5 -5
- package/dist/excalidraw/actions/actionToggleStats.d.ts +5 -5
- package/dist/excalidraw/actions/actionToggleViewMode.d.ts +5 -5
- package/dist/excalidraw/actions/actionToggleZenMode.d.ts +5 -5
- package/dist/excalidraw/actions/index.d.ts +1 -1
- package/dist/excalidraw/actions/index.js +1 -1
- package/dist/excalidraw/actions/manager.js +2 -1
- package/dist/excalidraw/align.d.ts +2 -2
- package/dist/excalidraw/align.js +2 -2
- package/dist/excalidraw/animated-trail.d.ts +33 -0
- package/dist/excalidraw/animated-trail.js +96 -0
- package/dist/excalidraw/animation-frame-handler.d.ts +16 -0
- package/dist/excalidraw/animation-frame-handler.js +55 -0
- package/dist/excalidraw/appState.d.ts +1 -1
- package/dist/excalidraw/appState.js +1 -3
- package/dist/excalidraw/clipboard.js +5 -5
- package/dist/excalidraw/components/Actions.d.ts +3 -3
- package/dist/excalidraw/components/Actions.js +18 -7
- package/dist/excalidraw/components/App.d.ts +23 -16
- package/dist/excalidraw/components/App.js +387 -272
- package/dist/excalidraw/components/Button.d.ts +1 -1
- package/dist/excalidraw/components/FilledButton.d.ts +2 -2
- package/dist/excalidraw/components/FilledButton.js +27 -3
- package/dist/excalidraw/components/FollowMode/FollowMode.js +1 -1
- package/dist/excalidraw/components/ImageExportDialog.d.ts +2 -1
- package/dist/excalidraw/components/ImageExportDialog.js +17 -13
- package/dist/excalidraw/components/JSONExportDialog.js +1 -1
- package/dist/excalidraw/components/{LaserTool/LaserPointerButton.d.ts → LaserPointerButton.d.ts} +1 -1
- package/dist/excalidraw/components/{LaserTool/LaserPointerButton.js → LaserPointerButton.js} +2 -2
- package/dist/excalidraw/components/LayerUI.js +3 -3
- package/dist/excalidraw/components/MobileMenu.js +1 -1
- package/dist/excalidraw/components/ProjectName.d.ts +0 -1
- package/dist/excalidraw/components/ProjectName.js +1 -1
- package/dist/excalidraw/components/PublishLibrary.js +1 -1
- package/dist/excalidraw/components/SVGLayer.d.ts +8 -0
- package/dist/excalidraw/components/SVGLayer.js +20 -0
- package/dist/excalidraw/components/ShareableLinkDialog.js +10 -10
- package/dist/excalidraw/components/Sidebar/Sidebar.d.ts +1 -1
- package/dist/excalidraw/components/Stack.d.ts +2 -2
- package/dist/excalidraw/components/TTDDialog/common.js +10 -1
- package/dist/excalidraw/components/TextField.d.ts +5 -2
- package/dist/excalidraw/components/TextField.js +6 -3
- package/dist/excalidraw/components/Toast.d.ts +3 -2
- package/dist/excalidraw/components/Toast.js +2 -2
- package/dist/excalidraw/components/ToolButton.js +2 -1
- package/dist/excalidraw/components/canvases/InteractiveCanvas.d.ts +2 -2
- package/dist/excalidraw/components/canvases/InteractiveCanvas.js +6 -5
- package/dist/excalidraw/components/canvases/StaticCanvas.d.ts +4 -3
- package/dist/excalidraw/components/canvases/StaticCanvas.js +7 -5
- package/dist/excalidraw/components/dropdownMenu/DropdownMenuContent.js +22 -2
- package/dist/excalidraw/components/hyperlink/Hyperlink.d.ts +19 -0
- package/dist/excalidraw/{element → components/hyperlink}/Hyperlink.js +40 -115
- package/dist/excalidraw/components/hyperlink/helpers.d.ts +7 -0
- package/dist/excalidraw/components/hyperlink/helpers.js +49 -0
- package/dist/excalidraw/components/icons.d.ts +2 -1
- package/dist/excalidraw/components/icons.js +2 -1
- package/dist/excalidraw/components/live-collaboration/LiveCollaborationTrigger.js +3 -2
- package/dist/excalidraw/components/main-menu/DefaultItems.js +5 -2
- package/dist/excalidraw/constants.d.ts +6 -0
- package/dist/excalidraw/constants.js +6 -0
- package/dist/excalidraw/data/blob.js +13 -14
- package/dist/excalidraw/data/filesystem.d.ts +1 -1
- package/dist/excalidraw/data/index.d.ts +2 -1
- package/dist/excalidraw/data/index.js +20 -16
- package/dist/excalidraw/data/json.d.ts +1 -1
- package/dist/excalidraw/data/json.js +5 -3
- package/dist/excalidraw/data/library.d.ts +60 -8
- package/dist/excalidraw/data/library.js +302 -33
- package/dist/excalidraw/data/resave.d.ts +1 -1
- package/dist/excalidraw/data/resave.js +2 -2
- package/dist/excalidraw/data/restore.js +8 -13
- package/dist/excalidraw/data/transform.js +13 -9
- package/dist/excalidraw/distribute.d.ts +2 -2
- package/dist/excalidraw/distribute.js +2 -2
- package/dist/excalidraw/element/ElementCanvasButtons.d.ts +3 -2
- package/dist/excalidraw/element/ElementCanvasButtons.js +4 -4
- package/dist/excalidraw/element/binding.d.ts +9 -9
- package/dist/excalidraw/element/binding.js +61 -59
- package/dist/excalidraw/element/bounds.d.ts +5 -5
- package/dist/excalidraw/element/bounds.js +29 -32
- package/dist/excalidraw/element/collision.d.ts +11 -11
- package/dist/excalidraw/element/collision.js +49 -46
- package/dist/excalidraw/element/containerCache.d.ts +11 -0
- package/dist/excalidraw/element/containerCache.js +14 -0
- package/dist/excalidraw/element/dragElements.js +10 -19
- package/dist/excalidraw/element/embeddable.d.ts +12 -13
- package/dist/excalidraw/element/embeddable.js +17 -27
- package/dist/excalidraw/element/image.js +1 -2
- package/dist/excalidraw/element/index.d.ts +8 -1
- package/dist/excalidraw/element/index.js +23 -1
- package/dist/excalidraw/element/linearElementEditor.d.ts +36 -36
- package/dist/excalidraw/element/linearElementEditor.js +79 -80
- package/dist/excalidraw/element/newElement.d.ts +4 -6
- package/dist/excalidraw/element/newElement.js +11 -16
- package/dist/excalidraw/element/resizeElements.d.ts +6 -6
- package/dist/excalidraw/element/resizeElements.js +40 -46
- package/dist/excalidraw/element/resizeTest.d.ts +3 -3
- package/dist/excalidraw/element/resizeTest.js +4 -4
- package/dist/excalidraw/element/sizeHelpers.d.ts +2 -2
- package/dist/excalidraw/element/sizeHelpers.js +2 -2
- package/dist/excalidraw/element/textElement.d.ts +34 -21
- package/dist/excalidraw/element/textElement.js +87 -111
- package/dist/excalidraw/element/textWysiwyg.d.ts +1 -6
- package/dist/excalidraw/element/textWysiwyg.js +15 -37
- package/dist/excalidraw/element/transformHandles.d.ts +4 -4
- package/dist/excalidraw/element/transformHandles.js +6 -6
- package/dist/excalidraw/element/typeChecks.js +4 -1
- package/dist/excalidraw/element/types.d.ts +24 -11
- package/dist/excalidraw/frame.d.ts +26 -20
- package/dist/excalidraw/frame.js +157 -84
- package/dist/excalidraw/groups.d.ts +3 -3
- package/dist/excalidraw/groups.js +11 -3
- package/dist/excalidraw/history.d.ts +1 -1
- package/dist/excalidraw/hooks/useLibraryItemSvg.js +1 -1
- package/dist/excalidraw/index.d.ts +9 -10
- package/dist/excalidraw/index.js +16 -12
- package/dist/excalidraw/laser-trails.d.ts +19 -0
- package/dist/excalidraw/laser-trails.js +95 -0
- package/dist/excalidraw/locales/en.json +10 -5
- package/dist/excalidraw/queue.d.ts +9 -0
- package/dist/excalidraw/queue.js +27 -0
- package/dist/excalidraw/reactUtils.d.ts +14 -0
- package/dist/excalidraw/reactUtils.js +45 -0
- package/dist/excalidraw/renderer/helpers.d.ts +13 -0
- package/dist/excalidraw/renderer/helpers.js +39 -0
- package/dist/excalidraw/renderer/interactiveScene.d.ts +20 -0
- package/dist/excalidraw/renderer/{renderScene.js → interactiveScene.js} +199 -474
- package/dist/excalidraw/renderer/renderElement.d.ts +6 -6
- package/dist/excalidraw/renderer/renderElement.js +54 -366
- package/dist/excalidraw/renderer/staticScene.d.ts +11 -0
- package/dist/excalidraw/renderer/staticScene.js +205 -0
- package/dist/excalidraw/renderer/staticSvgScene.d.ts +5 -0
- package/dist/excalidraw/renderer/staticSvgScene.js +385 -0
- package/dist/excalidraw/scene/Fonts.js +2 -1
- package/dist/excalidraw/scene/Renderer.d.ts +1 -1
- package/dist/excalidraw/scene/Renderer.js +32 -20
- package/dist/excalidraw/scene/Scene.d.ts +10 -9
- package/dist/excalidraw/scene/Scene.js +45 -21
- package/dist/excalidraw/scene/Shape.d.ts +3 -1
- package/dist/excalidraw/scene/Shape.js +7 -5
- package/dist/excalidraw/scene/ShapeCache.d.ts +2 -1
- package/dist/excalidraw/scene/ShapeCache.js +1 -0
- package/dist/excalidraw/scene/comparisons.js +2 -1
- package/dist/excalidraw/scene/export.d.ts +3 -0
- package/dist/excalidraw/scene/export.js +20 -40
- package/dist/excalidraw/scene/index.d.ts +0 -1
- package/dist/excalidraw/scene/index.js +0 -1
- package/dist/excalidraw/scene/scrollbars.d.ts +1 -1
- package/dist/excalidraw/scene/scrollbars.js +1 -1
- package/dist/excalidraw/scene/selection.d.ts +5 -5
- package/dist/excalidraw/scene/selection.js +16 -14
- package/dist/excalidraw/scene/types.d.ts +11 -5
- package/dist/excalidraw/snapping.d.ts +7 -7
- package/dist/excalidraw/snapping.js +21 -20
- package/dist/excalidraw/types.d.ts +16 -17
- package/dist/excalidraw/utility-types.d.ts +7 -0
- package/dist/excalidraw/utils.d.ts +21 -16
- package/dist/excalidraw/utils.js +43 -45
- package/dist/{dev/en-RLIAOBCI.json → prod/en-EY7E2L5O.json} +10 -5
- package/dist/prod/index.css +1 -1
- package/dist/prod/index.js +42 -42
- package/dist/utils/bbox.d.ts +2 -2
- package/dist/utils/export.d.ts +3 -3
- package/dist/utils/export.js +3 -13
- package/dist/utils/index.d.ts +2 -2
- package/dist/utils/index.js +2 -2
- package/dist/utils/withinBounds.d.ts +1 -1
- package/dist/utils/withinBounds.js +5 -2
- package/package.json +4 -4
- package/dist/browser/dev/excalidraw-assets-dev/chunk-2W5GQUR4.js.map +0 -7
- package/dist/browser/dev/excalidraw-assets-dev/chunk-KGZXLFLR.js +0 -53497
- package/dist/browser/dev/excalidraw-assets-dev/chunk-KGZXLFLR.js.map +0 -7
- package/dist/browser/dev/excalidraw-assets-dev/image-3MFRCKYM.css +0 -5797
- package/dist/browser/dev/excalidraw-assets-dev/image-3MFRCKYM.css.map +0 -7
- package/dist/browser/prod/excalidraw-assets/chunk-4YN2HN3S.js +0 -257
- package/dist/browser/prod/excalidraw-assets/chunk-OWLL6VOG.js +0 -11
- package/dist/browser/prod/excalidraw-assets/en-ERQOR3OC.js +0 -1
- package/dist/browser/prod/excalidraw-assets/image-LTLHTTSE.js +0 -1
- package/dist/browser/prod/excalidraw-assets/image-QBL334OA.css +0 -1
- package/dist/excalidraw/components/LaserTool/LaserPathManager.d.ts +0 -28
- package/dist/excalidraw/components/LaserTool/LaserPathManager.js +0 -225
- package/dist/excalidraw/components/LaserTool/LaserTool.d.ts +0 -8
- package/dist/excalidraw/components/LaserTool/LaserTool.js +0 -15
- package/dist/excalidraw/renderer/renderScene.d.ts +0 -25
- package/dist/excalidraw/vite.config.d.mts +0 -2
- package/dist/excalidraw/vite.config.mjs +0 -13
- /package/dist/browser/dev/excalidraw-assets-dev/{en-OC6JWP3X.js.map → en-BZY7JRTM.js.map} +0 -0
- /package/dist/browser/dev/excalidraw-assets-dev/{image-5TVMINCA.js.map → image-CVN3YKRW.js.map} +0 -0
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { register } from "../actions/register";
|
|
2
2
|
import { FONT_FAMILY, VERTICAL_ALIGN } from "../constants";
|
|
3
|
-
import { t } from "../i18n";
|
|
4
3
|
import { getFontString, updateActiveTool } from "../utils";
|
|
5
4
|
import { setCursorForShape } from "../cursor";
|
|
6
5
|
import { newTextElement } from "./newElement";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
6
|
+
import { wrapText } from "./textElement";
|
|
7
|
+
import { isIframeElement } from "./typeChecks";
|
|
9
8
|
const embeddedLinkCache = new Map();
|
|
10
9
|
const RE_YOUTUBE = /^(?:http(?:s)?:\/\/)?(?:www\.)?youtu(?:be\.com|\.be)\/(embed\/|watch\?v=|shorts\/|playlist\?list=|embed\/videoseries\?list=)?([a-zA-Z0-9_-]+)(?:\?t=|&t=|\?start=|&start=)?([a-zA-Z0-9_-]+)?[^\s]*$/;
|
|
11
10
|
const RE_VIMEO = /^(?:http(?:s)?:\/\/)?(?:(?:w){3}.)?(?:player\.)?vimeo\.com\/(?:video\/)?([^?\s]+)(?:\?.*)?$/;
|
|
@@ -13,8 +12,8 @@ const RE_FIGMA = /^https:\/\/(?:www\.)?figma\.com/;
|
|
|
13
12
|
const RE_GH_GIST = /^https:\/\/gist\.github\.com/;
|
|
14
13
|
const RE_GH_GIST_EMBED = /^<script[\s\S]*?\ssrc=["'](https:\/\/gist.github.com\/.*?)\.js["']/i;
|
|
15
14
|
// not anchored to start to allow <blockquote> twitter embeds
|
|
16
|
-
const RE_TWITTER = /(?:http(?:s)?:\/\/)?(?:(?:w){3}.)?twitter.com/;
|
|
17
|
-
const RE_TWITTER_EMBED = /^<blockquote[\s\S]*?\shref=["'](https:\/\/twitter.com\/[^"']*)/i;
|
|
15
|
+
const RE_TWITTER = /(?:http(?:s)?:\/\/)?(?:(?:w){3}.)?(?:twitter|x).com/;
|
|
16
|
+
const RE_TWITTER_EMBED = /^<blockquote[\s\S]*?\shref=["'](https:\/\/(?:twitter|x).com\/[^"']*)/i;
|
|
18
17
|
const RE_VALTOWN = /^https:\/\/(?:www\.)?val.town\/(v|embed)\/[a-zA-Z_$][0-9a-zA-Z_$]+\.[a-zA-Z_$][0-9a-zA-Z_$]+/;
|
|
19
18
|
const RE_GENERIC_EMBED = /^<(?:iframe|blockquote)[\s\S]*?\s(?:src|href)=["']([^"']*)["'][\s\S]*?>$/i;
|
|
20
19
|
const RE_GIPHY = /giphy.com\/(?:clips|embed|gifs)\/[a-zA-Z0-9]*?-?([a-zA-Z0-9]+)(?:[^a-zA-Z0-9]|$)/;
|
|
@@ -27,6 +26,7 @@ const ALLOWED_DOMAINS = new Set([
|
|
|
27
26
|
"link.excalidraw.com",
|
|
28
27
|
"gist.github.com",
|
|
29
28
|
"twitter.com",
|
|
29
|
+
"x.com",
|
|
30
30
|
"*.simplepdf.eu",
|
|
31
31
|
"stackblitz.com",
|
|
32
32
|
"val.town",
|
|
@@ -76,8 +76,8 @@ export const getEmbedLink = (link) => {
|
|
|
76
76
|
const vimeoLink = link.match(RE_VIMEO);
|
|
77
77
|
if (vimeoLink?.[1]) {
|
|
78
78
|
const target = vimeoLink?.[1];
|
|
79
|
-
const
|
|
80
|
-
?
|
|
79
|
+
const error = !/^\d+$/.test(target)
|
|
80
|
+
? new URIError("Invalid embed link format")
|
|
81
81
|
: undefined;
|
|
82
82
|
type = "video";
|
|
83
83
|
link = `https://player.vimeo.com/video/${target}?api=1`;
|
|
@@ -89,7 +89,7 @@ export const getEmbedLink = (link) => {
|
|
|
89
89
|
intrinsicSize: aspectRatio,
|
|
90
90
|
type,
|
|
91
91
|
});
|
|
92
|
-
return { link, intrinsicSize: aspectRatio, type,
|
|
92
|
+
return { link, intrinsicSize: aspectRatio, type, error };
|
|
93
93
|
}
|
|
94
94
|
const figmaLink = link.match(RE_FIGMA);
|
|
95
95
|
if (figmaLink) {
|
|
@@ -115,6 +115,8 @@ export const getEmbedLink = (link) => {
|
|
|
115
115
|
return { link, intrinsicSize: aspectRatio, type };
|
|
116
116
|
}
|
|
117
117
|
if (RE_TWITTER.test(link)) {
|
|
118
|
+
// the embed srcdoc still supports twitter.com domain only
|
|
119
|
+
link = link.replace(/\bx.com\b/, "twitter.com");
|
|
118
120
|
let ret;
|
|
119
121
|
// assume embed code
|
|
120
122
|
if (/<blockquote/.test(link)) {
|
|
@@ -168,18 +170,6 @@ export const getEmbedLink = (link) => {
|
|
|
168
170
|
embeddedLinkCache.set(link, { link, intrinsicSize: aspectRatio, type });
|
|
169
171
|
return { link, intrinsicSize: aspectRatio, type };
|
|
170
172
|
};
|
|
171
|
-
export const isIframeLikeOrItsLabel = (element) => {
|
|
172
|
-
if (isIframeLikeElement(element)) {
|
|
173
|
-
return true;
|
|
174
|
-
}
|
|
175
|
-
if (element.type === "text") {
|
|
176
|
-
const container = getContainerElement(element);
|
|
177
|
-
if (container && isFrameLikeElement(container)) {
|
|
178
|
-
return true;
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
return false;
|
|
182
|
-
};
|
|
183
173
|
export const createPlaceholderEmbeddableLabel = (element) => {
|
|
184
174
|
let text;
|
|
185
175
|
if (isIframeElement(element)) {
|
|
@@ -251,23 +241,23 @@ allowedHostnames) => {
|
|
|
251
241
|
}
|
|
252
242
|
return false;
|
|
253
243
|
};
|
|
254
|
-
export const
|
|
255
|
-
const twitterMatch =
|
|
244
|
+
export const maybeParseEmbedSrc = (str) => {
|
|
245
|
+
const twitterMatch = str.match(RE_TWITTER_EMBED);
|
|
256
246
|
if (twitterMatch && twitterMatch.length === 2) {
|
|
257
247
|
return twitterMatch[1];
|
|
258
248
|
}
|
|
259
|
-
const gistMatch =
|
|
249
|
+
const gistMatch = str.match(RE_GH_GIST_EMBED);
|
|
260
250
|
if (gistMatch && gistMatch.length === 2) {
|
|
261
251
|
return gistMatch[1];
|
|
262
252
|
}
|
|
263
|
-
if (RE_GIPHY.test(
|
|
264
|
-
return `https://giphy.com/embed/${RE_GIPHY.exec(
|
|
253
|
+
if (RE_GIPHY.test(str)) {
|
|
254
|
+
return `https://giphy.com/embed/${RE_GIPHY.exec(str)[1]}`;
|
|
265
255
|
}
|
|
266
|
-
const match =
|
|
256
|
+
const match = str.match(RE_GENERIC_EMBED);
|
|
267
257
|
if (match && match.length === 2) {
|
|
268
258
|
return match[1];
|
|
269
259
|
}
|
|
270
|
-
return
|
|
260
|
+
return str;
|
|
271
261
|
};
|
|
272
262
|
export const embeddableURLValidator = (url, validateEmbeddable) => {
|
|
273
263
|
if (!url) {
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
// ExcalidrawImageElement & related helpers
|
|
3
3
|
// -----------------------------------------------------------------------------
|
|
4
4
|
import { MIME_TYPES, SVG_NS } from "../constants";
|
|
5
|
-
import { t } from "../i18n";
|
|
6
5
|
import { isInitializedImageElement } from "./typeChecks";
|
|
7
6
|
export const loadHTMLImageElement = (dataURL) => {
|
|
8
7
|
return new Promise((resolve, reject) => {
|
|
@@ -67,7 +66,7 @@ export const normalizeSVG = async (SVGString) => {
|
|
|
67
66
|
const svg = doc.querySelector("svg");
|
|
68
67
|
const errorNode = doc.querySelector("parsererror");
|
|
69
68
|
if (errorNode || !isHTMLSVGElement(svg)) {
|
|
70
|
-
throw new Error(
|
|
69
|
+
throw new Error("Invalid SVG");
|
|
71
70
|
}
|
|
72
71
|
else {
|
|
73
72
|
if (!svg.hasAttribute("xmlns")) {
|
|
@@ -7,11 +7,18 @@ export { resizeTest, getCursorForResizingElement, getElementWithTransformHandleT
|
|
|
7
7
|
export { transformElements, getResizeOffsetXY, getResizeArrowDirection, } from "./resizeElements";
|
|
8
8
|
export { dragSelectedElements, getDragOffsetXY, dragNewElement, } from "./dragElements";
|
|
9
9
|
export { isTextElement, isExcalidrawElement } from "./typeChecks";
|
|
10
|
-
export { textWysiwyg } from "./textWysiwyg";
|
|
11
10
|
export { redrawTextBoundingBox } from "./textElement";
|
|
12
11
|
export { getPerfectElementSize, getLockedLinearCursorAlignSize, isInvisiblySmallElement, resizePerfectLineForNWHandler, getNormalizedDimensions, } from "./sizeHelpers";
|
|
13
12
|
export { showSelectedShapeActions } from "./showSelectedShapeActions";
|
|
13
|
+
/**
|
|
14
|
+
* @deprecated unsafe, use hashElementsVersion instead
|
|
15
|
+
*/
|
|
14
16
|
export declare const getSceneVersion: (elements: readonly ExcalidrawElement[]) => number;
|
|
17
|
+
/**
|
|
18
|
+
* Hashes elements' versionNonce (using djb2 algo). Order of elements matters.
|
|
19
|
+
*/
|
|
20
|
+
export declare const hashElementsVersion: (elements: readonly ExcalidrawElement[]) => number;
|
|
21
|
+
export declare const hashString: (s: string) => number;
|
|
15
22
|
export declare const getVisibleElements: (elements: readonly ExcalidrawElement[]) => readonly NonDeletedExcalidrawElement[];
|
|
16
23
|
export declare const getNonDeletedElements: <T extends ExcalidrawElement>(elements: readonly T[]) => readonly NonDeleted<T>[];
|
|
17
24
|
export declare const isNonDeletedElement: <T extends ExcalidrawElement>(element: T) => element is NonDeleted<T>;
|
|
@@ -8,11 +8,33 @@ export { resizeTest, getCursorForResizingElement, getElementWithTransformHandleT
|
|
|
8
8
|
export { transformElements, getResizeOffsetXY, getResizeArrowDirection, } from "./resizeElements";
|
|
9
9
|
export { dragSelectedElements, getDragOffsetXY, dragNewElement, } from "./dragElements";
|
|
10
10
|
export { isTextElement, isExcalidrawElement } from "./typeChecks";
|
|
11
|
-
export { textWysiwyg } from "./textWysiwyg";
|
|
12
11
|
export { redrawTextBoundingBox } from "./textElement";
|
|
13
12
|
export { getPerfectElementSize, getLockedLinearCursorAlignSize, isInvisiblySmallElement, resizePerfectLineForNWHandler, getNormalizedDimensions, } from "./sizeHelpers";
|
|
14
13
|
export { showSelectedShapeActions } from "./showSelectedShapeActions";
|
|
14
|
+
/**
|
|
15
|
+
* @deprecated unsafe, use hashElementsVersion instead
|
|
16
|
+
*/
|
|
15
17
|
export const getSceneVersion = (elements) => elements.reduce((acc, el) => acc + el.version, 0);
|
|
18
|
+
/**
|
|
19
|
+
* Hashes elements' versionNonce (using djb2 algo). Order of elements matters.
|
|
20
|
+
*/
|
|
21
|
+
export const hashElementsVersion = (elements) => {
|
|
22
|
+
let hash = 5381;
|
|
23
|
+
for (let i = 0; i < elements.length; i++) {
|
|
24
|
+
hash = (hash << 5) + hash + elements[i].versionNonce;
|
|
25
|
+
}
|
|
26
|
+
return hash >>> 0; // Ensure unsigned 32-bit integer
|
|
27
|
+
};
|
|
28
|
+
// string hash function (using djb2). Not cryptographically secure, use only
|
|
29
|
+
// for versioning and such.
|
|
30
|
+
export const hashString = (s) => {
|
|
31
|
+
let hash = 5381;
|
|
32
|
+
for (let i = 0; i < s.length; i++) {
|
|
33
|
+
const char = s.charCodeAt(i);
|
|
34
|
+
hash = (hash << 5) + hash + char;
|
|
35
|
+
}
|
|
36
|
+
return hash >>> 0; // Ensure unsigned 32-bit integer
|
|
37
|
+
};
|
|
16
38
|
export const getVisibleElements = (elements) => elements.filter((el) => !el.isDeleted && !isInvisiblySmallElement(el));
|
|
17
39
|
export const getNonDeletedElements = (elements) => elements.filter((element) => !element.isDeleted);
|
|
18
40
|
export const isNonDeletedElement = (element) => !element.isDeleted;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { NonDeleted, ExcalidrawLinearElement, ExcalidrawElement, PointBinding, ExcalidrawBindableElement, ExcalidrawTextElementWithContainer } from "./types";
|
|
2
|
+
import { NonDeleted, ExcalidrawLinearElement, ExcalidrawElement, PointBinding, ExcalidrawBindableElement, ExcalidrawTextElementWithContainer, ElementsMap, NonDeletedExcalidrawElement, NonDeletedSceneElementsMap } from "./types";
|
|
3
3
|
import { Bounds } from "./bounds";
|
|
4
4
|
import { Point, AppState, PointerCoords, InteractiveCanvasAppState } from "../types";
|
|
5
5
|
import History from "../history";
|
|
6
|
-
import Scene from "../scene/Scene";
|
|
7
6
|
declare const editorMidPointsCache: {
|
|
8
7
|
version: number | null;
|
|
9
8
|
points: (Point | null)[];
|
|
@@ -40,47 +39,48 @@ export declare class LinearElementEditor {
|
|
|
40
39
|
readonly endBindingElement: ExcalidrawBindableElement | null | "keep";
|
|
41
40
|
readonly hoverPointIndex: number;
|
|
42
41
|
readonly segmentMidPointHoveredCoords: Point | null;
|
|
43
|
-
constructor(element: NonDeleted<ExcalidrawLinearElement
|
|
42
|
+
constructor(element: NonDeleted<ExcalidrawLinearElement>);
|
|
44
43
|
static POINT_HANDLE_SIZE: number;
|
|
45
44
|
/**
|
|
46
45
|
* @param id the `elementId` from the instance of this class (so that we can
|
|
47
46
|
* statically guarantee this method returns an ExcalidrawLinearElement)
|
|
48
47
|
*/
|
|
49
|
-
static getElement(id: InstanceType<typeof LinearElementEditor>["elementId"]): NonDeleted<ExcalidrawLinearElement> | null;
|
|
50
|
-
static handleBoxSelection(event: PointerEvent, appState: AppState, setState: React.Component<any, AppState>["setState"]): false | undefined;
|
|
48
|
+
static getElement(id: InstanceType<typeof LinearElementEditor>["elementId"], elementsMap: ElementsMap): NonDeleted<ExcalidrawLinearElement> | null;
|
|
49
|
+
static handleBoxSelection(event: PointerEvent, appState: AppState, setState: React.Component<any, AppState>["setState"], elementsMap: NonDeletedSceneElementsMap): false | undefined;
|
|
51
50
|
/** @returns whether point was dragged */
|
|
52
51
|
static handlePointDragging(event: PointerEvent, appState: AppState, scenePointerX: number, scenePointerY: number, maybeSuggestBinding: (element: NonDeleted<ExcalidrawLinearElement>, pointSceneCoords: {
|
|
53
52
|
x: number;
|
|
54
53
|
y: number;
|
|
55
|
-
}[]) => void, linearElementEditor: LinearElementEditor): boolean;
|
|
56
|
-
static handlePointerUp(event: PointerEvent, editingLinearElement: LinearElementEditor, appState: AppState): LinearElementEditor;
|
|
57
|
-
static getEditorMidPoints: (element: NonDeleted<ExcalidrawLinearElement>, appState: InteractiveCanvasAppState) => (typeof editorMidPointsCache)["points"];
|
|
58
|
-
static updateEditorMidPointsCache: (element: NonDeleted<ExcalidrawLinearElement>, appState: InteractiveCanvasAppState) => void;
|
|
54
|
+
}[]) => void, linearElementEditor: LinearElementEditor, elementsMap: NonDeletedSceneElementsMap): boolean;
|
|
55
|
+
static handlePointerUp(event: PointerEvent, editingLinearElement: LinearElementEditor, appState: AppState, elements: readonly NonDeletedExcalidrawElement[], elementsMap: NonDeletedSceneElementsMap): LinearElementEditor;
|
|
56
|
+
static getEditorMidPoints: (element: NonDeleted<ExcalidrawLinearElement>, elementsMap: ElementsMap, appState: InteractiveCanvasAppState) => (typeof editorMidPointsCache)["points"];
|
|
57
|
+
static updateEditorMidPointsCache: (element: NonDeleted<ExcalidrawLinearElement>, elementsMap: ElementsMap, appState: InteractiveCanvasAppState) => void;
|
|
59
58
|
static getSegmentMidpointHitCoords: (linearElementEditor: LinearElementEditor, scenePointer: {
|
|
60
59
|
x: number;
|
|
61
60
|
y: number;
|
|
62
|
-
}, appState: AppState) => readonly [number, number] | null;
|
|
61
|
+
}, appState: AppState, elementsMap: ElementsMap) => readonly [number, number] | null;
|
|
63
62
|
static isSegmentTooShort(element: NonDeleted<ExcalidrawLinearElement>, startPoint: Point, endPoint: Point, zoom: AppState["zoom"]): boolean;
|
|
64
|
-
static getSegmentMidPoint(element: NonDeleted<ExcalidrawLinearElement>, startPoint: Point, endPoint: Point, endPointIndex: number): readonly [number, number];
|
|
65
|
-
static getSegmentMidPointIndex(linearElementEditor: LinearElementEditor, appState: AppState, midPoint: Point): number;
|
|
63
|
+
static getSegmentMidPoint(element: NonDeleted<ExcalidrawLinearElement>, startPoint: Point, endPoint: Point, endPointIndex: number, elementsMap: ElementsMap): readonly [number, number];
|
|
64
|
+
static getSegmentMidPointIndex(linearElementEditor: LinearElementEditor, appState: AppState, midPoint: Point, elementsMap: ElementsMap): number;
|
|
66
65
|
static handlePointerDown(event: React.PointerEvent<HTMLElement>, appState: AppState, history: History, scenePointer: {
|
|
67
66
|
x: number;
|
|
68
67
|
y: number;
|
|
69
|
-
}, linearElementEditor: LinearElementEditor): {
|
|
68
|
+
}, linearElementEditor: LinearElementEditor, elements: readonly NonDeletedExcalidrawElement[], elementsMap: NonDeletedSceneElementsMap): {
|
|
70
69
|
didAddPoint: boolean;
|
|
71
70
|
hitElement: NonDeleted<ExcalidrawElement> | null;
|
|
72
71
|
linearElementEditor: LinearElementEditor | null;
|
|
73
72
|
};
|
|
74
73
|
static arePointsEqual(point1: Point | null, point2: Point | null): boolean;
|
|
75
|
-
static handlePointerMove(event: React.PointerEvent<HTMLCanvasElement>, scenePointerX: number, scenePointerY: number, appState: AppState): LinearElementEditor | null;
|
|
74
|
+
static handlePointerMove(event: React.PointerEvent<HTMLCanvasElement>, scenePointerX: number, scenePointerY: number, appState: AppState, elementsMap: ElementsMap): LinearElementEditor | null;
|
|
76
75
|
/** scene coords */
|
|
77
|
-
static getPointGlobalCoordinates(element: NonDeleted<ExcalidrawLinearElement>, point: Point): readonly [number, number];
|
|
76
|
+
static getPointGlobalCoordinates(element: NonDeleted<ExcalidrawLinearElement>, point: Point, elementsMap: ElementsMap): readonly [number, number];
|
|
78
77
|
/** scene coords */
|
|
79
|
-
static getPointsGlobalCoordinates(element: NonDeleted<ExcalidrawLinearElement
|
|
80
|
-
static getPointAtIndexGlobalCoordinates(element: NonDeleted<ExcalidrawLinearElement>, indexMaybeFromEnd: number
|
|
81
|
-
|
|
82
|
-
static
|
|
83
|
-
static
|
|
78
|
+
static getPointsGlobalCoordinates(element: NonDeleted<ExcalidrawLinearElement>, elementsMap: ElementsMap): Point[];
|
|
79
|
+
static getPointAtIndexGlobalCoordinates(element: NonDeleted<ExcalidrawLinearElement>, indexMaybeFromEnd: number, // -1 for last element
|
|
80
|
+
elementsMap: ElementsMap): Point;
|
|
81
|
+
static pointFromAbsoluteCoords(element: NonDeleted<ExcalidrawLinearElement>, absoluteCoords: Point, elementsMap: ElementsMap): Point;
|
|
82
|
+
static getPointIndexUnderCursor(element: NonDeleted<ExcalidrawLinearElement>, elementsMap: ElementsMap, zoom: AppState["zoom"], x: number, y: number): number;
|
|
83
|
+
static createPointAt(element: NonDeleted<ExcalidrawLinearElement>, elementsMap: ElementsMap, scenePointerX: number, scenePointerY: number, gridSize: number | null): Point;
|
|
84
84
|
/**
|
|
85
85
|
* Normalizes line points so that the start point is at [0,0]. This is
|
|
86
86
|
* expected in various parts of the codebase. Also returns new x/y to account
|
|
@@ -92,7 +92,7 @@ export declare class LinearElementEditor {
|
|
|
92
92
|
y: number;
|
|
93
93
|
};
|
|
94
94
|
static normalizePoints(element: NonDeleted<ExcalidrawLinearElement>): void;
|
|
95
|
-
static duplicateSelectedPoints(appState: AppState): false | {
|
|
95
|
+
static duplicateSelectedPoints(appState: AppState, elementsMap: ElementsMap): false | {
|
|
96
96
|
appState: {
|
|
97
97
|
editingLinearElement: {
|
|
98
98
|
selectedPointsIndices: number[];
|
|
@@ -133,13 +133,13 @@ export declare class LinearElementEditor {
|
|
|
133
133
|
isLoading: boolean;
|
|
134
134
|
errorMessage: import("react").ReactNode;
|
|
135
135
|
activeEmbeddable: {
|
|
136
|
-
element:
|
|
137
|
-
state: "
|
|
136
|
+
element: NonDeletedExcalidrawElement;
|
|
137
|
+
state: "hover" | "active";
|
|
138
138
|
} | null;
|
|
139
|
-
draggingElement:
|
|
140
|
-
resizingElement:
|
|
139
|
+
draggingElement: NonDeletedExcalidrawElement | null;
|
|
140
|
+
resizingElement: NonDeletedExcalidrawElement | null;
|
|
141
141
|
multiElement: NonDeleted<ExcalidrawLinearElement> | null;
|
|
142
|
-
selectionElement:
|
|
142
|
+
selectionElement: NonDeletedExcalidrawElement | null;
|
|
143
143
|
isBindingEnabled: boolean;
|
|
144
144
|
startBoundElement: NonDeleted<ExcalidrawBindableElement> | null;
|
|
145
145
|
suggestedBindings: import("./binding").SuggestedBinding[];
|
|
@@ -152,7 +152,7 @@ export declare class LinearElementEditor {
|
|
|
152
152
|
};
|
|
153
153
|
editingFrame: string | null;
|
|
154
154
|
elementsToHighlight: NonDeleted<ExcalidrawElement>[] | null;
|
|
155
|
-
editingElement:
|
|
155
|
+
editingElement: NonDeletedExcalidrawElement | null;
|
|
156
156
|
activeTool: {
|
|
157
157
|
lastActiveTool: import("../types").ActiveTool | null;
|
|
158
158
|
locked: boolean;
|
|
@@ -181,7 +181,7 @@ export declare class LinearElementEditor {
|
|
|
181
181
|
scrollY: number;
|
|
182
182
|
cursorButton: "up" | "down";
|
|
183
183
|
scrolledOutside: boolean;
|
|
184
|
-
name: string;
|
|
184
|
+
name: string | null;
|
|
185
185
|
isResizing: boolean;
|
|
186
186
|
isRotating: boolean;
|
|
187
187
|
zoom: Readonly<{
|
|
@@ -194,14 +194,14 @@ export declare class LinearElementEditor {
|
|
|
194
194
|
tab?: string | undefined;
|
|
195
195
|
} | null;
|
|
196
196
|
openDialog: {
|
|
197
|
-
name: "
|
|
197
|
+
name: "imageExport" | "help" | "jsonExport";
|
|
198
198
|
} | {
|
|
199
199
|
name: "settings";
|
|
200
200
|
source: "settings" | "tool" | "generation";
|
|
201
201
|
tab: "text-to-diagram" | "diagram-to-code";
|
|
202
202
|
} | {
|
|
203
203
|
name: "ttd";
|
|
204
|
-
tab: "
|
|
204
|
+
tab: "text-to-diagram" | "mermaid";
|
|
205
205
|
} | null;
|
|
206
206
|
defaultSidebarDockedPreference: boolean;
|
|
207
207
|
lastPointerDownWith: import("./types").PointerType;
|
|
@@ -258,7 +258,7 @@ export declare class LinearElementEditor {
|
|
|
258
258
|
data: import("../charts").Spreadsheet;
|
|
259
259
|
};
|
|
260
260
|
pendingImageElementId: string | null;
|
|
261
|
-
showHyperlinkPopup: false | "
|
|
261
|
+
showHyperlinkPopup: false | "info" | "editor";
|
|
262
262
|
selectedLinearElement: LinearElementEditor | null;
|
|
263
263
|
snapLines: readonly import("../snapping").SnapLine[];
|
|
264
264
|
originSnapOffset: {
|
|
@@ -282,18 +282,18 @@ export declare class LinearElementEditor {
|
|
|
282
282
|
startBinding?: PointBinding;
|
|
283
283
|
endBinding?: PointBinding;
|
|
284
284
|
}): void;
|
|
285
|
-
static shouldAddMidpoint(linearElementEditor: LinearElementEditor, pointerCoords: PointerCoords, appState: AppState): boolean;
|
|
286
|
-
static addMidpoint(linearElementEditor: LinearElementEditor, pointerCoords: PointerCoords, appState: AppState, snapToGrid: boolean): {
|
|
285
|
+
static shouldAddMidpoint(linearElementEditor: LinearElementEditor, pointerCoords: PointerCoords, appState: AppState, elementsMap: ElementsMap): boolean;
|
|
286
|
+
static addMidpoint(linearElementEditor: LinearElementEditor, pointerCoords: PointerCoords, appState: AppState, snapToGrid: boolean, elementsMap: ElementsMap): {
|
|
287
287
|
pointerDownState: LinearElementEditor["pointerDownState"];
|
|
288
288
|
selectedPointsIndices: LinearElementEditor["selectedPointsIndices"];
|
|
289
289
|
} | undefined;
|
|
290
290
|
private static _updatePoints;
|
|
291
291
|
private static _getShiftLockedDelta;
|
|
292
|
-
static getBoundTextElementPosition: (element: ExcalidrawLinearElement, boundTextElement: ExcalidrawTextElementWithContainer) => {
|
|
292
|
+
static getBoundTextElementPosition: (element: ExcalidrawLinearElement, boundTextElement: ExcalidrawTextElementWithContainer, elementsMap: ElementsMap) => {
|
|
293
293
|
x: number;
|
|
294
294
|
y: number;
|
|
295
295
|
};
|
|
296
|
-
static getMinMaxXYWithBoundText: (element: ExcalidrawLinearElement, elementBounds: Bounds, boundTextElement: ExcalidrawTextElementWithContainer) => [number, number, number, number, number, number];
|
|
297
|
-
static getElementAbsoluteCoords: (element: ExcalidrawLinearElement, includeBoundText?: boolean) => [number, number, number, number, number, number];
|
|
296
|
+
static getMinMaxXYWithBoundText: (element: ExcalidrawLinearElement, elementsMap: ElementsMap, elementBounds: Bounds, boundTextElement: ExcalidrawTextElementWithContainer) => [number, number, number, number, number, number];
|
|
297
|
+
static getElementAbsoluteCoords: (element: ExcalidrawLinearElement, elementsMap: ElementsMap, includeBoundText?: boolean) => [number, number, number, number, number, number];
|
|
298
298
|
}
|
|
299
299
|
export {};
|