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 inline paste #3308

Merged
merged 1 commit into from
Nov 2, 2017
Merged

Fix inline paste #3308

merged 1 commit into from
Nov 2, 2017

Conversation

ellatrix
Copy link
Member

@ellatrix ellatrix commented Nov 2, 2017

Description

Fixes #3305. Broken since fecc4b3.

How Has This Been Tested?

Paste some pure text in a paragraph. Text should be inline. It's not, a new block is created.
Or, paste a link on a work. Word should be linked. Instead a new block with the link is created.

@ellatrix
Copy link
Member Author

ellatrix commented Nov 2, 2017

Maybe we can make this a bit more readable... :)

@ellatrix ellatrix requested a review from mcsf November 2, 2017 10:12
@mcsf
Copy link
Contributor

mcsf commented Nov 2, 2017

This, along with a private chat, shed some context for me on rawHandler's inline option. Note that the @param is wrongly typed, as it reads Boolean:

https://github.com/WordPress/gutenberg/blob/b47cbf52c05dd9450e24f8cafabfebcd04023f10/blocks/api/raw-handling/index.js#L28-L36

@mcsf
Copy link
Contributor

mcsf commented Nov 2, 2017

Maybe we can make this a bit more readable... :)

Indeed, if inline can encode more than two states, we should improve this. Ideas:

  • Plain enumeration: param takes values in HANDLER_AUTO, HANDLER_BLOCK, HANDLER_INLINE. IMO the most direct and plausible way to address this.
  • Masks: same idea, but if we need variations of state, we can combine with bitwise operations. Not idiomatic of JS, and likely confusing.
  • Class interface: param needs to be instanceof HandlerMode, created with new AutoHandlerMode(), new BlockHandlerMode(), etc. Offers some type safety, but seems very cumbersome, over-the-top, and also bulky for an interpreted language.
  • Algebraic data types: oh wait, this is JS. :trollface:

Copy link
Contributor

@mcsf mcsf left a comment

Choose a reason for hiding this comment

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

Let's revisit rawHandler soon. For now, we can get this fixed.

@ellatrix
Copy link
Member Author

ellatrix commented Nov 2, 2017

For the first point, would the parameter name stay inline?

@mcsf
Copy link
Contributor

mcsf commented Nov 2, 2017

For the first point, would the parameter name stay inline?

In my mind it would be more something like handleMode.

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.

2 participants