@@ -55,6 +55,8 @@ const PREVIEW_ZOOM_STEP = 0.05;
5555
5656const isElectron = ! ! window . electronAPI ;
5757
58+ const TREE_SELECTION_COMMAND_IDS = new Set ( [ 'delete-item' , 'duplicate-item' , 'rename-item' ] ) ;
59+
5860const resolveClipboardHelpUrl = ( ) : string | null => {
5961 if ( typeof navigator === 'undefined' ) {
6062 return null ;
@@ -1791,7 +1793,7 @@ export const MainApp: React.FC = () => {
17911793 const handleNewDocument = useCallback ( async ( parentId ?: string | null ) => {
17921794 addLog ( 'INFO' , 'User action: Create New Document.' ) ;
17931795 const effectiveParentId = parentId !== undefined ? parentId : getParentIdForNewItem ( ) ;
1794- const newDoc = await addDocument ( { parentId : effectiveParentId } ) ;
1796+ const newDoc = await addDocument ( { parentId : effectiveParentId , doc_type : 'rich_text' , language_hint : 'html' } ) ;
17951797 ensureNodeVisible ( newDoc ) ;
17961798 activateDocumentTab ( newDoc . id ) ;
17971799 setSelectedIds ( new Set ( [ newDoc . id ] ) ) ;
@@ -2128,12 +2130,9 @@ export const MainApp: React.FC = () => {
21282130 }
21292131 } , [ activeNodeId , activeNode , updateItem , addLog ] ) ;
21302132
2131- const handleCommitVersion = useCallback ( ( content : string ) => {
2132- if ( activeNodeId ) {
2133- return commitVersion ( activeNodeId , content ) ;
2134- }
2135- return Promise . resolve ( ) ;
2136- } , [ activeNodeId , commitVersion ] ) ;
2133+ const handleCommitVersion = useCallback ( ( documentId : string , content : string ) => {
2134+ return commitVersion ( documentId , content ) ;
2135+ } , [ commitVersion ] ) ;
21372136
21382137 const handleSaveTemplate = ( updatedTemplate : Partial < Omit < DocumentTemplate , 'template_id' > > ) => {
21392138 if ( activeTemplateId ) {
@@ -2861,22 +2860,28 @@ export const MainApp: React.FC = () => {
28612860 } ;
28622861 } , [ handleGlobalMouseMove , handleGlobalMouseUp ] ) ;
28632862
2864- useEffect ( ( ) => {
2863+ useEffect ( ( ) => {
28652864 const shortcutMap = getShortcutMap ( commands , settings . customShortcuts ) ;
2866-
2865+
28672866 const handleKeyDown = ( e : KeyboardEvent ) => {
28682867 const shortcut = formatShortcut ( e ) ;
28692868 const command = shortcutMap . get ( shortcut ) ;
28702869
28712870 const activeEl = document . activeElement ;
28722871 const isFormElement = activeEl && [ 'INPUT' , 'TEXTAREA' , 'SELECT' ] . includes ( activeEl . tagName ) ;
2872+ const isRichTextElement =
2873+ activeEl instanceof HTMLElement && Boolean ( activeEl . closest ( '[data-component="rich-text-editor"]' ) ) ;
28732874 const isPaletteInput = activeEl === commandPaletteInputRef . current ;
28742875 const isCommandPaletteToggle = command ?. id === 'toggle-command-palette' ;
28752876
28762877 if ( isFormElement && ! isPaletteInput && ! isCommandPaletteToggle ) {
28772878 return ;
28782879 }
28792880
2881+ if ( isRichTextElement && command && TREE_SELECTION_COMMAND_IDS . has ( command . id ) ) {
2882+ return ;
2883+ }
2884+
28802885 if ( command ?. category === 'Document Tree' && command . id !== 'document-tree-focus-search' ) {
28812886 const target = e . target as HTMLElement | null ;
28822887 const isWithinSidebar = target ?. closest ( '[data-component="document-tree-sidebar"]' ) ;
0 commit comments