ensure editingLinearElement handles are rendered on top (#1967)
This commit is contained in:
parent
df4e903bd6
commit
f295550940
@ -12,7 +12,9 @@ import { SceneHistory } from "../history";
|
|||||||
import { globalSceneState } from "../scene";
|
import { globalSceneState } from "../scene";
|
||||||
|
|
||||||
export class LinearElementEditor {
|
export class LinearElementEditor {
|
||||||
public elementId: ExcalidrawElement["id"];
|
public elementId: ExcalidrawElement["id"] & {
|
||||||
|
_brand: "excalidrawLinearElementId";
|
||||||
|
};
|
||||||
public activePointIndex: number | null;
|
public activePointIndex: number | null;
|
||||||
public draggingElementPointIndex: number | null;
|
public draggingElementPointIndex: number | null;
|
||||||
public lastUncommittedPoint: Point | null;
|
public lastUncommittedPoint: Point | null;
|
||||||
@ -20,7 +22,9 @@ export class LinearElementEditor {
|
|||||||
constructor(element: NonDeleted<ExcalidrawLinearElement>) {
|
constructor(element: NonDeleted<ExcalidrawLinearElement>) {
|
||||||
LinearElementEditor.normalizePoints(element);
|
LinearElementEditor.normalizePoints(element);
|
||||||
|
|
||||||
this.elementId = element.id;
|
this.elementId = element.id as string & {
|
||||||
|
_brand: "excalidrawLinearElementId";
|
||||||
|
};
|
||||||
this.activePointIndex = null;
|
this.activePointIndex = null;
|
||||||
this.lastUncommittedPoint = null;
|
this.lastUncommittedPoint = null;
|
||||||
this.draggingElementPointIndex = null;
|
this.draggingElementPointIndex = null;
|
||||||
@ -32,7 +36,11 @@ export class LinearElementEditor {
|
|||||||
|
|
||||||
static POINT_HANDLE_SIZE = 20;
|
static POINT_HANDLE_SIZE = 20;
|
||||||
|
|
||||||
static getElement(id: ExcalidrawElement["id"]) {
|
/**
|
||||||
|
* @param id the `elementId` from the instance of this class (so that we can
|
||||||
|
* statically guarantee this method returns an ExcalidrawLinearElement)
|
||||||
|
*/
|
||||||
|
static getElement(id: InstanceType<typeof LinearElementEditor>["elementId"]) {
|
||||||
const element = globalSceneState.getNonDeletedElement(id);
|
const element = globalSceneState.getNonDeletedElement(id);
|
||||||
if (element) {
|
if (element) {
|
||||||
return element as NonDeleted<ExcalidrawLinearElement>;
|
return element as NonDeleted<ExcalidrawLinearElement>;
|
||||||
|
@ -30,7 +30,6 @@ import { getSelectedElements } from "../scene/selection";
|
|||||||
|
|
||||||
import { renderElement, renderElementToSvg } from "./renderElement";
|
import { renderElement, renderElementToSvg } from "./renderElement";
|
||||||
import { getClientColors } from "../clients";
|
import { getClientColors } from "../clients";
|
||||||
import { isLinearElement } from "../element/typeChecks";
|
|
||||||
import { LinearElementEditor } from "../element/linearElementEditor";
|
import { LinearElementEditor } from "../element/linearElementEditor";
|
||||||
import {
|
import {
|
||||||
isSelectedViaGroup,
|
isSelectedViaGroup,
|
||||||
@ -220,14 +219,16 @@ export const renderScene = (
|
|||||||
|
|
||||||
visibleElements.forEach((element) => {
|
visibleElements.forEach((element) => {
|
||||||
renderElement(element, rc, context, renderOptimizations, sceneState);
|
renderElement(element, rc, context, renderOptimizations, sceneState);
|
||||||
if (
|
});
|
||||||
isLinearElement(element) &&
|
|
||||||
appState.editingLinearElement &&
|
if (appState.editingLinearElement) {
|
||||||
appState.editingLinearElement.elementId === element.id
|
const element = LinearElementEditor.getElement(
|
||||||
) {
|
appState.editingLinearElement.elementId,
|
||||||
|
);
|
||||||
|
if (element) {
|
||||||
renderLinearPointHandles(context, appState, sceneState, element);
|
renderLinearPointHandles(context, appState, sceneState, element);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
// Paint selection element
|
// Paint selection element
|
||||||
if (selectionElement) {
|
if (selectionElement) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user