Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
/** @jsx h */
import { Editor } from "slate";
import hyperprint from "slate-hyperprint";
import events from "./events";
import { createHTM } from "@convertkit/slate-htm";
import { createHyperscript } from "slate-hyperscript";
import diff from "jest-diff";
const h = createHyperscript({});
const html = createHTM({});
const SlateTest = options => {
// Create a value that is normalized using the same options as the editor.
const createValue = children => {
const editor = new Editor(options);
const value = html`
${children}
`;
editor.setValue(value);
return editor.value;
};
/** @jsx h */
// eslint-disable-next-line import/no-extraneous-dependencies
import { createHyperscript } from 'slate-hyperscript';
const h = createHyperscript({
blocks: {
heading: 'heading',
paragraph: 'paragraph',
ul_list: 'ul_list',
ol_list: 'ol_list',
list_item: 'list_item'
}
});
export default (
Slate + List Edition
This page is a basic example of Slate + slate-edit-list plugin.
Press Enter in a list to create a new list item. Press Enter
/** @jsx h */
// eslint-disable-next-line
import { createHyperscript } from 'slate-hyperscript';
const h = createHyperscript({
blocks: {
heading: 'heading',
paragraph: 'paragraph',
table: 'table',
table_row: 'table_row',
table_cell: 'table_cell'
}
});
const value = (
Slate + Table Edition
This page is a basic example of Slate + slate-edit-table plugin.
/** @jsx h */
// eslint-disable-next-line import/no-extraneous-dependencies
import { createHyperscript } from 'slate-hyperscript';
const h = createHyperscript({
blocks: {
paragraph: 'paragraph',
heading: 'heading',
code_block: 'code_block',
code_line: 'code_line'
},
inlines: {},
marks: {}
});
export default (
{'Slate Hyperprint'}
{
/* eslint-disable import/no-extraneous-dependencies */
const { createHyperscript } = require('slate-hyperscript')
/**
* Define a hyperscript.
*
* @type {Function}
*/
const h = createHyperscript({
blocks: {
line: 'line',
paragraph: 'paragraph',
quote: 'quote',
code: 'code',
list: 'list',
item: 'item',
image: 'image',
table: 'table',
tbody: 'tbody',
tr: 'tr',
td: 'td',
thead: 'thead',
th: 'th',
},
inlines: {
/** @jsx h */
// eslint-disable-next-line
import { createHyperscript } from 'slate-hyperscript';
const h = createHyperscript({
blocks: {
heading: 'heading',
paragraph: 'paragraph',
table: 'table',
table_row: 'table_row',
table_cell: 'table_cell'
}
});
const state = (
Slate + Table Edition
This page is a basic example of Slate + slate-edit-table plugin.
import { createHyperscript } from 'slate-hyperscript';
const h = createHyperscript({
blocks: {
paragraph: 'paragraph',
heading: 'heading',
code_block: 'code_block',
code_line: 'code_line',
image: {
type: 'image',
isVoid: true
}
},
inlines: {
link: 'link'
},
marks: {
bold: 'bold',
italic: 'italic'
el.childNodes[0].nodeName === 'CODE'
) {
parent = el.childNodes[0]
}
const children = Array.from(parent.childNodes)
.map(deserialize)
.flat()
if (el.nodeName === 'BODY') {
return jsx('fragment', {}, children)
}
if (ELEMENT_TAGS[nodeName]) {
const attrs = ELEMENT_TAGS[nodeName](el)
return jsx('element', attrs, children)
}
if (TEXT_TAGS[nodeName]) {
const attrs = TEXT_TAGS[nodeName](el)
return children.map(child => jsx('text', attrs, child))
}
return children
}
el.childNodes[0] &&
el.childNodes[0].nodeName === 'CODE'
) {
parent = el.childNodes[0]
}
const children = Array.from(parent.childNodes).map(deserialize)
if (el.nodeName === 'BODY') {
return jsx('fragment', {}, children)
}
if (ELEMENT_TAGS[nodeName]) {
const attrs = ELEMENT_TAGS[nodeName](el)
return jsx('element', attrs, children)
}
if (TEXT_TAGS[nodeName]) {
const attrs = TEXT_TAGS[nodeName](el)
return children.map(child => jsx('text', attrs, child))
}
return children
};
let parent = el
if (
nodeName === 'PRE' &&
el.childNodes[0] &&
el.childNodes[0].nodeName === 'CODE'
) {
parent = el.childNodes[0]
}
const children = Array.from(parent.childNodes)
.map(deserialize)
.flat()
if (el.nodeName === 'BODY') {
return jsx('fragment', {}, children)
}
if (ELEMENT_TAGS[nodeName]) {
const attrs = ELEMENT_TAGS[nodeName](el)
return jsx('element', attrs, children)
}
if (TEXT_TAGS[nodeName]) {
const attrs = TEXT_TAGS[nodeName](el)
return children.map(child => jsx('text', attrs, child))
}
return children
}