File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -235,20 +235,22 @@ export default {
235235 linkCustomAction () {
236236 this .menubarLinkCustomAction
237237 .action ()
238- .then ((link ) => {
239- this .insertLink (link )
238+ .then ((result ) => {
239+ this .insertLink (result )
240240 })
241241 .catch ((error ) => {
242242 console .error (' Custom link action promise rejected' , error)
243243 })
244244 },
245- insertLink (link ) {
246- if (! link ) {
245+ insertLink (result ) {
246+ if (! result ) {
247247 return
248248 }
249+ const { link , title = ' ' } =
250+ typeof result === ' string' ? { link: result } : result
249251 const chain = this .editor ? .chain ()
250252 if (this .editor ? .view .state ? .selection .empty ) {
251- chain .focus ().insertPreview (link).run ()
253+ chain .focus ().insertPreview (link, title ).run ()
252254 } else {
253255 chain .setLink ({ href: link }).focus ().run ()
254256 }
Original file line number Diff line number Diff line change @@ -144,10 +144,12 @@ export default Node.create({
144144 * Insert a preview for given link.
145145 *
146146 * @param {string } link - the link URL
147+ * @param {string|null } title - the link title (optional)
147148 */
148149 insertPreview :
149- ( link ) =>
150+ ( link , title = '' ) =>
150151 ( { state, chain } ) => {
152+ title = title . trim ( ) ?? link
151153 return chain ( )
152154 . insertContent ( {
153155 type : 'preview' ,
@@ -161,7 +163,7 @@ export default Node.create({
161163 attrs : { href : link } ,
162164 } ,
163165 ] ,
164- text : link ,
166+ text : title ,
165167 } ,
166168 ] ,
167169 } )
You can’t perform that action at this time.
0 commit comments