Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/2708 pasting tables #4285

Merged
merged 3 commits into from
Jun 19, 2023
Merged

Fix/2708 pasting tables #4285

merged 3 commits into from
Jun 19, 2023

Conversation

max-nextcloud
Copy link
Collaborator

📝 Summary

Fixes #2708.

Try to read the first table row as headings.

Pasting works via insertContent while opening uses setContent.
They use the schema in different ways.
So we also need to make sure to test both for some corner cases.

setContent is fairly flexible in turning the input
into a valid document structure.
insertContent however fails to resolve structures
that would require picking lower priority parent elements.

Note: Some tests in src/tests/nodes/Table.spec.js
fail when using insertContent instead of setContent.
Pasting the correponding html table is fixed never the less.

🏁 Checklist

  • Code is properly formatted (npm run lint / npm run stylelint / composer run cs:check)
  • Sign-off message is added to all commits
  • Tests (unit, integration and/or end-to-end) passing and the changes are covered with tests
  • Documentation is not required

@cypress
Copy link

cypress bot commented Jun 12, 2023

2 flaky tests on run #10263 ↗︎

0 147 1 0 Flakiness 2

Details:

Fix/2708 pasting tables
Project: Text Commit: c485bf02c6
Status: Passed Duration: 03:42 💡
Started: Jun 19, 2023 4:27 PM Ended: Jun 19, 2023 4:31 PM
Flakiness  nodes/HardBreak.spec.js • 1 flaky test

View Output Video

Test Artifacts
Hard break support > Can create hard breaks with shift+enter Output Screenshots
Flakiness  api/UsersApi.spec.js • 1 flaky test

View Output Video

Test Artifacts
The user mention API > fetches users with valid session Output Screenshots

This comment has been generated by cypress-bot as a result of this project's GitHub integration settings.

markdownThroughEditor,
markdownThroughEditorHtml,
markdownFromPaste
} from "./helpers";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpicking, but this probably needs adjustments to please the linter (single quotes, no semicolon).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Linter is not complaining though... funny.

Copy link
Member

@mejo- mejo- left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! I didn't test it yet, but the code changes look reasonable to me. Also learned about the :first-of-type CSS selector. And awesome that you extended the test matrix to cover the fixed issue 🎉

@mejo-
Copy link
Member

mejo- commented Jun 12, 2023

Probably we should backport this all the way back to stable25.

@juliusknorr
Copy link
Member

/backport to stable27

@juliusknorr
Copy link
Member

/backport to stable26

@juliusknorr
Copy link
Member

/backport to stable25

@@ -37,7 +39,7 @@ export default {
renderHtml(content) {
return '<pre>' + escapeHtml(content) + '</pre>'
},
extensions: () => [PlainText],
extensions: () => [PlainText, CodeBlock],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this change related or shouldn't this be a separate PR?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point... I'll split!

Copy link
Member

@juliusknorr juliusknorr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems good just a comment about if the code block change is related or rather something for a separate PR.

@mejo- mejo- requested a review from juliusknorr June 19, 2023 15:34
Fixes #2708.

Try to read the first table row as headings.

Pasting works via `insertContent` while opening uses `setContent`.
They use the schema in different ways.
So we also need to make sure to test both for some corner cases.

`setContent` is fairly flexible in turning the input
into a valid document structure.
`insertContent` however fails to resolve structures
that would require picking lower priority parent elements.

Note: Some tests in src/tests/nodes/Table.spec.js
fail when using `insertContent` instead of `setContent`.
Pasting the correponding html table is fixed never the less.

Signed-off-by: Max <[email protected]>
@mejo-
Copy link
Member

mejo- commented Jun 19, 2023

/compile

Signed-off-by: nextcloud-command <[email protected]>
@juliusknorr juliusknorr merged commit 3e347d5 into main Jun 19, 2023
@delete-merged-branch delete-merged-branch bot deleted the fix/2708-pasting-tables branch June 19, 2023 16:36
@backportbot-nextcloud
Copy link

The backport to stable27 failed. Please do this backport manually.

# Switch to the target branch and update it
git checkout stable27
git pull origin stable27

# Create the new backport branch
git checkout -b fix/foo-stable27

# Cherry pick the change from the commit sha1 of the change against the default branch
# This might cause conflicts. Resolve them.
git cherry-pick abc123

# Push the cherry pick commit to the remote repository and open a pull request
git push origin fix/foo-stable27

More info at https://docs.nextcloud.com/server/latest/developer_manual/getting_started/development_process.html#manual-backport

@backportbot-nextcloud
Copy link

The backport to stable26 failed. Please do this backport manually.

# Switch to the target branch and update it
git checkout stable26
git pull origin stable26

# Create the new backport branch
git checkout -b fix/foo-stable26

# Cherry pick the change from the commit sha1 of the change against the default branch
# This might cause conflicts. Resolve them.
git cherry-pick abc123

# Push the cherry pick commit to the remote repository and open a pull request
git push origin fix/foo-stable26

More info at https://docs.nextcloud.com/server/latest/developer_manual/getting_started/development_process.html#manual-backport

@backportbot-nextcloud
Copy link

The backport to stable25 failed. Please do this backport manually.

# Switch to the target branch and update it
git checkout stable25
git pull origin stable25

# Create the new backport branch
git checkout -b fix/foo-stable25

# Cherry pick the change from the commit sha1 of the change against the default branch
# This might cause conflicts. Resolve them.
git cherry-pick abc123

# Push the cherry pick commit to the remote repository and open a pull request
git push origin fix/foo-stable25

More info at https://docs.nextcloud.com/server/latest/developer_manual/getting_started/development_process.html#manual-backport

@mejo-
Copy link
Member

mejo- commented Jun 19, 2023

/backport 69d5889,92a3dcf9eddf616b92c203c1843500624faa9b93 to stable27

@mejo-
Copy link
Member

mejo- commented Jun 19, 2023

/backport 69d5889,92a3dcf9eddf616b92c203c1843500624faa9b93 to stable26

@mejo-
Copy link
Member

mejo- commented Jun 19, 2023

/backport 92a3dcf to stable25

@backportbot-nextcloud
Copy link

The backport to stable25 failed. Please do this backport manually.

# Switch to the target branch and update it
git checkout stable25
git pull origin stable25

# Create the new backport branch
git checkout -b fix/foo-stable25

# Cherry pick the change from the commit sha1 of the change against the default branch
# This might cause conflicts. Resolve them.
git cherry-pick abc123

# Push the cherry pick commit to the remote repository and open a pull request
git push origin fix/foo-stable25

More info at https://docs.nextcloud.com/server/latest/developer_manual/getting_started/development_process.html#manual-backport

@mejo-
Copy link
Member

mejo- commented Jun 20, 2023

Manual backport to stable25: #4326

@mejo- mejo- added backported successfully backported and removed backport-request labels Jun 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review backported successfully backported bug Something isn't working format: markdown
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Issue pasting certain tables
4 participants