From 1813bd4f0ebc2429d87d6433b5597282362ea19c Mon Sep 17 00:00:00 2001 From: zsviczian Date: Mon, 24 Jul 2023 16:51:53 +0200 Subject: [PATCH] feat: introducing Web-Embeds (alias iframe element) (#6691) Co-authored-by: dwelle --- .../excalidraw/api/props/props.mdx | 12 +- .../excalidraw/api/props/render-props.mdx | 13 + src/actions/actionAddToLibrary.ts | 20 +- src/actions/actionCanvas.tsx | 2 + src/actions/actionDeleteSelected.tsx | 1 + src/actions/actionFinalize.tsx | 1 + src/actions/types.ts | 1 + src/appState.ts | 2 + src/colors.ts | 2 +- src/components/Actions.tsx | 114 ++- src/components/App.tsx | 657 ++++++++++++++++-- src/components/EyeDropper.tsx | 2 +- src/components/HintViewer.tsx | 4 + src/components/LibraryMenu.tsx | 13 +- src/components/LibraryUnit.scss | 5 + src/components/icons.tsx | 8 + src/constants.ts | 14 +- src/css/styles.scss | 43 ++ src/data/restore.ts | 5 + src/data/url.ts | 26 + src/element/Hyperlink.scss | 4 - src/element/Hyperlink.tsx | 166 ++++- src/element/collision.ts | 20 +- src/element/embeddable.ts | 329 +++++++++ src/element/newElement.ts | 15 +- src/element/showSelectedShapeActions.ts | 14 +- src/element/typeChecks.ts | 23 +- src/element/types.ts | 15 + src/excalidraw-app/index.tsx | 37 +- src/hooks/useLibraryItemSvg.ts | 1 + src/keys.ts | 1 + src/locales/en.json | 20 +- src/packages/excalidraw/CHANGELOG.md | 19 + src/packages/excalidraw/example/App.tsx | 12 +- src/packages/excalidraw/index.tsx | 4 + src/packages/utils.ts | 3 + src/renderer/renderElement.ts | 169 ++++- src/renderer/renderScene.ts | 214 ++++-- src/scene/comparisons.ts | 28 +- src/scene/export.ts | 2 + .../__snapshots__/contextmenu.test.tsx.snap | 17 + .../regressionTests.test.tsx.snap | 53 ++ src/tests/data/restore.test.ts | 2 +- src/tests/fixtures/elementFixture.ts | 4 + src/tests/helpers/api.ts | 3 +- .../packages/__snapshots__/utils.test.ts.snap | 1 + src/types.ts | 29 +- src/utils.ts | 9 +- 48 files changed, 1924 insertions(+), 235 deletions(-) create mode 100644 src/element/embeddable.ts diff --git a/dev-docs/docs/@excalidraw/excalidraw/api/props/props.mdx b/dev-docs/docs/@excalidraw/excalidraw/api/props/props.mdx index a871874c543d..104d9dccd4c3 100644 --- a/dev-docs/docs/@excalidraw/excalidraw/api/props/props.mdx +++ b/dev-docs/docs/@excalidraw/excalidraw/api/props/props.mdx @@ -29,6 +29,8 @@ All `props` are *optional*. | [`handleKeyboardGlobally`](#handlekeyboardglobally) | `boolean` | `false` | Indicates whether to bind the keyboard events to document. | | [`autoFocus`](#autofocus) | `boolean` | `false` | indicates whether to focus the Excalidraw component on page load | | [`generateIdForFile`](#generateidforfile) | `function` | _ | Allows you to override `id` generation for files added on canvas | +| [`validateEmbeddable`](#validateEmbeddable) | string[] | `boolean | RegExp | RegExp[] | ((link: string) => boolean | undefined)` | \_ | use for custom src url validation | +| [`renderEmbeddable`](/docs/@excalidraw/excalidraw/api/props/render-props#renderEmbeddable) | `function` | \_ | Render function that can override the built-in `