question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Undoing inline marks doesn't work as expected

See original GitHub issue

Do you want to request a feature or report a bug?

Feel free to close this report if it’s a duplicate – I searched “undo” but nothing seemed to quite fit. I am not currently developing with Slate.js but discovered a reproducible bug in the example editor.

What’s the current behavior?

Tested in Chrome 58 on Mac

  1. Visit http://slatejs.org/#/rich-text
  2. On the top paragraph of the editor, select “ch text, mu
  3. Hit delete.
  4. Hit cmd-z.

Current behavior: The re-done text is “mu ch

What’s the expected behavior?

The editor should restore text to the original state: “ch text, mu

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
erquhartcommented, Jun 22, 2017

Some of the selection bugginess seemed to maybe share the same cause, so I was trying to determine if there’s a centralized ticket or effort for that cause, but it doesn’t sound like there’s a single underlying issue. Just learned, for example, about trackpad dragging having a 300ms timeout enforced at the OS level for Mac, which botches quick select/backspace maneuvers.

I’ll probably revisit this once we get through our initial implementation.

0reactions
kgdevcommented, Jul 30, 2017

In Transforms.removeMarkAtRange,

adding the following logic seems to solve the problem:


      const ranges = text.getRanges()
      let rangeIndex = 0
      ranges.forEach(range => {
          const {marks, text} = range
          const rangeLength = text.length

          if (marks.has(mark)) {
              const start = Math.max(index, rangeIndex)
              const end = Math.min(index + length, rangeIndex + rangeLength)

              if (start < end) {
                transform.removeMarkByKey(key, start, end - start, mark, { normalize })
              }
          }

          rangeIndex += rangeLength
      })

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why is this inline-block element pushed downward?
Its that why " inline-block " element is pushed downward. ... Without overflow:hidden it works as excepted and defined by 2 and 3....
Read more >
When a Line Doesn't Break | CSS-Tricks
The inline-block element adds a breaking character at the end of the text. Then the content property space comes after the breaking character ......
Read more >
Allow No file preview - neither overlay nor inline
I just discovered that we have no option for disabling the inline previewer. The preview version does not allow for animation in a...
Read more >
Fix program errors and improve code - Visual Studio (Windows)
Click on any line of code, right-click to open the context menu, and select Quick Actions and refactorings. If refactoring or improvement ...
Read more >
How to Remove an Anchor in Microsoft Word - Alphr
1. Create a new or open a Word document. 2. Go to File (top left corner). 3. At the bottom of the page,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found