File tree Expand file tree Collapse file tree 2 files changed +12
-5
lines changed
Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -38,7 +38,9 @@ export const addEmptyLink: Command = (state, dispatch) => {
3838 tr . setMeta ( imageRendererKey , meta ) ;
3939 }
4040 } else {
41- tr . setSelection ( TextSelection . create ( tr . doc , $to . pos - 1 ) ) ;
41+ const selectedText = state . doc . textBetween ( $from . pos , $to . pos ) ;
42+ const countOfWhitespacesAtEnd = selectedText . length - selectedText . trimEnd ( ) . length ;
43+ tr . setSelection ( TextSelection . create ( tr . doc , $to . pos - countOfWhitespacesAtEnd - 1 ) ) ;
4244 }
4345 dispatch ?.( tr ) ;
4446 return true ;
Original file line number Diff line number Diff line change 11import { Plugin , PluginKey } from 'prosemirror-state' ;
2- import { DecorationSet } from 'prosemirror-view' ;
2+ import { Decoration , DecorationSet } from 'prosemirror-view' ;
33
44import type { Meta , WidgetSpec } from './types' ;
55
@@ -30,11 +30,16 @@ export const WidgetDecorationPlugin = () => {
3030
3131 if ( meta ?. type === 'add' ) {
3232 const { descriptor} = meta ;
33- // @ts -expect-error // TODO
34- const deco = Decoration . widget < WidgetSpec > (
33+ const spec : WidgetSpec = {
34+ id : descriptor . id ,
35+ pos : descriptor . initPos ,
36+ descriptor,
37+ } ;
38+ const deco = Decoration . widget (
3539 descriptor . initPos ,
40+ // @ts -expect-error
3641 descriptor . render . bind ( descriptor ) ,
37- { id : descriptor . id , pos : descriptor . initPos , descriptor } ,
42+ spec ,
3843 ) ;
3944
4045 set = set . add ( tr . doc , [ deco ] ) ;
You can’t perform that action at this time.
0 commit comments