mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
Move fractional index in element
This commit is contained in:
parent
1c5b8372b9
commit
3782407c76
18 changed files with 88 additions and 45 deletions
|
@ -47,7 +47,9 @@
|
|||
"last 1 safari version"
|
||||
]
|
||||
},
|
||||
"dependencies": {},
|
||||
"dependencies": {
|
||||
"fractional-indexing": "3.2.0"
|
||||
},
|
||||
"devDependencies": {},
|
||||
"bugs": "https://github.com/excalidraw/excalidraw/issues",
|
||||
"repository": "https://github.com/excalidraw/excalidraw",
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
import { generateNKeysBetween } from "fractional-indexing";
|
||||
|
||||
import { arrayToMap } from "@excalidraw/common";
|
||||
|
||||
import { mutateElement } from "@excalidraw/element/mutateElement";
|
||||
import { getBoundTextElement } from "@excalidraw/element/textElement";
|
||||
import { hasBoundTextElement } from "@excalidraw/element/typeChecks";
|
||||
|
||||
import { arrayToMap } from "@excalidraw/common";
|
||||
|
||||
import type {
|
||||
ExcalidrawElement,
|
||||
FractionalIndex,
|
||||
OrderedExcalidrawElement,
|
||||
} from "@excalidraw/element/types";
|
||||
|
||||
import { InvalidFractionalIndexError } from "./errors";
|
||||
import { InvalidFractionalIndexError } from "../../excalidraw/errors";
|
||||
|
||||
/**
|
||||
* Envisioned relation between array order and fractional indices:
|
|
@ -1,15 +1,14 @@
|
|||
import { KEYS, arrayToMap } from "@excalidraw/common";
|
||||
|
||||
import { pointFrom } from "@excalidraw/math";
|
||||
import React from "react";
|
||||
|
||||
import { actionWrapTextInContainer } from "../actions/actionBoundText";
|
||||
import { getTransformHandles } from "../element/transformHandles";
|
||||
import { Excalidraw, isLinearElement } from "../index";
|
||||
import { KEYS } from "../keys";
|
||||
import { arrayToMap } from "../utils";
|
||||
import { actionWrapTextInContainer } from "@excalidraw/excalidraw/actions/actionBoundText";
|
||||
import { getTransformHandles } from "@excalidraw/element/transformHandles";
|
||||
import { Excalidraw, isLinearElement } from "@excalidraw/excalidraw";
|
||||
|
||||
import { API } from "./helpers/api";
|
||||
import { UI, Pointer, Keyboard } from "./helpers/ui";
|
||||
import { fireEvent, render } from "./test-utils";
|
||||
import { API } from "@excalidraw/excalidraw/tests/helpers/api";
|
||||
import { UI, Pointer, Keyboard } from "@excalidraw/excalidraw/tests/helpers/ui";
|
||||
import { fireEvent, render } from "@excalidraw/excalidraw/tests/test-utils";
|
||||
|
||||
const { h } = window;
|
||||
|
|
@ -1,18 +1,24 @@
|
|||
/* eslint-disable no-lone-blocks */
|
||||
import { generateKeyBetween } from "fractional-indexing";
|
||||
|
||||
import { deepCopyElement } from "../element/newElement";
|
||||
import { InvalidFractionalIndexError } from "../errors";
|
||||
import { arrayToMap } from "@excalidraw/common";
|
||||
|
||||
import {
|
||||
syncInvalidIndices,
|
||||
syncMovedIndices,
|
||||
validateFractionalIndices,
|
||||
} from "../fractionalIndex";
|
||||
import { arrayToMap } from "../utils";
|
||||
} from "@excalidraw/element/fractionalIndex";
|
||||
|
||||
import { API } from "./helpers/api";
|
||||
import { deepCopyElement } from "@excalidraw/element/newElement";
|
||||
|
||||
import type { ExcalidrawElement, FractionalIndex } from "../element/types";
|
||||
import { InvalidFractionalIndexError } from "@excalidraw/excalidraw/errors";
|
||||
|
||||
import { API } from "@excalidraw/excalidraw/tests/helpers/api";
|
||||
|
||||
import type {
|
||||
ExcalidrawElement,
|
||||
FractionalIndex,
|
||||
} from "@excalidraw/element/types";
|
||||
|
||||
describe("sync invalid indices with array order", () => {
|
||||
describe("should NOT sync empty array", () => {
|
|
@ -29,6 +29,8 @@ import {
|
|||
import { mutateElement } from "@excalidraw/element/mutateElement";
|
||||
import { measureText } from "@excalidraw/element/textMeasurements";
|
||||
|
||||
import { syncMovedIndices } from "@excalidraw/element/fractionalIndex";
|
||||
|
||||
import type {
|
||||
ExcalidrawElement,
|
||||
ExcalidrawLinearElement,
|
||||
|
@ -36,7 +38,6 @@ import type {
|
|||
ExcalidrawTextElement,
|
||||
} from "@excalidraw/element/types";
|
||||
|
||||
import { syncMovedIndices } from "../fractionalIndex";
|
||||
import { CaptureUpdateAction } from "../store";
|
||||
|
||||
import { register } from "./register";
|
||||
|
|
|
@ -26,6 +26,8 @@ import {
|
|||
isElementInGroup,
|
||||
} from "@excalidraw/element/groups";
|
||||
|
||||
import { syncMovedIndices } from "@excalidraw/element/fractionalIndex";
|
||||
|
||||
import type {
|
||||
ExcalidrawElement,
|
||||
ExcalidrawTextElement,
|
||||
|
@ -35,8 +37,6 @@ import type {
|
|||
import { ToolButton } from "../components/ToolButton";
|
||||
import { UngroupIcon, GroupIcon } from "../components/icons";
|
||||
|
||||
import { syncMovedIndices } from "../fractionalIndex";
|
||||
|
||||
import { t } from "../i18n";
|
||||
|
||||
import { isSomeElementSelected } from "../scene";
|
||||
|
|
|
@ -31,6 +31,11 @@ import {
|
|||
|
||||
import { getNonDeletedGroupIds } from "@excalidraw/element/groups";
|
||||
|
||||
import {
|
||||
orderByFractionalIndex,
|
||||
syncMovedIndices,
|
||||
} from "@excalidraw/element/fractionalIndex";
|
||||
|
||||
import type { BindableProp, BindingProp } from "@excalidraw/element/binding";
|
||||
|
||||
import type { ElementUpdate } from "@excalidraw/element/mutateElement";
|
||||
|
@ -46,7 +51,6 @@ import type {
|
|||
SceneElementsMap,
|
||||
} from "@excalidraw/element/types";
|
||||
|
||||
import { orderByFractionalIndex, syncMovedIndices } from "./fractionalIndex";
|
||||
import { getObservedAppState } from "./store";
|
||||
|
||||
import type {
|
||||
|
|
|
@ -284,6 +284,11 @@ import {
|
|||
selectGroupsForSelectedElements,
|
||||
} from "@excalidraw/element/groups";
|
||||
|
||||
import {
|
||||
syncInvalidIndices,
|
||||
syncMovedIndices,
|
||||
} from "@excalidraw/element/fractionalIndex";
|
||||
|
||||
import type { LocalPoint, Radians } from "@excalidraw/math";
|
||||
|
||||
import type {
|
||||
|
@ -447,7 +452,6 @@ import { LaserTrails } from "../laser-trails";
|
|||
import { withBatchedUpdates, withBatchedUpdatesThrottled } from "../reactUtils";
|
||||
import { textWysiwyg } from "../wysiwyg/textWysiwyg";
|
||||
import { isOverScrollBars } from "../scene/scrollbars";
|
||||
import { syncInvalidIndices, syncMovedIndices } from "../fractionalIndex";
|
||||
|
||||
import { isMaybeMermaidDefinition } from "../mermaid";
|
||||
|
||||
|
|
|
@ -2,13 +2,13 @@ import throttle from "lodash.throttle";
|
|||
|
||||
import { ENV, arrayToMap } from "@excalidraw/common";
|
||||
|
||||
import type { OrderedExcalidrawElement } from "@excalidraw/element/types";
|
||||
|
||||
import {
|
||||
orderByFractionalIndex,
|
||||
syncInvalidIndices,
|
||||
validateFractionalIndices,
|
||||
} from "../fractionalIndex";
|
||||
} from "@excalidraw/element/fractionalIndex";
|
||||
|
||||
import type { OrderedExcalidrawElement } from "@excalidraw/element/types";
|
||||
|
||||
import type { AppState } from "../types";
|
||||
import type { MakeBrand } from "../utility-types";
|
||||
|
|
|
@ -41,6 +41,8 @@ import {
|
|||
isUsingAdaptiveRadius,
|
||||
} from "@excalidraw/element/typeChecks";
|
||||
|
||||
import { syncInvalidIndices } from "@excalidraw/element/fractionalIndex";
|
||||
|
||||
import type { LocalPoint, Radians } from "@excalidraw/math";
|
||||
|
||||
import type {
|
||||
|
@ -62,7 +64,6 @@ import type {
|
|||
import { getDefaultAppState } from "../appState";
|
||||
|
||||
import { getLineHeight } from "../fonts/FontMetadata";
|
||||
import { syncInvalidIndices } from "../fractionalIndex";
|
||||
import {
|
||||
getNormalizedGridSize,
|
||||
getNormalizedGridStep,
|
||||
|
|
|
@ -34,6 +34,8 @@ import {
|
|||
} from "@excalidraw/element/textMeasurements";
|
||||
import { isArrowElement } from "@excalidraw/element/typeChecks";
|
||||
|
||||
import { syncInvalidIndices } from "@excalidraw/element/fractionalIndex";
|
||||
|
||||
import type { ElementConstructorOpts } from "@excalidraw/element/newElement";
|
||||
|
||||
import type {
|
||||
|
@ -58,7 +60,6 @@ import type {
|
|||
} from "@excalidraw/element/types";
|
||||
|
||||
import { getLineHeight } from "../fonts/FontMetadata";
|
||||
import { syncInvalidIndices } from "../fractionalIndex";
|
||||
|
||||
import type { MarkOptional } from "../utility-types";
|
||||
|
||||
|
|
|
@ -69,7 +69,6 @@
|
|||
"canvas-roundrect-polyfill": "0.0.1",
|
||||
"clsx": "1.1.1",
|
||||
"cross-env": "7.0.3",
|
||||
"fractional-indexing": "3.2.0",
|
||||
"fuzzy": "0.1.3",
|
||||
"image-blob-reduce": "3.0.1",
|
||||
"jotai": "2.11.0",
|
||||
|
|
|
@ -11,6 +11,12 @@ import { isFrameLikeElement } from "@excalidraw/element/typeChecks";
|
|||
|
||||
import { getElementsInGroup } from "@excalidraw/element/groups";
|
||||
|
||||
import {
|
||||
syncInvalidIndices,
|
||||
syncMovedIndices,
|
||||
validateFractionalIndices,
|
||||
} from "@excalidraw/element/fractionalIndex";
|
||||
|
||||
import type { LinearElementEditor } from "@excalidraw/element/linearElementEditor";
|
||||
import type {
|
||||
ExcalidrawElement,
|
||||
|
@ -24,12 +30,6 @@ import type {
|
|||
Ordered,
|
||||
} from "@excalidraw/element/types";
|
||||
|
||||
import {
|
||||
syncInvalidIndices,
|
||||
syncMovedIndices,
|
||||
validateFractionalIndices,
|
||||
} from "../fractionalIndex";
|
||||
|
||||
import { getSelectedElements } from "./selection";
|
||||
|
||||
import type { AppState } from "../types";
|
||||
|
|
|
@ -38,6 +38,8 @@ import {
|
|||
getRootElements,
|
||||
} from "@excalidraw/element/frame";
|
||||
|
||||
import { syncInvalidIndices } from "@excalidraw/element/fractionalIndex";
|
||||
|
||||
import type { Bounds } from "@excalidraw/element/bounds";
|
||||
|
||||
import type {
|
||||
|
@ -53,7 +55,6 @@ import { base64ToString, decode, encode, stringToBase64 } from "../data/encode";
|
|||
import { serializeAsJSON } from "../data/json";
|
||||
|
||||
import { Fonts } from "../fonts";
|
||||
import { syncInvalidIndices } from "../fractionalIndex";
|
||||
|
||||
import { renderStaticScene } from "../renderer/staticScene";
|
||||
import { renderSceneToSvg } from "../renderer/staticSvgScene";
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { syncInvalidIndices } from "@excalidraw/element/fractionalIndex";
|
||||
|
||||
import { reconcileElements } from "../../data/reconcile";
|
||||
import { syncInvalidIndices } from "../../fractionalIndex";
|
||||
import { randomInteger } from "../../random";
|
||||
import { cloneJSON } from "../../utils";
|
||||
|
||||
|
|
|
@ -4,12 +4,13 @@ import { arrayToMap, findIndex, findLastIndex } from "@excalidraw/common";
|
|||
|
||||
import { getElementsInGroup } from "@excalidraw/element/groups";
|
||||
|
||||
import { syncMovedIndices } from "@excalidraw/element/fractionalIndex";
|
||||
|
||||
import type {
|
||||
ExcalidrawElement,
|
||||
ExcalidrawFrameLikeElement,
|
||||
} from "@excalidraw/element/types";
|
||||
|
||||
import { syncMovedIndices } from "./fractionalIndex";
|
||||
import { getSelectedElements } from "./scene";
|
||||
import Scene from "./scene/Scene";
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue