@@ -158,64 +158,6 @@ export default () => {
158158 }
159159 }
160160
161- const insertImage = ( ) => {
162- const url = prompt ( 'Enter image URL:' , 'https://unsplash.it/400/300' )
163- if ( url && editor ) {
164- editor . chain ( ) . focus ( ) . setImage ( { src : url } ) . run ( )
165- }
166- }
167-
168- const insertYoutube = ( ) => {
169- const url = prompt ( 'Enter YouTube URL:' , 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' )
170- if ( url && editor ) {
171- editor . chain ( ) . focus ( ) . setYoutubeVideo ( { src : url } ) . run ( )
172- }
173- }
174-
175- const insertMention = ( ) => {
176- const name = prompt ( 'Enter mention name:' , 'John Doe' )
177- if ( name && editor ) {
178- // Generate a simple ID based on the name
179- const id = Math . random ( ) . toString ( 36 ) . substring ( 2 , 9 )
180- editor . chain ( ) . focus ( ) . insertContent ( `[@ id="${ id } " label="${ name } "]` , { contentType : 'markdown' } ) . run ( )
181- }
182- }
183-
184- const insertCustomReactNode = ( ) => {
185- const content = prompt ( 'Enter content for custom React node:' , 'Hello from React!' )
186- if ( content && editor ) {
187- editor . chain ( ) . focus ( ) . insertContent ( `:::react\n\n${ content } \n\n:::` , { contentType : 'markdown' } ) . run ( )
188- }
189- }
190-
191- const insertInlineMath = ( ) => {
192- const latex = prompt ( 'Enter LaTeX for inline math:' , 'E = mc^2' )
193- if ( latex && editor ) {
194- editor
195- . chain ( )
196- . focus ( )
197- . insertContent ( {
198- type : 'inlineMath' ,
199- attrs : { latex } ,
200- } )
201- . run ( )
202- }
203- }
204-
205- const insertBlockMath = ( ) => {
206- const latex = prompt ( 'Enter LaTeX for block math:' , '\\int_{-\\infty}^{\\infty} e^{-x^2} dx = \\sqrt{\\pi}' )
207- if ( latex && editor ) {
208- editor
209- . chain ( )
210- . focus ( )
211- . insertContent ( {
212- type : 'blockMath' ,
213- attrs : { latex } ,
214- } )
215- . run ( )
216- }
217- }
218-
219161 return (
220162 < div className = "markdown-parser-demo" >
221163 < div className = "control-group" >
@@ -253,29 +195,6 @@ export default () => {
253195
254196 < div className = "editor-panel" >
255197 < div className = "panel-label" > Tiptap Editor</ div >
256-
257- { /* Toolbar */ }
258- < div className = "editor-toolbar button-group" >
259- < button type = "button" onClick = { insertImage } disabled = { ! editor } title = "Insert Image" >
260- Insert Image
261- </ button >
262- < button type = "button" onClick = { insertYoutube } disabled = { ! editor } title = "Insert YouTube Video" >
263- Insert YouTube
264- </ button >
265- < button type = "button" onClick = { insertMention } disabled = { ! editor } title = "Insert Mention" >
266- Insert Mention
267- </ button >
268- < button type = "button" onClick = { insertInlineMath } disabled = { ! editor } title = "Insert Inline Math" >
269- Insert Inline Math
270- </ button >
271- < button type = "button" onClick = { insertBlockMath } disabled = { ! editor } title = "Insert Block Math" >
272- Insert Block Math
273- </ button >
274- < button type = "button" onClick = { insertCustomReactNode } disabled = { ! editor } title = "Insert Custom React Node" >
275- Insert React Node
276- </ button >
277- </ div >
278-
279198 < div className = "editor-container" >
280199 { editor ? < EditorContent editor = { editor } /> : < div > Loading editor…</ div > }
281200 </ div >
0 commit comments