mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
feat: remove automatic frame naming (#8302)
This commit is contained in:
parent
5a0771ad9c
commit
e844580b14
3 changed files with 6 additions and 35 deletions
|
@ -156,7 +156,6 @@ import {
|
||||||
isLinearElement,
|
isLinearElement,
|
||||||
isLinearElementType,
|
isLinearElementType,
|
||||||
isUsingAdaptiveRadius,
|
isUsingAdaptiveRadius,
|
||||||
isFrameElement,
|
|
||||||
isIframeElement,
|
isIframeElement,
|
||||||
isIframeLikeElement,
|
isIframeLikeElement,
|
||||||
isMagicFrameElement,
|
isMagicFrameElement,
|
||||||
|
@ -1288,15 +1287,7 @@ class App extends React.Component<AppProps, AppState> {
|
||||||
|
|
||||||
const isDarkTheme = this.state.theme === THEME.DARK;
|
const isDarkTheme = this.state.theme === THEME.DARK;
|
||||||
|
|
||||||
let frameIndex = 0;
|
|
||||||
let magicFrameIndex = 0;
|
|
||||||
|
|
||||||
return this.scene.getNonDeletedFramesLikes().map((f) => {
|
return this.scene.getNonDeletedFramesLikes().map((f) => {
|
||||||
if (isFrameElement(f)) {
|
|
||||||
frameIndex++;
|
|
||||||
} else {
|
|
||||||
magicFrameIndex++;
|
|
||||||
}
|
|
||||||
if (
|
if (
|
||||||
!isElementInViewport(
|
!isElementInViewport(
|
||||||
f,
|
f,
|
||||||
|
@ -1330,10 +1321,7 @@ class App extends React.Component<AppProps, AppState> {
|
||||||
|
|
||||||
let frameNameJSX;
|
let frameNameJSX;
|
||||||
|
|
||||||
const frameName = getFrameLikeTitle(
|
const frameName = getFrameLikeTitle(f);
|
||||||
f,
|
|
||||||
isFrameElement(f) ? frameIndex : magicFrameIndex,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (f.id === this.state.editingFrame) {
|
if (f.id === this.state.editingFrame) {
|
||||||
const frameNameInEdit = frameName;
|
const frameNameInEdit = frameName;
|
||||||
|
|
|
@ -755,15 +755,12 @@ export const isElementInFrame = (
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getFrameLikeTitle = (
|
export const getFrameLikeTitle = (element: ExcalidrawFrameLikeElement) => {
|
||||||
element: ExcalidrawFrameLikeElement,
|
|
||||||
frameIdx: number,
|
|
||||||
) => {
|
|
||||||
// TODO name frames "AI" only if specific to AI frames
|
// TODO name frames "AI" only if specific to AI frames
|
||||||
return element.name === null
|
return element.name === null
|
||||||
? isFrameElement(element)
|
? isFrameElement(element)
|
||||||
? `Frame ${frameIdx}`
|
? "Frame"
|
||||||
: `AI Frame $${frameIdx}`
|
: "AI Frame"
|
||||||
: element.name;
|
: element.name;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -34,11 +34,7 @@ import {
|
||||||
import { newTextElement } from "../element";
|
import { newTextElement } from "../element";
|
||||||
import { type Mutable } from "../utility-types";
|
import { type Mutable } from "../utility-types";
|
||||||
import { newElementWith } from "../element/mutateElement";
|
import { newElementWith } from "../element/mutateElement";
|
||||||
import {
|
import { isFrameLikeElement, isTextElement } from "../element/typeChecks";
|
||||||
isFrameElement,
|
|
||||||
isFrameLikeElement,
|
|
||||||
isTextElement,
|
|
||||||
} from "../element/typeChecks";
|
|
||||||
import type { RenderableElementsMap } from "./types";
|
import type { RenderableElementsMap } from "./types";
|
||||||
import { syncInvalidIndices } from "../fractionalIndex";
|
import { syncInvalidIndices } from "../fractionalIndex";
|
||||||
import { renderStaticScene } from "../renderer/staticScene";
|
import { renderStaticScene } from "../renderer/staticScene";
|
||||||
|
@ -88,15 +84,8 @@ const addFrameLabelsAsTextElements = (
|
||||||
opts: Pick<AppState, "exportWithDarkMode">,
|
opts: Pick<AppState, "exportWithDarkMode">,
|
||||||
) => {
|
) => {
|
||||||
const nextElements: NonDeletedExcalidrawElement[] = [];
|
const nextElements: NonDeletedExcalidrawElement[] = [];
|
||||||
let frameIndex = 0;
|
|
||||||
let magicFrameIndex = 0;
|
|
||||||
for (const element of elements) {
|
for (const element of elements) {
|
||||||
if (isFrameLikeElement(element)) {
|
if (isFrameLikeElement(element)) {
|
||||||
if (isFrameElement(element)) {
|
|
||||||
frameIndex++;
|
|
||||||
} else {
|
|
||||||
magicFrameIndex++;
|
|
||||||
}
|
|
||||||
let textElement: Mutable<ExcalidrawTextElement> = newTextElement({
|
let textElement: Mutable<ExcalidrawTextElement> = newTextElement({
|
||||||
x: element.x,
|
x: element.x,
|
||||||
y: element.y - FRAME_STYLE.nameOffsetY,
|
y: element.y - FRAME_STYLE.nameOffsetY,
|
||||||
|
@ -107,10 +96,7 @@ const addFrameLabelsAsTextElements = (
|
||||||
strokeColor: opts.exportWithDarkMode
|
strokeColor: opts.exportWithDarkMode
|
||||||
? FRAME_STYLE.nameColorDarkTheme
|
? FRAME_STYLE.nameColorDarkTheme
|
||||||
: FRAME_STYLE.nameColorLightTheme,
|
: FRAME_STYLE.nameColorLightTheme,
|
||||||
text: getFrameLikeTitle(
|
text: getFrameLikeTitle(element),
|
||||||
element,
|
|
||||||
isFrameElement(element) ? frameIndex : magicFrameIndex,
|
|
||||||
),
|
|
||||||
});
|
});
|
||||||
textElement.y -= textElement.height;
|
textElement.y -= textElement.height;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue