File tree Expand file tree Collapse file tree 4 files changed +48
-2
lines changed
Expand file tree Collapse file tree 4 files changed +48
-2
lines changed Original file line number Diff line number Diff line change 291291 on: change= {handleDescriptionChange}
292292 on: delete = {handleExitDescription}
293293 on: exitdescription= {handleExitDescription}
294+ on: selectup= {handleExitDescription}
295+ on: selectdown= {handleSelectDown}
294296 on: togglecomplete= {handleToggleComplete}
295297 on: hashtagclick= {handleHashtagClick}
296298 on: itemrefclick= {handleItemRefClick}
Original file line number Diff line number Diff line change 351351 on: change= {handleDescriptionChange}
352352 on: delete = {handleExitDescription}
353353 on: exitdescription= {handleExitDescription}
354+ on: selectup= {focusZoomedTitle}
355+ on: selectdown= {handleTitleSelectDown}
354356 on: blur= {handleDescriptionBlur}
355357 / >
356358 < / div>
Original file line number Diff line number Diff line change 252252 .run ()
253253 }
254254 }
255+
256+ function handleKeydown (event ) {
257+ if (isDescription) {
258+ // Basic stop propagation for everything.
259+ // KeyboardExtension will handle Enter, Shift-Enter, Arrows etc.
260+ // Since it's inside the container, it will see the event before this handler (bubbling phase).
261+ // Or rather, if we use a regular Svelte on:keydown, it's a bubbling listener on the div.
262+ event .stopPropagation ()
263+ }
264+ }
265+
266+ function handleMousedown (event ) {
267+ if (isDescription) {
268+ event .stopPropagation ()
269+ }
270+ }
255271< / script>
256272
257273< div class = " rich-editor-wrapper" class : description= {isDescription} class : zoomed- root= {isZoomedRoot}>
258274 < div
259275 bind: this = {editorElement}
260276 class = " editor-container"
277+ on: keydown= {handleKeydown}
278+ on: mousedown= {handleMousedown}
279+ role= " presentation"
261280 >< / div>
262281
263282 < div bind: this = {bubbleMenuElement} class = " bubble-menu" >
Original file line number Diff line number Diff line change @@ -102,15 +102,38 @@ export const KeyboardExtension = Extension.create({
102102 return false
103103 } ,
104104
105- 'ArrowUp' : ( ) => {
105+ 'ArrowUp' : ( { editor } ) => {
106+ if ( this . options . isDescription ) {
107+ const { state } = editor
108+ const { selection } = state
109+ if ( selection . from === 1 ) {
110+ if ( this . options . onArrowUp ) {
111+ this . options . onArrowUp ( )
112+ return true
113+ }
114+ }
115+ return false
116+ }
106117 if ( this . options . onArrowUp ) {
107118 this . options . onArrowUp ( )
108119 return true
109120 }
110121 return false
111122 } ,
112123
113- 'ArrowDown' : ( ) => {
124+ 'ArrowDown' : ( { editor } ) => {
125+ if ( this . options . isDescription ) {
126+ const { state } = editor
127+ const { selection, doc } = state
128+ // doc.content.size - 1 is the end of the last node's content
129+ if ( selection . to >= doc . content . size - 1 ) {
130+ if ( this . options . onArrowDown ) {
131+ this . options . onArrowDown ( )
132+ return true
133+ }
134+ }
135+ return false
136+ }
114137 if ( this . options . onArrowDown ) {
115138 this . options . onArrowDown ( )
116139 return true
You can’t perform that action at this time.
0 commit comments