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

Export some utils for the slate list package #48

Open
pradel opened this issue Sep 11, 2019 · 2 comments
Open

Export some utils for the slate list package #48

pradel opened this issue Sep 11, 2019 · 2 comments

Comments

@pradel
Copy link

pradel commented Sep 11, 2019

Hey! Thanks for this really cool plugin!
Would you accept a pr to export these functions as utils from the list package?

  const isListItem = block => block && block.type == blocks.list_item;

  const getListItem = (editor, block) => {
    const possibleListItem = editor.value.document.getParent(block.key);

    return isListItem(possibleListItem) ? possibleListItem : null;
  };

  const isList = block =>
    block &&
    (block.type == blocks.unordered_list || block.type == blocks.ordered_list);

  const getList = (editor, block) => {
    const possibleList = editor.value.document.getParent(block.key);
    return isList(possibleList) ? possibleList : null;
  };

I need these utils in order to be able to show an active status in my editor :)

@brendancarney
Copy link
Collaborator

Thanks! So it will require that we know the arguments passed into the plugin, so we couldn't just export them as utils. We could potentially add some queries: https://docs.slatejs.org/guides/commands-and-queries#reusing-commands-and-queries.

I'm not sure they will be much more helpful than using your own, like:

const isListItem = block =>  block.type == 'list-item`;

Let me know if you have any ideas.

@pradel
Copy link
Author

pradel commented Sep 17, 2019

@brendancarney I didn't know about queries, looks like a pretty good usecase for it 👍
I ended up duplicated these utils but this means that I have to keep my utils updated if you do any breaking change on your side for example.
If you are open to the queries idea I can submit a pr :)

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

No branches or pull requests

2 participants