@@ -6,7 +6,7 @@ import { TiptapModule } from '../types.ts'
66import { TiptapEditor } from '../editor.ts'
77
88export const iframeModule : TiptapModule = {
9- extensions : [ createIframeNode ( ) ] ,
9+ extensions : ( e ) => [ createIframeNode ( e ) ] ,
1010 isEnabled : ( wysiwygProfile ) => wysiwygProfile . hasPlugin ( 'iframe' ) ,
1111 toolbar : {
1212 group : 'insert' ,
@@ -44,7 +44,7 @@ function stripFalsy(attrs: Record<string, unknown>): Record<string, string> {
4444 return result
4545}
4646
47- function createIframeNode ( ) {
47+ function createIframeNode ( editor : TiptapEditor ) {
4848 return Node . create ( {
4949 name : 'iframe' ,
5050 group : 'inline' ,
@@ -73,13 +73,19 @@ function createIframeNode() {
7373 } ,
7474
7575 addNodeView ( ) {
76- return ( { node } ) => {
76+ return ( { node, getPos } ) => {
7777 const dom = document . createElement ( 'span' )
7878 dom . className = 'tiptap-iframe-placeholder'
7979 dom . contentEditable = 'false'
8080 dom . style . width = ( node . attrs . width || 300 ) + 'px'
8181 dom . style . height = ( node . attrs . height || 150 ) + 'px'
8282 dom . innerHTML = `<span class="tiptap-iframe-placeholder-icon">${ IconMovie } </span><span>${ node . attrs . title || node . attrs . src || 'Embed' } </span>`
83+ dom . addEventListener ( 'dblclick' , ( ) => {
84+ const pos = getPos ( )
85+ if ( typeof pos !== 'number' ) return
86+ editor . tiptap . chain ( ) . setNodeSelection ( pos ) . run ( )
87+ openIframeDialog ( editor )
88+ } )
8389 return { dom }
8490 }
8591 } ,
@@ -167,7 +173,7 @@ function openIframeDialog(editor: TiptapEditor): void {
167173
168174 dialog
169175 . addButton ( {
170- label : editor . trans ( 'button_insert' ) ,
176+ label : editor . trans ( existing ? 'button_update' : 'button_insert' ) ,
171177 variant : 'primary' ,
172178 onClick : ( d ) => {
173179 const parsed = parseEmbedCode ( textarea . value )
0 commit comments