mirror of
https://github.com/zadam/trilium.git
synced 2025-11-11 17:08:58 +01:00
refactor(mindmap): unnecessary content logic
This commit is contained in:
parent
3b5d749d86
commit
76bd6a5ab9
@ -18,12 +18,10 @@ interface MindElixirProps {
|
|||||||
containerProps?: Omit<HTMLAttributes<HTMLDivElement>, "ref">;
|
containerProps?: Omit<HTMLAttributes<HTMLDivElement>, "ref">;
|
||||||
containerRef?: RefObject<HTMLDivElement>;
|
containerRef?: RefObject<HTMLDivElement>;
|
||||||
editable: boolean;
|
editable: boolean;
|
||||||
content: MindElixirData;
|
|
||||||
onChange?: () => void;
|
onChange?: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function MindMap({ note, ntxId, noteContext }: TypeWidgetProps) {
|
export default function MindMap({ note, ntxId, noteContext }: TypeWidgetProps) {
|
||||||
const content = VanillaMindElixir.new(NEW_TOPIC_NAME);
|
|
||||||
const apiRef = useRef<MindElixirInstance>(null);
|
const apiRef = useRef<MindElixirInstance>(null);
|
||||||
const containerRef = useRef<HTMLDivElement>(null);
|
const containerRef = useRef<HTMLDivElement>(null);
|
||||||
const [ isReadOnly ] = useNoteLabelBoolean(note, "readOnly");
|
const [ isReadOnly ] = useNoteLabelBoolean(note, "readOnly");
|
||||||
@ -99,7 +97,6 @@ export default function MindMap({ note, ntxId, noteContext }: TypeWidgetProps) {
|
|||||||
<MindElixir
|
<MindElixir
|
||||||
containerRef={containerRef}
|
containerRef={containerRef}
|
||||||
apiRef={apiRef}
|
apiRef={apiRef}
|
||||||
content={content}
|
|
||||||
onChange={() => spacedUpdate.scheduleUpdate()}
|
onChange={() => spacedUpdate.scheduleUpdate()}
|
||||||
editable={!isReadOnly}
|
editable={!isReadOnly}
|
||||||
containerProps={{
|
containerProps={{
|
||||||
@ -110,7 +107,7 @@ export default function MindMap({ note, ntxId, noteContext }: TypeWidgetProps) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function MindElixir({ content, containerRef: externalContainerRef, containerProps, apiRef: externalApiRef, onChange, editable }: MindElixirProps) {
|
function MindElixir({ containerRef: externalContainerRef, containerProps, apiRef: externalApiRef, onChange, editable }: MindElixirProps) {
|
||||||
const containerRef = useSyncedRef<HTMLDivElement>(externalContainerRef, null);
|
const containerRef = useSyncedRef<HTMLDivElement>(externalContainerRef, null);
|
||||||
const apiRef = useRef<MindElixirInstance>(null);
|
const apiRef = useRef<MindElixirInstance>(null);
|
||||||
|
|
||||||
@ -125,7 +122,6 @@ function MindElixir({ content, containerRef: externalContainerRef, containerProp
|
|||||||
if (editable) {
|
if (editable) {
|
||||||
mind.install(nodeMenu);
|
mind.install(nodeMenu);
|
||||||
}
|
}
|
||||||
mind.init(content);
|
|
||||||
|
|
||||||
apiRef.current = mind;
|
apiRef.current = mind;
|
||||||
if (externalApiRef) {
|
if (externalApiRef) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user