Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2cb1fa5e14 |
@@ -23,7 +23,7 @@ All `props` are _optional_.
|
|||||||
| [`libraryReturnUrl`](#libraryreturnurl) | `string` | _ | What URL should [libraries.excalidraw.com](https://libraries.excalidraw.com) be installed to |
|
| [`libraryReturnUrl`](#libraryreturnurl) | `string` | _ | What URL should [libraries.excalidraw.com](https://libraries.excalidraw.com) be installed to |
|
||||||
| [`theme`](#theme) | `"light"` | `"dark"` | `"light"` | The theme of the Excalidraw component |
|
| [`theme`](#theme) | `"light"` | `"dark"` | `"light"` | The theme of the Excalidraw component |
|
||||||
| [`name`](#name) | `string` | | Name of the drawing |
|
| [`name`](#name) | `string` | | Name of the drawing |
|
||||||
| [`UIOptions`](/docs/@excalidraw/excalidraw/api/props/ui-options) | `object` | [DEFAULT UI OPTIONS](https://github.com/excalidraw/excalidraw/blob/master/packages/excalidraw/constants.ts#L151) | To customise UI options. Currently we support customising [`canvas actions`](/docs/@excalidraw/excalidraw/api/props/ui-options#canvasactions) |
|
| [`UIOptions`](/docs/@excalidraw/excalidraw/api/props/ui-options) | `object` | [DEFAULT UI OPTIONS](https://github.com/excalidraw/excalidraw/blob/master/packages/excalidraw/constants.ts#L151) | To customise UI options. Currently we support customising [`canvas actions`](#canvasactions) |
|
||||||
| [`detectScroll`](#detectscroll) | `boolean` | `true` | Indicates whether to update the offsets when nearest ancestor is scrolled. |
|
| [`detectScroll`](#detectscroll) | `boolean` | `true` | Indicates whether to update the offsets when nearest ancestor is scrolled. |
|
||||||
| [`handleKeyboardGlobally`](#handlekeyboardglobally) | `boolean` | `false` | Indicates whether to bind the keyboard events to document. |
|
| [`handleKeyboardGlobally`](#handlekeyboardglobally) | `boolean` | `false` | Indicates whether to bind the keyboard events to document. |
|
||||||
| [`autoFocus`](#autofocus) | `boolean` | `false` | indicates whether to focus the Excalidraw component on page load |
|
| [`autoFocus`](#autofocus) | `boolean` | `false` | indicates whether to focus the Excalidraw component on page load |
|
||||||
|
|||||||
@@ -442,6 +442,7 @@ class Collab extends PureComponent<Props, CollabState> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const fallbackInitializationHandler = () => {
|
const fallbackInitializationHandler = () => {
|
||||||
|
console.log("fallbackInitializationHandler");
|
||||||
this.initializeRoom({
|
this.initializeRoom({
|
||||||
roomLinkData: existingRoomLinkData,
|
roomLinkData: existingRoomLinkData,
|
||||||
fetchScene: true,
|
fetchScene: true,
|
||||||
@@ -516,7 +517,9 @@ class Collab extends PureComponent<Props, CollabState> {
|
|||||||
case WS_SUBTYPES.INVALID_RESPONSE:
|
case WS_SUBTYPES.INVALID_RESPONSE:
|
||||||
return;
|
return;
|
||||||
case WS_SUBTYPES.INIT: {
|
case WS_SUBTYPES.INIT: {
|
||||||
|
console.log("INIT (1)");
|
||||||
if (!this.portal.socketInitialized) {
|
if (!this.portal.socketInitialized) {
|
||||||
|
console.log("INIT (2)");
|
||||||
this.initializeRoom({ fetchScene: false });
|
this.initializeRoom({ fetchScene: false });
|
||||||
const remoteElements = decryptedData.payload.elements;
|
const remoteElements = decryptedData.payload.elements;
|
||||||
const reconciledElements = this.reconcileElements(remoteElements);
|
const reconciledElements = this.reconcileElements(remoteElements);
|
||||||
@@ -606,6 +609,7 @@ class Collab extends PureComponent<Props, CollabState> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
this.portal.socket.on("first-in-room", async () => {
|
this.portal.socket.on("first-in-room", async () => {
|
||||||
|
console.log("first-in-room");
|
||||||
if (this.portal.socket) {
|
if (this.portal.socket) {
|
||||||
this.portal.socket.off("first-in-room");
|
this.portal.socket.off("first-in-room");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,9 +38,17 @@ class Portal {
|
|||||||
this.roomId = id;
|
this.roomId = id;
|
||||||
this.roomKey = key;
|
this.roomKey = key;
|
||||||
|
|
||||||
|
this.socket.on("connect", () => {
|
||||||
|
console.log("connect");
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log("subbing to init-room");
|
||||||
|
|
||||||
// Initialize socket listeners
|
// Initialize socket listeners
|
||||||
this.socket.on("init-room", () => {
|
this.socket.on("init-room", () => {
|
||||||
|
console.log("init-room (1)");
|
||||||
if (this.socket) {
|
if (this.socket) {
|
||||||
|
console.log("init-room (2)");
|
||||||
this.socket.emit("join-room", this.roomId);
|
this.socket.emit("join-room", this.roomId);
|
||||||
trackEvent("share", "room joined");
|
trackEvent("share", "room joined");
|
||||||
}
|
}
|
||||||
@@ -53,6 +61,7 @@ class Portal {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
this.socket.on("room-user-change", (clients: SocketId[]) => {
|
this.socket.on("room-user-change", (clients: SocketId[]) => {
|
||||||
|
console.log("room-user-change", clients);
|
||||||
this.collab.setCollaborators(clients);
|
this.collab.setCollaborators(clients);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import { ToolButton } from "../components/ToolButton";
|
|||||||
import { getNonDeletedElements } from "../element";
|
import { getNonDeletedElements } from "../element";
|
||||||
import { isFrameLikeElement } from "../element/typeChecks";
|
import { isFrameLikeElement } from "../element/typeChecks";
|
||||||
import { ExcalidrawElement } from "../element/types";
|
import { ExcalidrawElement } from "../element/types";
|
||||||
|
import { updateFrameMembershipOfSelectedElements } from "../frame";
|
||||||
import { t } from "../i18n";
|
import { t } from "../i18n";
|
||||||
import { KEYS } from "../keys";
|
import { KEYS } from "../keys";
|
||||||
import { isSomeElementSelected } from "../scene";
|
import { isSomeElementSelected } from "../scene";
|
||||||
@@ -44,8 +45,10 @@ const alignSelectedElements = (
|
|||||||
|
|
||||||
const updatedElementsMap = arrayToMap(updatedElements);
|
const updatedElementsMap = arrayToMap(updatedElements);
|
||||||
|
|
||||||
return elements.map(
|
return updateFrameMembershipOfSelectedElements(
|
||||||
(element) => updatedElementsMap.get(element.id) || element,
|
elements.map((element) => updatedElementsMap.get(element.id) || element),
|
||||||
|
appState,
|
||||||
|
app,
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import { distributeElements, Distribution } from "../distribute";
|
|||||||
import { getNonDeletedElements } from "../element";
|
import { getNonDeletedElements } from "../element";
|
||||||
import { isFrameLikeElement } from "../element/typeChecks";
|
import { isFrameLikeElement } from "../element/typeChecks";
|
||||||
import { ExcalidrawElement } from "../element/types";
|
import { ExcalidrawElement } from "../element/types";
|
||||||
|
import { updateFrameMembershipOfSelectedElements } from "../frame";
|
||||||
import { t } from "../i18n";
|
import { t } from "../i18n";
|
||||||
import { CODES, KEYS } from "../keys";
|
import { CODES, KEYS } from "../keys";
|
||||||
import { isSomeElementSelected } from "../scene";
|
import { isSomeElementSelected } from "../scene";
|
||||||
@@ -35,8 +36,10 @@ const distributeSelectedElements = (
|
|||||||
|
|
||||||
const updatedElementsMap = arrayToMap(updatedElements);
|
const updatedElementsMap = arrayToMap(updatedElements);
|
||||||
|
|
||||||
return elements.map(
|
return updateFrameMembershipOfSelectedElements(
|
||||||
(element) => updatedElementsMap.get(element.id) || element,
|
elements.map((element) => updatedElementsMap.get(element.id) || element),
|
||||||
|
appState,
|
||||||
|
app,
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -104,8 +104,8 @@ const duplicateElements = (
|
|||||||
|
|
||||||
const idsOfElementsToDuplicate = arrayToMap(
|
const idsOfElementsToDuplicate = arrayToMap(
|
||||||
getSelectedElements(sortedElements, appState, {
|
getSelectedElements(sortedElements, appState, {
|
||||||
includeBoundTextElement: false,
|
includeBoundTextElement: true,
|
||||||
includeElementsInFrames: false,
|
includeElementsInFrames: true,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,11 @@ export const actionFlipHorizontal = register({
|
|||||||
trackEvent: { category: "element" },
|
trackEvent: { category: "element" },
|
||||||
perform: (elements, appState, _, app) => {
|
perform: (elements, appState, _, app) => {
|
||||||
return {
|
return {
|
||||||
elements: flipSelectedElements(elements, appState, "horizontal"),
|
elements: updateFrameMembershipOfSelectedElements(
|
||||||
|
flipSelectedElements(elements, appState, "horizontal"),
|
||||||
|
appState,
|
||||||
|
app,
|
||||||
|
),
|
||||||
appState,
|
appState,
|
||||||
commitToHistory: true,
|
commitToHistory: true,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -267,7 +267,6 @@ import {
|
|||||||
isTransparent,
|
isTransparent,
|
||||||
easeToValuesRAF,
|
easeToValuesRAF,
|
||||||
muteFSAbortError,
|
muteFSAbortError,
|
||||||
arrayToMap,
|
|
||||||
isTestEnv,
|
isTestEnv,
|
||||||
easeOut,
|
easeOut,
|
||||||
updateStable,
|
updateStable,
|
||||||
@@ -2178,13 +2177,6 @@ class App extends React.Component<AppProps, AppState> {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// update frame membership if needed
|
|
||||||
updateFrameMembershipOfSelectedElements(
|
|
||||||
this.scene.getElementsIncludingDeleted(),
|
|
||||||
this.state,
|
|
||||||
this,
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -4348,13 +4340,11 @@ class App extends React.Component<AppProps, AppState> {
|
|||||||
!(isTextElement(element) && element.containerId)),
|
!(isTextElement(element) && element.containerId)),
|
||||||
);
|
);
|
||||||
|
|
||||||
const elementsMap = arrayToMap(elements);
|
|
||||||
|
|
||||||
return getElementsAtPosition(elements, (element) =>
|
return getElementsAtPosition(elements, (element) =>
|
||||||
hitTest(element, this.state, this.frameNameBoundsCache, x, y),
|
hitTest(element, this.state, this.frameNameBoundsCache, x, y),
|
||||||
).filter((element) => {
|
).filter((element) => {
|
||||||
// hitting a frame's element from outside the frame is not considered a hit
|
// hitting a frame's element from outside the frame is not considered a hit
|
||||||
const containingFrame = getContainingFrame(element, elementsMap);
|
const containingFrame = getContainingFrame(element);
|
||||||
return containingFrame &&
|
return containingFrame &&
|
||||||
this.state.frameRendering.enabled &&
|
this.state.frameRendering.enabled &&
|
||||||
this.state.frameRendering.clip
|
this.state.frameRendering.clip
|
||||||
@@ -7689,10 +7679,7 @@ class App extends React.Component<AppProps, AppState> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (linearElement?.frameId) {
|
if (linearElement?.frameId) {
|
||||||
const frame = getContainingFrame(
|
const frame = getContainingFrame(linearElement);
|
||||||
linearElement,
|
|
||||||
arrayToMap(this.scene.getElementsIncludingDeleted()),
|
|
||||||
);
|
|
||||||
|
|
||||||
if (frame && linearElement) {
|
if (frame && linearElement) {
|
||||||
if (!elementOverlapsWithFrame(linearElement, frame)) {
|
if (!elementOverlapsWithFrame(linearElement, frame)) {
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import {
|
|||||||
getFrameChildren,
|
getFrameChildren,
|
||||||
} from "../frame";
|
} from "../frame";
|
||||||
import { isShallowEqual } from "../utils";
|
import { isShallowEqual } from "../utils";
|
||||||
import { arrayToMap } from "../utils";
|
|
||||||
import { isElementInViewport } from "../element/sizeHelpers";
|
import { isElementInViewport } from "../element/sizeHelpers";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -49,13 +48,11 @@ export const getElementsWithinSelection = (
|
|||||||
const [selectionX1, selectionY1, selectionX2, selectionY2] =
|
const [selectionX1, selectionY1, selectionX2, selectionY2] =
|
||||||
getElementAbsoluteCoords(selection);
|
getElementAbsoluteCoords(selection);
|
||||||
|
|
||||||
const elementsMap = arrayToMap(elements);
|
|
||||||
|
|
||||||
let elementsInSelection = elements.filter((element) => {
|
let elementsInSelection = elements.filter((element) => {
|
||||||
let [elementX1, elementY1, elementX2, elementY2] =
|
let [elementX1, elementY1, elementX2, elementY2] =
|
||||||
getElementBounds(element);
|
getElementBounds(element);
|
||||||
|
|
||||||
const containingFrame = getContainingFrame(element, elementsMap);
|
const containingFrame = getContainingFrame(element);
|
||||||
if (containingFrame) {
|
if (containingFrame) {
|
||||||
const [fx1, fy1, fx2, fy2] = getElementBounds(containingFrame);
|
const [fx1, fy1, fx2, fy2] = getElementBounds(containingFrame);
|
||||||
|
|
||||||
@@ -81,7 +78,7 @@ export const getElementsWithinSelection = (
|
|||||||
: elementsInSelection;
|
: elementsInSelection;
|
||||||
|
|
||||||
elementsInSelection = elementsInSelection.filter((element) => {
|
elementsInSelection = elementsInSelection.filter((element) => {
|
||||||
const containingFrame = getContainingFrame(element, elementsMap);
|
const containingFrame = getContainingFrame(element);
|
||||||
|
|
||||||
if (containingFrame) {
|
if (containingFrame) {
|
||||||
return elementOverlapsWithFrame(element, containingFrame);
|
return elementOverlapsWithFrame(element, containingFrame);
|
||||||
|
|||||||
Reference in New Issue
Block a user