JavaScript filterDescendants and findDescendant with slate.js

I'm working on making a wysiwyg editor using slate.js I'm in a situation where I'm trying to find the first node with text.

This picture below shows what I'm talking about:

Slate.js find first text pic

In my picture, I'd want to find the node that contains "this is my title.", even if there's several empty lines before it.

Basically if I have a bunch of text written in the editor, how do I find the first text that's not an empty string?

Looking through the docs, I've found the filterDescendants and findDescendants functions which seem to do what I'm looking for.

However, I'm unclear how to use them.

I've tried something like this:

this.state.state.startBlock.findDescendant((d) => d.text !== "")

But this just returns null

The docs say that findDescendant will "Deeply find a descendant node by iterator", where iterator is a function, but there's no examples provided for what sort of function you'd pass here.

Does anyone have any ideas or examples?

Answer:1

I have a function: function getNumber(number, array){ for(var i=0; i<array.length; i++){ if (array[i] == number) { return true; } else { return false; } } } console....

I have a function: function getNumber(number, array){ for(var i=0; i<array.length; i++){ if (array[i] == number) { return true; } else { return false; } } } console....

  1. check array length
  2. check array for value
  3. check array empty
  4. check array for duplicates
  5. check array empty javascript
  6. check array equality javascript
  7. check array of objects for value
  8. check array length python
  9. check array length php
  10. check array for duplicates javascript
  11. check array size
  12. check array is empty java
  13. check array length java
  14. check array size python
  15. check array empty python
  16. check array type python
  17. check arraylist is empty
  18. check array size java
  19. check array for string
  20. check array length bash

I would like to have a property dynamically accessed with a variable. For example, I have : data(){ redsection : '', bluesection : '', }, methods(){ changeColor(color, val){ ...

I would like to have a property dynamically accessed with a variable. For example, I have : data(){ redsection : '', bluesection : '', }, methods(){ changeColor(color, val){ ...

  1. vuejs pass variable to child component
  2. vuejs pass variable to component
  3. vuejs pass variable to css
  4. vuejs pass variable to parent
  5. vuejs pass variable to function
  6. vuejs pass variable to computed
  7. vuejs pass variable to method
  8. vuejs pass variable
  9. vuejs pass variable to child
  10. vuejs pass parameters to component
  11. vuejs router pass variable

I have a little problem here. ¿How i can manipulate a dynamically generated html, in Jquery? I have a function like: generatesomething : function(DestinationID,data){ result = $.DoSomething(data)...

I have a little problem here. ¿How i can manipulate a dynamically generated html, in Jquery? I have a function like: generatesomething : function(DestinationID,data){ result = $.DoSomething(data)...

How can I make a partial string match in Javascript? e.g. to match 'Alf' 'Alfred' -> true 'Alf' -> true 'alf' -> true 'al' -> true 'altered' -> false 'half' -> false '' -> false 'bob' -> false ...

How can I make a partial string match in Javascript? e.g. to match 'Alf' 'Alfred' -> true 'Alf' -> true 'alf' -> true 'al' -> true 'altered' -> false 'half' -> false '' -> false 'bob' -> false ...

  1. javascript matching strings
  2. js matching strings
  3. javascript compare strings
  4. javascript compare strings ignore case
  5. javascript compare strings equal
  6. javascript compare strings alphabetically
  7. javascript compare strings case insensitive
  8. javascript compare strings sort
  9. javascript compare strings as numbers
  10. javascript compare strings lexicographically
  11. javascript compare strings not equal
  12. javascript compare strings ignore whitespace
  13. javascript compare strings alphabetical order
  14. javascript compare strings contains
  15. javascript compare strings greater than
  16. javascript compare strings without case sensitive
  17. javascript compare strings like
  18. javascript compare strings and find difference
  19. javascript compare strings in array
  20. javascript compare strings with special characters