refactor(editor): unify selection key + clean node view
This commit is contained in:
parent
e296fc0979
commit
5ff0c22724
@ -436,18 +436,18 @@ function NodeView(props: {
|
|||||||
boxSizing: 'border-box',
|
boxSizing: 'border-box',
|
||||||
padding: `${node.props.paddingY ?? 0}px ${node.props.paddingX ?? 0}px`,
|
padding: `${node.props.paddingY ?? 0}px ${node.props.paddingX ?? 0}px`,
|
||||||
overflow: 'hidden',
|
overflow: 'hidden',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
style={{
|
||||||
|
whiteSpace: 'pre-wrap',
|
||||||
|
fontSize: node.props.fontSize ?? 24,
|
||||||
|
color: node.props.color ?? '#fff',
|
||||||
|
fontWeight: node.props.fontWeight ?? 400,
|
||||||
|
letterSpacing: `${node.props.letterSpacing ?? 0}px`,
|
||||||
|
writingMode: writingModeStyle,
|
||||||
|
cursor: node.props.link ? 'pointer' : 'default',
|
||||||
}}
|
}}
|
||||||
>
|
|
||||||
<span
|
|
||||||
style={{
|
|
||||||
whiteSpace: 'pre-wrap',
|
|
||||||
fontSize: node.props.fontSize ?? 24,
|
|
||||||
color: node.props.color ?? '#fff',
|
|
||||||
fontWeight: node.props.fontWeight ?? 400,
|
|
||||||
letterSpacing: `${node.props.letterSpacing ?? 0}px`,
|
|
||||||
writingMode: writingModeStyle,
|
|
||||||
cursor: node.props.link ? 'pointer' : 'default',
|
|
||||||
}}
|
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
if (!node.props.link) return;
|
if (!node.props.link) return;
|
||||||
const head = node.props.linkHead ?? 'http://';
|
const head = node.props.linkHead ?? 'http://';
|
||||||
|
|||||||
@ -14,6 +14,7 @@ import { bindEditorHotkeys } from './hotkeys';
|
|||||||
import { Canvas } from './Canvas';
|
import { Canvas } from './Canvas';
|
||||||
import { ContextMenu, type ContextMenuState } from './ContextMenu';
|
import { ContextMenu, type ContextMenuState } from './ContextMenu';
|
||||||
import { Inspector } from './Inspector';
|
import { Inspector } from './Inspector';
|
||||||
|
import { selectionKeyOf } from './selection';
|
||||||
import { createInitialState, editorReducer, exportScreenJSON } from './store';
|
import { createInitialState, editorReducer, exportScreenJSON } from './store';
|
||||||
|
|
||||||
const { Header, Sider, Content } = Layout;
|
const { Header, Sider, Content } = Layout;
|
||||||
@ -86,10 +87,7 @@ export function EditorApp() {
|
|||||||
|
|
||||||
const closeContextMenu = useCallback(() => setCtxMenu(null), []);
|
const closeContextMenu = useCallback(() => setCtxMenu(null), []);
|
||||||
|
|
||||||
const selectionKeyOf = useCallback((ids: string[]) => {
|
// selectionKeyOf imported from ./selection
|
||||||
// Keep stable regardless of ordering.
|
|
||||||
return [...ids].sort().join('|');
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const ctxMenuSyncedRef = useRef(false);
|
const ctxMenuSyncedRef = useRef(false);
|
||||||
|
|
||||||
@ -103,7 +101,7 @@ export function EditorApp() {
|
|||||||
}
|
}
|
||||||
dispatch(action);
|
dispatch(action);
|
||||||
},
|
},
|
||||||
[ctxMenu, dispatch, selectionKeyOf, state.selection.ids],
|
[ctxMenu, dispatch, state.selection.ids],
|
||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user