Compare commits

..

21 Commits

Author SHA1 Message Date
zsviczian 85ebc4e2f1 lint 2024-05-23 18:07:25 +00:00
zsviczian c79bb5ed6a changed logic to match regression tests 2024-05-23 18:02:05 +00:00
zsviczian 6ef88eb851 double tap eraser 2024-05-23 17:37:08 +00:00
David Luzar a71bb63d1f fix: fix twitter og image (#8050) 2024-05-23 11:52:37 +02:00
Marcel Mraz 661d6a4a75 fix: flaky snapshot tests with floating point precision issues (#8049) 2024-05-23 11:51:01 +02:00
David Luzar defd34923a docs: fix updateScene storeAction default tsdoc & document types (#8048) 2024-05-22 13:40:23 +02:00
Ryan Di c540bd68aa feat: wrap long text when pasting (#8026)
Co-authored-by: dwelle <5153846+dwelle@users.noreply.github.com>
2024-05-21 16:56:09 +02:00
Marcel Mraz eddbe55f50 fix: always re-generate index of defined moved elements (#8040) 2024-05-20 23:23:42 +02:00
Aakansha Doshi 2f9526da24 feat: upgrade to mermaid-to-excalidraw v1 🚀 (#8022)
* feat: upgrade to mermaid-to-excalidraw v1 🚀

* upgrade to v1
2024-05-20 11:19:38 +05:30
David Luzar 1b6e3fe05b feat: rerender canvas on focus (#8035) 2024-05-19 22:20:40 +02:00
VatsalSoni_13 afe52c89a7 fix: undo/redo when exiting view mode (#8024)
Co-authored-by: dwelle <5153846+dwelle@users.noreply.github.com>
2024-05-19 15:54:52 +02:00
zsviczian be4e127f6c fix: Two finger panning is slow (#7849)
Co-authored-by: dwelle <5153846+dwelle@users.noreply.github.com>
2024-05-19 14:23:43 +02:00
Karthik Nishanth ff0b4394b1 feat: add missing type="button" (#8030) 2024-05-18 08:36:08 +00:00
Hey 7d8b7fc14d fix: compatible safari layers button svg (#8020)
Co-authored-by: ysen <ysen.ge@hairobotics.com>
Co-authored-by: dwelle <5153846+dwelle@users.noreply.github.com>
2024-05-15 15:22:05 +02:00
Ryan Di 971b4d4ae6 feat: text wrapping (#7999)
* resize single elements from the side

* fix lint

* do not resize texts from the sides (for we want to wrap/unwrap)

* omit side handles for frames too

* upgrade types

* enable resizing from the sides for multiple elements as well

* fix lint

* maintain aspect ratio when elements are not of the same angle

* lint

* always resize proportionally for multiple elements

* increase side resizing padding

* code cleanup

* adaptive handles

* do not resize for linear elements with only two points

* prioritize point dragging over edge resizing

* lint

* allow free resizing for multiple elements at degree 0

* always resize from the sides

* reduce hit threshold

* make small multiple elements movable

* lint

* show side handles on touch screen and mobile devices

* differentiate touchscreens

* keep proportional with text in multi-element resizing

* update snapshot

* update multi elements resizing logic

* lint

* reduce side resizing padding

* bound texts do not scale in normal cases

* lint

* test sides for texts

* wrap text

* do not update text size when changing its alignment

* keep text wrapped/unwrapped when editing

* change wrapped size to auto size from context menu

* fix test

* lint

* increase min width for wrapped texts

* wrap wrapped text in container

* unwrap when binding text to container

* rename `wrapped` to `autoResize`

* fix lint

* revert: use `center` align when wrapping text in container

* update snaps

* fix lint

* simplify logic on autoResize

* lint and test

* snapshots

* remove unnecessary code

* snapshots

* fix: defaults not set correctly

* tests for wrapping texts when resized

* tests for text wrapping when edited

* fix autoResize refactor

* include autoResize flag check

* refactor

* feat: rename action label & change contextmenu position

* fix: update version on `autoResize` action

* fix infinite loop when editing text in a container

* simplify

* always maintain `width` if `!autoResize`

* maintain `x` if `!autoResize`

* maintain `y` pos after fontSize change if `!autoResize`

* refactor

* when editing, do not wrap text in textWysiwyg

* simplify text editor

* make test more readable

* comment

* rename action to match file name

* revert function signature change

* only update  in app

---------

Co-authored-by: dwelle <5153846+dwelle@users.noreply.github.com>
2024-05-15 21:04:53 +08:00
David Luzar cc4c51996c build: specify packageManager field (#8010) 2024-05-14 10:45:27 +02:00
Guillaume Grossetie 79257a1923 fix: correctly resolve the package version (#8016)
The property name is `VITE_PKG_VERSION` (not `PKG_VERSION`)

Resolves #7984
2024-05-14 13:31:02 +05:30
Marcel Mraz dc66261c19 fix: re-introduce wysiwyg width offset (#8014) 2024-05-13 17:38:21 +02:00
David Luzar 273ba803d9 fix: font not rendered correctly on init (#8002) 2024-05-10 16:37:46 +02:00
David Luzar 301e83805d feat: add install-PWA to command palette (#7935) 2024-05-08 22:02:28 +02:00
David Luzar ed5ce8d3de fix: command palette filter (#7981) 2024-05-08 17:56:05 +02:00
89 changed files with 2302 additions and 1253 deletions
+1 -1
View File
@@ -14,4 +14,4 @@ jobs:
- name: Install and test
run: |
yarn install
yarn test
yarn test:app
+3 -3
View File
@@ -3,9 +3,9 @@
"version": "0.1.0",
"private": true,
"scripts": {
"build:workspaces": "yarn workspace @excalidraw/utils run build:esm && yarn workspace @excalidraw/excalidraw run build:esm",
"dev": "yarn build:workspaces && next dev -p 3005",
"build": "yarn build:workspaces && next build",
"build:workspace": "yarn workspace @excalidraw/excalidraw run build:esm",
"dev": "yarn build:workspace && next dev -p 3005",
"build": "yarn build:workspace && next build",
"start": "next start -p 3006",
"lint": "next lint"
},
@@ -12,9 +12,8 @@
"typescript": "^5"
},
"scripts": {
"build:workspaces": "yarn workspace @excalidraw/utils run build:esm && yarn workspace @excalidraw/excalidraw run build:esm",
"start": "yarn build:workspaces && vite",
"build": "yarn build:workspaces && vite build",
"start": "yarn workspace @excalidraw/excalidraw run build:esm && vite",
"build": "yarn workspace @excalidraw/excalidraw run build:esm && vite build",
"build:preview": "yarn build && vite preview --port 5002"
}
}
+47
View File
@@ -126,6 +126,38 @@ polyfill();
window.EXCALIDRAW_THROTTLE_RENDER = true;
declare global {
interface BeforeInstallPromptEventChoiceResult {
outcome: "accepted" | "dismissed";
}
interface BeforeInstallPromptEvent extends Event {
prompt(): Promise<void>;
userChoice: Promise<BeforeInstallPromptEventChoiceResult>;
}
interface WindowEventMap {
beforeinstallprompt: BeforeInstallPromptEvent;
}
}
let pwaEvent: BeforeInstallPromptEvent | null = null;
// Adding a listener outside of the component as it may (?) need to be
// subscribed early to catch the event.
//
// Also note that it will fire only if certain heuristics are met (user has
// used the app for some time, etc.)
window.addEventListener(
"beforeinstallprompt",
(event: BeforeInstallPromptEvent) => {
// prevent Chrome <= 67 from automatically showing the prompt
event.preventDefault();
// cache for later use
pwaEvent = event;
},
);
let isSelfEmbedding = false;
if (window.self !== window.top) {
@@ -1100,6 +1132,21 @@ const ExcalidrawWrapper = () => {
);
},
},
{
label: t("labels.installPWA"),
category: DEFAULT_CATEGORIES.app,
predicate: () => !!pwaEvent,
perform: () => {
if (pwaEvent) {
pwaEvent.prompt();
pwaEvent.userChoice.then(() => {
// event cannot be reused, but we'll hopefully
// grab new one as the event should be fired again
pwaEvent = null;
});
}
},
},
]}
/>
</Excalidraw>
+3 -3
View File
@@ -20,7 +20,7 @@
name="description"
content="Excalidraw is a virtual collaborative whiteboard tool that lets you easily sketch diagrams that have a hand-drawn feel to them."
/>
<meta name="image" content="https://excalidraw.com/og-image-2.png" />
<meta name="image" content="https://excalidraw.com/og-image-3.png" />
<!-- Open Graph / Facebook -->
<meta property="og:site_name" content="Excalidraw" />
@@ -35,7 +35,7 @@
property="og:description"
content="Excalidraw is a virtual collaborative whiteboard tool that lets you easily sketch diagrams that have a hand-drawn feel to them."
/>
<meta property="og:image" content="https://excalidraw.com/og-image-2.png" />
<meta property="og:image" content="https://excalidraw.com/og-image-3.png" />
<!-- Twitter -->
<meta property="twitter:card" content="summary_large_image" />
@@ -51,7 +51,7 @@
/>
<meta
property="twitter:image"
content="https://excalidraw.com/og-twitter-v2.png"
content="https://excalidraw.com/og-image-3.png"
/>
<!-- General tags -->
-17
View File
@@ -1,17 +0,0 @@
import type { ImportedDataState } from "../../packages/excalidraw/data/types";
import { STORAGE_KEYS } from "../app_constants";
export const initLocalStorage = (data: ImportedDataState) => {
if (data.elements) {
localStorage.setItem(
STORAGE_KEYS.LOCAL_STORAGE_ELEMENTS,
JSON.stringify(data.elements),
);
}
if (data.appState) {
localStorage.setItem(
STORAGE_KEYS.LOCAL_STORAGE_APP_STATE,
JSON.stringify(data.appState),
);
}
};
+5 -5
View File
@@ -1,6 +1,7 @@
{
"private": true,
"name": "excalidraw-monorepo",
"packageManager": "yarn@1.22.22",
"workspaces": [
"excalidraw-app",
"packages/excalidraw",
@@ -63,8 +64,7 @@
"build:app:docker": "yarn --cwd ./excalidraw-app build:app:docker",
"build:app": "yarn --cwd ./excalidraw-app build:app",
"build:version": "yarn --cwd ./excalidraw-app build:version",
"build": "yarn workspace @excalidraw/utils build:esm && yarn --cwd ./excalidraw-app build",
"clear:workspaces": "yarn workspace @excalidraw/utils run clear && yarn workspace @excalidraw/excalidraw run clear",
"build": "yarn --cwd ./excalidraw-app build",
"fix:code": "yarn test:code --fix",
"fix:other": "yarn prettier --write",
"fix": "yarn fix:other && yarn fix:code",
@@ -72,7 +72,7 @@
"locales-coverage:description": "node scripts/locales-coverage-description.js",
"prepare": "husky install",
"prettier": "prettier \"**/*.{css,scss,json,md,html,yml}\" --ignore-path=.eslintignore",
"start": "yarn clear:workspaces && yarn workspace @excalidraw/utils run build:esm && yarn --cwd ./excalidraw-app start & node scripts/watchUtils.js",
"start": "yarn --cwd ./excalidraw-app start",
"start:app:production": "npm run build && npx http-server build -a localhost -p 5001 -o",
"test:all": "yarn test:typecheck && yarn test:code && yarn test:other && yarn test:app --watch=false",
"test:app": "vitest",
@@ -80,8 +80,8 @@
"test:other": "yarn prettier --list-different",
"test:typecheck": "tsc",
"test:update": "yarn test:app --update --watch=false",
"test": "yarn clear:workspaces && yarn workspace @excalidraw/utils build:esm && yarn test:app",
"test:coverage": "yarn clear:workspaces && yarn workspace @excalidraw/utils build:esm && yarn test:app --coverage",
"test": "yarn test:app",
"test:coverage": "vitest --coverage",
"test:coverage:watch": "vitest --coverage --watch",
"test:ui": "yarn test --ui --coverage.enabled=true",
"autorelease": "node scripts/autorelease.js",
@@ -1,8 +1,8 @@
import {
BOUND_TEXT_PADDING,
ROUNDNESS,
VERTICAL_ALIGN,
TEXT_ALIGN,
VERTICAL_ALIGN,
} from "../constants";
import { isTextElement, newElement } from "../element";
import { mutateElement } from "../element/mutateElement";
@@ -142,6 +142,7 @@ export const actionBindText = register({
containerId: container.id,
verticalAlign: VERTICAL_ALIGN.MIDDLE,
textAlign: TEXT_ALIGN.CENTER,
autoResize: true,
});
mutateElement(container, {
boundElements: (container.boundElements || []).concat({
@@ -296,6 +297,7 @@ export const actionWrapTextInContainer = register({
verticalAlign: VERTICAL_ALIGN.MIDDLE,
boundElements: null,
textAlign: TEXT_ALIGN.CENTER,
autoResize: true,
},
false,
);
+10 -2
View File
@@ -65,7 +65,10 @@ export const createUndoAction: ActionCreator = (history, store) => ({
PanelComponent: ({ updateData, data }) => {
const { isUndoStackEmpty } = useEmitter<HistoryChangedEvent>(
history.onHistoryChangedEmitter,
new HistoryChangedEvent(),
new HistoryChangedEvent(
history.isUndoStackEmpty,
history.isRedoStackEmpty,
),
);
return (
@@ -76,6 +79,7 @@ export const createUndoAction: ActionCreator = (history, store) => ({
onClick={updateData}
size={data?.size || "medium"}
disabled={isUndoStackEmpty}
data-testid="button-undo"
/>
);
},
@@ -103,7 +107,10 @@ export const createRedoAction: ActionCreator = (history, store) => ({
PanelComponent: ({ updateData, data }) => {
const { isRedoStackEmpty } = useEmitter(
history.onHistoryChangedEmitter,
new HistoryChangedEvent(),
new HistoryChangedEvent(
history.isUndoStackEmpty,
history.isRedoStackEmpty,
),
);
return (
@@ -114,6 +121,7 @@ export const createRedoAction: ActionCreator = (history, store) => ({
onClick={updateData}
size={data?.size || "medium"}
disabled={isRedoStackEmpty}
data-testid="button-redo"
/>
);
},
@@ -167,7 +167,7 @@ const offsetElementAfterFontResize = (
prevElement: ExcalidrawTextElement,
nextElement: ExcalidrawTextElement,
) => {
if (isBoundToContainer(nextElement)) {
if (isBoundToContainer(nextElement) || !nextElement.autoResize) {
return nextElement;
}
return mutateElement(
@@ -0,0 +1,48 @@
import { isTextElement } from "../element";
import { newElementWith } from "../element/mutateElement";
import { measureText } from "../element/textElement";
import { getSelectedElements } from "../scene";
import { StoreAction } from "../store";
import type { AppClassProperties } from "../types";
import { getFontString } from "../utils";
import { register } from "./register";
export const actionTextAutoResize = register({
name: "autoResize",
label: "labels.autoResize",
icon: null,
trackEvent: { category: "element" },
predicate: (elements, appState, _: unknown, app: AppClassProperties) => {
const selectedElements = getSelectedElements(elements, appState);
return (
selectedElements.length === 1 &&
isTextElement(selectedElements[0]) &&
!selectedElements[0].autoResize
);
},
perform: (elements, appState, _, app) => {
const selectedElements = getSelectedElements(elements, appState);
return {
appState,
elements: elements.map((element) => {
if (element.id === selectedElements[0].id && isTextElement(element)) {
const metrics = measureText(
element.originalText,
getFontString(element),
element.lineHeight,
);
return newElementWith(element, {
autoResize: true,
width: metrics.width,
height: metrics.height,
text: element.originalText,
});
}
return element;
}),
storeAction: StoreAction.CAPTURE,
};
},
});
+2 -1
View File
@@ -134,7 +134,8 @@ export type ActionName =
| "setEmbeddableAsActiveTool"
| "createContainerFromText"
| "wrapTextInContainer"
| "commandPalette";
| "commandPalette"
| "autoResize";
export type PanelComponentProps = {
elements: readonly ExcalidrawElement[];
+17 -8
View File
@@ -1477,19 +1477,28 @@ export class ElementsChange implements Change<SceneElementsMap> {
return elements;
}
const previous = Array.from(elements.values());
const reordered = orderByFractionalIndex([...previous]);
const unordered = Array.from(elements.values());
const ordered = orderByFractionalIndex([...unordered]);
const moved = Delta.getRightDifferences(unordered, ordered, true).reduce(
(acc, arrayIndex) => {
const candidate = unordered[Number(arrayIndex)];
if (candidate && changed.has(candidate.id)) {
acc.set(candidate.id, candidate);
}
if (
!flags.containsVisibleDifference &&
Delta.isRightDifferent(previous, reordered, true)
) {
return acc;
},
new Map(),
);
if (!flags.containsVisibleDifference && moved.size) {
// we found a difference in order!
flags.containsVisibleDifference = true;
}
// let's synchronize all invalid indices of moved elements
return arrayToMap(syncMovedIndices(reordered, changed)) as typeof elements;
// synchronize all elements that were actually moved
// could fallback to synchronizing all invalid indices
return arrayToMap(syncMovedIndices(ordered, moved)) as typeof elements;
}
/**
@@ -468,6 +468,7 @@ export const ExitZenModeAction = ({
showExitZenModeBtn: boolean;
}) => (
<button
type="button"
className={clsx("disable-zen-mode", {
"disable-zen-mode--visible": showExitZenModeBtn,
})}
+115 -57
View File
@@ -88,6 +88,7 @@ import {
isIOS,
supportsResizeObserver,
DEFAULT_COLLISION_THRESHOLD,
DEFAULT_TEXT_ALIGN,
} from "../constants";
import type { ExportedElements } from "../data";
import { exportCanvas, loadFromBlob } from "../data";
@@ -114,7 +115,7 @@ import {
newTextElement,
newImageElement,
transformElements,
updateTextElement,
refreshTextDimensions,
redrawTextBoundingBox,
getElementAbsoluteCoords,
} from "../element";
@@ -224,7 +225,7 @@ import type {
} from "../scene/types";
import { getStateForZoom } from "../scene/zoom";
import { findShapeByKey } from "../shapes";
import type { GeometricShape } from "@excalidraw/utils";
import type { GeometricShape } from "../../utils/geometry/shape";
import {
getClosedCurveShape,
getCurveShape,
@@ -232,8 +233,8 @@ import {
getFreedrawShape,
getPolygonShape,
getSelectionBoxShape,
isPointInShape,
} from "@excalidraw/utils";
} from "../../utils/geometry/shape";
import { isPointInShape } from "../../utils/collision";
import type {
AppClassProperties,
AppProps,
@@ -331,6 +332,8 @@ import {
getLineHeightInPx,
isMeasureTextSupported,
isValidTextContainer,
measureText,
wrapText,
} from "../element/textElement";
import {
showHyperlinkTooltip,
@@ -367,7 +370,11 @@ import {
actionRemoveAllElementsFromFrame,
actionSelectAllElementsInFrame,
} from "../actions/actionFrame";
import { actionToggleHandTool, zoomToFit } from "../actions/actionCanvas";
import {
actionToggleEraserTool,
actionToggleHandTool,
zoomToFit,
} from "../actions/actionCanvas";
import { jotaiStore } from "../jotai";
import { activeConfirmDialogAtom } from "./ActiveConfirmDialog";
import { ImageSceneDataError } from "../errors";
@@ -403,7 +410,7 @@ import { Emitter } from "../emitter";
import { ElementCanvasButtons } from "../element/ElementCanvasButtons";
import type { MagicCacheData } from "../data/magic";
import { diagramToHTML } from "../data/magic";
import { exportToBlob } from "@excalidraw/utils";
import { exportToBlob } from "../../utils/export";
import { COLOR_PALETTE } from "../colors";
import { ElementCanvasButton } from "./MagicButton";
import { MagicIcon, copyIcon, fullscreenIcon } from "./icons";
@@ -429,6 +436,8 @@ import {
isPointHittingLinkIcon,
} from "./hyperlink/helpers";
import { getShortcutFromShortcutName } from "../actions/shortcuts";
import { actionTextAutoResize } from "../actions/actionTextAutoResize";
import { getVisibleSceneBounds } from "../element/bounds";
const AppContext = React.createContext<AppClassProperties>(null!);
const AppPropsContext = React.createContext<AppProps>(null!);
@@ -714,10 +723,7 @@ class App extends React.Component<AppProps, AppState> {
id: this.id,
};
this.fonts = new Fonts({
scene: this.scene,
onSceneUpdated: this.onSceneUpdated,
});
this.fonts = new Fonts({ scene: this.scene });
this.history = new History();
this.actionManager.registerAll(actions);
@@ -940,7 +946,7 @@ class App extends React.Component<AppProps, AppState> {
});
if (updated) {
this.scene.informMutation();
this.scene.triggerUpdate();
}
// GC
@@ -1452,10 +1458,10 @@ class App extends React.Component<AppProps, AppState> {
const selectedElements = this.scene.getSelectedElements(this.state);
const { renderTopRightUI, renderCustomStats } = this.props;
const versionNonce = this.scene.getVersionNonce();
const sceneNonce = this.scene.getSceneNonce();
const { elementsMap, visibleElements } =
this.renderer.getRenderableElements({
versionNonce,
sceneNonce,
zoom: this.state.zoom,
offsetLeft: this.state.offsetLeft,
offsetTop: this.state.offsetTop,
@@ -1673,7 +1679,7 @@ class App extends React.Component<AppProps, AppState> {
elementsMap={elementsMap}
allElementsMap={allElementsMap}
visibleElements={visibleElements}
versionNonce={versionNonce}
sceneNonce={sceneNonce}
selectionNonce={
this.state.selectionElement?.versionNonce
}
@@ -1695,7 +1701,7 @@ class App extends React.Component<AppProps, AppState> {
elementsMap={elementsMap}
visibleElements={visibleElements}
selectedElements={selectedElements}
versionNonce={versionNonce}
sceneNonce={sceneNonce}
selectionNonce={
this.state.selectionElement?.versionNonce
}
@@ -1819,7 +1825,7 @@ class App extends React.Component<AppProps, AppState> {
);
}
this.magicGenerations.set(frameElement.id, data);
this.onSceneUpdated();
this.triggerRender();
};
private getTextFromElements(elements: readonly ExcalidrawElement[]) {
@@ -2444,7 +2450,7 @@ class App extends React.Component<AppProps, AppState> {
this.history.record(increment.elementsChange, increment.appStateChange);
});
this.scene.addCallback(this.onSceneUpdated);
this.scene.onUpdate(this.triggerRender);
this.addEventListeners();
if (this.props.autoFocus && this.excalidrawContainerRef.current) {
@@ -2489,6 +2495,7 @@ class App extends React.Component<AppProps, AppState> {
public componentWillUnmount() {
this.renderer.destroy();
this.scene = new Scene();
this.fonts = new Fonts({ scene: this.scene });
this.renderer = new Renderer(this.scene);
this.files = {};
this.imageCache.clear();
@@ -2566,7 +2573,7 @@ class App extends React.Component<AppProps, AppState> {
addEventListener(document, EVENT.KEYUP, this.onKeyUp, { passive: true }),
addEventListener(
document,
EVENT.MOUSE_MOVE,
EVENT.POINTER_MOVE,
this.updateCurrentCursorPosition,
),
// rerender text elements on font load to fix #637 && #1553
@@ -2595,6 +2602,9 @@ class App extends React.Component<AppProps, AppState> {
),
addEventListener(window, EVENT.FOCUS, () => {
this.maybeCleanupAfterMissingPointerUp(null);
// browsers (chrome?) tend to free up memory a lot, which results
// in canvas context being cleared. Thus re-render on focus.
this.triggerRender(true);
}),
);
@@ -3339,32 +3349,53 @@ class App extends React.Component<AppProps, AppState> {
text,
fontSize: this.state.currentItemFontSize,
fontFamily: this.state.currentItemFontFamily,
textAlign: this.state.currentItemTextAlign,
textAlign: DEFAULT_TEXT_ALIGN,
verticalAlign: DEFAULT_VERTICAL_ALIGN,
locked: false,
};
const fontString = getFontString({
fontSize: textElementProps.fontSize,
fontFamily: textElementProps.fontFamily,
});
const lineHeight = getDefaultLineHeight(textElementProps.fontFamily);
const [x1, , x2] = getVisibleSceneBounds(this.state);
// long texts should not go beyond 800 pixels in width nor should it go below 200 px
const maxTextWidth = Math.max(Math.min((x2 - x1) * 0.5, 800), 200);
const LINE_GAP = 10;
let currentY = y;
const lines = isPlainPaste ? [text] : text.split("\n");
const textElements = lines.reduce(
(acc: ExcalidrawTextElement[], line, idx) => {
const text = line.trim();
const lineHeight = getDefaultLineHeight(textElementProps.fontFamily);
if (text.length) {
const originalText = line.trim();
if (originalText.length) {
const topLayerFrame = this.getTopLayerFrameAtSceneCoords({
x,
y: currentY,
});
let metrics = measureText(originalText, fontString, lineHeight);
const isTextWrapped = metrics.width > maxTextWidth;
const text = isTextWrapped
? wrapText(originalText, fontString, maxTextWidth)
: originalText;
metrics = isTextWrapped
? measureText(text, fontString, lineHeight)
: metrics;
const startX = x - metrics.width / 2;
const startY = currentY - metrics.height / 2;
const element = newTextElement({
...textElementProps,
x,
y: currentY,
x: startX,
y: startY,
text,
originalText,
lineHeight,
autoResize: !isTextWrapped,
frameId: topLayerFrame ? topLayerFrame.id : null,
});
acc.push(element);
@@ -3670,7 +3701,7 @@ class App extends React.Component<AppProps, AppState> {
ShapeCache.delete(element);
}
});
this.scene.informMutation();
this.scene.triggerUpdate();
this.addNewImagesToImageCache();
},
@@ -3681,7 +3712,7 @@ class App extends React.Component<AppProps, AppState> {
elements?: SceneData["elements"];
appState?: Pick<AppState, K> | null;
collaborators?: SceneData["collaborators"];
/** @default StoreAction.CAPTURE */
/** @default StoreAction.NONE */
storeAction?: SceneData["storeAction"];
}) => {
const nextElements = syncInvalidIndices(sceneData.elements ?? []);
@@ -3730,8 +3761,15 @@ class App extends React.Component<AppProps, AppState> {
},
);
private onSceneUpdated = () => {
this.setState({});
private triggerRender = (
/** force always re-renders canvas even if no change */
force?: boolean,
) => {
if (force === true) {
this.scene.triggerUpdate();
} else {
this.setState({});
}
};
/**
@@ -4300,25 +4338,22 @@ class App extends React.Component<AppProps, AppState> {
) {
const elementsMap = this.scene.getElementsMapIncludingDeleted();
const updateElement = (
text: string,
originalText: string,
isDeleted: boolean,
) => {
const updateElement = (nextOriginalText: string, isDeleted: boolean) => {
this.scene.replaceAllElements([
// Not sure why we include deleted elements as well hence using deleted elements map
...this.scene.getElementsIncludingDeleted().map((_element) => {
if (_element.id === element.id && isTextElement(_element)) {
return updateTextElement(
_element,
getContainerElement(_element, elementsMap),
elementsMap,
{
text,
isDeleted,
originalText,
},
);
return newElementWith(_element, {
originalText: nextOriginalText,
isDeleted: isDeleted ?? _element.isDeleted,
// returns (wrapped) text and new dimensions
...refreshTextDimensions(
_element,
getContainerElement(_element, elementsMap),
elementsMap,
nextOriginalText,
),
});
}
return _element;
}),
@@ -4341,15 +4376,15 @@ class App extends React.Component<AppProps, AppState> {
viewportY - this.state.offsetTop,
];
},
onChange: withBatchedUpdates((text) => {
updateElement(text, text, false);
onChange: withBatchedUpdates((nextOriginalText) => {
updateElement(nextOriginalText, false);
if (isNonDeletedElement(element)) {
updateBoundElements(element, elementsMap);
}
}),
onSubmit: withBatchedUpdates(({ text, viaKeyboard, originalText }) => {
const isDeleted = !text.trim();
updateElement(text, originalText, isDeleted);
onSubmit: withBatchedUpdates(({ viaKeyboard, nextOriginalText }) => {
const isDeleted = !nextOriginalText.trim();
updateElement(nextOriginalText, isDeleted);
// select the created text element only if submitting via keyboard
// (when submitting via click it should act as signal to deselect)
if (!isDeleted && viaKeyboard) {
@@ -4394,7 +4429,7 @@ class App extends React.Component<AppProps, AppState> {
// do an initial update to re-initialize element position since we were
// modifying element's x/y for sake of editor (case: syncing to remote)
updateElement(element.text, element.originalText, false);
updateElement(element.originalText, false);
}
private deselectElements() {
@@ -4836,6 +4871,7 @@ class App extends React.Component<AppProps, AppState> {
});
};
private debounceDoubleClickTimestamp: number = 0;
private handleCanvasDoubleClick = (
event: React.MouseEvent<HTMLCanvasElement>,
) => {
@@ -4844,6 +4880,23 @@ class App extends React.Component<AppProps, AppState> {
if (this.state.multiElement) {
return;
}
if (
this.state.penMode &&
this.lastPointerDownEvent?.pointerType === "touch" &&
this.state.activeTool.type !== "selection"
) {
const now = Date.now();
if (now - this.debounceDoubleClickTimestamp < 200) {
//handleCanvasDoubleClick click fires twice in case of touch.
//Once from the onTouchStart event handler, once from the double click event handler
return;
}
this.debounceDoubleClickTimestamp = now;
this.updateScene(actionToggleEraserTool.perform([] as any, this.state));
return;
}
// we should only be able to double click when mode is selection
if (this.state.activeTool.type !== "selection") {
return;
@@ -5101,8 +5154,11 @@ class App extends React.Component<AppProps, AppState> {
this.translateCanvas({
zoom: zoomState.zoom,
scrollX: zoomState.scrollX + deltaX / nextZoom,
scrollY: zoomState.scrollY + deltaY / nextZoom,
// 2x multiplier is just a magic number that makes this work correctly
// on touchscreen devices (note: if we get report that panning is slower/faster
// than actual movement, consider swapping with devicePixelRatio)
scrollX: zoomState.scrollX + 2 * (deltaX / nextZoom),
scrollY: zoomState.scrollY + 2 * (deltaY / nextZoom),
shouldCacheIgnoreZoom: true,
});
});
@@ -5577,7 +5633,7 @@ class App extends React.Component<AppProps, AppState> {
}
this.elementsPendingErasure = new Set(this.elementsPendingErasure);
this.onSceneUpdated();
this.triggerRender();
}
};
@@ -8069,7 +8125,7 @@ class App extends React.Component<AppProps, AppState> {
this.scene.getNonDeletedElementsMap(),
);
this.scene.informMutation();
this.scene.triggerUpdate();
}
}
}
@@ -8564,7 +8620,7 @@ class App extends React.Component<AppProps, AppState> {
private restoreReadyToEraseElements = () => {
this.elementsPendingErasure = new Set();
this.onSceneUpdated();
this.triggerRender();
};
private eraseElements = () => {
@@ -8978,7 +9034,7 @@ class App extends React.Component<AppProps, AppState> {
files,
);
if (updatedFiles.size) {
this.scene.informMutation();
this.scene.triggerUpdate();
}
}
};
@@ -9633,6 +9689,7 @@ class App extends React.Component<AppProps, AppState> {
}
return [
CONTEXT_MENU_SEPARATOR,
actionCut,
actionCopy,
actionPaste,
@@ -9645,6 +9702,7 @@ class App extends React.Component<AppProps, AppState> {
actionPasteStyles,
CONTEXT_MENU_SEPARATOR,
actionGroup,
actionTextAutoResize,
actionUnbindText,
actionBindText,
actionWrapTextInContainer,
@@ -28,6 +28,7 @@ export const ButtonIconSelect = <T extends Object>(
{props.options.map((option) =>
props.type === "button" ? (
<button
type="button"
key={option.text}
onClick={(event) => props.onClick(option.value, event)}
className={clsx({
@@ -22,7 +22,12 @@ export const CheckboxItem: React.FC<{
).focus();
}}
>
<button className="Checkbox-box" role="checkbox" aria-checked={checked}>
<button
type="button"
className="Checkbox-box"
role="checkbox"
aria-checked={checked}
>
{checkIcon}
</button>
<div className="Checkbox-label">{children}</div>
@@ -540,7 +540,7 @@ function CommandPaletteInner({
...command,
icon: command.icon || boltIcon,
order: command.order ?? getCategoryOrder(command.category),
haystack: `${deburr(command.label)} ${
haystack: `${deburr(command.label.toLocaleLowerCase())} ${
command.keywords?.join(" ") || ""
}`,
};
@@ -777,7 +777,9 @@ function CommandPaletteInner({
return;
}
const _query = deburr(commandSearch.replace(/[<>-_| ]/g, ""));
const _query = deburr(
commandSearch.toLocaleLowerCase().replace(/[<>_| -]/g, ""),
);
matchingCommands = fuzzy
.filter(_query, matchingCommands, {
extract: (command) => command.haystack,
@@ -105,6 +105,7 @@ export const ContextMenu = React.memo(
}}
>
<button
type="button"
className={clsx("context-menu-item", {
dangerous: actionName === "deleteSelectedElements",
checkmark: item.checked?.(appState),
@@ -123,6 +123,7 @@ export const Dialog = (props: DialogProps) => {
onClick={onClose}
title={t("buttons.close")}
aria-label={t("buttons.close")}
type="button"
>
{CloseIcon}
</button>
@@ -27,7 +27,11 @@ const FollowMode = ({
{userToFollow.username}
</span>
</div>
<button onClick={onDisconnect} className="follow-mode__disconnect-btn">
<button
type="button"
onClick={onDisconnect}
className="follow-mode__disconnect-btn"
>
{CloseIcon}
</button>
</div>
@@ -108,6 +108,7 @@ function Picker<T>({
<div className="picker-content" ref={rGallery}>
{options.map((option, i) => (
<button
type="button"
className={clsx("picker-option", {
active: value === option.value,
})}
@@ -171,6 +172,7 @@ export function IconPicker<T>({
<div>
<button
name={group}
type="button"
className={isActive ? "active" : ""}
aria-label={label}
onClick={() => setActive(!isActive)}
@@ -23,7 +23,7 @@ import { nativeFileSystemSupported } from "../data/filesystem";
import type { NonDeletedExcalidrawElement } from "../element/types";
import { t } from "../i18n";
import { isSomeElementSelected } from "../scene";
import { exportToCanvas } from "@excalidraw/utils";
import { exportToCanvas } from "../../utils/export";
import { copyIcon, downloadIcon, helpIcon } from "./icons";
import { Dialog } from "./Dialog";
+2 -1
View File
@@ -444,7 +444,7 @@ const LayerUI = ({
);
ShapeCache.delete(element);
}
Scene.getScene(selectedElements[0])?.informMutation();
Scene.getScene(selectedElements[0])?.triggerUpdate();
} else if (colorPickerType === "elementBackground") {
setAppState({
currentItemBackgroundColor: color,
@@ -555,6 +555,7 @@ const LayerUI = ({
)}
{appState.scrolledOutside && (
<button
type="button"
className="scroll-back-to-content"
onClick={() => {
setAppState((appState) => ({
@@ -194,6 +194,7 @@ export const MobileMenu = ({
!appState.openMenu &&
!appState.openSidebar && (
<button
type="button"
className="scroll-back-to-content"
onClick={() => {
setAppState((appState) => ({
@@ -65,6 +65,7 @@ const ChartPreviewBtn = (props: {
return (
<button
type="button"
className="ChartPreview"
onClick={() => {
if (chartElements) {
@@ -7,7 +7,7 @@ import { t } from "../i18n";
import Trans from "./Trans";
import type { LibraryItems, LibraryItem, UIAppState } from "../types";
import { exportToCanvas, exportToSvg } from "@excalidraw/utils";
import { exportToCanvas, exportToSvg } from "../../utils/export";
import {
EDITOR_LS_KEYS,
EXPORT_DATA_TYPES,
@@ -19,7 +19,7 @@ type InteractiveCanvasProps = {
elementsMap: RenderableElementsMap;
visibleElements: readonly NonDeletedExcalidrawElement[];
selectedElements: readonly NonDeletedExcalidrawElement[];
versionNonce: number | undefined;
sceneNonce: number | undefined;
selectionNonce: number | undefined;
scale: number;
appState: InteractiveCanvasAppState;
@@ -206,10 +206,10 @@ const areEqual = (
// This could be further optimised if needed, as we don't have to render interactive canvas on each scene mutation
if (
prevProps.selectionNonce !== nextProps.selectionNonce ||
prevProps.versionNonce !== nextProps.versionNonce ||
prevProps.sceneNonce !== nextProps.sceneNonce ||
prevProps.scale !== nextProps.scale ||
// we need to memoize on elementsMap because they may have renewed
// even if versionNonce didn't change (e.g. we filter elements out based
// even if sceneNonce didn't change (e.g. we filter elements out based
// on appState)
prevProps.elementsMap !== nextProps.elementsMap ||
prevProps.visibleElements !== nextProps.visibleElements ||
@@ -19,7 +19,7 @@ type StaticCanvasProps = {
elementsMap: RenderableElementsMap;
allElementsMap: NonDeletedSceneElementsMap;
visibleElements: readonly NonDeletedExcalidrawElement[];
versionNonce: number | undefined;
sceneNonce: number | undefined;
selectionNonce: number | undefined;
scale: number;
appState: StaticCanvasAppState;
@@ -112,10 +112,10 @@ const areEqual = (
nextProps: StaticCanvasProps,
) => {
if (
prevProps.versionNonce !== nextProps.versionNonce ||
prevProps.sceneNonce !== nextProps.sceneNonce ||
prevProps.scale !== nextProps.scale ||
// we need to memoize on elementsMap because they may have renewed
// even if versionNonce didn't change (e.g. we filter elements out based
// even if sceneNonce didn't change (e.g. we filter elements out based
// on appState)
prevProps.elementsMap !== nextProps.elementsMap ||
prevProps.visibleElements !== nextProps.visibleElements
+6 -2
View File
@@ -698,14 +698,18 @@ export const BringForwardIcon = createIcon(arrownNarrowUpJSX, tablerIconProps);
export const SendBackwardIcon = createIcon(arrownNarrowUpJSX, {
...tablerIconProps,
transform: "rotate(180)",
style: {
transform: "rotate(180deg)",
},
});
export const BringToFrontIcon = createIcon(arrowBarToTopJSX, tablerIconProps);
export const SendToBackIcon = createIcon(arrowBarToTopJSX, {
...tablerIconProps,
transform: "rotate(180)",
style: {
transform: "rotate(180deg)",
},
});
//
@@ -228,6 +228,7 @@ exports[`Test Transform > Test arrow bindings > should bind arrows to existing s
exports[`Test Transform > Test arrow bindings > should bind arrows to existing text elements when start / end provided with ids 1`] = `
{
"angle": 0,
"autoResize": true,
"backgroundColor": "transparent",
"boundElements": [
{
@@ -273,6 +274,7 @@ exports[`Test Transform > Test arrow bindings > should bind arrows to existing t
exports[`Test Transform > Test arrow bindings > should bind arrows to existing text elements when start / end provided with ids 2`] = `
{
"angle": 0,
"autoResize": true,
"backgroundColor": "transparent",
"boundElements": [
{
@@ -378,6 +380,7 @@ exports[`Test Transform > Test arrow bindings > should bind arrows to existing t
exports[`Test Transform > Test arrow bindings > should bind arrows to existing text elements when start / end provided with ids 4`] = `
{
"angle": 0,
"autoResize": true,
"backgroundColor": "transparent",
"boundElements": null,
"containerId": "id48",
@@ -478,6 +481,7 @@ exports[`Test Transform > Test arrow bindings > should bind arrows to shapes whe
exports[`Test Transform > Test arrow bindings > should bind arrows to shapes when start / end provided without ids 2`] = `
{
"angle": 0,
"autoResize": true,
"backgroundColor": "transparent",
"boundElements": null,
"containerId": "id37",
@@ -652,6 +656,7 @@ exports[`Test Transform > Test arrow bindings > should bind arrows to text when
exports[`Test Transform > Test arrow bindings > should bind arrows to text when start / end provided without ids 2`] = `
{
"angle": 0,
"autoResize": true,
"backgroundColor": "transparent",
"boundElements": null,
"containerId": "id41",
@@ -692,6 +697,7 @@ exports[`Test Transform > Test arrow bindings > should bind arrows to text when
exports[`Test Transform > Test arrow bindings > should bind arrows to text when start / end provided without ids 3`] = `
{
"angle": 0,
"autoResize": true,
"backgroundColor": "transparent",
"boundElements": [
{
@@ -737,6 +743,7 @@ exports[`Test Transform > Test arrow bindings > should bind arrows to text when
exports[`Test Transform > Test arrow bindings > should bind arrows to text when start / end provided without ids 4`] = `
{
"angle": 0,
"autoResize": true,
"backgroundColor": "transparent",
"boundElements": [
{
@@ -1194,6 +1201,7 @@ exports[`Test Transform > should transform regular shapes 6`] = `
exports[`Test Transform > should transform text element 1`] = `
{
"angle": 0,
"autoResize": true,
"backgroundColor": "transparent",
"boundElements": null,
"containerId": null,
@@ -1234,6 +1242,7 @@ exports[`Test Transform > should transform text element 1`] = `
exports[`Test Transform > should transform text element 2`] = `
{
"angle": 0,
"autoResize": true,
"backgroundColor": "transparent",
"boundElements": null,
"containerId": null,
@@ -1566,6 +1575,7 @@ exports[`Test Transform > should transform the elements correctly when linear el
exports[`Test Transform > should transform the elements correctly when linear elements have single point 7`] = `
{
"angle": 0,
"autoResize": true,
"backgroundColor": "transparent",
"boundElements": null,
"containerId": "B",
@@ -1608,6 +1618,7 @@ exports[`Test Transform > should transform the elements correctly when linear el
exports[`Test Transform > should transform the elements correctly when linear elements have single point 8`] = `
{
"angle": 0,
"autoResize": true,
"backgroundColor": "transparent",
"boundElements": null,
"containerId": "A",
@@ -1650,6 +1661,7 @@ exports[`Test Transform > should transform the elements correctly when linear el
exports[`Test Transform > should transform the elements correctly when linear elements have single point 9`] = `
{
"angle": 0,
"autoResize": true,
"backgroundColor": "transparent",
"boundElements": null,
"containerId": "Alice",
@@ -1692,6 +1704,7 @@ exports[`Test Transform > should transform the elements correctly when linear el
exports[`Test Transform > should transform the elements correctly when linear elements have single point 10`] = `
{
"angle": 0,
"autoResize": true,
"backgroundColor": "transparent",
"boundElements": null,
"containerId": "Bob",
@@ -1734,6 +1747,7 @@ exports[`Test Transform > should transform the elements correctly when linear el
exports[`Test Transform > should transform the elements correctly when linear elements have single point 11`] = `
{
"angle": 0,
"autoResize": true,
"backgroundColor": "transparent",
"boundElements": null,
"containerId": "Bob_Alice",
@@ -1774,6 +1788,7 @@ exports[`Test Transform > should transform the elements correctly when linear el
exports[`Test Transform > should transform the elements correctly when linear elements have single point 12`] = `
{
"angle": 0,
"autoResize": true,
"backgroundColor": "transparent",
"boundElements": null,
"containerId": "Bob_B",
@@ -2022,6 +2037,7 @@ exports[`Test Transform > should transform to labelled arrows when label provide
exports[`Test Transform > should transform to labelled arrows when label provided for arrows 5`] = `
{
"angle": 0,
"autoResize": true,
"backgroundColor": "transparent",
"boundElements": null,
"containerId": "id25",
@@ -2062,6 +2078,7 @@ exports[`Test Transform > should transform to labelled arrows when label provide
exports[`Test Transform > should transform to labelled arrows when label provided for arrows 6`] = `
{
"angle": 0,
"autoResize": true,
"backgroundColor": "transparent",
"boundElements": null,
"containerId": "id26",
@@ -2102,6 +2119,7 @@ exports[`Test Transform > should transform to labelled arrows when label provide
exports[`Test Transform > should transform to labelled arrows when label provided for arrows 7`] = `
{
"angle": 0,
"autoResize": true,
"backgroundColor": "transparent",
"boundElements": null,
"containerId": "id27",
@@ -2143,6 +2161,7 @@ LABELLED ARROW",
exports[`Test Transform > should transform to labelled arrows when label provided for arrows 8`] = `
{
"angle": 0,
"autoResize": true,
"backgroundColor": "transparent",
"boundElements": null,
"containerId": "id28",
@@ -2406,6 +2425,7 @@ exports[`Test Transform > should transform to text containers when label provide
exports[`Test Transform > should transform to text containers when label provided 7`] = `
{
"angle": 0,
"autoResize": true,
"backgroundColor": "transparent",
"boundElements": null,
"containerId": "id13",
@@ -2446,6 +2466,7 @@ exports[`Test Transform > should transform to text containers when label provide
exports[`Test Transform > should transform to text containers when label provided 8`] = `
{
"angle": 0,
"autoResize": true,
"backgroundColor": "transparent",
"boundElements": null,
"containerId": "id14",
@@ -2487,6 +2508,7 @@ CONTAINER",
exports[`Test Transform > should transform to text containers when label provided 9`] = `
{
"angle": 0,
"autoResize": true,
"backgroundColor": "transparent",
"boundElements": null,
"containerId": "id15",
@@ -2530,6 +2552,7 @@ CONTAINER",
exports[`Test Transform > should transform to text containers when label provided 10`] = `
{
"angle": 0,
"autoResize": true,
"backgroundColor": "transparent",
"boundElements": null,
"containerId": "id16",
@@ -2571,6 +2594,7 @@ TEXT CONTAINER",
exports[`Test Transform > should transform to text containers when label provided 11`] = `
{
"angle": 0,
"autoResize": true,
"backgroundColor": "transparent",
"boundElements": null,
"containerId": "id17",
@@ -2613,6 +2637,7 @@ CONTAINER",
exports[`Test Transform > should transform to text containers when label provided 12`] = `
{
"angle": 0,
"autoResize": true,
"backgroundColor": "transparent",
"boundElements": null,
"containerId": "id18",
+1 -1
View File
@@ -208,7 +208,7 @@ const restoreElement = (
verticalAlign: element.verticalAlign || DEFAULT_VERTICAL_ALIGN,
containerId: element.containerId ?? null,
originalText: element.originalText || text,
autoResize: element.autoResize ?? true,
lineHeight,
});
+1 -1
View File
@@ -26,7 +26,7 @@ import type {
import { getElementAbsoluteCoords } from "./bounds";
import type { AppClassProperties, AppState, Point } from "../types";
import { isPointOnShape } from "@excalidraw/utils";
import { isPointOnShape } from "../../utils/collision";
import { getElementAtPosition } from "../scene";
import {
isArrowElement,
+3 -6
View File
@@ -8,12 +8,9 @@ import type {
import { getElementBounds } from "./bounds";
import type { FrameNameBounds } from "../types";
import type { Polygon, GeometricShape } from "@excalidraw/utils";
import {
getPolygonShape,
isPointInShape,
isPointOnShape,
} from "@excalidraw/utils";
import type { Polygon, GeometricShape } from "../../utils/geometry/shape";
import { getPolygonShape } from "../../utils/geometry/shape";
import { isPointInShape, isPointOnShape } from "../../utils/collision";
import { isTransparent } from "../utils";
import {
hasBoundTextElement,
-1
View File
@@ -9,7 +9,6 @@ import { isLinearElementType } from "./typeChecks";
export {
newElement,
newTextElement,
updateTextElement,
refreshTextDimensions,
newLinearElement,
newImageElement,
+4 -2
View File
@@ -98,7 +98,7 @@ export const mutateElement = <TElement extends Mutable<ExcalidrawElement>>(
element.updated = getUpdatedTimestamp();
if (informMutation) {
Scene.getScene(element)?.informMutation();
Scene.getScene(element)?.triggerUpdate();
}
return element;
@@ -107,6 +107,8 @@ export const mutateElement = <TElement extends Mutable<ExcalidrawElement>>(
export const newElementWith = <TElement extends ExcalidrawElement>(
element: TElement,
updates: ElementUpdate<TElement>,
/** pass `true` to always regenerate */
force = false,
): TElement => {
let didChange = false;
for (const key in updates) {
@@ -123,7 +125,7 @@ export const newElementWith = <TElement extends ExcalidrawElement>(
}
}
if (!didChange) {
if (!didChange && !force) {
return element;
}
+35 -41
View File
@@ -215,6 +215,7 @@ const getTextElementPositionOffsets = (
export const newTextElement = (
opts: {
text: string;
originalText?: string;
fontSize?: number;
fontFamily?: FontFamilyValues;
textAlign?: TextAlign;
@@ -222,6 +223,7 @@ export const newTextElement = (
containerId?: ExcalidrawTextContainer["id"] | null;
lineHeight?: ExcalidrawTextElement["lineHeight"];
strokeWidth?: ExcalidrawTextElement["strokeWidth"];
autoResize?: ExcalidrawTextElement["autoResize"];
} & ElementConstructorOpts,
): NonDeleted<ExcalidrawTextElement> => {
const fontFamily = opts.fontFamily || DEFAULT_FONT_FAMILY;
@@ -240,24 +242,28 @@ export const newTextElement = (
metrics,
);
const textElement = newElementWith(
{
..._newElementBase<ExcalidrawTextElement>("text", opts),
text,
fontSize,
fontFamily,
textAlign,
verticalAlign,
x: opts.x - offsets.x,
y: opts.y - offsets.y,
width: metrics.width,
height: metrics.height,
containerId: opts.containerId || null,
originalText: text,
lineHeight,
},
const textElementProps: ExcalidrawTextElement = {
..._newElementBase<ExcalidrawTextElement>("text", opts),
text,
fontSize,
fontFamily,
textAlign,
verticalAlign,
x: opts.x - offsets.x,
y: opts.y - offsets.y,
width: metrics.width,
height: metrics.height,
containerId: opts.containerId || null,
originalText: opts.originalText ?? text,
autoResize: opts.autoResize ?? true,
lineHeight,
};
const textElement: ExcalidrawTextElement = newElementWith(
textElementProps,
{},
);
return textElement;
};
@@ -271,18 +277,25 @@ const getAdjustedDimensions = (
width: number;
height: number;
} => {
const { width: nextWidth, height: nextHeight } = measureText(
let { width: nextWidth, height: nextHeight } = measureText(
nextText,
getFontString(element),
element.lineHeight,
);
// wrapped text
if (!element.autoResize) {
nextWidth = element.width;
}
const { textAlign, verticalAlign } = element;
let x: number;
let y: number;
if (
textAlign === "center" &&
verticalAlign === VERTICAL_ALIGN.MIDDLE &&
!element.containerId
!element.containerId &&
element.autoResize
) {
const prevMetrics = measureText(
element.text,
@@ -343,38 +356,19 @@ export const refreshTextDimensions = (
if (textElement.isDeleted) {
return;
}
if (container) {
if (container || !textElement.autoResize) {
text = wrapText(
text,
getFontString(textElement),
getBoundTextMaxWidth(container, textElement),
container
? getBoundTextMaxWidth(container, textElement)
: textElement.width,
);
}
const dimensions = getAdjustedDimensions(textElement, elementsMap, text);
return { text, ...dimensions };
};
export const updateTextElement = (
textElement: ExcalidrawTextElement,
container: ExcalidrawTextContainer | null,
elementsMap: ElementsMap,
{
text,
isDeleted,
originalText,
}: {
text: string;
isDeleted?: boolean;
originalText: string;
},
): ExcalidrawTextElement => {
return newElementWith(textElement, {
originalText,
isDeleted: isDeleted ?? textElement.isDeleted,
...refreshTextDimensions(textElement, container, elementsMap, originalText),
});
};
export const newFreeDrawElement = (
opts: {
type: "freedraw";
+123 -22
View File
@@ -1,4 +1,8 @@
import { MIN_FONT_SIZE, SHIFT_LOCKING_ANGLE } from "../constants";
import {
BOUND_TEXT_PADDING,
MIN_FONT_SIZE,
SHIFT_LOCKING_ANGLE,
} from "../constants";
import { rescalePoints } from "../points";
import { rotate, centerPoint, rotatePoint } from "../math";
@@ -45,6 +49,9 @@ import {
handleBindTextResize,
getBoundTextMaxWidth,
getApproxMinLineHeight,
wrapText,
measureText,
getMinCharWidth,
} from "./textElement";
import { LinearElementEditor } from "./linearElementEditor";
import { isInGroup } from "../groups";
@@ -84,14 +91,9 @@ export const transformElements = (
shouldRotateWithDiscreteAngle,
);
updateBoundElements(element, elementsMap);
} else if (
isTextElement(element) &&
(transformHandleType === "nw" ||
transformHandleType === "ne" ||
transformHandleType === "sw" ||
transformHandleType === "se")
) {
} else if (isTextElement(element) && transformHandleType) {
resizeSingleTextElement(
originalElements,
element,
elementsMap,
transformHandleType,
@@ -223,9 +225,10 @@ const measureFontSizeFromWidth = (
};
const resizeSingleTextElement = (
originalElements: PointerDownState["originalElements"],
element: NonDeleted<ExcalidrawTextElement>,
elementsMap: ElementsMap,
transformHandleType: "nw" | "ne" | "sw" | "se",
transformHandleType: TransformHandleDirection,
shouldResizeFromCenter: boolean,
pointerX: number,
pointerY: number,
@@ -245,17 +248,19 @@ const resizeSingleTextElement = (
let scaleX = 0;
let scaleY = 0;
if (transformHandleType.includes("e")) {
scaleX = (rotatedX - x1) / (x2 - x1);
}
if (transformHandleType.includes("w")) {
scaleX = (x2 - rotatedX) / (x2 - x1);
}
if (transformHandleType.includes("n")) {
scaleY = (y2 - rotatedY) / (y2 - y1);
}
if (transformHandleType.includes("s")) {
scaleY = (rotatedY - y1) / (y2 - y1);
if (transformHandleType !== "e" && transformHandleType !== "w") {
if (transformHandleType.includes("e")) {
scaleX = (rotatedX - x1) / (x2 - x1);
}
if (transformHandleType.includes("w")) {
scaleX = (x2 - rotatedX) / (x2 - x1);
}
if (transformHandleType.includes("n")) {
scaleY = (y2 - rotatedY) / (y2 - y1);
}
if (transformHandleType.includes("s")) {
scaleY = (rotatedY - y1) / (y2 - y1);
}
}
const scale = Math.max(scaleX, scaleY);
@@ -318,6 +323,102 @@ const resizeSingleTextElement = (
y: nextY,
});
}
if (transformHandleType === "e" || transformHandleType === "w") {
const stateAtResizeStart = originalElements.get(element.id)!;
const [x1, y1, x2, y2] = getResizedElementAbsoluteCoords(
stateAtResizeStart,
stateAtResizeStart.width,
stateAtResizeStart.height,
true,
);
const startTopLeft: Point = [x1, y1];
const startBottomRight: Point = [x2, y2];
const startCenter: Point = centerPoint(startTopLeft, startBottomRight);
const rotatedPointer = rotatePoint(
[pointerX, pointerY],
startCenter,
-stateAtResizeStart.angle,
);
const [esx1, , esx2] = getResizedElementAbsoluteCoords(
element,
element.width,
element.height,
true,
);
const boundsCurrentWidth = esx2 - esx1;
const atStartBoundsWidth = startBottomRight[0] - startTopLeft[0];
const minWidth =
getMinCharWidth(getFontString(element)) + BOUND_TEXT_PADDING * 2;
let scaleX = atStartBoundsWidth / boundsCurrentWidth;
if (transformHandleType.includes("e")) {
scaleX = (rotatedPointer[0] - startTopLeft[0]) / boundsCurrentWidth;
}
if (transformHandleType.includes("w")) {
scaleX = (startBottomRight[0] - rotatedPointer[0]) / boundsCurrentWidth;
}
const newWidth =
element.width * scaleX < minWidth ? minWidth : element.width * scaleX;
const text = wrapText(
element.originalText,
getFontString(element),
Math.abs(newWidth),
);
const metrics = measureText(
text,
getFontString(element),
element.lineHeight,
);
const eleNewHeight = metrics.height;
const [newBoundsX1, newBoundsY1, newBoundsX2, newBoundsY2] =
getResizedElementAbsoluteCoords(
stateAtResizeStart,
newWidth,
eleNewHeight,
true,
);
const newBoundsWidth = newBoundsX2 - newBoundsX1;
const newBoundsHeight = newBoundsY2 - newBoundsY1;
let newTopLeft = [...startTopLeft] as [number, number];
if (["n", "w", "nw"].includes(transformHandleType)) {
newTopLeft = [
startBottomRight[0] - Math.abs(newBoundsWidth),
startTopLeft[1],
];
}
// adjust topLeft to new rotation point
const angle = stateAtResizeStart.angle;
const rotatedTopLeft = rotatePoint(newTopLeft, startCenter, angle);
const newCenter: Point = [
newTopLeft[0] + Math.abs(newBoundsWidth) / 2,
newTopLeft[1] + Math.abs(newBoundsHeight) / 2,
];
const rotatedNewCenter = rotatePoint(newCenter, startCenter, angle);
newTopLeft = rotatePoint(rotatedTopLeft, rotatedNewCenter, -angle);
const resizedElement: Partial<ExcalidrawTextElement> = {
width: Math.abs(newWidth),
height: Math.abs(metrics.height),
x: newTopLeft[0],
y: newTopLeft[1],
text,
autoResize: false,
};
mutateElement(element, resizedElement);
}
};
export const resizeSingleElement = (
@@ -876,7 +977,7 @@ export const resizeMultipleElements = (
}
}
Scene.getScene(elementsAndUpdates[0].element)?.informMutation();
Scene.getScene(elementsAndUpdates[0].element)?.triggerUpdate();
};
const rotateMultipleElements = (
@@ -938,7 +1039,7 @@ const rotateMultipleElements = (
}
});
Scene.getScene(elements[0])?.informMutation();
Scene.getScene(elements[0])?.triggerUpdate();
};
export const getResizeOffsetXY = (
+8 -8
View File
@@ -20,8 +20,12 @@ import type { AppState, Device, Zoom } from "../types";
import type { Bounds } from "./bounds";
import { getElementAbsoluteCoords } from "./bounds";
import { SIDE_RESIZING_THRESHOLD } from "../constants";
import { angleToDegrees, pointOnLine, pointRotate } from "@excalidraw/utils";
import type { Line, Point } from "@excalidraw/utils";
import {
angleToDegrees,
pointOnLine,
pointRotate,
} from "../../utils/geometry/geometry";
import type { Line, Point } from "../../utils/geometry/shape";
import { isLinearElement } from "./typeChecks";
const isInsideTransformHandle = (
@@ -83,12 +87,8 @@ export const resizeTest = (
elementsMap,
);
// Note that for a text element, when "resized" from the side
// we should make it wrap/unwrap
if (
element.type !== "text" &&
!(isLinearElement(element) && element.points.length <= 2)
) {
// do not resize from the sides for linear elements with only two points
if (!(isLinearElement(element) && element.points.length <= 2)) {
const SPACING = SIDE_RESIZING_THRESHOLD / zoom.value;
const sides = getSelectionBorders(
[x1 - SPACING, y1 - SPACING],
+10 -4
View File
@@ -48,7 +48,7 @@ export const redrawTextBoundingBox = (
textElement: ExcalidrawTextElement,
container: ExcalidrawElement | null,
elementsMap: ElementsMap,
informMutation: boolean = true,
informMutation = true,
) => {
let maxWidth = undefined;
const boundTextUpdates = {
@@ -62,21 +62,27 @@ export const redrawTextBoundingBox = (
boundTextUpdates.text = textElement.text;
if (container) {
maxWidth = getBoundTextMaxWidth(container, textElement);
if (container || !textElement.autoResize) {
maxWidth = container
? getBoundTextMaxWidth(container, textElement)
: textElement.width;
boundTextUpdates.text = wrapText(
textElement.originalText,
getFontString(textElement),
maxWidth,
);
}
const metrics = measureText(
boundTextUpdates.text,
getFontString(textElement),
textElement.lineHeight,
);
boundTextUpdates.width = metrics.width;
// Note: only update width for unwrapped text and bound texts (which always have autoResize set to true)
if (textElement.autoResize) {
boundTextUpdates.width = metrics.width;
}
boundTextUpdates.height = metrics.height;
if (container) {
+115 -15
View File
@@ -236,6 +236,117 @@ describe("textWysiwyg", () => {
});
});
describe("Test text wrapping", () => {
const { h } = window;
const dimensions = { height: 400, width: 800 };
beforeAll(() => {
mockBoundingClientRect(dimensions);
});
beforeEach(async () => {
await render(<Excalidraw handleKeyboardGlobally={true} />);
// @ts-ignore
h.app.refreshViewportBreakpoints();
// @ts-ignore
h.app.refreshEditorBreakpoints();
h.elements = [];
});
afterAll(() => {
restoreOriginalGetBoundingClientRect();
});
it("should keep width when editing a wrapped text", async () => {
const text = API.createElement({
type: "text",
text: "Excalidraw\nEditor",
});
h.elements = [text];
const prevWidth = text.width;
const prevHeight = text.height;
const prevText = text.text;
// text is wrapped
UI.resize(text, "e", [-20, 0]);
expect(text.width).not.toEqual(prevWidth);
expect(text.height).not.toEqual(prevHeight);
expect(text.text).not.toEqual(prevText);
expect(text.autoResize).toBe(false);
const wrappedWidth = text.width;
const wrappedHeight = text.height;
const wrappedText = text.text;
// edit text
UI.clickTool("selection");
mouse.doubleClickAt(text.x + text.width / 2, text.y + text.height / 2);
const editor = await getTextEditor(textEditorSelector);
expect(editor).not.toBe(null);
expect(h.state.editingElement?.id).toBe(text.id);
expect(h.elements.length).toBe(1);
const nextText = `${wrappedText} is great!`;
updateTextEditor(editor, nextText);
await new Promise((cb) => setTimeout(cb, 0));
editor.blur();
expect(h.elements[0].width).toEqual(wrappedWidth);
expect(h.elements[0].height).toBeGreaterThan(wrappedHeight);
// remove all texts and then add it back editing
updateTextEditor(editor, "");
await new Promise((cb) => setTimeout(cb, 0));
updateTextEditor(editor, nextText);
await new Promise((cb) => setTimeout(cb, 0));
editor.blur();
expect(h.elements[0].width).toEqual(wrappedWidth);
});
it("should restore original text after unwrapping a wrapped text", async () => {
const originalText = "Excalidraw\neditor\nis great!";
const text = API.createElement({
type: "text",
text: originalText,
});
h.elements = [text];
// wrap
UI.resize(text, "e", [-40, 0]);
// enter text editing mode
UI.clickTool("selection");
mouse.doubleClickAt(text.x + text.width / 2, text.y + text.height / 2);
const editor = await getTextEditor(textEditorSelector);
editor.blur();
// restore after unwrapping
UI.resize(text, "e", [40, 0]);
expect((h.elements[0] as ExcalidrawTextElement).text).toBe(originalText);
// wrap again and add a new line
UI.resize(text, "e", [-30, 0]);
const wrappedText = text.text;
UI.clickTool("selection");
mouse.doubleClickAt(text.x + text.width / 2, text.y + text.height / 2);
updateTextEditor(editor, `${wrappedText}\nA new line!`);
await new Promise((cb) => setTimeout(cb, 0));
editor.blur();
// remove the newly added line
UI.clickTool("selection");
mouse.doubleClickAt(text.x + text.width / 2, text.y + text.height / 2);
updateTextEditor(editor, wrappedText);
await new Promise((cb) => setTimeout(cb, 0));
editor.blur();
// unwrap
UI.resize(text, "e", [30, 0]);
// expect the text to be restored the same
expect((h.elements[0] as ExcalidrawTextElement).text).toBe(originalText);
});
});
describe("Test container-unbound text", () => {
const { h } = window;
const dimensions = { height: 400, width: 800 };
@@ -800,26 +911,15 @@ describe("textWysiwyg", () => {
mouse.down();
const text = h.elements[1] as ExcalidrawTextElementWithContainer;
let editor = await getTextEditor(textEditorSelector, true);
const editor = await getTextEditor(textEditorSelector, true);
await new Promise((r) => setTimeout(r, 0));
updateTextEditor(editor, "Hello World!");
editor.blur();
expect(text.fontFamily).toEqual(FONT_FAMILY.Virgil);
UI.clickTool("text");
mouse.clickAt(
rectangle.x + rectangle.width / 2,
rectangle.y + rectangle.height / 2,
);
mouse.down();
editor = await getTextEditor(textEditorSelector, true);
editor.select();
fireEvent.click(screen.getByTitle(/code/i));
await new Promise((r) => setTimeout(r, 0));
editor.blur();
expect(
(h.elements[1] as ExcalidrawTextElementWithContainer).fontFamily,
).toEqual(FONT_FAMILY.Cascadia);
@@ -964,7 +1064,7 @@ describe("textWysiwyg", () => {
expect([h.elements[1].x, h.elements[1].y]).toMatchInlineSnapshot(`
[
85,
4.999999999999986,
"5.00000",
]
`);
@@ -1009,8 +1109,8 @@ describe("textWysiwyg", () => {
UI.resize(rectangle, "ne", [rectangle.x + 100, rectangle.y - 100]);
expect([h.elements[1].x, h.elements[1].y]).toMatchInlineSnapshot(`
[
374.99999999999994,
-535.0000000000001,
"375.00000",
"-535.00000",
]
`);
});
+14 -15
View File
@@ -79,12 +79,14 @@ export const textWysiwyg = ({
app,
}: {
id: ExcalidrawElement["id"];
onChange?: (text: string) => void;
onSubmit: (data: {
text: string;
viaKeyboard: boolean;
originalText: string;
}) => void;
/**
* textWysiwyg only deals with `originalText`
*
* Note: `text`, which can be wrapped and therefore different from `originalText`,
* is derived from `originalText`
*/
onChange?: (nextOriginalText: string) => void;
onSubmit: (data: { viaKeyboard: boolean; nextOriginalText: string }) => void;
getViewportCoords: (x: number, y: number) => [number, number];
element: ExcalidrawTextElement;
canvas: HTMLCanvasElement;
@@ -129,11 +131,8 @@ export const textWysiwyg = ({
app.scene.getNonDeletedElementsMap(),
);
let maxWidth = updatedTextElement.width;
let maxHeight = updatedTextElement.height;
let textElementWidth = updatedTextElement.width;
// Set to element height by default since that's
// what is going to be used for unbounded text
const textElementHeight = updatedTextElement.height;
if (container && updatedTextElement.containerId) {
@@ -226,6 +225,8 @@ export const textWysiwyg = ({
if (!container) {
maxWidth = (appState.width - 8 - viewportX) / appState.zoom.value;
textElementWidth = Math.min(textElementWidth, maxWidth);
} else {
textElementWidth += 0.5;
}
// Make sure text editor height doesn't go beyond viewport
@@ -260,6 +261,7 @@ export const textWysiwyg = ({
if (isTestEnv()) {
editable.style.fontFamily = getFontFamilyString(updatedTextElement);
}
mutateElement(updatedTextElement, { x: coordX, y: coordY });
}
};
@@ -276,7 +278,7 @@ export const textWysiwyg = ({
let whiteSpace = "pre";
let wordBreak = "normal";
if (isBoundToContainer(element)) {
if (isBoundToContainer(element) || !element.autoResize) {
whiteSpace = "pre-wrap";
wordBreak = "break-word";
}
@@ -499,14 +501,12 @@ export const textWysiwyg = ({
if (!updateElement) {
return;
}
let text = editable.value;
const container = getContainerElement(
updateElement,
app.scene.getNonDeletedElementsMap(),
);
if (container) {
text = updateElement.text;
if (editable.value.trim()) {
const boundTextElementId = getBoundTextElementId(container);
if (!boundTextElementId || boundTextElementId !== element.id) {
@@ -538,9 +538,8 @@ export const textWysiwyg = ({
}
onSubmit({
text,
viaKeyboard: submittedViaKeyboard,
originalText: editable.value,
nextOriginalText: editable.value,
});
};
@@ -644,7 +643,7 @@ export const textWysiwyg = ({
};
// handle updates of textElement properties of editing element
const unbindUpdate = Scene.getScene(element)!.addCallback(() => {
const unbindUpdate = Scene.getScene(element)!.onUpdate(() => {
updateWysiwygStyle();
const isColorPickerActive = !!document.activeElement?.closest(
".color-picker-content",
@@ -9,7 +9,6 @@ import type { Bounds } from "./bounds";
import { getElementAbsoluteCoords } from "./bounds";
import { rotate } from "../math";
import type { Device, InteractiveCanvasAppState, Zoom } from "../types";
import { isTextElement } from ".";
import { isFrameLikeElement, isLinearElement } from "./typeChecks";
import {
DEFAULT_TRANSFORM_HANDLE_SPACING,
@@ -65,13 +64,6 @@ export const OMIT_SIDES_FOR_FRAME = {
rotation: true,
};
const OMIT_SIDES_FOR_TEXT_ELEMENT = {
e: true,
s: true,
n: true,
w: true,
};
const OMIT_SIDES_FOR_LINE_SLASH = {
e: true,
s: true,
@@ -290,8 +282,6 @@ export const getTransformHandles = (
omitSides = OMIT_SIDES_FOR_LINE_BACKSLASH;
}
}
} else if (isTextElement(element)) {
omitSides = OMIT_SIDES_FOR_TEXT_ELEMENT;
} else if (isFrameLikeElement(element)) {
omitSides = {
...omitSides,
+7
View File
@@ -193,6 +193,13 @@ export type ExcalidrawTextElement = _ExcalidrawElementBase &
verticalAlign: VerticalAlign;
containerId: ExcalidrawGenericElement["id"] | null;
originalText: string;
/**
* If `true` the width will fit the text. If `false`, the text will
* wrap to fit the width.
*
* @default true
*/
autoResize: boolean;
/**
* Unitless line height (aligned to W3C). To get line height in px, multiply
* with font size (using `getLineHeightInPx` helper).
+2 -18
View File
@@ -133,27 +133,11 @@ const getMovedIndicesGroups = (
let i = 0;
while (i < elements.length) {
if (
movedElements.has(elements[i].id) &&
!isValidFractionalIndex(
elements[i]?.index,
elements[i - 1]?.index,
elements[i + 1]?.index,
)
) {
if (movedElements.has(elements[i].id)) {
const indicesGroup = [i - 1, i]; // push the lower bound index as the first item
while (++i < elements.length) {
if (
!(
movedElements.has(elements[i].id) &&
!isValidFractionalIndex(
elements[i]?.index,
elements[i - 1]?.index,
elements[i + 1]?.index,
)
)
) {
if (!movedElements.has(elements[i].id)) {
break;
}
+1 -4
View File
@@ -27,10 +27,7 @@ import { getElementsWithinSelection, getSelectedElements } from "./scene";
import { getElementsInGroup, selectGroupsFromGivenElements } from "./groups";
import type { ExcalidrawElementsIncludingDeleted } from "./scene/Scene";
import { getElementLineSegments } from "./element/bounds";
import {
doLineSegmentsIntersect,
elementsOverlappingBBox,
} from "@excalidraw/utils";
import { doLineSegmentsIntersect, elementsOverlappingBBox } from "../utils/";
import { isFrameElement, isFrameLikeElement } from "./element/typeChecks";
import type { ReadonlySetLike } from "./utility-types";
@@ -2,7 +2,7 @@ import { atom, useAtom } from "jotai";
import { useEffect, useState } from "react";
import { COLOR_PALETTE } from "../colors";
import { jotaiScope } from "../jotai";
import { exportToSvg } from "@excalidraw/utils";
import { exportToSvg } from "../../utils/export";
import type { LibraryItem } from "../types";
export type SvgCache = Map<LibraryItem["id"], SVGSVGElement>;
+2 -2
View File
@@ -227,7 +227,7 @@ export {
exportToBlob,
exportToSvg,
exportToClipboard,
} from "@excalidraw/utils";
} from "../utils/export";
export { serializeAsJSON, serializeLibraryAsJSON } from "./data/json";
export {
@@ -283,4 +283,4 @@ export {
elementsOverlappingBBox,
isElementInsideBBox,
elementPartiallyOverlapsWithOrContainsBBox,
} from "@excalidraw/utils";
} from "../utils/withinBounds";
+3 -1
View File
@@ -148,7 +148,9 @@
"discordChat": "Discord chat",
"zoomToFitViewport": "Zoom to fit in viewport",
"zoomToFitSelection": "Zoom to fit selection",
"zoomToFit": "Zoom to fit all elements"
"zoomToFit": "Zoom to fit all elements",
"installPWA": "Install Excalidraw locally (PWA)",
"autoResize": "Enable text auto-resizing"
},
"library": {
"noItems": "No items added yet...",
+1 -3
View File
@@ -58,8 +58,7 @@
"dependencies": {
"@braintree/sanitize-url": "6.0.2",
"@excalidraw/laser-pointer": "1.3.1",
"@excalidraw/mermaid-to-excalidraw": "0.3.0",
"@excalidraw/utils": "*",
"@excalidraw/mermaid-to-excalidraw": "1.0.0",
"@excalidraw/random-username": "1.1.0",
"@radix-ui/react-popover": "1.0.3",
"@radix-ui/react-tabs": "1.0.2",
@@ -132,7 +131,6 @@
"pack": "yarn build:umd && yarn pack",
"start": "node ../../scripts/buildExample.mjs && vite",
"build:example": "node ../../scripts/buildExample.mjs",
"clear": "rm -rf dist",
"size": "yarn build:umd && size-limit"
}
}
+6 -22
View File
@@ -1,7 +1,5 @@
import { isTextElement, refreshTextDimensions } from "../element";
import { isTextElement } from "../element";
import { newElementWith } from "../element/mutateElement";
import { getContainerElement } from "../element/textElement";
import { isBoundToContainer } from "../element/typeChecks";
import type {
ExcalidrawElement,
ExcalidrawTextElement,
@@ -12,17 +10,9 @@ import { ShapeCache } from "./ShapeCache";
export class Fonts {
private scene: Scene;
private onSceneUpdated: () => void;
constructor({
scene,
onSceneUpdated,
}: {
scene: Scene;
onSceneUpdated: () => void;
}) {
constructor({ scene }: { scene: Scene }) {
this.scene = scene;
this.onSceneUpdated = onSceneUpdated;
}
// it's ok to track fonts across multiple instances only once, so let's use
@@ -57,22 +47,16 @@ export class Fonts {
let didUpdate = false;
this.scene.mapElements((element) => {
if (isTextElement(element) && !isBoundToContainer(element)) {
ShapeCache.delete(element);
if (isTextElement(element)) {
didUpdate = true;
return newElementWith(element, {
...refreshTextDimensions(
element,
getContainerElement(element, this.scene.getNonDeletedElementsMap()),
this.scene.getNonDeletedElementsMap(),
),
});
ShapeCache.delete(element);
return newElementWith(element, {}, true);
}
return element;
});
if (didUpdate) {
this.onSceneUpdated();
this.scene.triggerUpdate();
}
};
+3 -4
View File
@@ -107,9 +107,8 @@ export class Renderer {
width,
editingElement,
pendingImageElementId,
// unused but serves we cache on it to invalidate elements if they
// get mutated
versionNonce: _versionNonce,
// cache-invalidation nonce
sceneNonce: _sceneNonce,
}: {
zoom: AppState["zoom"];
offsetLeft: AppState["offsetLeft"];
@@ -120,7 +119,7 @@ export class Renderer {
width: AppState["width"];
editingElement: AppState["editingElement"];
pendingImageElementId: AppState["pendingImageElementId"];
versionNonce: ReturnType<InstanceType<typeof Scene>["getVersionNonce"]>;
sceneNonce: ReturnType<InstanceType<typeof Scene>["getSceneNonce"]>;
}) => {
const elements = this.scene.getNonDeletedElements();
+15 -9
View File
@@ -138,7 +138,17 @@ class Scene {
elements: null,
cache: new Map(),
};
private versionNonce: number | undefined;
/**
* Random integer regenerated each scene update.
*
* Does not relate to elements versions, it's only a renderer
* cache-invalidation nonce at the moment.
*/
private sceneNonce: number | undefined;
getSceneNonce() {
return this.sceneNonce;
}
getNonDeletedElementsMap() {
return this.nonDeletedElementsMap;
@@ -214,10 +224,6 @@ class Scene {
return (this.elementsMap.get(id) as T | undefined) || null;
}
getVersionNonce() {
return this.versionNonce;
}
getNonDeletedElement(
id: ExcalidrawElement["id"],
): NonDeleted<ExcalidrawElement> | null {
@@ -286,18 +292,18 @@ class Scene {
this.frames = nextFrameLikes;
this.nonDeletedFramesLikes = getNonDeletedElements(this.frames).elements;
this.informMutation();
this.triggerUpdate();
}
informMutation() {
this.versionNonce = randomInteger();
triggerUpdate() {
this.sceneNonce = randomInteger();
for (const callback of Array.from(this.callbacks)) {
callback();
}
}
addCallback(cb: SceneStateCallback): SceneStateCallbackRemover {
onUpdate(cb: SceneStateCallback): SceneStateCallbackRemover {
if (this.callbacks.has(cb)) {
throw new Error();
}
+1 -1
View File
@@ -339,7 +339,7 @@ export const exportToSvg = async (
assetPath =
window.EXCALIDRAW_ASSET_PATH ||
`https://unpkg.com/${import.meta.env.VITE_PKG_NAME}@${
import.meta.env.PKG_VERSION
import.meta.env.VITE_PKG_VERSION
}`;
if (assetPath?.startsWith("/")) {
+31 -5
View File
@@ -6,6 +6,7 @@ import { deepCopyElement } from "./element/newElement";
import type { OrderedExcalidrawElement } from "./element/types";
import { Emitter } from "./emitter";
import type { AppState, ObservedAppState } from "./types";
import type { ValueOf } from "./utility-types";
import { isShallowEqual } from "./utils";
// hidden non-enumerable property for runtime checks
@@ -35,16 +36,41 @@ const isObservedAppState = (
): appState is ObservedAppState =>
!!Reflect.get(appState, hiddenObservedAppStateProp);
export type StoreActionType = "capture" | "update" | "none";
export const StoreAction: {
[K in Uppercase<StoreActionType>]: StoreActionType;
} = {
export const StoreAction = {
/**
* Immediately undoable.
*
* Use for updates which should be captured.
* Should be used for most of the local updates.
*
* These updates will _immediately_ make it to the local undo / redo stacks.
*/
CAPTURE: "capture",
/**
* Never undoable.
*
* Use for updates which should never be recorded, such as remote updates
* or scene initialization.
*
* These updates will _never_ make it to the local undo / redo stacks.
*/
UPDATE: "update",
/**
* Eventually undoable.
*
* Use for updates which should not be captured immediately - likely
* exceptions which are part of some async multi-step process. Otherwise, all
* such updates would end up being captured with the next
* `StoreAction.CAPTURE` - triggered either by the next `updateScene`
* or internally by the editor.
*
* These updates will _eventually_ make it to the local undo / redo stacks.
*/
NONE: "none",
} as const;
export type StoreActionType = ValueOf<typeof StoreAction>;
/**
* Represent an increment to the Store.
*/
@@ -12,6 +12,7 @@ exports[`contextMenu element > right-clicking on a group should select whole gro
"collaborators": Map {},
"contextMenu": {
"items": [
"separator",
{
"icon": <svg
aria-hidden="true"
@@ -26,7 +27,7 @@ exports[`contextMenu element > right-clicking on a group should select whole gro
viewBox="0 0 24 24"
>
<g
strokeWidth={1.25}
strokeWidth={"1.25000"}
>
<path
d="M0 0h24v24H0z"
@@ -129,7 +130,7 @@ exports[`contextMenu element > right-clicking on a group should select whole gro
viewBox="0 0 24 24"
>
<g
strokeWidth={1.25}
strokeWidth={"1.25000"}
>
<path
d="M0 0h24v24H0z"
@@ -181,7 +182,7 @@ exports[`contextMenu element > right-clicking on a group should select whole gro
viewBox="0 0 24 24"
>
<g
strokeWidth={1.25}
strokeWidth={"1.25000"}
>
<path
d="M0 0h24v24H0z"
@@ -247,7 +248,7 @@ exports[`contextMenu element > right-clicking on a group should select whole gro
viewBox="0 0 24 24"
>
<g
strokeWidth={1.25}
strokeWidth={"1.25000"}
>
<path
d="M0 0h24v24H0z"
@@ -287,7 +288,7 @@ exports[`contextMenu element > right-clicking on a group should select whole gro
viewBox="0 0 24 24"
>
<g
strokeWidth={1.25}
strokeWidth={"1.25000"}
>
<path
d="M0 0h24v24H0z"
@@ -326,6 +327,16 @@ exports[`contextMenu element > right-clicking on a group should select whole gro
"category": "element",
},
},
{
"icon": null,
"label": "labels.autoResize",
"name": "autoResize",
"perform": [Function],
"predicate": [Function],
"trackEvent": {
"category": "element",
},
},
{
"label": "labels.unbindText",
"name": "unbindText",
@@ -387,11 +398,15 @@ exports[`contextMenu element > right-clicking on a group should select whole gro
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth={2}
transform="rotate(180)"
style={
{
"transform": "rotate(180deg)",
}
}
viewBox="0 0 24 24"
>
<g
strokeWidth={1.5}
strokeWidth={"1.50000"}
>
<path
d="M0 0h24v24H0z"
@@ -438,7 +453,7 @@ exports[`contextMenu element > right-clicking on a group should select whole gro
viewBox="0 0 24 24"
>
<g
strokeWidth={1.5}
strokeWidth={"1.50000"}
>
<path
d="M0 0h24v24H0z"
@@ -482,11 +497,15 @@ exports[`contextMenu element > right-clicking on a group should select whole gro
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth={2}
transform="rotate(180)"
style={
{
"transform": "rotate(180deg)",
}
}
viewBox="0 0 24 24"
>
<g
strokeWidth={1.5}
strokeWidth={"1.50000"}
>
<path
d="M0 0h24v24H0z"
@@ -535,7 +554,7 @@ exports[`contextMenu element > right-clicking on a group should select whole gro
viewBox="0 0 24 24"
>
<g
strokeWidth={1.5}
strokeWidth={"1.50000"}
>
<path
d="M0 0h24v24H0z"
@@ -584,7 +603,7 @@ exports[`contextMenu element > right-clicking on a group should select whole gro
viewBox="0 0 24 24"
>
<g
strokeWidth={1.25}
strokeWidth={"1.25000"}
>
<path
d="M0 0h24v24H0z"
@@ -624,7 +643,7 @@ exports[`contextMenu element > right-clicking on a group should select whole gro
viewBox="0 0 24 24"
>
<g
strokeWidth={1.25}
strokeWidth={"1.25000"}
>
<path
d="M0 0h24v24H0z"
@@ -4414,6 +4433,7 @@ exports[`contextMenu element > shows 'Group selection' in context menu for multi
"collaborators": Map {},
"contextMenu": {
"items": [
"separator",
{
"icon": <svg
aria-hidden="true"
@@ -4428,7 +4448,7 @@ exports[`contextMenu element > shows 'Group selection' in context menu for multi
viewBox="0 0 24 24"
>
<g
strokeWidth={1.25}
strokeWidth={"1.25000"}
>
<path
d="M0 0h24v24H0z"
@@ -4531,7 +4551,7 @@ exports[`contextMenu element > shows 'Group selection' in context menu for multi
viewBox="0 0 24 24"
>
<g
strokeWidth={1.25}
strokeWidth={"1.25000"}
>
<path
d="M0 0h24v24H0z"
@@ -4583,7 +4603,7 @@ exports[`contextMenu element > shows 'Group selection' in context menu for multi
viewBox="0 0 24 24"
>
<g
strokeWidth={1.25}
strokeWidth={"1.25000"}
>
<path
d="M0 0h24v24H0z"
@@ -4649,7 +4669,7 @@ exports[`contextMenu element > shows 'Group selection' in context menu for multi
viewBox="0 0 24 24"
>
<g
strokeWidth={1.25}
strokeWidth={"1.25000"}
>
<path
d="M0 0h24v24H0z"
@@ -4689,7 +4709,7 @@ exports[`contextMenu element > shows 'Group selection' in context menu for multi
viewBox="0 0 24 24"
>
<g
strokeWidth={1.25}
strokeWidth={"1.25000"}
>
<path
d="M0 0h24v24H0z"
@@ -4728,6 +4748,16 @@ exports[`contextMenu element > shows 'Group selection' in context menu for multi
"category": "element",
},
},
{
"icon": null,
"label": "labels.autoResize",
"name": "autoResize",
"perform": [Function],
"predicate": [Function],
"trackEvent": {
"category": "element",
},
},
{
"label": "labels.unbindText",
"name": "unbindText",
@@ -4789,11 +4819,15 @@ exports[`contextMenu element > shows 'Group selection' in context menu for multi
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth={2}
transform="rotate(180)"
style={
{
"transform": "rotate(180deg)",
}
}
viewBox="0 0 24 24"
>
<g
strokeWidth={1.5}
strokeWidth={"1.50000"}
>
<path
d="M0 0h24v24H0z"
@@ -4840,7 +4874,7 @@ exports[`contextMenu element > shows 'Group selection' in context menu for multi
viewBox="0 0 24 24"
>
<g
strokeWidth={1.5}
strokeWidth={"1.50000"}
>
<path
d="M0 0h24v24H0z"
@@ -4884,11 +4918,15 @@ exports[`contextMenu element > shows 'Group selection' in context menu for multi
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth={2}
transform="rotate(180)"
style={
{
"transform": "rotate(180deg)",
}
}
viewBox="0 0 24 24"
>
<g
strokeWidth={1.5}
strokeWidth={"1.50000"}
>
<path
d="M0 0h24v24H0z"
@@ -4937,7 +4975,7 @@ exports[`contextMenu element > shows 'Group selection' in context menu for multi
viewBox="0 0 24 24"
>
<g
strokeWidth={1.5}
strokeWidth={"1.50000"}
>
<path
d="M0 0h24v24H0z"
@@ -4986,7 +5024,7 @@ exports[`contextMenu element > shows 'Group selection' in context menu for multi
viewBox="0 0 24 24"
>
<g
strokeWidth={1.25}
strokeWidth={"1.25000"}
>
<path
d="M0 0h24v24H0z"
@@ -5026,7 +5064,7 @@ exports[`contextMenu element > shows 'Group selection' in context menu for multi
viewBox="0 0 24 24"
>
<g
strokeWidth={1.25}
strokeWidth={"1.25000"}
>
<path
d="M0 0h24v24H0z"
@@ -5514,6 +5552,7 @@ exports[`contextMenu element > shows 'Ungroup selection' in context menu for gro
"collaborators": Map {},
"contextMenu": {
"items": [
"separator",
{
"icon": <svg
aria-hidden="true"
@@ -5528,7 +5567,7 @@ exports[`contextMenu element > shows 'Ungroup selection' in context menu for gro
viewBox="0 0 24 24"
>
<g
strokeWidth={1.25}
strokeWidth={"1.25000"}
>
<path
d="M0 0h24v24H0z"
@@ -5631,7 +5670,7 @@ exports[`contextMenu element > shows 'Ungroup selection' in context menu for gro
viewBox="0 0 24 24"
>
<g
strokeWidth={1.25}
strokeWidth={"1.25000"}
>
<path
d="M0 0h24v24H0z"
@@ -5683,7 +5722,7 @@ exports[`contextMenu element > shows 'Ungroup selection' in context menu for gro
viewBox="0 0 24 24"
>
<g
strokeWidth={1.25}
strokeWidth={"1.25000"}
>
<path
d="M0 0h24v24H0z"
@@ -5749,7 +5788,7 @@ exports[`contextMenu element > shows 'Ungroup selection' in context menu for gro
viewBox="0 0 24 24"
>
<g
strokeWidth={1.25}
strokeWidth={"1.25000"}
>
<path
d="M0 0h24v24H0z"
@@ -5789,7 +5828,7 @@ exports[`contextMenu element > shows 'Ungroup selection' in context menu for gro
viewBox="0 0 24 24"
>
<g
strokeWidth={1.25}
strokeWidth={"1.25000"}
>
<path
d="M0 0h24v24H0z"
@@ -5828,6 +5867,16 @@ exports[`contextMenu element > shows 'Ungroup selection' in context menu for gro
"category": "element",
},
},
{
"icon": null,
"label": "labels.autoResize",
"name": "autoResize",
"perform": [Function],
"predicate": [Function],
"trackEvent": {
"category": "element",
},
},
{
"label": "labels.unbindText",
"name": "unbindText",
@@ -5889,11 +5938,15 @@ exports[`contextMenu element > shows 'Ungroup selection' in context menu for gro
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth={2}
transform="rotate(180)"
style={
{
"transform": "rotate(180deg)",
}
}
viewBox="0 0 24 24"
>
<g
strokeWidth={1.5}
strokeWidth={"1.50000"}
>
<path
d="M0 0h24v24H0z"
@@ -5940,7 +5993,7 @@ exports[`contextMenu element > shows 'Ungroup selection' in context menu for gro
viewBox="0 0 24 24"
>
<g
strokeWidth={1.5}
strokeWidth={"1.50000"}
>
<path
d="M0 0h24v24H0z"
@@ -5984,11 +6037,15 @@ exports[`contextMenu element > shows 'Ungroup selection' in context menu for gro
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth={2}
transform="rotate(180)"
style={
{
"transform": "rotate(180deg)",
}
}
viewBox="0 0 24 24"
>
<g
strokeWidth={1.5}
strokeWidth={"1.50000"}
>
<path
d="M0 0h24v24H0z"
@@ -6037,7 +6094,7 @@ exports[`contextMenu element > shows 'Ungroup selection' in context menu for gro
viewBox="0 0 24 24"
>
<g
strokeWidth={1.5}
strokeWidth={"1.50000"}
>
<path
d="M0 0h24v24H0z"
@@ -6086,7 +6143,7 @@ exports[`contextMenu element > shows 'Ungroup selection' in context menu for gro
viewBox="0 0 24 24"
>
<g
strokeWidth={1.25}
strokeWidth={"1.25000"}
>
<path
d="M0 0h24v24H0z"
@@ -6126,7 +6183,7 @@ exports[`contextMenu element > shows 'Ungroup selection' in context menu for gro
viewBox="0 0 24 24"
>
<g
strokeWidth={1.25}
strokeWidth={"1.25000"}
>
<path
d="M0 0h24v24H0z"
@@ -6684,7 +6741,7 @@ exports[`contextMenu element > shows context menu for canvas > [end of test] app
viewBox="0 0 24 24"
>
<g
strokeWidth={1.25}
strokeWidth={"1.25000"}
>
<path
d="M0 0h24v24H0z"
@@ -6736,7 +6793,7 @@ exports[`contextMenu element > shows context menu for canvas > [end of test] app
viewBox="0 0 24 24"
>
<g
strokeWidth={1.25}
strokeWidth={"1.25000"}
>
<path
d="M0 0h24v24H0z"
@@ -6948,7 +7005,7 @@ exports[`contextMenu element > shows context menu for canvas > [end of test] app
viewBox="0 0 24 24"
>
<g
strokeWidth={1.5}
strokeWidth={"1.50000"}
>
<path
d="M0 0h24v24H0z"
@@ -7004,7 +7061,7 @@ exports[`contextMenu element > shows context menu for canvas > [end of test] app
viewBox="0 0 24 24"
>
<g
strokeWidth={1.25}
strokeWidth={"1.25000"}
>
<path
d="M0 0h24v24H0z"
@@ -7048,7 +7105,7 @@ exports[`contextMenu element > shows context menu for canvas > [end of test] app
viewBox="0 0 24 24"
>
<g
strokeWidth={1.25}
strokeWidth={"1.25000"}
>
<path
d="M0 0h24v24H0z"
@@ -7101,7 +7158,7 @@ exports[`contextMenu element > shows context menu for canvas > [end of test] app
<g
fill="none"
stroke="currentColor"
strokeWidth={1.5}
strokeWidth={"1.50000"}
>
<path
d="M0 0h24v24H0z"
@@ -7143,7 +7200,7 @@ exports[`contextMenu element > shows context menu for canvas > [end of test] app
viewBox="0 0 24 24"
>
<g
strokeWidth={1.25}
strokeWidth={"1.25000"}
>
<path
d="M0 0h24v24H0z"
@@ -7321,6 +7378,7 @@ exports[`contextMenu element > shows context menu for element > [end of test] ap
"collaborators": Map {},
"contextMenu": {
"items": [
"separator",
{
"icon": <svg
aria-hidden="true"
@@ -7335,7 +7393,7 @@ exports[`contextMenu element > shows context menu for element > [end of test] ap
viewBox="0 0 24 24"
>
<g
strokeWidth={1.25}
strokeWidth={"1.25000"}
>
<path
d="M0 0h24v24H0z"
@@ -7438,7 +7496,7 @@ exports[`contextMenu element > shows context menu for element > [end of test] ap
viewBox="0 0 24 24"
>
<g
strokeWidth={1.25}
strokeWidth={"1.25000"}
>
<path
d="M0 0h24v24H0z"
@@ -7490,7 +7548,7 @@ exports[`contextMenu element > shows context menu for element > [end of test] ap
viewBox="0 0 24 24"
>
<g
strokeWidth={1.25}
strokeWidth={"1.25000"}
>
<path
d="M0 0h24v24H0z"
@@ -7556,7 +7614,7 @@ exports[`contextMenu element > shows context menu for element > [end of test] ap
viewBox="0 0 24 24"
>
<g
strokeWidth={1.25}
strokeWidth={"1.25000"}
>
<path
d="M0 0h24v24H0z"
@@ -7596,7 +7654,7 @@ exports[`contextMenu element > shows context menu for element > [end of test] ap
viewBox="0 0 24 24"
>
<g
strokeWidth={1.25}
strokeWidth={"1.25000"}
>
<path
d="M0 0h24v24H0z"
@@ -7635,6 +7693,16 @@ exports[`contextMenu element > shows context menu for element > [end of test] ap
"category": "element",
},
},
{
"icon": null,
"label": "labels.autoResize",
"name": "autoResize",
"perform": [Function],
"predicate": [Function],
"trackEvent": {
"category": "element",
},
},
{
"label": "labels.unbindText",
"name": "unbindText",
@@ -7696,11 +7764,15 @@ exports[`contextMenu element > shows context menu for element > [end of test] ap
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth={2}
transform="rotate(180)"
style={
{
"transform": "rotate(180deg)",
}
}
viewBox="0 0 24 24"
>
<g
strokeWidth={1.5}
strokeWidth={"1.50000"}
>
<path
d="M0 0h24v24H0z"
@@ -7747,7 +7819,7 @@ exports[`contextMenu element > shows context menu for element > [end of test] ap
viewBox="0 0 24 24"
>
<g
strokeWidth={1.5}
strokeWidth={"1.50000"}
>
<path
d="M0 0h24v24H0z"
@@ -7791,11 +7863,15 @@ exports[`contextMenu element > shows context menu for element > [end of test] ap
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth={2}
transform="rotate(180)"
style={
{
"transform": "rotate(180deg)",
}
}
viewBox="0 0 24 24"
>
<g
strokeWidth={1.5}
strokeWidth={"1.50000"}
>
<path
d="M0 0h24v24H0z"
@@ -7844,7 +7920,7 @@ exports[`contextMenu element > shows context menu for element > [end of test] ap
viewBox="0 0 24 24"
>
<g
strokeWidth={1.5}
strokeWidth={"1.50000"}
>
<path
d="M0 0h24v24H0z"
@@ -7893,7 +7969,7 @@ exports[`contextMenu element > shows context menu for element > [end of test] ap
viewBox="0 0 24 24"
>
<g
strokeWidth={1.25}
strokeWidth={"1.25000"}
>
<path
d="M0 0h24v24H0z"
@@ -7933,7 +8009,7 @@ exports[`contextMenu element > shows context menu for element > [end of test] ap
viewBox="0 0 24 24"
>
<g
strokeWidth={1.25}
strokeWidth={"1.25000"}
>
<path
d="M0 0h24v24H0z"
@@ -8188,6 +8264,7 @@ exports[`contextMenu element > shows context menu for element > [end of test] ap
"collaborators": Map {},
"contextMenu": {
"items": [
"separator",
{
"icon": <svg
aria-hidden="true"
@@ -8202,7 +8279,7 @@ exports[`contextMenu element > shows context menu for element > [end of test] ap
viewBox="0 0 24 24"
>
<g
strokeWidth={1.25}
strokeWidth={"1.25000"}
>
<path
d="M0 0h24v24H0z"
@@ -8305,7 +8382,7 @@ exports[`contextMenu element > shows context menu for element > [end of test] ap
viewBox="0 0 24 24"
>
<g
strokeWidth={1.25}
strokeWidth={"1.25000"}
>
<path
d="M0 0h24v24H0z"
@@ -8357,7 +8434,7 @@ exports[`contextMenu element > shows context menu for element > [end of test] ap
viewBox="0 0 24 24"
>
<g
strokeWidth={1.25}
strokeWidth={"1.25000"}
>
<path
d="M0 0h24v24H0z"
@@ -8423,7 +8500,7 @@ exports[`contextMenu element > shows context menu for element > [end of test] ap
viewBox="0 0 24 24"
>
<g
strokeWidth={1.25}
strokeWidth={"1.25000"}
>
<path
d="M0 0h24v24H0z"
@@ -8463,7 +8540,7 @@ exports[`contextMenu element > shows context menu for element > [end of test] ap
viewBox="0 0 24 24"
>
<g
strokeWidth={1.25}
strokeWidth={"1.25000"}
>
<path
d="M0 0h24v24H0z"
@@ -8502,6 +8579,16 @@ exports[`contextMenu element > shows context menu for element > [end of test] ap
"category": "element",
},
},
{
"icon": null,
"label": "labels.autoResize",
"name": "autoResize",
"perform": [Function],
"predicate": [Function],
"trackEvent": {
"category": "element",
},
},
{
"label": "labels.unbindText",
"name": "unbindText",
@@ -8563,11 +8650,15 @@ exports[`contextMenu element > shows context menu for element > [end of test] ap
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth={2}
transform="rotate(180)"
style={
{
"transform": "rotate(180deg)",
}
}
viewBox="0 0 24 24"
>
<g
strokeWidth={1.5}
strokeWidth={"1.50000"}
>
<path
d="M0 0h24v24H0z"
@@ -8614,7 +8705,7 @@ exports[`contextMenu element > shows context menu for element > [end of test] ap
viewBox="0 0 24 24"
>
<g
strokeWidth={1.5}
strokeWidth={"1.50000"}
>
<path
d="M0 0h24v24H0z"
@@ -8658,11 +8749,15 @@ exports[`contextMenu element > shows context menu for element > [end of test] ap
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth={2}
transform="rotate(180)"
style={
{
"transform": "rotate(180deg)",
}
}
viewBox="0 0 24 24"
>
<g
strokeWidth={1.5}
strokeWidth={"1.50000"}
>
<path
d="M0 0h24v24H0z"
@@ -8711,7 +8806,7 @@ exports[`contextMenu element > shows context menu for element > [end of test] ap
viewBox="0 0 24 24"
>
<g
strokeWidth={1.5}
strokeWidth={"1.50000"}
>
<path
d="M0 0h24v24H0z"
@@ -8760,7 +8855,7 @@ exports[`contextMenu element > shows context menu for element > [end of test] ap
viewBox="0 0 24 24"
>
<g
strokeWidth={1.25}
strokeWidth={"1.25000"}
>
<path
d="M0 0h24v24H0z"
@@ -8800,7 +8895,7 @@ exports[`contextMenu element > shows context menu for element > [end of test] ap
viewBox="0 0 24 24"
>
<g
strokeWidth={1.25}
strokeWidth={"1.25000"}
>
<path
d="M0 0h24v24H0z"
File diff suppressed because it is too large Load Diff
@@ -5,7 +5,7 @@ exports[`Test Linear Elements > Test bound text element > should match styles fo
class="excalidraw-wysiwyg"
data-type="wysiwyg"
dir="auto"
style="position: absolute; display: inline-block; min-height: 1em; backface-visibility: hidden; margin: 0px; padding: 0px; border: 0px; outline: 0; resize: none; background: transparent; overflow: hidden; z-index: var(--zIndex-wysiwyg); word-break: break-word; white-space: pre-wrap; overflow-wrap: break-word; box-sizing: content-box; width: 10px; height: 25px; left: 35px; top: 7.5px; transform: translate(0px, 0px) scale(1) rotate(0deg); text-align: center; vertical-align: middle; color: rgb(30, 30, 30); opacity: 1; filter: var(--theme-filter); max-height: 992.5px; font: Emoji 20px 20px; line-height: 1.25; font-family: Virgil, Segoe UI Emoji;"
style="position: absolute; display: inline-block; min-height: 1em; backface-visibility: hidden; margin: 0px; padding: 0px; border: 0px; outline: 0; resize: none; background: transparent; overflow: hidden; z-index: var(--zIndex-wysiwyg); word-break: break-word; white-space: pre-wrap; overflow-wrap: break-word; box-sizing: content-box; width: 10.5px; height: 25px; left: 35px; top: 7.5px; transform: translate(0px, 0px) scale(1) rotate(0deg); text-align: center; vertical-align: middle; color: rgb(30, 30, 30); opacity: 1; filter: var(--theme-filter); max-height: 992.5px; font: Emoji 20px 20px; line-height: 1.25; font-family: Virgil, Segoe UI Emoji;"
tabindex="0"
wrap="off"
/>
@@ -189,13 +189,13 @@ exports[`move element > rectangles with binding arrow 7`] = `
"endArrowhead": "arrow",
"endBinding": {
"elementId": "id1",
"focus": -0.46666666666666673,
"focus": "-0.46667",
"gap": 10,
},
"fillStyle": "solid",
"frameId": null,
"groupIds": [],
"height": 81.48231043525051,
"height": "81.48231",
"id": "id2",
"index": "a2",
"isDeleted": false,
@@ -210,7 +210,7 @@ exports[`move element > rectangles with binding arrow 7`] = `
],
[
81,
81.48231043525051,
"81.48231",
],
],
"roughness": 1,
@@ -221,7 +221,7 @@ exports[`move element > rectangles with binding arrow 7`] = `
"startArrowhead": null,
"startBinding": {
"elementId": "id0",
"focus": -0.6000000000000001,
"focus": "-0.60000",
"gap": 10,
},
"strokeColor": "#1e1e1e",
@@ -233,6 +233,6 @@ exports[`move element > rectangles with binding arrow 7`] = `
"versionNonce": 2066753033,
"width": 81,
"x": 110,
"y": 49.981789081137734,
"y": "49.98179",
}
`;
@@ -336,7 +336,7 @@ History {
"groupIds": [
"id5",
],
"index": "a1V",
"index": "a2",
},
"inserted": {
"groupIds": [],
@@ -348,9 +348,11 @@ History {
"groupIds": [
"id5",
],
"index": "a3",
},
"inserted": {
"groupIds": [],
"index": "a2",
},
},
},
@@ -719,7 +721,7 @@ History {
"groupIds": [
"id4",
],
"index": "a1V",
"index": "a2",
},
"inserted": {
"groupIds": [],
@@ -731,9 +733,11 @@ History {
"groupIds": [
"id4",
],
"index": "a3",
},
"inserted": {
"groupIds": [],
"index": "a2",
},
},
},
@@ -1856,7 +1860,7 @@ History {
"groupIds": [
"id5",
],
"index": "a1V",
"index": "a2",
},
"inserted": {
"groupIds": [],
@@ -1868,9 +1872,11 @@ History {
"groupIds": [
"id5",
],
"index": "a3",
},
"inserted": {
"groupIds": [],
"index": "a2",
},
},
},
@@ -10752,7 +10758,7 @@ exports[`regression tests > pinch-to-zoom works > [end of test] appState 1`] = `
"pendingImageElementId": null,
"previousSelectedElementIds": {},
"resizingElement": null,
"scrollX": -2.916666666666668,
"scrollX": "-6.25000",
"scrollY": 0,
"scrolledOutside": false,
"selectedElementIds": {},
@@ -12810,7 +12816,7 @@ History {
"id5",
"id3",
],
"index": "a1V",
"index": "a2",
},
"inserted": {
"groupIds": [
@@ -12825,11 +12831,13 @@ History {
"id5",
"id3",
],
"index": "a3",
},
"inserted": {
"groupIds": [
"id3",
],
"index": "a2",
},
},
},
@@ -13688,8 +13696,8 @@ exports[`regression tests > two-finger scroll works > [end of test] appState 1`]
"pendingImageElementId": null,
"previousSelectedElementIds": {},
"resizingElement": null,
"scrollX": 10,
"scrollY": -10,
"scrollX": 20,
"scrollY": "-18.53553",
"scrolledOutside": false,
"selectedElementIds": {},
"selectedElementsAreBeingDragged": false,
@@ -302,6 +302,7 @@ exports[`restoreElements > should restore line and draw elements correctly 2`] =
exports[`restoreElements > should restore text element correctly passing value for each attribute 1`] = `
{
"angle": 0,
"autoResize": true,
"backgroundColor": "transparent",
"boundElements": [],
"containerId": null,
@@ -315,7 +316,7 @@ exports[`restoreElements > should restore text element correctly passing value f
"id": "id-text01",
"index": "a0",
"isDeleted": false,
"lineHeight": 1.25,
"lineHeight": "1.25000",
"link": null,
"locked": false,
"opacity": 100,
@@ -337,13 +338,14 @@ exports[`restoreElements > should restore text element correctly passing value f
"verticalAlign": "middle",
"width": 100,
"x": -20,
"y": -8.75,
"y": "-8.75000",
}
`;
exports[`restoreElements > should restore text element correctly with unknown font family, null text and undefined alignment 1`] = `
{
"angle": 0,
"autoResize": true,
"backgroundColor": "transparent",
"boundElements": [],
"containerId": null,
@@ -357,7 +359,7 @@ exports[`restoreElements > should restore text element correctly with unknown fo
"id": "id-text01",
"index": "a0",
"isDeleted": true,
"lineHeight": 1.25,
"lineHeight": "1.25000",
"link": null,
"locked": false,
"opacity": 100,
+116 -91
View File
@@ -77,97 +77,6 @@ describe("sync invalid indices with array order", () => {
});
});
describe("should NOT sync index when it is already valid", () => {
testMovedIndicesSync({
elements: [
{ id: "A", index: "a2" },
{ id: "B", index: "a4" },
],
movedElements: ["A"],
expect: {
validInput: true,
unchangedElements: ["A", "B"],
},
});
testMovedIndicesSync({
elements: [
{ id: "A", index: "a2" },
{ id: "B", index: "a4" },
],
movedElements: ["B"],
expect: {
validInput: true,
unchangedElements: ["A", "B"],
},
});
});
describe("should NOT sync indices when they are already valid", () => {
{
testMovedIndicesSync({
elements: [
{ id: "A", index: "a1" },
{ id: "B", index: "a0" },
{ id: "C", index: "a2" },
],
movedElements: ["B", "C"],
expect: {
// this should not sync 'C'
unchangedElements: ["A", "C"],
},
});
testMovedIndicesSync({
elements: [
{ id: "A", index: "a1" },
{ id: "B", index: "a0" },
{ id: "C", index: "a2" },
],
movedElements: ["A", "B"],
expect: {
// but this should sync 'A' as it's invalid!
unchangedElements: ["C"],
},
});
}
testMovedIndicesSync({
elements: [
{ id: "A", index: "a0" },
{ id: "B", index: "a2" },
{ id: "C", index: "a1" },
{ id: "D", index: "a1" },
{ id: "E", index: "a2" },
],
movedElements: ["B", "D", "E"],
expect: {
// should not sync 'E'
unchangedElements: ["A", "C", "E"],
},
});
testMovedIndicesSync({
elements: [
{ id: "A" },
{ id: "B" },
{ id: "C", index: "a0" },
{ id: "D", index: "a2" },
{ id: "E" },
{ id: "F", index: "a3" },
{ id: "G" },
{ id: "H", index: "a1" },
{ id: "I", index: "a2" },
{ id: "J" },
],
movedElements: ["A", "B", "D", "E", "F", "G", "J"],
expect: {
// should not sync 'D' and 'F'
unchangedElements: ["C", "D", "F"],
},
});
});
describe("should sync when fractional index is not defined", () => {
testMovedIndicesSync({
elements: [{ id: "A" }],
@@ -384,6 +293,122 @@ describe("sync invalid indices with array order", () => {
});
});
describe("should sync all moved elements regardless of their validity", () => {
testMovedIndicesSync({
elements: [
{ id: "A", index: "a2" },
{ id: "B", index: "a4" },
],
movedElements: ["A"],
expect: {
validInput: true,
unchangedElements: ["B"],
},
});
testMovedIndicesSync({
elements: [
{ id: "A", index: "a2" },
{ id: "B", index: "a4" },
],
movedElements: ["B"],
expect: {
validInput: true,
unchangedElements: ["A"],
},
});
testMovedIndicesSync({
elements: [
{ id: "C", index: "a2" },
{ id: "D", index: "a3" },
{ id: "A", index: "a0" },
{ id: "B", index: "a1" },
],
movedElements: ["C", "D"],
expect: {
unchangedElements: ["A", "B"],
},
});
testMovedIndicesSync({
elements: [
{ id: "A", index: "a1" },
{ id: "B", index: "a2" },
{ id: "D", index: "a4" },
{ id: "C", index: "a3" },
{ id: "F", index: "a6" },
{ id: "E", index: "a5" },
{ id: "H", index: "a8" },
{ id: "G", index: "a7" },
{ id: "I", index: "a9" },
],
movedElements: ["D", "F", "H"],
expect: {
unchangedElements: ["A", "B", "C", "E", "G", "I"],
},
});
{
testMovedIndicesSync({
elements: [
{ id: "A", index: "a1" },
{ id: "B", index: "a0" },
{ id: "C", index: "a2" },
],
movedElements: ["B", "C"],
expect: {
unchangedElements: ["A"],
},
});
testMovedIndicesSync({
elements: [
{ id: "A", index: "a1" },
{ id: "B", index: "a0" },
{ id: "C", index: "a2" },
],
movedElements: ["A", "B"],
expect: {
unchangedElements: ["C"],
},
});
}
testMovedIndicesSync({
elements: [
{ id: "A", index: "a0" },
{ id: "B", index: "a2" },
{ id: "C", index: "a1" },
{ id: "D", index: "a1" },
{ id: "E", index: "a2" },
],
movedElements: ["B", "D", "E"],
expect: {
unchangedElements: ["A", "C"],
},
});
testMovedIndicesSync({
elements: [
{ id: "A" },
{ id: "B" },
{ id: "C", index: "a0" },
{ id: "D", index: "a2" },
{ id: "E" },
{ id: "F", index: "a3" },
{ id: "G" },
{ id: "H", index: "a1" },
{ id: "I", index: "a2" },
{ id: "J" },
],
movedElements: ["A", "B", "D", "E", "F", "G", "J"],
expect: {
unchangedElements: ["C", "H", "I"],
},
});
});
describe("should generate fractions for explicitly moved elements", () => {
describe("should generate a fraction between 'A' and 'C'", () => {
testMovedIndicesSync({
+125 -2
View File
@@ -10,8 +10,9 @@ import { Excalidraw } from "../index";
import { Keyboard, Pointer, UI } from "./helpers/ui";
import { API } from "./helpers/api";
import { getDefaultAppState } from "../appState";
import { fireEvent, waitFor } from "@testing-library/react";
import { fireEvent, queryByTestId, waitFor } from "@testing-library/react";
import { createUndoAction, createRedoAction } from "../actions/actionHistory";
import { actionToggleViewMode } from "../actions/actionToggleViewMode";
import { EXPORT_DATA_TYPES, MIME_TYPES } from "../constants";
import type { AppState, ExcalidrawImperativeAPI } from "../types";
import { arrayToMap, resolvablePromise } from "../utils";
@@ -49,7 +50,6 @@ const checkpoint = (name: string) => {
expect(renderStaticScene.mock.calls.length).toMatchSnapshot(
`[${name}] number of renders`,
);
// `scrolledOutside` does not appear to be stable between test runs
// `selectedLinearElemnt` includes `startBindingElement` containing seed and versionNonce
const {
@@ -1688,6 +1688,129 @@ describe("history", () => {
]);
});
});
it("should disable undo/redo buttons when stacks empty", async () => {
const { container } = await render(
<Excalidraw
initialData={{
elements: [API.createElement({ type: "rectangle", id: "A" })],
}}
/>,
);
const undoAction = createUndoAction(h.history, h.store);
const redoAction = createRedoAction(h.history, h.store);
await waitFor(() => {
expect(h.elements).toEqual([expect.objectContaining({ id: "A" })]);
expect(h.history.isUndoStackEmpty).toBeTruthy();
expect(h.history.isRedoStackEmpty).toBeTruthy();
});
const undoButton = queryByTestId(container, "button-undo");
const redoButton = queryByTestId(container, "button-redo");
expect(undoButton).toBeDisabled();
expect(redoButton).toBeDisabled();
const rectangle = UI.createElement("rectangle");
expect(h.elements).toEqual([
expect.objectContaining({ id: "A" }),
expect.objectContaining({ id: rectangle.id }),
]);
expect(h.history.isUndoStackEmpty).toBeFalsy();
expect(h.history.isRedoStackEmpty).toBeTruthy();
expect(undoButton).not.toBeDisabled();
expect(redoButton).toBeDisabled();
act(() => h.app.actionManager.executeAction(undoAction));
expect(h.history.isUndoStackEmpty).toBeTruthy();
expect(h.history.isRedoStackEmpty).toBeFalsy();
expect(undoButton).toBeDisabled();
expect(redoButton).not.toBeDisabled();
act(() => h.app.actionManager.executeAction(redoAction));
expect(h.history.isUndoStackEmpty).toBeFalsy();
expect(h.history.isRedoStackEmpty).toBeTruthy();
expect(undoButton).not.toBeDisabled();
expect(redoButton).toBeDisabled();
});
it("remounting undo/redo buttons should initialize undo/redo state correctly", async () => {
const { container } = await render(
<Excalidraw
initialData={{
elements: [API.createElement({ type: "rectangle", id: "A" })],
}}
/>,
);
const undoAction = createUndoAction(h.history, h.store);
await waitFor(() => {
expect(h.elements).toEqual([expect.objectContaining({ id: "A" })]);
expect(h.history.isUndoStackEmpty).toBeTruthy();
expect(h.history.isRedoStackEmpty).toBeTruthy();
});
expect(queryByTestId(container, "button-undo")).toBeDisabled();
expect(queryByTestId(container, "button-redo")).toBeDisabled();
// testing undo button
// -----------------------------------------------------------------------
const rectangle = UI.createElement("rectangle");
expect(h.elements).toEqual([
expect.objectContaining({ id: "A" }),
expect.objectContaining({ id: rectangle.id }),
]);
expect(h.history.isUndoStackEmpty).toBeFalsy();
expect(h.history.isRedoStackEmpty).toBeTruthy();
expect(queryByTestId(container, "button-undo")).not.toBeDisabled();
expect(queryByTestId(container, "button-redo")).toBeDisabled();
act(() => h.app.actionManager.executeAction(actionToggleViewMode));
expect(h.state.viewModeEnabled).toBe(true);
expect(queryByTestId(container, "button-undo")).toBeNull();
expect(queryByTestId(container, "button-redo")).toBeNull();
act(() => h.app.actionManager.executeAction(actionToggleViewMode));
expect(h.state.viewModeEnabled).toBe(false);
await waitFor(() => {
expect(queryByTestId(container, "button-undo")).not.toBeDisabled();
expect(queryByTestId(container, "button-redo")).toBeDisabled();
});
// testing redo button
// -----------------------------------------------------------------------
act(() => h.app.actionManager.executeAction(undoAction));
expect(h.history.isUndoStackEmpty).toBeTruthy();
expect(h.history.isRedoStackEmpty).toBeFalsy();
expect(queryByTestId(container, "button-undo")).toBeDisabled();
expect(queryByTestId(container, "button-redo")).not.toBeDisabled();
act(() => h.app.actionManager.executeAction(actionToggleViewMode));
expect(h.state.viewModeEnabled).toBe(true);
expect(queryByTestId(container, "button-undo")).toBeNull();
expect(queryByTestId(container, "button-redo")).toBeNull();
act(() => h.app.actionManager.executeAction(actionToggleViewMode));
expect(h.state.viewModeEnabled).toBe(false);
expect(h.history.isUndoStackEmpty).toBeTruthy();
expect(h.history.isRedoStackEmpty).toBeFalsy();
expect(queryByTestId(container, "button-undo")).toBeDisabled();
expect(queryByTestId(container, "button-redo")).not.toBeDisabled();
});
});
describe("multiplayer undo/redo", () => {
@@ -319,12 +319,12 @@ describe("Test Linear Elements", () => {
expect(midPointsWithRoundEdge).toMatchInlineSnapshot(`
[
[
55.9697848965255,
47.442326230998205,
"55.96978",
"47.44233",
],
[
76.08587175006699,
43.294165939653226,
"76.08587",
"43.29417",
],
]
`);
@@ -381,12 +381,12 @@ describe("Test Linear Elements", () => {
expect(newMidPoints).toMatchInlineSnapshot(`
[
[
105.96978489652551,
67.4423262309982,
"105.96978",
"67.44233",
],
[
126.08587175006699,
63.294165939653226,
"126.08587",
"63.29417",
],
]
`);
@@ -627,16 +627,16 @@ describe("Test Linear Elements", () => {
0,
],
[
85.96978489652551,
77.4423262309982,
"85.96978",
"77.44233",
],
[
70,
50,
],
[
106.08587175006699,
73.29416593965323,
"106.08587",
"73.29417",
],
[
40,
@@ -683,12 +683,12 @@ describe("Test Linear Elements", () => {
expect(newMidPoints).toMatchInlineSnapshot(`
[
[
31.884084517616053,
23.13275505472383,
"31.88408",
"23.13276",
],
[
77.74792546875662,
44.57840982272327,
"77.74793",
"44.57841",
],
]
`);
@@ -769,12 +769,12 @@ describe("Test Linear Elements", () => {
expect(newMidPoints).toMatchInlineSnapshot(`
[
[
55.9697848965255,
47.442326230998205,
"55.96978",
"47.44233",
],
[
76.08587175006699,
43.294165939653226,
"76.08587",
"43.29417",
],
]
`);
@@ -928,8 +928,8 @@ describe("Test Linear Elements", () => {
);
expect(position).toMatchInlineSnapshot(`
{
"x": 85.82201843191861,
"y": 75.63461309860818,
"x": "85.82202",
"y": "75.63461",
}
`);
});
@@ -972,10 +972,10 @@ describe("Test Linear Elements", () => {
]);
expect((h.elements[1] as ExcalidrawTextElementWithContainer).text)
.toMatchInlineSnapshot(`
"Online whiteboard
collaboration made
easy"
`);
"Online whiteboard
collaboration made
easy"
`);
});
it("should bind text to arrow when clicked on arrow and enter pressed", async () => {
@@ -1006,10 +1006,10 @@ describe("Test Linear Elements", () => {
]);
expect((h.elements[1] as ExcalidrawTextElementWithContainer).text)
.toMatchInlineSnapshot(`
"Online whiteboard
collaboration made
easy"
`);
"Online whiteboard
collaboration made
easy"
`);
});
it("should not bind text to line when double clicked", async () => {
@@ -1068,15 +1068,15 @@ describe("Test Linear Elements", () => {
true,
),
).toMatchInlineSnapshot(`
[
20,
20,
105,
80,
55.45893770831013,
45,
]
`);
[
20,
20,
105,
80,
"55.45894",
45,
]
`);
UI.resize(container, "ne", [300, 200]);
@@ -1084,7 +1084,7 @@ describe("Test Linear Elements", () => {
.toMatchInlineSnapshot(`
{
"height": 130,
"width": 366.11716195150507,
"width": "366.11716",
}
`);
@@ -1095,11 +1095,11 @@ describe("Test Linear Elements", () => {
arrayToMap(h.elements),
),
).toMatchInlineSnapshot(`
{
"x": 271.11716195150507,
"y": 45,
}
`);
{
"x": "271.11716",
"y": 45,
}
`);
expect((h.elements[1] as ExcalidrawTextElementWithContainer).text)
.toMatchInlineSnapshot(`
"Online whiteboard
@@ -1112,15 +1112,15 @@ describe("Test Linear Elements", () => {
true,
),
).toMatchInlineSnapshot(`
[
20,
35,
501.11716195150507,
95,
205.4589377083102,
52.5,
]
`);
[
20,
35,
"501.11716",
95,
"205.45894",
"52.50000",
]
`);
});
it("should resize and position the bound text correctly when 2 pointer linear element resized", () => {
+106
View File
@@ -426,6 +426,112 @@ describe("text element", () => {
expect(text.fontSize).toBe(fontSize);
});
});
// text can be resized from sides
it("can be resized from e", async () => {
const text = UI.createElement("text");
await UI.editText(text, "Excalidraw\nEditor");
const width = text.width;
const height = text.height;
UI.resize(text, "e", [30, 0]);
expect(text.width).toBe(width + 30);
expect(text.height).toBe(height);
UI.resize(text, "e", [-30, 0]);
expect(text.width).toBe(width);
expect(text.height).toBe(height);
});
it("can be resized from w", async () => {
const text = UI.createElement("text");
await UI.editText(text, "Excalidraw\nEditor");
const width = text.width;
const height = text.height;
UI.resize(text, "w", [-50, 0]);
expect(text.width).toBe(width + 50);
expect(text.height).toBe(height);
UI.resize(text, "w", [50, 0]);
expect(text.width).toBe(width);
expect(text.height).toBe(height);
});
it("wraps when width is narrower than texts inside", async () => {
const text = UI.createElement("text");
await UI.editText(text, "Excalidraw\nEditor");
const prevWidth = text.width;
const prevHeight = text.height;
const prevText = text.text;
UI.resize(text, "w", [50, 0]);
expect(text.width).toBe(prevWidth - 50);
expect(text.height).toBeGreaterThan(prevHeight);
expect(text.text).not.toEqual(prevText);
expect(text.autoResize).toBe(false);
UI.resize(text, "w", [-50, 0]);
expect(text.width).toBe(prevWidth);
expect(text.height).toEqual(prevHeight);
expect(text.text).toEqual(prevText);
expect(text.autoResize).toBe(false);
UI.resize(text, "e", [-20, 0]);
expect(text.width).toBe(prevWidth - 20);
expect(text.height).toBeGreaterThan(prevHeight);
expect(text.text).not.toEqual(prevText);
expect(text.autoResize).toBe(false);
UI.resize(text, "e", [20, 0]);
expect(text.width).toBe(prevWidth);
expect(text.height).toEqual(prevHeight);
expect(text.text).toEqual(prevText);
expect(text.autoResize).toBe(false);
});
it("keeps properties when wrapped", async () => {
const text = UI.createElement("text");
await UI.editText(text, "Excalidraw\nEditor");
const alignment = text.textAlign;
const fontSize = text.fontSize;
const fontFamily = text.fontFamily;
UI.resize(text, "e", [-60, 0]);
expect(text.textAlign).toBe(alignment);
expect(text.fontSize).toBe(fontSize);
expect(text.fontFamily).toBe(fontFamily);
expect(text.autoResize).toBe(false);
UI.resize(text, "e", [60, 0]);
expect(text.textAlign).toBe(alignment);
expect(text.fontSize).toBe(fontSize);
expect(text.fontFamily).toBe(fontFamily);
expect(text.autoResize).toBe(false);
});
it("has a minimum width when wrapped", async () => {
const text = UI.createElement("text");
await UI.editText(text, "Excalidraw\nEditor");
const width = text.width;
UI.resize(text, "e", [-width, 0]);
expect(text.width).not.toEqual(0);
UI.resize(text, "e", [width - text.width, 0]);
expect(text.width).toEqual(width);
expect(text.autoResize).toBe(false);
UI.resize(text, "w", [width, 0]);
expect(text.width).not.toEqual(0);
UI.resize(text, "w", [text.width - width, 0]);
expect(text.width).toEqual(width);
expect(text.autoResize).toBe(false);
});
});
describe("image element", () => {
@@ -6,7 +6,7 @@ import {
rectangleWithLinkFixture,
} from "../fixtures/elementFixture";
import { API } from "../helpers/api";
import { exportToCanvas, exportToSvg } from "../../../utils/src/export";
import { exportToCanvas, exportToSvg } from "../../../utils";
import { FRAME_STYLE } from "../../constants";
import { prepareElementsForExport } from "../../data";
@@ -250,6 +250,7 @@ describe("exporting frames", () => {
exportPadding: 0,
exportingFrame: frame,
});
// frame itself isn't exported
expect(svg.querySelector(`[data-id="${frame.id}"]`)).toBeNull();
// frame child is exported
+17
View File
@@ -242,3 +242,20 @@ expect.extend({
};
},
});
/**
* Serializer for IEE754 float pointing numbers to avoid random failures due to tiny precision differences
*/
expect.addSnapshotSerializer({
serialize(val, config, indentation, depth, refs, printer) {
return printer(val.toFixed(5), config, indentation, depth, refs);
},
test(val) {
return (
typeof val === "number" &&
Number.isFinite(val) &&
!Number.isNaN(val) &&
!Number.isInteger(val)
);
},
});
+1 -2
View File
@@ -1,6 +1,5 @@
{
"extends": "../../tsconfig",
"exclude": ["**/*.test.*", "tests", "types", "examples", "packages/**/dist/**", "dist"],
"exclude": ["**/*.test.*", "tests", "types", "examples", "dist"],
"compilerOptions": {
"target": "ESNext",
"strict": true,
@@ -1,5 +1,5 @@
import type { Bounds } from "../../excalidraw/element/bounds";
import type { Point } from "../../excalidraw/types";
import type { Bounds } from "../excalidraw/element/bounds";
import type { Point } from "../excalidraw/types";
export type LineSegment = [Point, Point];
@@ -1,9 +1,9 @@
import * as utils from "../src/export";
import { diagramFactory } from "../../excalidraw/tests/fixtures/diagramFixture";
import * as utils from ".";
import { diagramFactory } from "../excalidraw/tests/fixtures/diagramFixture";
import { vi } from "vitest";
import * as mockedSceneExportUtils from "../../excalidraw/scene/export";
import * as mockedSceneExportUtils from "../excalidraw/scene/export";
import { MIME_TYPES } from "../../excalidraw/constants";
import { MIME_TYPES } from "../excalidraw/constants";
const exportToSvgSpy = vi.spyOn(mockedSceneExportUtils, "exportToSvg");
@@ -1,23 +1,23 @@
import {
exportToCanvas as _exportToCanvas,
exportToSvg as _exportToSvg,
} from "../../excalidraw/scene/export";
import { getDefaultAppState } from "../../excalidraw/appState";
import type { AppState, BinaryFiles } from "../../excalidraw/types";
} from "../excalidraw/scene/export";
import { getDefaultAppState } from "../excalidraw/appState";
import type { AppState, BinaryFiles } from "../excalidraw/types";
import type {
ExcalidrawElement,
ExcalidrawFrameLikeElement,
NonDeleted,
} from "../../excalidraw/element/types";
import { restore } from "../../excalidraw/data/restore";
import { MIME_TYPES } from "../../excalidraw/constants";
import { encodePngMetadata } from "../../excalidraw/data/image";
import { serializeAsJSON } from "../../excalidraw/data/json";
} from "../excalidraw/element/types";
import { restore } from "../excalidraw/data/restore";
import { MIME_TYPES } from "../excalidraw/constants";
import { encodePngMetadata } from "../excalidraw/data/image";
import { serializeAsJSON } from "../excalidraw/data/json";
import {
copyBlobToClipboardAsPng,
copyTextToSystemClipboard,
copyToClipboard,
} from "../../excalidraw/clipboard";
} from "../excalidraw/clipboard";
export { MIME_TYPES };
@@ -170,8 +170,6 @@ export const exportToSvg = async ({
exportPadding?: number;
renderEmbeddables?: boolean;
}): Promise<SVGSVGElement> => {
console.info("Watching exportToSVG :)");
const { elements: restoredElements, appState: restoredAppState } = restore(
{ elements, appState },
null,
@@ -11,15 +11,8 @@ import {
pointOnPolyline,
pointRightofLine,
pointRotate,
} from "../src/geometry/geometry";
import type {
Curve,
Ellipse,
Line,
Point,
Polygon,
Polyline,
} from "../src/geometry/shape";
} from "./geometry";
import type { Curve, Ellipse, Line, Point, Polygon, Polyline } from "./shape";
describe("point and line", () => {
const line: Line = [
@@ -1,4 +1,4 @@
import { distance2d } from "../../../excalidraw/math";
import { distance2d } from "../../excalidraw/math";
import type {
Point,
Line,
@@ -12,7 +12,7 @@
* to pure shapes
*/
import { getElementAbsoluteCoords } from "../../../excalidraw/element";
import { getElementAbsoluteCoords } from "../../excalidraw/element";
import type {
ElementsMap,
ExcalidrawDiamondElement,
@@ -27,7 +27,7 @@ import type {
ExcalidrawRectangleElement,
ExcalidrawSelectionElement,
ExcalidrawTextElement,
} from "../../../excalidraw/element/types";
} from "../../excalidraw/element/types";
import { angleToDegrees, close, pointAdd, pointRotate } from "./geometry";
import { pointsOnBezierCurves } from "points-on-curve";
import type { Drawable, Op } from "roughjs/bin/core";
+3 -6
View File
@@ -1,6 +1,3 @@
export * from "./src/export";
export * from "./src/withinBounds";
export * from "./src/bbox";
export * from "./src/collision";
export * from "./src/geometry/shape";
export * from "./src/geometry/geometry";
export * from "./export";
export * from "./withinBounds";
export * from "./bbox";
-3
View File
@@ -64,7 +64,6 @@
"@babel/preset-typescript": "7.18.6",
"babel-loader": "8.2.5",
"babel-plugin-transform-class-properties": "6.24.1",
"chokidar": "3.6.0",
"cross-env": "7.0.3",
"css-loader": "6.7.1",
"file-loader": "6.2.0",
@@ -80,10 +79,8 @@
"scripts": {
"gen:types": "rm -rf types && tsc",
"build:umd": "cross-env NODE_ENV=production webpack --config webpack.prod.config.js",
"build:src": "rm -rf dist && node ../../scripts/buildUtils.js",
"build:esm": "rm -rf dist && node ../../scripts/buildUtils.js && yarn gen:types",
"build:umd:withAnalyzer": "cross-env NODE_ENV=production ANALYZER=true webpack --config webpack.prod.config.js",
"clear": "rm -rf dist",
"pack": "yarn build:umd && yarn pack"
}
}
@@ -1,102 +0,0 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
exports[`exportToSvg > with default arguments 1`] = `
{
"activeEmbeddable": null,
"activeTool": {
"customType": null,
"lastActiveTool": null,
"locked": false,
"type": "selection",
},
"collaborators": Map {},
"contextMenu": null,
"currentChartType": "bar",
"currentItemBackgroundColor": "transparent",
"currentItemEndArrowhead": "arrow",
"currentItemFillStyle": "solid",
"currentItemFontFamily": 1,
"currentItemFontSize": 20,
"currentItemOpacity": 100,
"currentItemRoughness": 1,
"currentItemRoundness": "round",
"currentItemStartArrowhead": null,
"currentItemStrokeColor": "#1e1e1e",
"currentItemStrokeStyle": "solid",
"currentItemStrokeWidth": 2,
"currentItemTextAlign": "left",
"cursorButton": "up",
"defaultSidebarDockedPreference": false,
"draggingElement": null,
"editingElement": null,
"editingFrame": null,
"editingGroupId": null,
"editingLinearElement": null,
"elementsToHighlight": null,
"errorMessage": null,
"exportBackground": true,
"exportEmbedScene": false,
"exportPadding": undefined,
"exportScale": 1,
"exportWithDarkMode": false,
"fileHandle": null,
"followedBy": Set {},
"frameRendering": {
"clip": true,
"enabled": true,
"name": true,
"outline": true,
},
"frameToHighlight": null,
"gridSize": null,
"isBindingEnabled": true,
"isLoading": false,
"isResizing": false,
"isRotating": false,
"lastPointerDownWith": "mouse",
"multiElement": null,
"name": "name",
"objectsSnapModeEnabled": false,
"openDialog": null,
"openMenu": null,
"openPopup": null,
"openSidebar": null,
"originSnapOffset": {
"x": 0,
"y": 0,
},
"pasteDialog": {
"data": null,
"shown": false,
},
"penDetected": false,
"penMode": false,
"pendingImageElementId": null,
"previousSelectedElementIds": {},
"resizingElement": null,
"scrollX": 0,
"scrollY": 0,
"scrolledOutside": false,
"selectedElementIds": {},
"selectedElementsAreBeingDragged": false,
"selectedGroupIds": {},
"selectedLinearElement": null,
"selectionElement": null,
"shouldCacheIgnoreZoom": false,
"showHyperlinkPopup": false,
"showStats": false,
"showWelcomeScreen": false,
"snapLines": [],
"startBoundElement": null,
"suggestedBindings": [],
"theme": "light",
"toast": null,
"userToFollow": null,
"viewBackgroundColor": "#ffffff",
"viewModeEnabled": false,
"zenModeEnabled": false,
"zoom": {
"value": 1,
},
}
`;
+3 -3
View File
@@ -1,16 +1,16 @@
{
"extends": "../../tsconfig",
"exclude": ["**/*.test.*", "**/tests/*", "types", "examples", "packages/**/dist/**", "dist"],
"compilerOptions": {
"target": "ESNext",
"strict": true,
"outDir": "dist",
"skipLibCheck": true,
"declaration": true,
"emitDeclarationOnly": true,
"allowSyntheticDefaultImports": true,
"module": "ESNext",
"moduleResolution": "Node",
"resolveJsonModule": true,
"jsx": "react-jsx"
}
},
"exclude": ["**/*.test.*", "**/tests/*", "types", "dist"]
}
@@ -1,10 +1,7 @@
import {
decodePngMetadata,
decodeSvgMetadata,
} from "../../excalidraw/data/image";
import type { ImportedDataState } from "../../excalidraw/data/types";
import * as utils from "../index";
import { API } from "../../excalidraw/tests/helpers/api";
import { decodePngMetadata, decodeSvgMetadata } from "../excalidraw/data/image";
import type { ImportedDataState } from "../excalidraw/data/types";
import * as utils from "../utils";
import { API } from "../excalidraw/tests/helpers/api";
// NOTE this test file is using the actual API, unmocked. Hence splitting it
// from the other test file, because I couldn't figure out how to test
@@ -1,10 +1,10 @@
import type { Bounds } from "../../excalidraw/element/bounds";
import { API } from "../../excalidraw/tests/helpers/api";
import type { Bounds } from "../excalidraw/element/bounds";
import { API } from "../excalidraw/tests/helpers/api";
import {
elementPartiallyOverlapsWithOrContainsBBox,
elementsOverlappingBBox,
isElementInsideBBox,
} from "../src/withinBounds";
} from "./withinBounds";
const makeElement = (x: number, y: number, width: number, height: number) =>
API.createElement({
@@ -3,19 +3,19 @@ import type {
ExcalidrawFreeDrawElement,
ExcalidrawLinearElement,
NonDeletedExcalidrawElement,
} from "../../excalidraw/element/types";
} from "../excalidraw/element/types";
import {
isArrowElement,
isExcalidrawElement,
isFreeDrawElement,
isLinearElement,
isTextElement,
} from "../../excalidraw/element/typeChecks";
import { isValueInRange, rotatePoint } from "../../excalidraw/math";
import type { Point } from "../../excalidraw/types";
import type { Bounds } from "../../excalidraw/element/bounds";
import { getElementBounds } from "../../excalidraw/element/bounds";
import { arrayToMap } from "../../excalidraw/utils";
} from "../excalidraw/element/typeChecks";
import { isValueInRange, rotatePoint } from "../excalidraw/math";
import type { Point } from "../excalidraw/types";
import type { Bounds } from "../excalidraw/element/bounds";
import { getElementBounds } from "../excalidraw/element/bounds";
import { arrayToMap } from "../excalidraw/utils";
type Element = NonDeletedExcalidrawElement;
type Elements = readonly NonDeletedExcalidrawElement[];

Before

Width:  |  Height:  |  Size: 72 KiB

After

Width:  |  Height:  |  Size: 72 KiB

+1 -2
View File
@@ -4,7 +4,7 @@ import { execSync } from "child_process";
const createDevBuild = async () => {
return await esbuild.build({
entryPoints: ["../../examples/excalidraw/with-script-in-browser/index.tsx"],
entryPoints: ["../../examples/excalidraw/with-script-in-browser/index.tsx"],
outfile:
"../../examples/excalidraw/with-script-in-browser/public/bundle.js",
define: {
@@ -13,7 +13,6 @@ const createDevBuild = async () => {
bundle: true,
format: "esm",
plugins: [sassPlugin()],
external: ["@excalidraw/utils"],
loader: {
".woff2": "dataurl",
".html": "copy",
-2
View File
@@ -53,7 +53,6 @@ const browserConfig = {
".woff2": "copy",
".ttf": "copy",
},
external: ["@excalidraw/utils"],
};
const createESMBrowserBuild = async () => {
// Development unminified build with source maps
@@ -108,7 +107,6 @@ const rawConfig = {
".json": "copy",
},
packages: "external",
external: ["@excalidraw/utils"],
};
const createESMRawBuild = async () => {
-4
View File
@@ -8,7 +8,6 @@ const browserConfig = {
bundle: true,
format: "esm",
plugins: [sassPlugin()],
external: ["@excalidraw/utils"],
};
// Will be used later for treeshaking
@@ -81,7 +80,6 @@ const rawConfig = {
format: "esm",
packages: "external",
plugins: [sassPlugin()],
external: ["@excalidraw/utils"],
};
// const BASE_PATH = `${path.resolve(`${__dirname}/..`)}`;
@@ -121,7 +119,5 @@ const createESMRawBuild = async () => {
fs.writeFileSync("meta-raw-prod.json", JSON.stringify(rawProd.metafile));
};
console.info("BUILDING UTILS STARTED");
createESMRawBuild();
createESMBrowserBuild();
console.info("BUILDING UTILS COMPLETE");
-16
View File
@@ -1,16 +0,0 @@
const chokidar = require("chokidar");
const path = require("path");
const { execSync } = require("child_process");
const BASE_PATH = `${path.resolve(`${__dirname}/..`)}`;
const utilsDir = `${BASE_PATH}/packages/utils/src`;
// One-liner for current directory
chokidar.watch(utilsDir).on("change", (event) => {
console.info("Watching", event);
try {
execSync(`yarn workspace @excalidraw/utils run build:src`);
} catch (err) {
console.error("Error when building workspace", err);
}
console.info("BUILD DONE");
});
+1 -1
View File
@@ -17,5 +17,5 @@
"jsx": "react-jsx"
},
"include": ["packages", "excalidraw-app"],
"exclude": ["packages/excalidraw/types", "examples", "packages/**/tests/**", "packages/**/dist/**", "excalidraw-app/tests"]
"exclude": ["packages/excalidraw/types", "examples"]
}
+61 -129
View File
@@ -234,11 +234,6 @@
resolved "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.24.0.tgz#945681931a52f15ce879fd5b86ce2dae6d3d7f2a"
integrity sha512-9cUznXMG0+FxRuJfvL82QlTqIzhVW9sL0KjMPHhAOOvpQGL8QtdxnBKILjBqxlHyliz0yCa1G903ZXI/FuHy2w==
"@babel/helper-plugin-utils@^7.24.5":
version "7.24.5"
resolved "https://registry.yarnpkg.com/@babel/helper-plugin-utils/-/helper-plugin-utils-7.24.5.tgz#a924607dd254a65695e5bd209b98b902b3b2f11a"
integrity sha512-xjNLDopRzW2o6ba0gKbkZq5YWEBaK3PCyTOY1K2P/O07LGMhMqlMXPxwN4S5/RhWuCobT8z0jrlKGlYmeR1OhQ==
"@babel/helper-remap-async-to-generator@^7.18.6", "@babel/helper-remap-async-to-generator@^7.18.9", "@babel/helper-remap-async-to-generator@^7.22.20":
version "7.22.20"
resolved "https://registry.npmjs.org/@babel/helper-remap-async-to-generator/-/helper-remap-async-to-generator-7.22.20.tgz#7b68e1cb4fa964d2996fd063723fb48eca8498e0"
@@ -278,14 +273,7 @@
dependencies:
"@babel/types" "^7.22.5"
"@babel/helper-split-export-declaration@^7.24.5":
version "7.24.5"
resolved "https://registry.yarnpkg.com/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.24.5.tgz#b9a67f06a46b0b339323617c8c6213b9055a78b6"
integrity sha512-5CHncttXohrHk8GWOFCcCl4oRD9fKosWlIRgWm4ql9VYioKm52Mk2xsmoohvm7f3JoiLSM5ZgJuRaf5QZZYd3Q==
dependencies:
"@babel/types" "^7.24.5"
"@babel/helper-string-parser@^7.23.4", "@babel/helper-string-parser@^7.24.1":
"@babel/helper-string-parser@^7.23.4":
version "7.24.1"
resolved "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.24.1.tgz#f99c36d3593db9540705d0739a1f10b5e20c696e"
integrity sha512-2ofRCjnnA9y+wk8b9IAREroeUP02KHp431N2mhKniy2yKIDKpbrHv9eXwm8cBeWQYcJmzv5qKCu65P47eCF7CQ==
@@ -295,11 +283,6 @@
resolved "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.20.tgz#c4ae002c61d2879e724581d96665583dbc1dc0e0"
integrity sha512-Y4OZ+ytlatR8AI+8KZfKuL5urKp7qey08ha31L8b3BwewJAoJamTzyvxPR/5D+KkdJCGPq/+8TukHBlY10FX9A==
"@babel/helper-validator-identifier@^7.24.5":
version "7.24.5"
resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.24.5.tgz#918b1a7fa23056603506370089bd990d8720db62"
integrity sha512-3q93SSKX2TWCG30M2G2kwaKeTYgEUp5Snjuj8qm729SObL6nbtUldAi37qbxkD5gg3xnBio+f9nqpSepGZMvxA==
"@babel/helper-validator-option@^7.18.6", "@babel/helper-validator-option@^7.23.5":
version "7.23.5"
resolved "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.23.5.tgz#907a3fbd4523426285365d1206c423c4c5520307"
@@ -717,20 +700,13 @@
dependencies:
"@babel/helper-plugin-utils" "^7.24.0"
"@babel/plugin-transform-block-scoping@^7.18.6", "@babel/plugin-transform-block-scoping@^7.24.4":
"@babel/plugin-transform-block-scoping@^7.18.6", "@babel/plugin-transform-block-scoping@^7.18.9", "@babel/plugin-transform-block-scoping@^7.24.4":
version "7.24.4"
resolved "https://registry.npmjs.org/@babel/plugin-transform-block-scoping/-/plugin-transform-block-scoping-7.24.4.tgz#28f5c010b66fbb8ccdeef853bef1935c434d7012"
integrity sha512-nIFUZIpGKDf9O9ttyRXpHFpKC+X3Y5mtshZONuEUYBomAKoM4y029Jr+uB1bHGPhNmK8YXHevDtKDOLmtRrp6g==
dependencies:
"@babel/helper-plugin-utils" "^7.24.0"
"@babel/plugin-transform-block-scoping@^7.18.9":
version "7.24.5"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-block-scoping/-/plugin-transform-block-scoping-7.24.5.tgz#89574191397f85661d6f748d4b89ee4d9ee69a2a"
integrity sha512-sMfBc3OxghjC95BkYrYocHL3NaOplrcaunblzwXhGmlPwpmfsxr4vK+mBBt49r+S240vahmv+kUxkeKgs+haCw==
dependencies:
"@babel/helper-plugin-utils" "^7.24.5"
"@babel/plugin-transform-class-properties@^7.24.1":
version "7.24.1"
resolved "https://registry.npmjs.org/@babel/plugin-transform-class-properties/-/plugin-transform-class-properties-7.24.1.tgz#bcbf1aef6ba6085cfddec9fc8d58871cf011fc29"
@@ -748,7 +724,7 @@
"@babel/helper-plugin-utils" "^7.24.0"
"@babel/plugin-syntax-class-static-block" "^7.14.5"
"@babel/plugin-transform-classes@^7.18.6", "@babel/plugin-transform-classes@^7.24.1":
"@babel/plugin-transform-classes@^7.18.6", "@babel/plugin-transform-classes@^7.18.9", "@babel/plugin-transform-classes@^7.24.1":
version "7.24.1"
resolved "https://registry.npmjs.org/@babel/plugin-transform-classes/-/plugin-transform-classes-7.24.1.tgz#5bc8fc160ed96378184bc10042af47f50884dcb1"
integrity sha512-ZTIe3W7UejJd3/3R4p7ScyyOoafetUShSf4kCqV0O7F/RiHxVj/wRaRnQlrGwflvcehNA8M42HkAiEDYZu2F1Q==
@@ -762,20 +738,6 @@
"@babel/helper-split-export-declaration" "^7.22.6"
globals "^11.1.0"
"@babel/plugin-transform-classes@^7.18.9":
version "7.24.5"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-classes/-/plugin-transform-classes-7.24.5.tgz#05e04a09df49a46348299a0e24bfd7e901129339"
integrity sha512-gWkLP25DFj2dwe9Ck8uwMOpko4YsqyfZJrOmqqcegeDYEbp7rmn4U6UQZNj08UF6MaX39XenSpKRCvpDRBtZ7Q==
dependencies:
"@babel/helper-annotate-as-pure" "^7.22.5"
"@babel/helper-compilation-targets" "^7.23.6"
"@babel/helper-environment-visitor" "^7.22.20"
"@babel/helper-function-name" "^7.23.0"
"@babel/helper-plugin-utils" "^7.24.5"
"@babel/helper-replace-supers" "^7.24.1"
"@babel/helper-split-export-declaration" "^7.24.5"
globals "^11.1.0"
"@babel/plugin-transform-computed-properties@^7.18.6", "@babel/plugin-transform-computed-properties@^7.18.9", "@babel/plugin-transform-computed-properties@^7.24.1":
version "7.24.1"
resolved "https://registry.npmjs.org/@babel/plugin-transform-computed-properties/-/plugin-transform-computed-properties-7.24.1.tgz#bc7e787f8e021eccfb677af5f13c29a9934ed8a7"
@@ -784,20 +746,13 @@
"@babel/helper-plugin-utils" "^7.24.0"
"@babel/template" "^7.24.0"
"@babel/plugin-transform-destructuring@^7.18.6", "@babel/plugin-transform-destructuring@^7.24.1":
"@babel/plugin-transform-destructuring@^7.18.6", "@babel/plugin-transform-destructuring@^7.18.9", "@babel/plugin-transform-destructuring@^7.24.1":
version "7.24.1"
resolved "https://registry.npmjs.org/@babel/plugin-transform-destructuring/-/plugin-transform-destructuring-7.24.1.tgz#b1e8243af4a0206841973786292b8c8dd8447345"
integrity sha512-ow8jciWqNxR3RYbSNVuF4U2Jx130nwnBnhRw6N6h1bOejNkABmcI5X5oz29K4alWX7vf1C+o6gtKXikzRKkVdw==
dependencies:
"@babel/helper-plugin-utils" "^7.24.0"
"@babel/plugin-transform-destructuring@^7.18.9":
version "7.24.5"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-destructuring/-/plugin-transform-destructuring-7.24.5.tgz#80843ee6a520f7362686d1a97a7b53544ede453c"
integrity sha512-SZuuLyfxvsm+Ah57I/i1HVjveBENYK9ue8MJ7qkc7ndoNjqquJiElzA7f5yaAXjyW2hKojosOTAQQRX50bPSVg==
dependencies:
"@babel/helper-plugin-utils" "^7.24.5"
"@babel/plugin-transform-dotall-regex@^7.18.6", "@babel/plugin-transform-dotall-regex@^7.24.1", "@babel/plugin-transform-dotall-regex@^7.4.4":
version "7.24.1"
resolved "https://registry.npmjs.org/@babel/plugin-transform-dotall-regex/-/plugin-transform-dotall-regex-7.24.1.tgz#d56913d2f12795cc9930801b84c6f8c47513ac13"
@@ -993,20 +948,13 @@
"@babel/helper-skip-transparent-expression-wrappers" "^7.22.5"
"@babel/plugin-syntax-optional-chaining" "^7.8.3"
"@babel/plugin-transform-parameters@^7.18.6", "@babel/plugin-transform-parameters@^7.20.7", "@babel/plugin-transform-parameters@^7.24.1":
"@babel/plugin-transform-parameters@^7.18.6", "@babel/plugin-transform-parameters@^7.18.8", "@babel/plugin-transform-parameters@^7.20.7", "@babel/plugin-transform-parameters@^7.24.1":
version "7.24.1"
resolved "https://registry.npmjs.org/@babel/plugin-transform-parameters/-/plugin-transform-parameters-7.24.1.tgz#983c15d114da190506c75b616ceb0f817afcc510"
integrity sha512-8Jl6V24g+Uw5OGPeWNKrKqXPDw2YDjLc53ojwfMcKwlEoETKU9rU0mHUtcg9JntWI/QYzGAXNWEcVHZ+fR+XXg==
dependencies:
"@babel/helper-plugin-utils" "^7.24.0"
"@babel/plugin-transform-parameters@^7.18.8":
version "7.24.5"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-parameters/-/plugin-transform-parameters-7.24.5.tgz#5c3b23f3a6b8fed090f9b98f2926896d3153cc62"
integrity sha512-9Co00MqZ2aoky+4j2jhofErthm6QVLKbpQrvz20c3CH9KQCLHyNB+t2ya4/UrRpQGR+Wrwjg9foopoeSdnHOkA==
dependencies:
"@babel/helper-plugin-utils" "^7.24.5"
"@babel/plugin-transform-private-methods@^7.24.1":
version "7.24.1"
resolved "https://registry.npmjs.org/@babel/plugin-transform-private-methods/-/plugin-transform-private-methods-7.24.1.tgz#a0faa1ae87eff077e1e47a5ec81c3aef383dc15a"
@@ -1096,7 +1044,7 @@
"@babel/plugin-transform-runtime@7.18.6":
version "7.18.6"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-runtime/-/plugin-transform-runtime-7.18.6.tgz#77b14416015ea93367ca06979710f5000ff34ccb"
resolved "https://registry.npmjs.org/@babel/plugin-transform-runtime/-/plugin-transform-runtime-7.18.6.tgz#77b14416015ea93367ca06979710f5000ff34ccb"
integrity sha512-8uRHk9ZmRSnWqUgyae249EJZ94b0yAGLBIqzZzl+0iEdbno55Pmlt/32JZsHwXD9k/uZj18Aqqk35wBX4CBTXA==
dependencies:
"@babel/helper-module-imports" "^7.18.6"
@@ -1159,20 +1107,13 @@
dependencies:
"@babel/helper-plugin-utils" "^7.24.0"
"@babel/plugin-transform-typeof-symbol@^7.18.6", "@babel/plugin-transform-typeof-symbol@^7.24.1":
"@babel/plugin-transform-typeof-symbol@^7.18.6", "@babel/plugin-transform-typeof-symbol@^7.18.9", "@babel/plugin-transform-typeof-symbol@^7.24.1":
version "7.24.1"
resolved "https://registry.npmjs.org/@babel/plugin-transform-typeof-symbol/-/plugin-transform-typeof-symbol-7.24.1.tgz#6831f78647080dec044f7e9f68003d99424f94c7"
integrity sha512-CBfU4l/A+KruSUoW+vTQthwcAdwuqbpRNB8HQKlZABwHRhsdHZ9fezp4Sn18PeAlYxTNiLMlx4xUBV3AWfg1BA==
dependencies:
"@babel/helper-plugin-utils" "^7.24.0"
"@babel/plugin-transform-typeof-symbol@^7.18.9":
version "7.24.5"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-typeof-symbol/-/plugin-transform-typeof-symbol-7.24.5.tgz#703cace5ef74155fb5eecab63cbfc39bdd25fe12"
integrity sha512-UTGnhYVZtTAjdwOTzT+sCyXmTn8AhaxOS/MjG9REclZ6ULHWF9KoCZur0HSGU7hk8PdBFKKbYe6+gqdXWz84Jg==
dependencies:
"@babel/helper-plugin-utils" "^7.24.5"
"@babel/plugin-transform-typescript@7.18.8":
version "7.18.8"
resolved "https://registry.npmjs.org/@babel/plugin-transform-typescript/-/plugin-transform-typescript-7.18.8.tgz#303feb7a920e650f2213ef37b36bbf327e6fa5a0"
@@ -1306,7 +1247,7 @@
"@babel/preset-env@7.18.9":
version "7.18.9"
resolved "https://registry.yarnpkg.com/@babel/preset-env/-/preset-env-7.18.9.tgz#9b3425140d724fbe590322017466580844c7eaff"
resolved "https://registry.npmjs.org/@babel/preset-env/-/preset-env-7.18.9.tgz#9b3425140d724fbe590322017466580844c7eaff"
integrity sha512-75pt/q95cMIHWssYtyfjVlvI+QEZQThQbKvR9xH+F/Agtw/s4Wfc2V9Bwd/P39VtixB7oWxGdH4GteTTwYJWMg==
dependencies:
"@babel/compat-data" "^7.18.8"
@@ -1582,15 +1523,6 @@
"@babel/helper-validator-identifier" "^7.22.20"
to-fast-properties "^2.0.0"
"@babel/types@^7.24.5":
version "7.24.5"
resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.24.5.tgz#7661930afc638a5383eb0c4aee59b74f38db84d7"
integrity sha512-6mQNsaLeXTw0nxYUYu+NSa4Hx4BlF1x1x8/PMFbiR+GBSr+2DkECc69b8hgy2frEodNcvPffeH8YfWd3LI6jhQ==
dependencies:
"@babel/helper-string-parser" "^7.24.1"
"@babel/helper-validator-identifier" "^7.24.5"
to-fast-properties "^2.0.0"
"@bcoe/v8-coverage@^0.2.3":
version "0.2.3"
resolved "https://registry.npmjs.org/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
@@ -1608,7 +1540,7 @@
"@discoveryjs/json-ext@^0.5.0":
version "0.5.7"
resolved "https://registry.yarnpkg.com/@discoveryjs/json-ext/-/json-ext-0.5.7.tgz#1d572bfbbe14b7704e0ba0f39b74815b84870d70"
resolved "https://registry.npmjs.org/@discoveryjs/json-ext/-/json-ext-0.5.7.tgz#1d572bfbbe14b7704e0ba0f39b74815b84870d70"
integrity sha512-dBVuXR082gk3jsFp7Rd/JI4kytwGHecnCoTtXFb7DB6CNHp4rg5k1bhg0nWdLGLnOV71lmDzGQaLMy8iPLY0pw==
"@esbuild/aix-ppc64@0.19.10":
@@ -1998,10 +1930,10 @@
resolved "https://registry.npmjs.org/@excalidraw/markdown-to-text/-/markdown-to-text-0.1.2.tgz#1703705e7da608cf478f17bfe96fb295f55a23eb"
integrity sha512-1nDXBNAojfi3oSFwJswKREkFm5wrSjqay81QlyRv2pkITG/XYB5v+oChENVBQLcxQwX4IUATWvXM5BcaNhPiIg==
"@excalidraw/mermaid-to-excalidraw@0.3.0":
version "0.3.0"
resolved "https://registry.npmjs.org/@excalidraw/mermaid-to-excalidraw/-/mermaid-to-excalidraw-0.3.0.tgz#94c438133fc66db6b920e237abda5152b62e6cb0"
integrity sha512-eyFN8y2ES3HFtETZWZZBakkSB5ROfnHJeCLeBlMgrIk1fxbXpPtxlu2VwGNpqPjDiCfV5FYnx7FaZ4CRiVRVMg==
"@excalidraw/mermaid-to-excalidraw@1.0.0":
version "1.0.0"
resolved "https://registry.yarnpkg.com/@excalidraw/mermaid-to-excalidraw/-/mermaid-to-excalidraw-1.0.0.tgz#8c058d2a43230425cba96d01e4a669a2d7c586a2"
integrity sha512-RGSoJBY2gFag6mQOIwa3OakTrvAZYx0bwvnr5ojuCZInih8Fxhje4X1WZfsaQx+GATEH8Ioq3O3b1FPDg4nKjQ==
dependencies:
"@excalidraw/markdown-to-text" "0.1.2"
mermaid "10.9.0"
@@ -3213,7 +3145,7 @@
"@types/estree@^0.0.51":
version "0.0.51"
resolved "https://registry.yarnpkg.com/@types/estree/-/estree-0.0.51.tgz#cfd70924a25a3fd32b218e5e420e6897e1ac4f40"
resolved "https://registry.npmjs.org/@types/estree/-/estree-0.0.51.tgz#cfd70924a25a3fd32b218e5e420e6897e1ac4f40"
integrity sha512-CuPgU6f3eT/XgKKPqKd/gLZV1Xmvf1a2R5POBOGQa6uv82xpls89HU5zKeVoyR8XzHd1RGNOlQlvUe3CFkjWNQ==
"@types/istanbul-lib-coverage@*", "@types/istanbul-lib-coverage@^2.0.0", "@types/istanbul-lib-coverage@^2.0.1":
@@ -3611,7 +3543,7 @@
"@webassemblyjs/ast@1.11.1":
version "1.11.1"
resolved "https://registry.yarnpkg.com/@webassemblyjs/ast/-/ast-1.11.1.tgz#2bfd767eae1a6996f432ff7e8d7fc75679c0b6a7"
resolved "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.11.1.tgz#2bfd767eae1a6996f432ff7e8d7fc75679c0b6a7"
integrity sha512-ukBh14qFLjxTQNTXocdyksN5QdM28S1CxHt2rdskFyL+xFV7VremuBLVbmCePj+URalXBENx/9Lm7lnhihtCSw==
dependencies:
"@webassemblyjs/helper-numbers" "1.11.1"
@@ -3627,7 +3559,7 @@
"@webassemblyjs/floating-point-hex-parser@1.11.1":
version "1.11.1"
resolved "https://registry.yarnpkg.com/@webassemblyjs/floating-point-hex-parser/-/floating-point-hex-parser-1.11.1.tgz#f6c61a705f0fd7a6aecaa4e8198f23d9dc179e4f"
resolved "https://registry.npmjs.org/@webassemblyjs/floating-point-hex-parser/-/floating-point-hex-parser-1.11.1.tgz#f6c61a705f0fd7a6aecaa4e8198f23d9dc179e4f"
integrity sha512-iGRfyc5Bq+NnNuX8b5hwBrRjzf0ocrJPI6GWFodBFzmFnyvrQ83SHKhmilCU/8Jv67i4GJZBMhEzltxzcNagtQ==
"@webassemblyjs/floating-point-hex-parser@1.11.6":
@@ -3637,7 +3569,7 @@
"@webassemblyjs/helper-api-error@1.11.1":
version "1.11.1"
resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-api-error/-/helper-api-error-1.11.1.tgz#1a63192d8788e5c012800ba6a7a46c705288fd16"
resolved "https://registry.npmjs.org/@webassemblyjs/helper-api-error/-/helper-api-error-1.11.1.tgz#1a63192d8788e5c012800ba6a7a46c705288fd16"
integrity sha512-RlhS8CBCXfRUR/cwo2ho9bkheSXG0+NwooXcc3PAILALf2QLdFyj7KGsKRbVc95hZnhnERon4kW/D3SZpp6Tcg==
"@webassemblyjs/helper-api-error@1.11.6":
@@ -3647,7 +3579,7 @@
"@webassemblyjs/helper-buffer@1.11.1":
version "1.11.1"
resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-buffer/-/helper-buffer-1.11.1.tgz#832a900eb444884cde9a7cad467f81500f5e5ab5"
resolved "https://registry.npmjs.org/@webassemblyjs/helper-buffer/-/helper-buffer-1.11.1.tgz#832a900eb444884cde9a7cad467f81500f5e5ab5"
integrity sha512-gwikF65aDNeeXa8JxXa2BAk+REjSyhrNC9ZwdT0f8jc4dQQeDQ7G4m0f2QCLPJiMTTO6wfDmRmj/pW0PsUvIcA==
"@webassemblyjs/helper-buffer@1.12.1":
@@ -3657,7 +3589,7 @@
"@webassemblyjs/helper-numbers@1.11.1":
version "1.11.1"
resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-numbers/-/helper-numbers-1.11.1.tgz#64d81da219fbbba1e3bd1bfc74f6e8c4e10a62ae"
resolved "https://registry.npmjs.org/@webassemblyjs/helper-numbers/-/helper-numbers-1.11.1.tgz#64d81da219fbbba1e3bd1bfc74f6e8c4e10a62ae"
integrity sha512-vDkbxiB8zfnPdNK9Rajcey5C0w+QJugEglN0of+kmO8l7lDb77AnlKYQF7aarZuCrv+l0UvqL+68gSDr3k9LPQ==
dependencies:
"@webassemblyjs/floating-point-hex-parser" "1.11.1"
@@ -3675,7 +3607,7 @@
"@webassemblyjs/helper-wasm-bytecode@1.11.1":
version "1.11.1"
resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-wasm-bytecode/-/helper-wasm-bytecode-1.11.1.tgz#f328241e41e7b199d0b20c18e88429c4433295e1"
resolved "https://registry.npmjs.org/@webassemblyjs/helper-wasm-bytecode/-/helper-wasm-bytecode-1.11.1.tgz#f328241e41e7b199d0b20c18e88429c4433295e1"
integrity sha512-PvpoOGiJwXeTrSf/qfudJhwlvDQxFgelbMqtq52WWiXC6Xgg1IREdngmPN3bs4RoO83PnL/nFrxucXj1+BX62Q==
"@webassemblyjs/helper-wasm-bytecode@1.11.6":
@@ -3685,7 +3617,7 @@
"@webassemblyjs/helper-wasm-section@1.11.1":
version "1.11.1"
resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-wasm-section/-/helper-wasm-section-1.11.1.tgz#21ee065a7b635f319e738f0dd73bfbda281c097a"
resolved "https://registry.npmjs.org/@webassemblyjs/helper-wasm-section/-/helper-wasm-section-1.11.1.tgz#21ee065a7b635f319e738f0dd73bfbda281c097a"
integrity sha512-10P9No29rYX1j7F3EVPX3JvGPQPae+AomuSTPiF9eBQeChHI6iqjMIwR9JmOJXwpnn/oVGDk7I5IlskuMwU/pg==
dependencies:
"@webassemblyjs/ast" "1.11.1"
@@ -3705,7 +3637,7 @@
"@webassemblyjs/ieee754@1.11.1":
version "1.11.1"
resolved "https://registry.yarnpkg.com/@webassemblyjs/ieee754/-/ieee754-1.11.1.tgz#963929e9bbd05709e7e12243a099180812992614"
resolved "https://registry.npmjs.org/@webassemblyjs/ieee754/-/ieee754-1.11.1.tgz#963929e9bbd05709e7e12243a099180812992614"
integrity sha512-hJ87QIPtAMKbFq6CGTkZYJivEwZDbQUgYd3qKSadTNOhVY7p+gfP6Sr0lLRVTaG1JjFj+r3YchoqRYxNH3M0GQ==
dependencies:
"@xtuc/ieee754" "^1.2.0"
@@ -3719,7 +3651,7 @@
"@webassemblyjs/leb128@1.11.1":
version "1.11.1"
resolved "https://registry.yarnpkg.com/@webassemblyjs/leb128/-/leb128-1.11.1.tgz#ce814b45574e93d76bae1fb2644ab9cdd9527aa5"
resolved "https://registry.npmjs.org/@webassemblyjs/leb128/-/leb128-1.11.1.tgz#ce814b45574e93d76bae1fb2644ab9cdd9527aa5"
integrity sha512-BJ2P0hNZ0u+Th1YZXJpzW6miwqQUGcIHT1G/sf72gLVD9DZ5AdYTqPNbHZh6K1M5VmKvFXwGSWZADz+qBWxeRw==
dependencies:
"@xtuc/long" "4.2.2"
@@ -3733,7 +3665,7 @@
"@webassemblyjs/utf8@1.11.1":
version "1.11.1"
resolved "https://registry.yarnpkg.com/@webassemblyjs/utf8/-/utf8-1.11.1.tgz#d1f8b764369e7c6e6bae350e854dec9a59f0a3ff"
resolved "https://registry.npmjs.org/@webassemblyjs/utf8/-/utf8-1.11.1.tgz#d1f8b764369e7c6e6bae350e854dec9a59f0a3ff"
integrity sha512-9kqcxAEdMhiwQkHpkNiorZzqpGrodQQ2IGrHHxCy+Ozng0ofyMA0lTqiLkVs1uzTRejX+/O0EOT7KxqVPuXosQ==
"@webassemblyjs/utf8@1.11.6":
@@ -3743,7 +3675,7 @@
"@webassemblyjs/wasm-edit@1.11.1":
version "1.11.1"
resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-edit/-/wasm-edit-1.11.1.tgz#ad206ebf4bf95a058ce9880a8c092c5dec8193d6"
resolved "https://registry.npmjs.org/@webassemblyjs/wasm-edit/-/wasm-edit-1.11.1.tgz#ad206ebf4bf95a058ce9880a8c092c5dec8193d6"
integrity sha512-g+RsupUC1aTHfR8CDgnsVRVZFJqdkFHpsHMfJuWQzWU3tvnLC07UqHICfP+4XyL2tnr1amvl1Sdp06TnYCmVkA==
dependencies:
"@webassemblyjs/ast" "1.11.1"
@@ -3771,7 +3703,7 @@
"@webassemblyjs/wasm-gen@1.11.1":
version "1.11.1"
resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-gen/-/wasm-gen-1.11.1.tgz#86c5ea304849759b7d88c47a32f4f039ae3c8f76"
resolved "https://registry.npmjs.org/@webassemblyjs/wasm-gen/-/wasm-gen-1.11.1.tgz#86c5ea304849759b7d88c47a32f4f039ae3c8f76"
integrity sha512-F7QqKXwwNlMmsulj6+O7r4mmtAlCWfO/0HdgOxSklZfQcDu0TpLiD1mRt/zF25Bk59FIjEuGAIyn5ei4yMfLhA==
dependencies:
"@webassemblyjs/ast" "1.11.1"
@@ -3793,7 +3725,7 @@
"@webassemblyjs/wasm-opt@1.11.1":
version "1.11.1"
resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-opt/-/wasm-opt-1.11.1.tgz#657b4c2202f4cf3b345f8a4c6461c8c2418985f2"
resolved "https://registry.npmjs.org/@webassemblyjs/wasm-opt/-/wasm-opt-1.11.1.tgz#657b4c2202f4cf3b345f8a4c6461c8c2418985f2"
integrity sha512-VqnkNqnZlU5EB64pp1l7hdm3hmQw7Vgqa0KF/KCNO9sIpI6Fk6brDEiX+iCOYrvMuBWDws0NkTOxYEb85XQHHw==
dependencies:
"@webassemblyjs/ast" "1.11.1"
@@ -3813,7 +3745,7 @@
"@webassemblyjs/wasm-parser@1.11.1":
version "1.11.1"
resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-parser/-/wasm-parser-1.11.1.tgz#86ca734534f417e9bd3c67c7a1c75d8be41fb199"
resolved "https://registry.npmjs.org/@webassemblyjs/wasm-parser/-/wasm-parser-1.11.1.tgz#86ca734534f417e9bd3c67c7a1c75d8be41fb199"
integrity sha512-rrBujw+dJu32gYB7/Lup6UhdkPx9S9SnobZzRVL7VcBH9Bt9bCBLEuX/YXOOtBsOZ4NQrRykKhffRWHvigQvOA==
dependencies:
"@webassemblyjs/ast" "1.11.1"
@@ -3837,7 +3769,7 @@
"@webassemblyjs/wast-printer@1.11.1":
version "1.11.1"
resolved "https://registry.yarnpkg.com/@webassemblyjs/wast-printer/-/wast-printer-1.11.1.tgz#d0c73beda8eec5426f10ae8ef55cee5e7084c2f0"
resolved "https://registry.npmjs.org/@webassemblyjs/wast-printer/-/wast-printer-1.11.1.tgz#d0c73beda8eec5426f10ae8ef55cee5e7084c2f0"
integrity sha512-IQboUWM4eKzWW+N/jij2sRatKMh99QEelo3Eb2q0qXkvPRISAj8Qxtmw5itwqK+TTkBuUIE45AxYPToqPtL5gg==
dependencies:
"@webassemblyjs/ast" "1.11.1"
@@ -3853,19 +3785,19 @@
"@webpack-cli/configtest@^1.2.0":
version "1.2.0"
resolved "https://registry.yarnpkg.com/@webpack-cli/configtest/-/configtest-1.2.0.tgz#7b20ce1c12533912c3b217ea68262365fa29a6f5"
resolved "https://registry.npmjs.org/@webpack-cli/configtest/-/configtest-1.2.0.tgz#7b20ce1c12533912c3b217ea68262365fa29a6f5"
integrity sha512-4FB8Tj6xyVkyqjj1OaTqCjXYULB9FMkqQ8yGrZjRDrYh0nOE+7Lhs45WioWQQMV+ceFlE368Ukhe6xdvJM9Egg==
"@webpack-cli/info@^1.5.0":
version "1.5.0"
resolved "https://registry.yarnpkg.com/@webpack-cli/info/-/info-1.5.0.tgz#6c78c13c5874852d6e2dd17f08a41f3fe4c261b1"
resolved "https://registry.npmjs.org/@webpack-cli/info/-/info-1.5.0.tgz#6c78c13c5874852d6e2dd17f08a41f3fe4c261b1"
integrity sha512-e8tSXZpw2hPl2uMJY6fsMswaok5FdlGNRTktvFk2sD8RjH0hE2+XistawJx1vmKteh4NmGmNUrp+Tb2w+udPcQ==
dependencies:
envinfo "^7.7.3"
"@webpack-cli/serve@^1.7.0":
version "1.7.0"
resolved "https://registry.yarnpkg.com/@webpack-cli/serve/-/serve-1.7.0.tgz#e1993689ac42d2b16e9194376cfb6753f6254db1"
resolved "https://registry.npmjs.org/@webpack-cli/serve/-/serve-1.7.0.tgz#e1993689ac42d2b16e9194376cfb6753f6254db1"
integrity sha512-oxnCNGj88fL+xzV+dacXs44HcDwf1ovs3AuEzvP7mqXw7fQntqIhQ1BRmynh4qEKQSSSRSWVyXRjmTbZIX9V2Q==
"@xtuc/ieee754@^1.2.0":
@@ -4660,7 +4592,7 @@ check-error@^1.0.2, check-error@^1.0.3:
dependencies:
get-func-name "^2.0.2"
chokidar@3.6.0, "chokidar@>=3.0.0 <4.0.0", chokidar@^3.5.1, chokidar@^3.5.3:
"chokidar@>=3.0.0 <4.0.0", chokidar@^3.5.1, chokidar@^3.5.3:
version "3.6.0"
resolved "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz#197c6cc669ef2a8dc5e7b4d97ee4e092c3eb0d5b"
integrity sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==
@@ -4741,7 +4673,7 @@ cliui@^8.0.1:
clone-deep@^4.0.1:
version "4.0.1"
resolved "https://registry.yarnpkg.com/clone-deep/-/clone-deep-4.0.1.tgz#c19fd9bdbbf85942b4fd979c84dcf7d5f07c2387"
resolved "https://registry.npmjs.org/clone-deep/-/clone-deep-4.0.1.tgz#c19fd9bdbbf85942b4fd979c84dcf7d5f07c2387"
integrity sha512-neHB9xuzh/wk0dIHweyAXv2aPGZIVk3pLMe+/RNzINf17fe0OG96QroktYAUm7SM1PBnzTabaLboqqxDyMU+SQ==
dependencies:
is-plain-object "^2.0.4"
@@ -5584,7 +5516,7 @@ dotenv@^16.0.0:
duplexer@^0.1.2:
version "0.1.2"
resolved "https://registry.yarnpkg.com/duplexer/-/duplexer-0.1.2.tgz#3abe43aef3835f8ae077d136ddce0f276b0400e6"
resolved "https://registry.npmjs.org/duplexer/-/duplexer-0.1.2.tgz#3abe43aef3835f8ae077d136ddce0f276b0400e6"
integrity sha512-jtD6YG370ZCIi/9GTaJKQxWTZD045+4R4hTk/x1UyoqadyJ9x9CgSi1RlVDQF8U2sxLLSnFkCaMihqljHIWgMg==
eastasianwidth@^0.2.0:
@@ -5674,9 +5606,9 @@ entities@^4.4.0:
integrity sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==
envinfo@^7.7.3:
version "7.13.0"
resolved "https://registry.yarnpkg.com/envinfo/-/envinfo-7.13.0.tgz#81fbb81e5da35d74e814941aeab7c325a606fb31"
integrity sha512-cvcaMr7KqXVh4nyzGTVqTum+gAiL265x5jUWQIDLq//zOGbW+gSW/C+OWLleY/rs9Qole6AZLMXPbtIFQbqu+Q==
version "7.11.1"
resolved "https://registry.npmjs.org/envinfo/-/envinfo-7.11.1.tgz#2ffef77591057081b0129a8fd8cf6118da1b94e1"
integrity sha512-8PiZgZNIB4q/Lw4AhOvAfB/ityHAd2bli3lESSWmWSzSsl5dKpy5N1d1Rfkd2teq/g9xN90lc6o98DOjMeYHpg==
error-ex@^1.3.1:
version "1.3.2"
@@ -5786,7 +5718,7 @@ es-iterator-helpers@^1.0.15, es-iterator-helpers@^1.0.17:
es-module-lexer@^0.9.0:
version "0.9.3"
resolved "https://registry.yarnpkg.com/es-module-lexer/-/es-module-lexer-0.9.3.tgz#6f13db00cc38417137daf74366f535c8eb438f19"
resolved "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-0.9.3.tgz#6f13db00cc38417137daf74366f535c8eb438f19"
integrity sha512-1HQ2M2sPtxwnvOvT1ZClHyQDiggdNjURWpY2we6aMKCQiUVxTmVs2UYPLIrD84sS+kMdUwfBSylbJPwNnBrnHQ==
es-module-lexer@^1.2.1:
@@ -6360,7 +6292,7 @@ fast-levenshtein@^2.0.6:
fastest-levenshtein@^1.0.12:
version "1.0.16"
resolved "https://registry.yarnpkg.com/fastest-levenshtein/-/fastest-levenshtein-1.0.16.tgz#210e61b6ff181de91ea9b3d1b84fdedd47e034e5"
resolved "https://registry.npmjs.org/fastest-levenshtein/-/fastest-levenshtein-1.0.16.tgz#210e61b6ff181de91ea9b3d1b84fdedd47e034e5"
integrity sha512-eRnCtTTtGZFpQCwhJiUOuxPQWRXVKYDn0b2PeHfXL6/Zi53SLAzAHfVhVWK2AryC/WH05kGfxhFIPvTF0SXQzg==
fastq@^1.6.0:
@@ -6398,7 +6330,7 @@ file-entry-cache@^6.0.1:
file-loader@6.2.0:
version "6.2.0"
resolved "https://registry.yarnpkg.com/file-loader/-/file-loader-6.2.0.tgz#baef7cf8e1840df325e4390b4484879480eebe4d"
resolved "https://registry.npmjs.org/file-loader/-/file-loader-6.2.0.tgz#baef7cf8e1840df325e4390b4484879480eebe4d"
integrity sha512-qo3glqyTa61Ytg4u73GultjHGjdRyig3tG6lPtyX/jOEJvHif9uB0/OCI2Kif6ctF3caQTW2G5gym21oAsI4pw==
dependencies:
loader-utils "^2.0.0"
@@ -6471,7 +6403,7 @@ flat-cache@^3.0.4:
flat@^5.0.2:
version "5.0.2"
resolved "https://registry.yarnpkg.com/flat/-/flat-5.0.2.tgz#8ca6fe332069ffa9d324c327198c598259ceb241"
resolved "https://registry.npmjs.org/flat/-/flat-5.0.2.tgz#8ca6fe332069ffa9d324c327198c598259ceb241"
integrity sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ==
flatted@^3.2.7, flatted@^3.2.9:
@@ -6729,7 +6661,7 @@ graphemer@^1.4.0:
gzip-size@^6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/gzip-size/-/gzip-size-6.0.0.tgz#065367fd50c239c0671cbcbad5be3e2eeb10e462"
resolved "https://registry.npmjs.org/gzip-size/-/gzip-size-6.0.0.tgz#065367fd50c239c0671cbcbad5be3e2eeb10e462"
integrity sha512-ax7ZYomf6jqPTQ4+XCpUGyXKHk5WweS+e05MBO4/y3WJ5RkmPXNKvX+bx1behVILVwr6JSQvZAku021CHPXG3Q==
dependencies:
duplexer "^0.1.2"
@@ -6970,7 +6902,7 @@ import-fresh@^3.0.0, import-fresh@^3.2.1:
import-local@^3.0.2:
version "3.1.0"
resolved "https://registry.yarnpkg.com/import-local/-/import-local-3.1.0.tgz#b4479df8a5fd44f6cdce24070675676063c95cb4"
resolved "https://registry.npmjs.org/import-local/-/import-local-3.1.0.tgz#b4479df8a5fd44f6cdce24070675676063c95cb4"
integrity sha512-ASB07uLtnDs1o6EHjKpX34BKYDSqnFerfTOJL2HvMqF70LnxpjkzDB8J44oT9pu4AMPkQwf8jl6szgvNd2tRIg==
dependencies:
pkg-dir "^4.2.0"
@@ -7025,7 +6957,7 @@ internmap@^1.0.0:
interpret@^2.2.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/interpret/-/interpret-2.2.0.tgz#1a78a0b5965c40a5416d007ad6f50ad27c417df9"
resolved "https://registry.npmjs.org/interpret/-/interpret-2.2.0.tgz#1a78a0b5965c40a5416d007ad6f50ad27c417df9"
integrity sha512-Ju0Bz/cEia55xDwUWEa8+olFpCiQoypjnQySseKtmjNrnps3P+xfpUmGr90T7yjlVJmOtybRvPXhKMbHr+fWnw==
invariant@^2.2.2, invariant@^2.2.4:
@@ -7181,7 +7113,7 @@ is-obj@^1.0.1:
is-plain-object@^2.0.4:
version "2.0.4"
resolved "https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-2.0.4.tgz#2c163b3fafb1b606d9d17928f05c2a1c38e07677"
resolved "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz#2c163b3fafb1b606d9d17928f05c2a1c38e07677"
integrity sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==
dependencies:
isobject "^3.0.1"
@@ -7279,7 +7211,7 @@ isexe@^2.0.0:
isobject@^3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/isobject/-/isobject-3.0.1.tgz#4e431e92b11a9731636aa1f9c8d1ccbcfdab78df"
resolved "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz#4e431e92b11a9731636aa1f9c8d1ccbcfdab78df"
integrity sha512-WhB9zCku7EGTj/HQQRz5aUQEUeoQZH2bWcltRErOpymJ4boYE6wL9Tbr23krRPSZ+C5zqNSrSw+Cc7sZZ4b7vg==
istanbul-lib-coverage@^3.0.0, istanbul-lib-coverage@^3.2.0:
@@ -7586,7 +7518,7 @@ khroma@^2.0.0:
kind-of@^6.0.2:
version "6.0.3"
resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-6.0.3.tgz#07c05034a6c349fa06e24fa35aa76db4580ce4dd"
resolved "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz#07c05034a6c349fa06e24fa35aa76db4580ce4dd"
integrity sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==
kleur@^4.0.3:
@@ -8218,7 +8150,7 @@ mri@^1.1.0:
mrmime@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/mrmime/-/mrmime-1.0.1.tgz#5f90c825fad4bdd41dc914eff5d1a8cfdaf24f27"
resolved "https://registry.npmjs.org/mrmime/-/mrmime-1.0.1.tgz#5f90c825fad4bdd41dc914eff5d1a8cfdaf24f27"
integrity sha512-hzzEagAgDyoU1Q6yg5uI+AorQgdvMCur3FcKf7NhMKWsaYg+RnbTyHRa/9IlLF9rf455MOCtcqqrQQ83pPP7Uw==
mrmime@^2.0.0:
@@ -9077,7 +9009,7 @@ realistic-structured-clone@^2.0.1:
rechoir@^0.7.0:
version "0.7.1"
resolved "https://registry.yarnpkg.com/rechoir/-/rechoir-0.7.1.tgz#9478a96a1ca135b5e88fc027f03ee92d6c645686"
resolved "https://registry.npmjs.org/rechoir/-/rechoir-0.7.1.tgz#9478a96a1ca135b5e88fc027f03ee92d6c645686"
integrity sha512-/njmZ8s1wVeR6pjTZ+0nCnv8SpZNRMT2D1RLOJQESlYFDBvwpTA4KWJpZ+sBJ4+vhjILRcK7JIFdGCdxEAAitg==
dependencies:
resolve "^1.9.0"
@@ -9188,7 +9120,7 @@ requires-port@^1.0.0:
resolve-cwd@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/resolve-cwd/-/resolve-cwd-3.0.0.tgz#0f0075f1bb2544766cf73ba6a6e2adfebcb13f2d"
resolved "https://registry.npmjs.org/resolve-cwd/-/resolve-cwd-3.0.0.tgz#0f0075f1bb2544766cf73ba6a6e2adfebcb13f2d"
integrity sha512-OrZaX2Mb+rJCpH/6CpSqt9xFVpN++x01XnN2ie9g6P5/3xelLAkXWVADpdz1IHD/KFfEXyE6V0U01OQ3UO2rEg==
dependencies:
resolve-from "^5.0.0"
@@ -9200,7 +9132,7 @@ resolve-from@^4.0.0:
resolve-from@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-5.0.0.tgz#c35225843df8f776df21c57557bc087e9dfdfc69"
resolved "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz#c35225843df8f776df21c57557bc087e9dfdfc69"
integrity sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==
resolve@^1.14.2, resolve@^1.19.0, resolve@^1.22.4, resolve@^1.22.6, resolve@^1.9.0:
@@ -9509,7 +9441,7 @@ set-function-name@^2.0.1, set-function-name@^2.0.2:
shallow-clone@^3.0.0:
version "3.0.1"
resolved "https://registry.yarnpkg.com/shallow-clone/-/shallow-clone-3.0.1.tgz#8f2981ad92531f55035b01fb230769a40e02efa3"
resolved "https://registry.npmjs.org/shallow-clone/-/shallow-clone-3.0.1.tgz#8f2981ad92531f55035b01fb230769a40e02efa3"
integrity sha512-/6KqX+GVUdqPuPPd2LxDDxzX6CAbjJehAAOKlNpqqUpAqPM6HeL8f+o3a+JsyGjn2lv0WY8UsTgUJjU9Ok55NA==
dependencies:
kind-of "^6.0.2"
@@ -9553,7 +9485,7 @@ signal-exit@^4.1.0:
sirv@^1.0.7:
version "1.0.19"
resolved "https://registry.yarnpkg.com/sirv/-/sirv-1.0.19.tgz#1d73979b38c7fe91fcba49c85280daa9c2363b49"
resolved "https://registry.npmjs.org/sirv/-/sirv-1.0.19.tgz#1d73979b38c7fe91fcba49c85280daa9c2363b49"
integrity sha512-JuLThK3TnZG1TAKDwNIqNq6QA2afLOCcm+iE8D1Kj3GA40pSPsxQjjJl0J8X3tsR7T+CP1GavpzLwYkgVLWrZQ==
dependencies:
"@polka/url" "^1.0.0-next.20"
@@ -10061,7 +9993,7 @@ to-regex-range@^5.0.1:
totalist@^1.0.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/totalist/-/totalist-1.1.0.tgz#a4d65a3e546517701e3e5c37a47a70ac97fe56df"
resolved "https://registry.npmjs.org/totalist/-/totalist-1.1.0.tgz#a4d65a3e546517701e3e5c37a47a70ac97fe56df"
integrity sha512-gduQwd1rOdDMGxFG1gEvhV88Oirdo2p+KjoYFU7k2g+i7n6AFFbDQ5kMPUsW0pNbfQsB/cwXvT1i4Bue0s9g5g==
totalist@^3.0.0:
@@ -10642,7 +10574,7 @@ webidl-conversions@^7.0.0:
webpack-bundle-analyzer@4.5.0:
version "4.5.0"
resolved "https://registry.yarnpkg.com/webpack-bundle-analyzer/-/webpack-bundle-analyzer-4.5.0.tgz#1b0eea2947e73528754a6f9af3e91b2b6e0f79d5"
resolved "https://registry.npmjs.org/webpack-bundle-analyzer/-/webpack-bundle-analyzer-4.5.0.tgz#1b0eea2947e73528754a6f9af3e91b2b6e0f79d5"
integrity sha512-GUMZlM3SKwS8Z+CKeIFx7CVoHn3dXFcUAjT/dcZQQmfSZGvitPfMob2ipjai7ovFFqPvTqkEZ/leL4O0YOdAYQ==
dependencies:
acorn "^8.0.4"
@@ -10657,7 +10589,7 @@ webpack-bundle-analyzer@4.5.0:
webpack-cli@4.10.0:
version "4.10.0"
resolved "https://registry.yarnpkg.com/webpack-cli/-/webpack-cli-4.10.0.tgz#37c1d69c8d85214c5a65e589378f53aec64dab31"
resolved "https://registry.npmjs.org/webpack-cli/-/webpack-cli-4.10.0.tgz#37c1d69c8d85214c5a65e589378f53aec64dab31"
integrity sha512-NLhDfH/h4O6UOy+0LSso42xvYypClINuMNBVVzX4vX98TmTaTUxwRbXdhucbFMd2qLaCTcLq/PdYrvi8onw90w==
dependencies:
"@discoveryjs/json-ext" "^0.5.0"
@@ -10675,7 +10607,7 @@ webpack-cli@4.10.0:
webpack-merge@^5.7.3:
version "5.10.0"
resolved "https://registry.yarnpkg.com/webpack-merge/-/webpack-merge-5.10.0.tgz#a3ad5d773241e9c682803abf628d4cd62b8a4177"
resolved "https://registry.npmjs.org/webpack-merge/-/webpack-merge-5.10.0.tgz#a3ad5d773241e9c682803abf628d4cd62b8a4177"
integrity sha512-+4zXKdx7UnO+1jaN4l2lHVD+mFvnlZQP/6ljaJVb4SZiwIKeUnrT5l0gkT8z+n4hKpC+jpOv6O9R+gLtag7pSA==
dependencies:
clone-deep "^4.0.1"
@@ -10689,7 +10621,7 @@ webpack-sources@^3.2.3:
webpack@5.76.0:
version "5.76.0"
resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.76.0.tgz#f9fb9fb8c4a7dbdcd0d56a98e56b8a942ee2692c"
resolved "https://registry.npmjs.org/webpack/-/webpack-5.76.0.tgz#f9fb9fb8c4a7dbdcd0d56a98e56b8a942ee2692c"
integrity sha512-l5sOdYBDunyf72HW8dF23rFtWq/7Zgvt/9ftMof71E/yUb1YLOBmTgA2K4vQthB3kotMrSj609txVE0dnr2fjA==
dependencies:
"@types/eslint-scope" "^3.7.3"
@@ -10884,7 +10816,7 @@ why-is-node-running@^2.2.2:
wildcard@^2.0.0:
version "2.0.1"
resolved "https://registry.yarnpkg.com/wildcard/-/wildcard-2.0.1.tgz#5ab10d02487198954836b6349f74fff961e10f67"
resolved "https://registry.npmjs.org/wildcard/-/wildcard-2.0.1.tgz#5ab10d02487198954836b6349f74fff961e10f67"
integrity sha512-CC1bOL87PIWSBhDcTrdeLo6eGT7mCFtrg0uIJtqJUFyK+eJnzl8A1niH56uu7KMa5XFrtiV+AQuHO3n7DsHnLQ==
workbox-background-sync@7.0.0:
@@ -11075,7 +11007,7 @@ ws@8.5.0:
ws@^7.3.1:
version "7.5.9"
resolved "https://registry.yarnpkg.com/ws/-/ws-7.5.9.tgz#54fa7db29f4c7cec68b1ddd3a89de099942bb591"
resolved "https://registry.npmjs.org/ws/-/ws-7.5.9.tgz#54fa7db29f4c7cec68b1ddd3a89de099942bb591"
integrity sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q==
ws@^8.13.0: