Skip to content

Commit 8a51a79

Browse files
fix: better paste handling (#1324)
* fix: misc paste issues * fix * Fixed `transformPasted` * Updated tests * Added test cases * `transformPasted` only get selection checked when table is being pasted * Extracted `shouldApplyFix` * Added comment * Added comments * Added test --------- Co-authored-by: matthewlipski <matthewlipski@gmail.com>
1 parent 5c69f17 commit 8a51a79

29 files changed

+983
-47
lines changed

packages/core/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
"prosemirror-model": "^1.23.0",
8585
"prosemirror-state": "^1.4.3",
8686
"prosemirror-tables": "^1.6.1",
87-
"prosemirror-transform": "^1.9.0",
87+
"prosemirror-transform": "^1.10.2",
8888
"prosemirror-view": "^1.33.7",
8989
"rehype-format": "^5.0.0",
9090
"rehype-parse": "^8.0.4",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
[
2+
{
3+
"children": [],
4+
"content": [
5+
{
6+
"styles": {},
7+
"text": "ParagraphParagraph",
8+
"type": "text",
9+
},
10+
],
11+
"id": "0",
12+
"props": {
13+
"backgroundColor": "default",
14+
"textAlignment": "left",
15+
"textColor": "default",
16+
},
17+
"type": "paragraph",
18+
},
19+
{
20+
"children": [],
21+
"content": {
22+
"columnWidths": [
23+
undefined,
24+
undefined,
25+
],
26+
"rows": [
27+
{
28+
"cells": [
29+
[
30+
{
31+
"styles": {},
32+
"text": "Table Cell",
33+
"type": "text",
34+
},
35+
],
36+
[
37+
{
38+
"styles": {},
39+
"text": "Table Cell",
40+
"type": "text",
41+
},
42+
],
43+
],
44+
},
45+
{
46+
"cells": [
47+
[
48+
{
49+
"styles": {},
50+
"text": "Table Cell",
51+
"type": "text",
52+
},
53+
],
54+
[
55+
{
56+
"styles": {},
57+
"text": "Table Cell",
58+
"type": "text",
59+
},
60+
],
61+
],
62+
},
63+
],
64+
"type": "tableContent",
65+
},
66+
"id": "1",
67+
"props": {
68+
"textColor": "default",
69+
},
70+
"type": "table",
71+
},
72+
{
73+
"children": [],
74+
"content": [
75+
{
76+
"styles": {},
77+
"text": "Custom Paragraph",
78+
"type": "text",
79+
},
80+
],
81+
"id": "2",
82+
"props": {},
83+
"type": "customParagraph",
84+
},
85+
{
86+
"children": [],
87+
"content": [],
88+
"id": "3",
89+
"props": {
90+
"backgroundColor": "default",
91+
"textAlignment": "left",
92+
"textColor": "default",
93+
},
94+
"type": "paragraph",
95+
},
96+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
[
2+
{
3+
"children": [],
4+
"content": [
5+
{
6+
"styles": {},
7+
"text": "ParagraphParagraph",
8+
"type": "text",
9+
},
10+
],
11+
"id": "0",
12+
"props": {
13+
"backgroundColor": "default",
14+
"textAlignment": "left",
15+
"textColor": "default",
16+
},
17+
"type": "paragraph",
18+
},
19+
{
20+
"children": [],
21+
"content": {
22+
"columnWidths": [
23+
undefined,
24+
undefined,
25+
],
26+
"rows": [
27+
{
28+
"cells": [
29+
[
30+
{
31+
"styles": {},
32+
"text": "Table Cell",
33+
"type": "text",
34+
},
35+
],
36+
[
37+
{
38+
"styles": {},
39+
"text": "Table Cell",
40+
"type": "text",
41+
},
42+
],
43+
],
44+
},
45+
{
46+
"cells": [
47+
[
48+
{
49+
"styles": {},
50+
"text": "Table Cell",
51+
"type": "text",
52+
},
53+
],
54+
[
55+
{
56+
"styles": {},
57+
"text": "Table Cell",
58+
"type": "text",
59+
},
60+
],
61+
],
62+
},
63+
],
64+
"type": "tableContent",
65+
},
66+
"id": "1",
67+
"props": {
68+
"textColor": "default",
69+
},
70+
"type": "table",
71+
},
72+
{
73+
"children": [],
74+
"content": [
75+
{
76+
"styles": {},
77+
"text": "Custom Paragraph",
78+
"type": "text",
79+
},
80+
],
81+
"id": "2",
82+
"props": {},
83+
"type": "customParagraph",
84+
},
85+
{
86+
"children": [],
87+
"content": [],
88+
"id": "3",
89+
"props": {
90+
"backgroundColor": "default",
91+
"textAlignment": "left",
92+
"textColor": "default",
93+
},
94+
"type": "paragraph",
95+
},
96+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
[
2+
{
3+
"children": [],
4+
"content": [
5+
{
6+
"styles": {},
7+
"text": "Paragraph",
8+
"type": "text",
9+
},
10+
],
11+
"id": "0",
12+
"props": {
13+
"backgroundColor": "default",
14+
"textAlignment": "left",
15+
"textColor": "default",
16+
},
17+
"type": "paragraph",
18+
},
19+
{
20+
"children": [],
21+
"content": undefined,
22+
"id": "4",
23+
"props": {
24+
"backgroundColor": "default",
25+
"caption": "",
26+
"name": "",
27+
"previewWidth": 512,
28+
"showPreview": true,
29+
"textAlignment": "left",
30+
"url": "exampleURL",
31+
},
32+
"type": "image",
33+
},
34+
{
35+
"children": [],
36+
"content": {
37+
"columnWidths": [
38+
undefined,
39+
undefined,
40+
],
41+
"rows": [
42+
{
43+
"cells": [
44+
[
45+
{
46+
"styles": {},
47+
"text": "Table Cell",
48+
"type": "text",
49+
},
50+
],
51+
[
52+
{
53+
"styles": {},
54+
"text": "Table Cell",
55+
"type": "text",
56+
},
57+
],
58+
],
59+
},
60+
{
61+
"cells": [
62+
[
63+
{
64+
"styles": {},
65+
"text": "Table Cell",
66+
"type": "text",
67+
},
68+
],
69+
[
70+
{
71+
"styles": {},
72+
"text": "Table Cell",
73+
"type": "text",
74+
},
75+
],
76+
],
77+
},
78+
],
79+
"type": "tableContent",
80+
},
81+
"id": "1",
82+
"props": {
83+
"textColor": "default",
84+
},
85+
"type": "table",
86+
},
87+
{
88+
"children": [],
89+
"content": [
90+
{
91+
"styles": {},
92+
"text": "Custom Paragraph",
93+
"type": "text",
94+
},
95+
],
96+
"id": "2",
97+
"props": {},
98+
"type": "customParagraph",
99+
},
100+
{
101+
"children": [],
102+
"content": [],
103+
"id": "3",
104+
"props": {
105+
"backgroundColor": "default",
106+
"textAlignment": "left",
107+
"textColor": "default",
108+
},
109+
"type": "paragraph",
110+
},
111+
]

0 commit comments

Comments
 (0)