mirror of
https://github.com/IRBorisov/ConceptPortal.git
synced 2025-06-25 20:40:36 +03:00
B: Adjust selection for Constituenta editor
This commit is contained in:
parent
22d8e0fadd
commit
65440e29f0
|
@ -1,6 +1,6 @@
|
|||
'use client';
|
||||
|
||||
import { useState } from 'react';
|
||||
import { useEffect, useState } from 'react';
|
||||
import clsx from 'clsx';
|
||||
|
||||
import { useWindowSize } from '@/hooks/use-window-size';
|
||||
|
@ -20,7 +20,8 @@ import { ToolbarConstituenta } from './toolbar-constituenta';
|
|||
const SIDELIST_LAYOUT_THRESHOLD = 1000; // px
|
||||
|
||||
export function EditorConstituenta() {
|
||||
const { schema, activeCst, isContentEditable, moveUp, moveDown, cloneCst, navigateCst } = useRSEdit();
|
||||
const { schema, activeCst, isContentEditable, selected, setSelected, moveUp, moveDown, cloneCst, navigateCst } =
|
||||
useRSEdit();
|
||||
const windowSize = useWindowSize();
|
||||
const mainHeight = useMainHeight();
|
||||
|
||||
|
@ -33,6 +34,12 @@ export function EditorConstituenta() {
|
|||
const disabled = !activeCst || !isContentEditable || isProcessing;
|
||||
const isNarrow = !!windowSize.width && windowSize.width <= SIDELIST_LAYOUT_THRESHOLD;
|
||||
|
||||
useEffect(() => {
|
||||
if (activeCst && selected.length !== 1) {
|
||||
setSelected([activeCst.id]);
|
||||
}
|
||||
}, [activeCst, selected, setSelected]);
|
||||
|
||||
function handleInput(event: React.KeyboardEvent<HTMLDivElement>) {
|
||||
if (disabled) {
|
||||
return;
|
||||
|
|
Loading…
Reference in New Issue
Block a user