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

Solve update and revert issues in the writer #3758

Merged
merged 6 commits into from
Oct 7, 2021

Conversation

bastianallgeier
Copy link
Member

@bastianallgeier bastianallgeier commented Oct 6, 2021

Describe the PR

Prosemirror takes the content and applies its own HTML parsing rules. This means that whenever you add a new value to the Writer field from the backend or the value is being pasted from the clipboard, Prosemirror needs to have another look at the HTML first and make adjustments if needed.

So far, there was no update event after Prosemirror finished its own adjustments. That could cause a difference between the value that was pasted initially and whatever Prosemirror made out of it.

With this PR, the writer instantly sends an update if the initial HTML is different from the adjusted HTML. This update will make sure that the changes store is correct and reverting can happen properly.

Release notes

Fixes

Fixed regressions from 3.6.0-beta.2

Breaking changes

None

Related issues/ideas

Ready?

  • Unit tests for fixed bug/feature
  • In-code documentation (wherever needed)
  • CI checks pass

When merging

@bastianallgeier bastianallgeier added this to the 3.6.0-beta.3 milestone Oct 6, 2021
@bastianallgeier bastianallgeier requested a review from a team October 6, 2021 09:21
@afbora
Copy link
Member

afbora commented Oct 6, 2021

The savebar doesn't appear when I click it 🎉

But even if I save the page, the savebar appears every time I refresh the page.

@bastianallgeier
Copy link
Member Author

@afbora really? 😭😭😭😭

@bastianallgeier
Copy link
Member Author

@afbora I just tried again and cannot reproduce the behaviour you describe. Can you post the steps you are taking?

@afbora
Copy link
Member

afbora commented Oct 6, 2021

@bastianallgeier Here my steps

revert.mp4

@bastianallgeier
Copy link
Member Author

So it only happens when you paste something or also when you create blocks manually?

@bastianallgeier
Copy link
Member Author

Ok, I guess I just answered it myself. I can reproduce it when I paste stuff.

@afbora
Copy link
Member

afbora commented Oct 6, 2021

Paste, yes. I'm digging which block occured when paste.

@afbora
Copy link
Member

afbora commented Oct 6, 2021

I guess this issue about   chars somewhere when pasting.

Actually

<p>The&nbsp;<code>split()</code>&nbsp;method similarly applies when dealing with a <a href="https://getkirby.com/docs/reference/panel/fields/multiselect" rel="noopener noreferrer">multiselect</a> field.</p>

Expected

<p>The <code>split()</code> method similarly applies when dealing with a <a href="https://getkirby.com/docs/reference/panel/fields/multiselect" rel="noopener noreferrer">multiselect</a> field.</p>

@bastianallgeier
Copy link
Member Author

Yes, but this should still be solved as soon as you safe and reload.

@afbora
Copy link
Member

afbora commented Oct 6, 2021

I've noticed, inserting \u00a0 char for space when pasting. When update \u00a0 to empty space ( ) manually (from content file), issue disappeared.

@bastianallgeier
Copy link
Member Author

Ok, I think I found it this time. When you paste from the clipboard, the OS/browser is adding invisible non-breaking spaces. Those cause the difference between the final HTML and the current state. It's pretty messed up, but the solution seems simple.

@bastianallgeier
Copy link
Member Author

Shit. It's still not fully solved. I hate this shit.

@bastianallgeier
Copy link
Member Author

Getting there

@afbora
Copy link
Member

afbora commented Oct 6, 2021

Now works great except codecov 🙂

@bastianallgeier
Copy link
Member Author

@afbora fixed

@bastianallgeier bastianallgeier merged commit 4f977d7 into develop Oct 7, 2021
@bastianallgeier bastianallgeier deleted the fix/3736-writer-update-issue branch October 7, 2021 11:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants