|
|
@ -1341,8 +1341,18 @@ class App extends React.Component<AppProps, AppState> {
|
|
|
|
_cache: new Map(),
|
|
|
|
_cache: new Map(),
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private resetEditingFrame = (frame: ExcalidrawFrameLikeElement | null) => {
|
|
|
|
|
|
|
|
if (frame) {
|
|
|
|
|
|
|
|
mutateElement(frame, { name: frame.name?.trim() || null });
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
this.setState({ editingFrame: null });
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
private renderFrameNames = () => {
|
|
|
|
private renderFrameNames = () => {
|
|
|
|
if (!this.state.frameRendering.enabled || !this.state.frameRendering.name) {
|
|
|
|
if (!this.state.frameRendering.enabled || !this.state.frameRendering.name) {
|
|
|
|
|
|
|
|
if (this.state.editingFrame) {
|
|
|
|
|
|
|
|
this.resetEditingFrame(null);
|
|
|
|
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -1364,6 +1374,9 @@ class App extends React.Component<AppProps, AppState> {
|
|
|
|
this.scene.getNonDeletedElementsMap(),
|
|
|
|
this.scene.getNonDeletedElementsMap(),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
|
|
|
|
if (this.state.editingFrame === f.id) {
|
|
|
|
|
|
|
|
this.resetEditingFrame(f);
|
|
|
|
|
|
|
|
}
|
|
|
|
// if frame not visible, don't render its name
|
|
|
|
// if frame not visible, don't render its name
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1375,11 +1388,6 @@ class App extends React.Component<AppProps, AppState> {
|
|
|
|
|
|
|
|
|
|
|
|
const FRAME_NAME_EDIT_PADDING = 6;
|
|
|
|
const FRAME_NAME_EDIT_PADDING = 6;
|
|
|
|
|
|
|
|
|
|
|
|
const reset = () => {
|
|
|
|
|
|
|
|
mutateElement(f, { name: f.name?.trim() || null });
|
|
|
|
|
|
|
|
this.setState({ editingFrame: null });
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let frameNameJSX;
|
|
|
|
let frameNameJSX;
|
|
|
|
|
|
|
|
|
|
|
|
const frameName = getFrameLikeTitle(f);
|
|
|
|
const frameName = getFrameLikeTitle(f);
|
|
|
@ -1397,13 +1405,13 @@ class App extends React.Component<AppProps, AppState> {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}}
|
|
|
|
}}
|
|
|
|
onFocus={(e) => e.target.select()}
|
|
|
|
onFocus={(e) => e.target.select()}
|
|
|
|
onBlur={() => reset()}
|
|
|
|
onBlur={() => this.resetEditingFrame(f)}
|
|
|
|
onKeyDown={(event) => {
|
|
|
|
onKeyDown={(event) => {
|
|
|
|
// for some inexplicable reason, `onBlur` triggered on ESC
|
|
|
|
// for some inexplicable reason, `onBlur` triggered on ESC
|
|
|
|
// does not reset `state.editingFrame` despite being called,
|
|
|
|
// does not reset `state.editingFrame` despite being called,
|
|
|
|
// and we need to reset it here as well
|
|
|
|
// and we need to reset it here as well
|
|
|
|
if (event.key === KEYS.ESCAPE || event.key === KEYS.ENTER) {
|
|
|
|
if (event.key === KEYS.ESCAPE || event.key === KEYS.ENTER) {
|
|
|
|
reset();
|
|
|
|
this.resetEditingFrame(f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}}
|
|
|
|
}}
|
|
|
|
style={{
|
|
|
|
style={{
|
|
|
|