Kit / slate-plugins

A collection of plugins for SlateJS, maintained by ConvertKit
https://convertkit-slate-plugins.netlify.com/
MIT License
52 stars 22 forks source link

Deserialization results in broken plugin functionality #33

Open barrymun opened 5 years ago

barrymun commented 5 years ago

When deserializing some html so that it can be used with a slatejs editor inner list-items are lost. Using the following sample html:

<ol>
  <li>
    one
    <ol>
      <li>
         two
      </li>
    </ol>
  </li>
</ol>

Here, the ordered list within the list-item containing "one" will be lost as this seems to be part of the slate architecture.

Looking at the above sample code, wrapping the "one" in a div (as part of the deserialization process) will preserve the inner ordered list, but now the list slate-list-plugin will not work as intended - the plugin will not allow you to add or remove new list-items and does not seem to recognize the structure as a list because the inner list-item "two" will now also be wrapped in a div.

When loading some Value like the following into the editor, however, everything works as intended and the above issue is not encountered (like in the example):

{"object":"value","document":{"object":"document","data":{},"nodes":[{"object":"block","type":"ordered-list","data":{},"nodes":[{"object":"block","type":"list-item","data":{},"nodes":[{"object":"block","type":"list-item-child","data":{},"nodes":[{"object":"text","leaves":[{"object":"leaf","text":"one","marks":[]}]}]},{"object":"block","type":"ordered-list","data":{},"nodes":[{"object":"block","type":"list-item","data":{},"nodes":[{"object":"block","type":"list-item-child","data":{},"nodes":[{"object":"text","leaves":[{"object":"leaf","text":"two","marks":[]}]}]}]}]}]}]}]}}

Was looking through the codebase for a sample deserialization method but could not find one, but this seems to be an issue with deserialization.