Skip to content

Commit

Permalink
fix: better paste handling (#1324)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
YousefED and matthewlipski authored Dec 20, 2024
1 parent 5c69f17 commit 8a51a79
Show file tree
Hide file tree
Showing 29 changed files with 983 additions and 47 deletions.
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"prosemirror-model": "^1.23.0",
"prosemirror-state": "^1.4.3",
"prosemirror-tables": "^1.6.1",
"prosemirror-transform": "^1.9.0",
"prosemirror-transform": "^1.10.2",
"prosemirror-view": "^1.33.7",
"rehype-format": "^5.0.0",
"rehype-parse": "^8.0.4",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
[
{
"children": [],
"content": [
{
"styles": {},
"text": "ParagraphParagraph",
"type": "text",
},
],
"id": "0",
"props": {
"backgroundColor": "default",
"textAlignment": "left",
"textColor": "default",
},
"type": "paragraph",
},
{
"children": [],
"content": {
"columnWidths": [
undefined,
undefined,
],
"rows": [
{
"cells": [
[
{
"styles": {},
"text": "Table Cell",
"type": "text",
},
],
[
{
"styles": {},
"text": "Table Cell",
"type": "text",
},
],
],
},
{
"cells": [
[
{
"styles": {},
"text": "Table Cell",
"type": "text",
},
],
[
{
"styles": {},
"text": "Table Cell",
"type": "text",
},
],
],
},
],
"type": "tableContent",
},
"id": "1",
"props": {
"textColor": "default",
},
"type": "table",
},
{
"children": [],
"content": [
{
"styles": {},
"text": "Custom Paragraph",
"type": "text",
},
],
"id": "2",
"props": {},
"type": "customParagraph",
},
{
"children": [],
"content": [],
"id": "3",
"props": {
"backgroundColor": "default",
"textAlignment": "left",
"textColor": "default",
},
"type": "paragraph",
},
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
[
{
"children": [],
"content": [
{
"styles": {},
"text": "ParagraphParagraph",
"type": "text",
},
],
"id": "0",
"props": {
"backgroundColor": "default",
"textAlignment": "left",
"textColor": "default",
},
"type": "paragraph",
},
{
"children": [],
"content": {
"columnWidths": [
undefined,
undefined,
],
"rows": [
{
"cells": [
[
{
"styles": {},
"text": "Table Cell",
"type": "text",
},
],
[
{
"styles": {},
"text": "Table Cell",
"type": "text",
},
],
],
},
{
"cells": [
[
{
"styles": {},
"text": "Table Cell",
"type": "text",
},
],
[
{
"styles": {},
"text": "Table Cell",
"type": "text",
},
],
],
},
],
"type": "tableContent",
},
"id": "1",
"props": {
"textColor": "default",
},
"type": "table",
},
{
"children": [],
"content": [
{
"styles": {},
"text": "Custom Paragraph",
"type": "text",
},
],
"id": "2",
"props": {},
"type": "customParagraph",
},
{
"children": [],
"content": [],
"id": "3",
"props": {
"backgroundColor": "default",
"textAlignment": "left",
"textColor": "default",
},
"type": "paragraph",
},
]
111 changes: 111 additions & 0 deletions packages/core/src/api/clipboard/__snapshots__/external/pasteImage.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
[
{
"children": [],
"content": [
{
"styles": {},
"text": "Paragraph",
"type": "text",
},
],
"id": "0",
"props": {
"backgroundColor": "default",
"textAlignment": "left",
"textColor": "default",
},
"type": "paragraph",
},
{
"children": [],
"content": undefined,
"id": "4",
"props": {
"backgroundColor": "default",
"caption": "",
"name": "",
"previewWidth": 512,
"showPreview": true,
"textAlignment": "left",
"url": "exampleURL",
},
"type": "image",
},
{
"children": [],
"content": {
"columnWidths": [
undefined,
undefined,
],
"rows": [
{
"cells": [
[
{
"styles": {},
"text": "Table Cell",
"type": "text",
},
],
[
{
"styles": {},
"text": "Table Cell",
"type": "text",
},
],
],
},
{
"cells": [
[
{
"styles": {},
"text": "Table Cell",
"type": "text",
},
],
[
{
"styles": {},
"text": "Table Cell",
"type": "text",
},
],
],
},
],
"type": "tableContent",
},
"id": "1",
"props": {
"textColor": "default",
},
"type": "table",
},
{
"children": [],
"content": [
{
"styles": {},
"text": "Custom Paragraph",
"type": "text",
},
],
"id": "2",
"props": {},
"type": "customParagraph",
},
{
"children": [],
"content": [],
"id": "3",
"props": {
"backgroundColor": "default",
"textAlignment": "left",
"textColor": "default",
},
"type": "paragraph",
},
]
Loading

0 comments on commit 8a51a79

Please sign in to comment.