How to use the slate-html-serializer.default function in slate-html-serializer

To help you get started, we’ve selected a few slate-html-serializer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ianstormtaylor / slate / benchmark / slate-html-serializer / html-serializer / deserialize.js View on Github external
/** @jsx h */
/* eslint-disable react/jsx-key */

const Html = require('slate-html-serializer').default
const { JSDOM } = require('jsdom') // eslint-disable-line import/no-extraneous-dependencies

const html = new Html({
  parseHtml: JSDOM.fragment,
  rules: [
    {
      deserialize(el, next) {
        switch (el.tagName.toLowerCase()) {
          case 'blockquote':
            return {
              object: 'block',
              type: 'quote',
              nodes: next(el.childNodes),
            }
          case 'p': {
            return {
              object: 'block',
              type: 'paragraph',
              nodes: next(el.childNodes),
github ianstormtaylor / slate / benchmark / slate-html-serializer / html-serializer / serialize.js View on Github external
/** @jsx h */
/* eslint-disable react/jsx-key */

const Html = require('slate-html-serializer').default
const React = require('react')
const h = require('../../helpers/h')
const { JSDOM } = require('jsdom') // eslint-disable-line import/no-extraneous-dependencies

const html = new Html({
  parseHtml: JSDOM.fragment,
  rules: [
    {
      serialize(obj, children) {
        switch (obj.object) {
          case 'block': {
            switch (obj.type) {
              case 'paragraph':
                return React.createElement('p', {}, children)
              case 'quote':
                return React.createElement('blockquote', {}, children)
            }
          }
          case 'mark': {
            switch (obj.type) {
              case 'bold':

slate-html-serializer

An HTML serializer for Slate editors.

MIT
Latest version published 5 years ago

Package Health Score

72 / 100
Full package analysis

Popular slate-html-serializer functions