Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4c5e196f25 | |||
| 25af9023d4 | |||
| 76795c7d1b | |||
| ca22a52102 | |||
| a249f332a2 |
@@ -18,6 +18,7 @@ import {
|
|||||||
getDefaultAppState,
|
getDefaultAppState,
|
||||||
isEraserActive,
|
isEraserActive,
|
||||||
isHandToolActive,
|
isHandToolActive,
|
||||||
|
isLaserPointerActive,
|
||||||
} from "../appState";
|
} from "../appState";
|
||||||
import { DEFAULT_CANVAS_BACKGROUND_PICKS } from "../colors";
|
import { DEFAULT_CANVAS_BACKGROUND_PICKS } from "../colors";
|
||||||
import { Bounds } from "../element/bounds";
|
import { Bounds } from "../element/bounds";
|
||||||
@@ -439,3 +440,44 @@ export const actionToggleHandTool = register({
|
|||||||
},
|
},
|
||||||
keyTest: (event) => event.key === KEYS.H,
|
keyTest: (event) => event.key === KEYS.H,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const actionToggleLaserPointer = register({
|
||||||
|
name: "toggleLaserPointerTool",
|
||||||
|
viewMode: true,
|
||||||
|
trackEvent: { category: "menu" },
|
||||||
|
perform(elements, appState, _, app) {
|
||||||
|
let activeTool: AppState["activeTool"];
|
||||||
|
|
||||||
|
if (isLaserPointerActive(appState)) {
|
||||||
|
activeTool = updateActiveTool(appState, {
|
||||||
|
...(appState.activeTool.lastActiveTool || {
|
||||||
|
type: appState.viewModeEnabled ? "hand" : "selection",
|
||||||
|
}),
|
||||||
|
lastActiveToolBeforeEraser: null,
|
||||||
|
});
|
||||||
|
setCursor(
|
||||||
|
app.interactiveCanvas,
|
||||||
|
appState.viewModeEnabled ? CURSOR_TYPE.GRAB : CURSOR_TYPE.POINTER,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
activeTool = updateActiveTool(appState, {
|
||||||
|
type: "laser",
|
||||||
|
lastActiveToolBeforeEraser: appState.activeTool,
|
||||||
|
});
|
||||||
|
setCursor(app.interactiveCanvas, CURSOR_TYPE.CROSSHAIR);
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
appState: {
|
||||||
|
...appState,
|
||||||
|
selectedElementIds: {},
|
||||||
|
selectedGroupIds: {},
|
||||||
|
activeEmbeddable: null,
|
||||||
|
activeTool,
|
||||||
|
},
|
||||||
|
commitToHistory: true,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
checked: (appState) => appState.activeTool.type === "laser",
|
||||||
|
contextItemLabel: "labels.laser",
|
||||||
|
});
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ export type ShortcutName =
|
|||||||
| "flipVertical"
|
| "flipVertical"
|
||||||
| "hyperlink"
|
| "hyperlink"
|
||||||
| "toggleElementLock"
|
| "toggleElementLock"
|
||||||
|
| "toggleLaserPointerTool"
|
||||||
>
|
>
|
||||||
| "saveScene"
|
| "saveScene"
|
||||||
| "imageExport";
|
| "imageExport";
|
||||||
@@ -83,6 +84,7 @@ const shortcutMap: Record<ShortcutName, string[]> = {
|
|||||||
viewMode: [getShortcutKey("Alt+R")],
|
viewMode: [getShortcutKey("Alt+R")],
|
||||||
hyperlink: [getShortcutKey("CtrlOrCmd+K")],
|
hyperlink: [getShortcutKey("CtrlOrCmd+K")],
|
||||||
toggleElementLock: [getShortcutKey("CtrlOrCmd+Shift+L")],
|
toggleElementLock: [getShortcutKey("CtrlOrCmd+Shift+L")],
|
||||||
|
toggleLaserPointerTool: [getShortcutKey("K")],
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getShortcutFromShortcutName = (name: ShortcutName) => {
|
export const getShortcutFromShortcutName = (name: ShortcutName) => {
|
||||||
|
|||||||
@@ -124,7 +124,8 @@ export type ActionName =
|
|||||||
| "setFrameAsActiveTool"
|
| "setFrameAsActiveTool"
|
||||||
| "setEmbeddableAsActiveTool"
|
| "setEmbeddableAsActiveTool"
|
||||||
| "createContainerFromText"
|
| "createContainerFromText"
|
||||||
| "wrapTextInContainer";
|
| "wrapTextInContainer"
|
||||||
|
| "toggleLaserPointerTool";
|
||||||
|
|
||||||
export type PanelComponentProps = {
|
export type PanelComponentProps = {
|
||||||
elements: readonly ExcalidrawElement[];
|
elements: readonly ExcalidrawElement[];
|
||||||
|
|||||||
@@ -266,3 +266,11 @@ export const isHandToolActive = ({
|
|||||||
}) => {
|
}) => {
|
||||||
return activeTool.type === "hand";
|
return activeTool.type === "hand";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const isLaserPointerActive = ({
|
||||||
|
activeTool,
|
||||||
|
}: {
|
||||||
|
activeTool: AppState["activeTool"];
|
||||||
|
}) => {
|
||||||
|
return activeTool.type === "laser";
|
||||||
|
};
|
||||||
|
|||||||
+56
-76
@@ -46,6 +46,7 @@ import {
|
|||||||
getDefaultAppState,
|
getDefaultAppState,
|
||||||
isEraserActive,
|
isEraserActive,
|
||||||
isHandToolActive,
|
isHandToolActive,
|
||||||
|
isLaserPointerActive,
|
||||||
} from "../appState";
|
} from "../appState";
|
||||||
import { parseClipboard } from "../clipboard";
|
import { parseClipboard } from "../clipboard";
|
||||||
import {
|
import {
|
||||||
@@ -343,7 +344,11 @@ import {
|
|||||||
actionRemoveAllElementsFromFrame,
|
actionRemoveAllElementsFromFrame,
|
||||||
actionSelectAllElementsInFrame,
|
actionSelectAllElementsInFrame,
|
||||||
} from "../actions/actionFrame";
|
} from "../actions/actionFrame";
|
||||||
import { actionToggleHandTool, zoomToFit } from "../actions/actionCanvas";
|
import {
|
||||||
|
actionToggleHandTool,
|
||||||
|
zoomToFit,
|
||||||
|
actionToggleLaserPointer,
|
||||||
|
} from "../actions/actionCanvas";
|
||||||
import { jotaiStore } from "../jotai";
|
import { jotaiStore } from "../jotai";
|
||||||
import { activeConfirmDialogAtom } from "./ActiveConfirmDialog";
|
import { activeConfirmDialogAtom } from "./ActiveConfirmDialog";
|
||||||
import {
|
import {
|
||||||
@@ -1211,7 +1216,6 @@ class App extends React.Component<AppProps, AppState> {
|
|||||||
}
|
}
|
||||||
app={this}
|
app={this}
|
||||||
isCollaborating={this.props.isCollaborating}
|
isCollaborating={this.props.isCollaborating}
|
||||||
uiDisabled={this.props.ui === false}
|
|
||||||
>
|
>
|
||||||
{this.props.children}
|
{this.props.children}
|
||||||
</LayerUI>
|
</LayerUI>
|
||||||
@@ -1238,16 +1242,14 @@ class App extends React.Component<AppProps, AppState> {
|
|||||||
closable={this.state.toast.closable}
|
closable={this.state.toast.closable}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{this.state.contextMenu &&
|
{this.state.contextMenu && (
|
||||||
this.props.interactive !== false &&
|
<ContextMenu
|
||||||
this.props.ui !== false && (
|
items={this.state.contextMenu.items}
|
||||||
<ContextMenu
|
top={this.state.contextMenu.top}
|
||||||
items={this.state.contextMenu.items}
|
left={this.state.contextMenu.left}
|
||||||
top={this.state.contextMenu.top}
|
actionManager={this.actionManager}
|
||||||
left={this.state.contextMenu.left}
|
/>
|
||||||
actionManager={this.actionManager}
|
)}
|
||||||
/>
|
|
||||||
)}
|
|
||||||
<StaticCanvas
|
<StaticCanvas
|
||||||
canvas={this.canvas}
|
canvas={this.canvas}
|
||||||
rc={this.rc}
|
rc={this.rc}
|
||||||
@@ -2111,10 +2113,6 @@ class App extends React.Component<AppProps, AppState> {
|
|||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.props.interactive === false) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!didTapTwice) {
|
if (!didTapTwice) {
|
||||||
didTapTwice = true;
|
didTapTwice = true;
|
||||||
clearTimeout(tappedTwiceTimer);
|
clearTimeout(tappedTwiceTimer);
|
||||||
@@ -2149,10 +2147,6 @@ class App extends React.Component<AppProps, AppState> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
private onTouchEnd = (event: TouchEvent) => {
|
private onTouchEnd = (event: TouchEvent) => {
|
||||||
if (this.props.interactive === false) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.resetContextMenuTimer();
|
this.resetContextMenuTimer();
|
||||||
if (event.touches.length > 0) {
|
if (event.touches.length > 0) {
|
||||||
this.setState({
|
this.setState({
|
||||||
@@ -2169,10 +2163,6 @@ class App extends React.Component<AppProps, AppState> {
|
|||||||
|
|
||||||
public pasteFromClipboard = withBatchedUpdates(
|
public pasteFromClipboard = withBatchedUpdates(
|
||||||
async (event: ClipboardEvent | null) => {
|
async (event: ClipboardEvent | null) => {
|
||||||
if (this.props.interactive === false) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const isPlainPaste = !!(IS_PLAIN_PASTE && event);
|
const isPlainPaste = !!(IS_PLAIN_PASTE && event);
|
||||||
|
|
||||||
// #686
|
// #686
|
||||||
@@ -2925,7 +2915,22 @@ class App extends React.Component<AppProps, AppState> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (event.key === KEYS.K && !event.altKey && !event[KEYS.CTRL_OR_CMD]) {
|
||||||
|
if (isLaserPointerActive(this.state)) {
|
||||||
|
this.setActiveTool({
|
||||||
|
type: "selection",
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.setActiveTool({ type: "laser" });
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (this.state.viewModeEnabled) {
|
if (this.state.viewModeEnabled) {
|
||||||
|
//revert to hand in case a key is pressed (K is handled above)
|
||||||
|
if (event.key !== KEYS.K) {
|
||||||
|
this.setActiveTool({ type: "selection" });
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3075,15 +3080,6 @@ class App extends React.Component<AppProps, AppState> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.key === KEYS.K && !event.altKey && !event[KEYS.CTRL_OR_CMD]) {
|
|
||||||
if (this.state.activeTool.type === "laser") {
|
|
||||||
this.setActiveTool({ type: "selection" });
|
|
||||||
} else {
|
|
||||||
this.setActiveTool({ type: "laser" });
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (
|
if (
|
||||||
event[KEYS.CTRL_OR_CMD] &&
|
event[KEYS.CTRL_OR_CMD] &&
|
||||||
(event.key === KEYS.BACKSPACE || event.key === KEYS.DELETE)
|
(event.key === KEYS.BACKSPACE || event.key === KEYS.DELETE)
|
||||||
@@ -3215,10 +3211,6 @@ class App extends React.Component<AppProps, AppState> {
|
|||||||
private onGestureStart = withBatchedUpdates((event: GestureEvent) => {
|
private onGestureStart = withBatchedUpdates((event: GestureEvent) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
if (this.props.interactive === false) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// we only want to deselect on touch screens because user may have selected
|
// we only want to deselect on touch screens because user may have selected
|
||||||
// elements by mistake while zooming
|
// elements by mistake while zooming
|
||||||
if (this.isTouchScreenMultiTouchGesture()) {
|
if (this.isTouchScreenMultiTouchGesture()) {
|
||||||
@@ -3234,10 +3226,6 @@ class App extends React.Component<AppProps, AppState> {
|
|||||||
private onGestureChange = withBatchedUpdates((event: GestureEvent) => {
|
private onGestureChange = withBatchedUpdates((event: GestureEvent) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
if (this.props.interactive === false) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// onGestureChange only has zoom factor but not the center.
|
// onGestureChange only has zoom factor but not the center.
|
||||||
// If we're on iPad or iPhone, then we recognize multi-touch and will
|
// If we're on iPad or iPhone, then we recognize multi-touch and will
|
||||||
// zoom in at the right location in the touchmove handler
|
// zoom in at the right location in the touchmove handler
|
||||||
@@ -3269,11 +3257,6 @@ class App extends React.Component<AppProps, AppState> {
|
|||||||
// fires only on Safari
|
// fires only on Safari
|
||||||
private onGestureEnd = withBatchedUpdates((event: GestureEvent) => {
|
private onGestureEnd = withBatchedUpdates((event: GestureEvent) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
if (this.props.interactive === false) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// reselect elements only on touch screens (see onGestureStart)
|
// reselect elements only on touch screens (see onGestureStart)
|
||||||
if (this.isTouchScreenMultiTouchGesture()) {
|
if (this.isTouchScreenMultiTouchGesture()) {
|
||||||
this.setState({
|
this.setState({
|
||||||
@@ -3640,6 +3623,18 @@ class App extends React.Component<AppProps, AppState> {
|
|||||||
if (this.state.multiElement) {
|
if (this.state.multiElement) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.state.viewModeEnabled) {
|
||||||
|
if (this.state.activeTool.type === "laser") {
|
||||||
|
this.setActiveTool({ type: "selection" });
|
||||||
|
setCursor(this.interactiveCanvas, CURSOR_TYPE.GRAB);
|
||||||
|
} else {
|
||||||
|
this.setActiveTool({ type: "laser" });
|
||||||
|
setCursor(this.interactiveCanvas, CURSOR_TYPE.CROSSHAIR);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// we should only be able to double click when mode is selection
|
// we should only be able to double click when mode is selection
|
||||||
if (this.state.activeTool.type !== "selection") {
|
if (this.state.activeTool.type !== "selection") {
|
||||||
return;
|
return;
|
||||||
@@ -3855,10 +3850,6 @@ class App extends React.Component<AppProps, AppState> {
|
|||||||
private handleCanvasPointerMove = (
|
private handleCanvasPointerMove = (
|
||||||
event: React.PointerEvent<HTMLCanvasElement>,
|
event: React.PointerEvent<HTMLCanvasElement>,
|
||||||
) => {
|
) => {
|
||||||
if (this.props.interactive === false) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.savePointer(event.clientX, event.clientY, this.state.cursorButton);
|
this.savePointer(event.clientX, event.clientY, this.state.cursorButton);
|
||||||
|
|
||||||
if (gesture.pointers.has(event.pointerId)) {
|
if (gesture.pointers.has(event.pointerId)) {
|
||||||
@@ -4511,10 +4502,8 @@ class App extends React.Component<AppProps, AppState> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.props.interactive !== false) {
|
if (this.handleCanvasPanUsingWheelOrSpaceDrag(event)) {
|
||||||
if (this.handleCanvasPanUsingWheelOrSpaceDrag(event)) {
|
return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.lastPointerDownEvent = event;
|
this.lastPointerDownEvent = event;
|
||||||
@@ -4546,20 +4535,14 @@ class App extends React.Component<AppProps, AppState> {
|
|||||||
selectedElementsAreBeingDragged: false,
|
selectedElementsAreBeingDragged: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (
|
if (this.handleDraggingScrollBar(event, pointerDownState)) {
|
||||||
this.props.interactive !== false &&
|
|
||||||
this.handleDraggingScrollBar(event, pointerDownState)
|
|
||||||
) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.clearSelectionIfNotUsingSelection();
|
this.clearSelectionIfNotUsingSelection();
|
||||||
this.updateBindingEnabledOnPointerMove(event);
|
this.updateBindingEnabledOnPointerMove(event);
|
||||||
|
|
||||||
if (
|
if (this.handleSelectionOnPointerDown(event, pointerDownState)) {
|
||||||
this.props.interactive !== false &&
|
|
||||||
this.handleSelectionOnPointerDown(event, pointerDownState)
|
|
||||||
) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4641,15 +4624,15 @@ class App extends React.Component<AppProps, AppState> {
|
|||||||
const onPointerMove =
|
const onPointerMove =
|
||||||
this.onPointerMoveFromPointerDownHandler(pointerDownState);
|
this.onPointerMoveFromPointerDownHandler(pointerDownState);
|
||||||
|
|
||||||
|
const onPointerUp =
|
||||||
|
this.onPointerUpFromPointerDownHandler(pointerDownState);
|
||||||
|
|
||||||
|
const onKeyDown = this.onKeyDownFromPointerDownHandler(pointerDownState);
|
||||||
|
const onKeyUp = this.onKeyUpFromPointerDownHandler(pointerDownState);
|
||||||
|
|
||||||
|
lastPointerUp = onPointerUp;
|
||||||
|
|
||||||
if (!this.state.viewModeEnabled || this.state.activeTool.type === "laser") {
|
if (!this.state.viewModeEnabled || this.state.activeTool.type === "laser") {
|
||||||
const onPointerUp =
|
|
||||||
this.onPointerUpFromPointerDownHandler(pointerDownState);
|
|
||||||
|
|
||||||
const onKeyDown = this.onKeyDownFromPointerDownHandler(pointerDownState);
|
|
||||||
const onKeyUp = this.onKeyUpFromPointerDownHandler(pointerDownState);
|
|
||||||
|
|
||||||
lastPointerUp = onPointerUp;
|
|
||||||
|
|
||||||
window.addEventListener(EVENT.POINTER_MOVE, onPointerMove);
|
window.addEventListener(EVENT.POINTER_MOVE, onPointerMove);
|
||||||
window.addEventListener(EVENT.POINTER_UP, onPointerUp);
|
window.addEventListener(EVENT.POINTER_UP, onPointerUp);
|
||||||
window.addEventListener(EVENT.KEYDOWN, onKeyDown);
|
window.addEventListener(EVENT.KEYDOWN, onKeyDown);
|
||||||
@@ -4779,7 +4762,7 @@ class App extends React.Component<AppProps, AppState> {
|
|||||||
(event.button === POINTER_BUTTON.WHEEL ||
|
(event.button === POINTER_BUTTON.WHEEL ||
|
||||||
(event.button === POINTER_BUTTON.MAIN && isHoldingSpace) ||
|
(event.button === POINTER_BUTTON.MAIN && isHoldingSpace) ||
|
||||||
isHandToolActive(this.state) ||
|
isHandToolActive(this.state) ||
|
||||||
this.state.viewModeEnabled)
|
(this.state.viewModeEnabled && !isLaserPointerActive(this.state)))
|
||||||
) ||
|
) ||
|
||||||
isTextElement(this.state.editingElement)
|
isTextElement(this.state.editingElement)
|
||||||
) {
|
) {
|
||||||
@@ -7844,10 +7827,6 @@ class App extends React.Component<AppProps, AppState> {
|
|||||||
) => {
|
) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
if (this.props.interactive === false) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (
|
if (
|
||||||
(("pointerType" in event.nativeEvent &&
|
(("pointerType" in event.nativeEvent &&
|
||||||
event.nativeEvent.pointerType === "touch") ||
|
event.nativeEvent.pointerType === "touch") ||
|
||||||
@@ -8187,6 +8166,7 @@ class App extends React.Component<AppProps, AppState> {
|
|||||||
actionToggleZenMode,
|
actionToggleZenMode,
|
||||||
actionToggleViewMode,
|
actionToggleViewMode,
|
||||||
actionToggleStats,
|
actionToggleStats,
|
||||||
|
actionToggleLaserPointer,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -8259,7 +8239,7 @@ class App extends React.Component<AppProps, AppState> {
|
|||||||
event: WheelEvent | React.WheelEvent<HTMLDivElement | HTMLCanvasElement>,
|
event: WheelEvent | React.WheelEvent<HTMLDivElement | HTMLCanvasElement>,
|
||||||
) => {
|
) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
if (isPanning || this.props.interactive === false) {
|
if (isPanning) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ export class LaserPathManager {
|
|||||||
private collaboratorsState: Map<string, CollabolatorState> = new Map();
|
private collaboratorsState: Map<string, CollabolatorState> = new Map();
|
||||||
|
|
||||||
private rafId: number | undefined;
|
private rafId: number | undefined;
|
||||||
private lastUpdate = 0;
|
private isDrawing = false;
|
||||||
private container: SVGSVGElement | undefined;
|
private container: SVGSVGElement | undefined;
|
||||||
|
|
||||||
constructor(private app: App) {
|
constructor(private app: App) {
|
||||||
@@ -100,7 +100,7 @@ export class LaserPathManager {
|
|||||||
|
|
||||||
destroy() {
|
destroy() {
|
||||||
this.stop();
|
this.stop();
|
||||||
this.lastUpdate = 0;
|
this.isDrawing = false;
|
||||||
this.ownState = instantiateCollabolatorState();
|
this.ownState = instantiateCollabolatorState();
|
||||||
this.collaboratorsState = new Map();
|
this.collaboratorsState = new Map();
|
||||||
}
|
}
|
||||||
@@ -127,7 +127,7 @@ export class LaserPathManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private updatePath(state: CollabolatorState) {
|
private updatePath(state: CollabolatorState) {
|
||||||
this.lastUpdate = performance.now();
|
this.isDrawing = true;
|
||||||
|
|
||||||
if (!this.isRunning) {
|
if (!this.isRunning) {
|
||||||
this.start();
|
this.start();
|
||||||
@@ -160,7 +160,7 @@ export class LaserPathManager {
|
|||||||
|
|
||||||
this.updateCollabolatorsState();
|
this.updateCollabolatorsState();
|
||||||
|
|
||||||
if (performance.now() - this.lastUpdate < DECAY_TIME * 2) {
|
if (this.isDrawing) {
|
||||||
this.update();
|
this.update();
|
||||||
} else {
|
} else {
|
||||||
this.isRunning = false;
|
this.isRunning = false;
|
||||||
@@ -250,6 +250,8 @@ export class LaserPathManager {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let somePathsExist = false;
|
||||||
|
|
||||||
for (const [key, state] of this.collaboratorsState.entries()) {
|
for (const [key, state] of this.collaboratorsState.entries()) {
|
||||||
if (!this.app.state.collaborators.has(key)) {
|
if (!this.app.state.collaborators.has(key)) {
|
||||||
state.svg.remove();
|
state.svg.remove();
|
||||||
@@ -269,6 +271,10 @@ export class LaserPathManager {
|
|||||||
paths += ` ${this.draw(state.currentPath)}`;
|
paths += ` ${this.draw(state.currentPath)}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (paths.trim()) {
|
||||||
|
somePathsExist = true;
|
||||||
|
}
|
||||||
|
|
||||||
state.svg.setAttribute("d", paths);
|
state.svg.setAttribute("d", paths);
|
||||||
state.svg.setAttribute("fill", getClientColor(key));
|
state.svg.setAttribute("fill", getClientColor(key));
|
||||||
}
|
}
|
||||||
@@ -287,7 +293,17 @@ export class LaserPathManager {
|
|||||||
paths += ` ${this.draw(this.ownState.currentPath)}`;
|
paths += ` ${this.draw(this.ownState.currentPath)}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
paths = paths.trim();
|
||||||
|
|
||||||
|
if (paths) {
|
||||||
|
somePathsExist = true;
|
||||||
|
}
|
||||||
|
|
||||||
this.ownState.svg.setAttribute("d", paths);
|
this.ownState.svg.setAttribute("d", paths);
|
||||||
this.ownState.svg.setAttribute("fill", "red");
|
this.ownState.svg.setAttribute("fill", "red");
|
||||||
|
|
||||||
|
if (!somePathsExist) {
|
||||||
|
this.isDrawing = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,7 +79,6 @@ interface LayerUIProps {
|
|||||||
children?: React.ReactNode;
|
children?: React.ReactNode;
|
||||||
app: AppClassProperties;
|
app: AppClassProperties;
|
||||||
isCollaborating: boolean;
|
isCollaborating: boolean;
|
||||||
uiDisabled: boolean;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const DefaultMainMenu: React.FC<{
|
const DefaultMainMenu: React.FC<{
|
||||||
@@ -138,7 +137,6 @@ const LayerUI = ({
|
|||||||
children,
|
children,
|
||||||
app,
|
app,
|
||||||
isCollaborating,
|
isCollaborating,
|
||||||
uiDisabled,
|
|
||||||
}: LayerUIProps) => {
|
}: LayerUIProps) => {
|
||||||
const device = useDevice();
|
const device = useDevice();
|
||||||
const tunnels = useInitializeTunnels();
|
const tunnels = useInitializeTunnels();
|
||||||
@@ -356,10 +354,6 @@ const LayerUI = ({
|
|||||||
|
|
||||||
const isSidebarDocked = useAtomValue(isSidebarDockedAtom, jotaiScope);
|
const isSidebarDocked = useAtomValue(isSidebarDockedAtom, jotaiScope);
|
||||||
|
|
||||||
if (uiDisabled) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
const layerUIJSX = (
|
const layerUIJSX = (
|
||||||
<>
|
<>
|
||||||
{/* ------------------------- tunneled UI ---------------------------- */}
|
{/* ------------------------- tunneled UI ---------------------------- */}
|
||||||
|
|||||||
@@ -155,9 +155,7 @@ const InteractiveCanvas = (props: InteractiveCanvasProps) => {
|
|||||||
onPointerCancel={props.onPointerCancel}
|
onPointerCancel={props.onPointerCancel}
|
||||||
onTouchMove={props.onTouchMove}
|
onTouchMove={props.onTouchMove}
|
||||||
onPointerDown={props.onPointerDown}
|
onPointerDown={props.onPointerDown}
|
||||||
onDoubleClick={
|
onDoubleClick={props.onDoubleClick}
|
||||||
props.appState.viewModeEnabled ? undefined : props.onDoubleClick
|
|
||||||
}
|
|
||||||
>
|
>
|
||||||
{t("labels.drawingCanvas")}
|
{t("labels.drawingCanvas")}
|
||||||
</canvas>
|
</canvas>
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"labels": {
|
"labels": {
|
||||||
|
"laser": "Toggle laser pointer",
|
||||||
"paste": "Paste",
|
"paste": "Paste",
|
||||||
"pasteAsPlaintext": "Paste as plaintext",
|
"pasteAsPlaintext": "Paste as plaintext",
|
||||||
"pasteCharts": "Paste charts",
|
"pasteCharts": "Paste charts",
|
||||||
|
|||||||
@@ -44,8 +44,6 @@ const ExcalidrawBase = (props: ExcalidrawProps) => {
|
|||||||
children,
|
children,
|
||||||
validateEmbeddable,
|
validateEmbeddable,
|
||||||
renderEmbeddable,
|
renderEmbeddable,
|
||||||
ui,
|
|
||||||
interactive,
|
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
const canvasActions = props.UIOptions?.canvasActions;
|
const canvasActions = props.UIOptions?.canvasActions;
|
||||||
@@ -102,7 +100,7 @@ const ExcalidrawBase = (props: ExcalidrawProps) => {
|
|||||||
onPointerUpdate={onPointerUpdate}
|
onPointerUpdate={onPointerUpdate}
|
||||||
renderTopRightUI={renderTopRightUI}
|
renderTopRightUI={renderTopRightUI}
|
||||||
langCode={langCode}
|
langCode={langCode}
|
||||||
viewModeEnabled={interactive === false ? true : viewModeEnabled}
|
viewModeEnabled={viewModeEnabled}
|
||||||
zenModeEnabled={zenModeEnabled}
|
zenModeEnabled={zenModeEnabled}
|
||||||
gridModeEnabled={gridModeEnabled}
|
gridModeEnabled={gridModeEnabled}
|
||||||
libraryReturnUrl={libraryReturnUrl}
|
libraryReturnUrl={libraryReturnUrl}
|
||||||
@@ -121,8 +119,6 @@ const ExcalidrawBase = (props: ExcalidrawProps) => {
|
|||||||
onScrollChange={onScrollChange}
|
onScrollChange={onScrollChange}
|
||||||
validateEmbeddable={validateEmbeddable}
|
validateEmbeddable={validateEmbeddable}
|
||||||
renderEmbeddable={renderEmbeddable}
|
renderEmbeddable={renderEmbeddable}
|
||||||
ui={ui}
|
|
||||||
interactive={interactive}
|
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
</App>
|
</App>
|
||||||
|
|||||||
@@ -445,8 +445,6 @@ export interface ExcalidrawProps {
|
|||||||
element: NonDeleted<ExcalidrawEmbeddableElement>,
|
element: NonDeleted<ExcalidrawEmbeddableElement>,
|
||||||
appState: AppState,
|
appState: AppState,
|
||||||
) => JSX.Element | null;
|
) => JSX.Element | null;
|
||||||
interactive?: boolean;
|
|
||||||
ui?: boolean;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export type SceneData = {
|
export type SceneData = {
|
||||||
|
|||||||
Reference in New Issue
Block a user