Slate: Marks always "bleeding" into new line by default

Created on 26 Jan 2018  路  7Comments  路  Source: ianstormtaylor/slate

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

Bug

What's the current behavior?

Tested with v0.32.1 on Chrome/Firefox/Safari locally as well as in the examples page (below gif recorded as of today 1/24/2018): It appears that, with given two paragraphs, if there are marks on the ending text of the previous paragraph, they always carry over to the following paragraph by default.

Below are a couple issues reproduced from this bug, using the examples page.
zvpylyfylr
(http://recordit.co/zvPYlyFYlr)

  • Styling the end of the text with bold, then hitting enter to hard break leads the following paragraph to be bolded by default as well. I did search through the previous issues and from #1269 I see there was some discussion around this behavior; but I think the decision was ultimately not to support the auto carry over and let users to decide for themselves (#1273). Given this, it leads me to believe this is a bug.
  • Another unintuitive behavior is when you manipulate the previous paragraph (by deleting ! character), it automatically affects the following paragraph even though the edit operation was not related and done only to the first paragraph. I imagine this is rather unexpected for most use cases. (I'm not certain, but back in the days Slate used to use zero-width space to deal with empty text and such, but I don't think the latest version does that anymore- maybe related?)

Omitting JSFiddle, because reproducible with the example page.

What's the expected behavior?

  • Hard breaking on text with marks does not automatically carry over the style to the following split paragraph
  • Editing marks/style of a paragraph in isolation should not affect the following paragraph.

I took a quick look at splitBlock and other associated internals but I must admit, I was pretty lost in it 馃槄.. Really appreciate Slate and the work everyone has put in - let me know in any ways I can help.

bug

All 7 comments

I'd actually expect marks to carry over into next paragraph. Sometimes it's undesirable but that's what I would expect and that's what most editors seem to do.

I don't personally have too strong of opinions as to what the correct behavior here should be, since it is subjective and dependent on one's situation.. I'd add, from my observations, more consumer oriented products like Dropbox Paper and Notation tend to not carry over marks/styles, but If this is the agreed behavior for Slate, I can live with this.

From looking at the previous discussion such as #1269 though, I wonder whether this is indeed the intended behavior? Maybe @justinweiss or @ianstormtaylor could opine on this? :)

Happy to close it if it's indeed expected. Thank you!

@thomaswhyyou you're right, this is not expected. I thought it was reverted by https://github.com/aha-app/slate/commit/3b5f499dbf83ebb1cffebe5efe2595019b66484f but it seems like it might not have been fully?

Are you on the latest slate and slate-react versions?

@ianstormtaylor Yes, I also ran locally in a fresh react project with the latest versions available, and observed the same behavior. For completeness, here are the dependencies and its versions used:

  "dependencies": {
    "immutable": "^3.8.2",
    "is-hotkey": "^0.1.1",
    "react": "^16.2.0",
    "react-dom": "^16.2.0",
    "react-scripts": "1.1.0",
    "slate": "^0.32.1",
    "slate-auto-replace": "^0.9.0",
    "slate-react": "^0.11.1"
  },

It's back, changed your mind?

Possibly here:

Commands.splitBlock = (editor, depth = 1) => {
  deleteExpanded(editor)

  const { value } = editor
  const { selection, document } = value
  const marks = selection.marks || document.getInsertMarksAtRange(selection)
  editor.splitBlockAtRange(selection, depth).moveToEnd()

  if (marks && marks.size !== 0) {
    editor.select({ marks })
  }
}

Have the same issue with versions:

    "slate": "^0.58.1",
    "slate-history": "^0.57.1",
    "slate-react": "^0.57.1",

Any ideas how to solve this behaviour?

Agree this is still happening

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vdms picture vdms  路  3Comments

chriserickson picture chriserickson  路  3Comments

ianstormtaylor picture ianstormtaylor  路  3Comments

ezakto picture ezakto  路  3Comments

chrpeter picture chrpeter  路  3Comments