File tree 1 file changed +27
-0
lines changed
1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change
1
+ import { nodeInputRule , nodePasteRule } from '@tiptap/core'
1
2
import Image from '@tiptap/extension-image'
2
3
import { type CommandProps , VueNodeViewRenderer } from '@tiptap/vue-3'
3
4
@@ -102,4 +103,30 @@ export default Image.extend({
102
103
} ,
103
104
}
104
105
} ,
106
+ addPasteRules ( ) {
107
+ return [
108
+ ...( this . parent ?.( ) ?? [ ] ) ,
109
+ nodePasteRule ( {
110
+ find : / ! \[ ( [ ^ \] ] * ) \] \( ( [ ^ ) \s ] + ) (?: \s + " ( [ ^ " ] + ) " ? ) ? \) / g,
111
+ type : this . type ,
112
+ getAttributes : ( match ) => {
113
+ const [ , alt , src , title ] = match
114
+ return { src, alt, title }
115
+ } ,
116
+ } ) ,
117
+ ]
118
+ } ,
119
+ addInputRules ( ) {
120
+ return [
121
+ ...( this . parent ?.( ) ?? [ ] ) ,
122
+ nodeInputRule ( {
123
+ find : / ! \[ ( [ \S ] + ) \] \( ( [ ^ ) \s ] + ) (?: \s + " ( [ \S ] + ) " ? ) ? \) / g,
124
+ type : this . type ,
125
+ getAttributes : ( match ) => {
126
+ const [ , alt , src , title ] = match
127
+ return { src, alt, title }
128
+ } ,
129
+ } ) ,
130
+ ]
131
+ } ,
105
132
} )
You can’t perform that action at this time.
0 commit comments