-
Notifications
You must be signed in to change notification settings - Fork 12
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
Upgrade to slate 0.44 #6
base: master
Are you sure you want to change the base?
Conversation
lib/index.js
Outdated
toRemove.forEach((failure) => change = change.removeNodeByKey(failure.key)) | ||
return true | ||
function onChange(change, next) { | ||
if (!canBeEmpty) return next(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I realize this is old code but this is a little confusing to me and is smells like a performance issue. Is this going over the entire document to look for void inlines and rip them out? What's the purpose of this event handler?
Might be a better question for @YurkaninRyan
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey Cameron, it's been awhile but we use zero-width spaces to keep "empty" inlines around. This cleans them up if you unfocus them.
There may be a better way to do this.
function onSelect(event, change, next) { | ||
const selection = findRange(window.getSelection(), change.editor); | ||
const selectionIsAtEndOfInline = | ||
change.value.focusInline && | ||
selection.focusOffset === change.value.focusInline.text.length; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dont think we're supposed to return the change here anymore when the plugin runs a command. I believe the correct thing to return is undefined. But I'm not exactly sure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We only return next()
if we want plugins down the stack to continue handling the event. If we want to handle the event ourselves and stop propagation, then we don't return anything (although I think it's ok to return anything else but next()
).
Hi, I hope you and @YurkaninRyan don't mind but I was also looking at upgrading this plugin for my own upgrade and happened upon this PR. So I took the liberty of reviewing it. The changes look good I think! Just a few things that I believe need to be corrected.
Thanks for putting in this PR, hopefully ryan gets a chance to look at it soon :) |
Hey @YurkaninRyan – thanks for the great plugin here. Are you interested in merging and publishing these updates which are required to work with the latest Slate versions or should we go ahead and fork the project? |
It seems pretty clear that the chances of this project being updates are low. Can we (well, you, to be specific) create a fork and publish to npm (maybe as |
@travigd I can do that. I intend to create a monorepo (like slate-plugins) to share a bunch of plugins that I have built. I suppose that I should do that sooner than later so that I can publish this and others can start doing that. Additionally, it would be nice to bring some more organization and collaboration to the slate plugin ecosystem. By creating an actively maintained monorepo, it should prevent things like this (out-of-date and unmaintained repos) from happening and make it easier for others to contribute. We could either combine forces with slate-plugins and add some plugins to it or start a new one. Open to ideas... |
Maybe an |
Is there a way to use this fork? I tried installing it and then whitelisting it in the babel config (so it gets compiled), but it doesn't seem to be doing anything |
Hi @Jarred-Sumner, I've been meaning to create a monorepo or something that is more contributor-friendly but I haven't gotten around to it. In the meantime, you should be able to clone my fork, check out the slate-0.42 branch, install, and then |
Some slate API changes: https://github.com/ianstormtaylor/slate/blob/master/packages/slate/Changelog.md#0420--october-9-2018
This also adds prettier for code formatting 👍
I was running into some error when running the example but I tested in my own project and it's working with slate 0.42.2.
UPDATE: I've push a new commit that upgrades to slate 0.44.