File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -14,8 +14,6 @@ import {
1414 selectedRect ,
1515 selectionCell ,
1616} from '@tiptap/pm/tables'
17- // eslint-disable-next-line n/no-extraneous-import
18- import { Fragment } from 'prosemirror-model'
1917
2018/**
2119 *
@@ -209,25 +207,4 @@ export default Table.extend({
209207 }
210208 } ,
211209
212- addProseMirrorPlugins ( ) {
213- return [
214- new Plugin ( {
215- props : {
216- handlePaste : ( view , event , slice ) => {
217- if ( slice . content . childCount > 1 ) {
218- const firstNode = slice . content . firstChild
219- let newTextContent = firstNode . textContent
220-
221- for ( let i = 1 ; i < slice . content . childCount ; i ++ ) {
222- newTextContent += '\n' + slice . content . child ( i ) . textContent
223- }
224-
225- slice . content = Fragment . empty . addToStart ( view . state . schema . text ( newTextContent , firstNode . marks ) )
226- }
227- } ,
228- } ,
229- } ) ,
230- ]
231- } ,
232-
233210} )
Original file line number Diff line number Diff line change 11import { TableCell } from '@tiptap/extension-table-cell'
2+ import { Plugin } from '@tiptap/pm/state'
3+ import { Fragment } from '@tiptap/pm/model'
24
35export default TableCell . extend ( {
46 content : 'inline*' ,
@@ -30,4 +32,27 @@ export default TableCell.extend({
3032 } ,
3133 }
3234 } ,
35+
36+ addProseMirrorPlugins ( ) {
37+ return [
38+ new Plugin ( {
39+ props : {
40+ handlePaste : ( view , event , slice ) => {
41+ if ( slice . content . childCount > 1 ) {
42+ const state = view . state
43+ const childNodes = [ ]
44+ for ( let i = 0 ; i < slice . content . childCount ; i ++ ) {
45+ if ( i ) {
46+ childNodes . push ( state . schema . text ( '\n' ) )
47+ }
48+ childNodes . push ( state . schema . text ( slice . content . child ( i ) . textContent , slice . content . child ( i ) . firstChild . marks ) )
49+ }
50+ const newNode = view . state . schema . node ( 'paragraph' , [ ] , childNodes )
51+ slice . content = Fragment . empty . addToStart ( newNode )
52+ }
53+ } ,
54+ } ,
55+ } ) ,
56+ ]
57+ } ,
3358} )
You can’t perform that action at this time.
0 commit comments