1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-09-01 03:11:44 +02:00

Merge branch 'master' of github.com:ianstormtaylor/slate

This commit is contained in:
Ian Storm Taylor
2018-01-04 15:27:06 -08:00
144 changed files with 842 additions and 820 deletions

View File

@@ -10,7 +10,7 @@ const html = new Html({
rules: [
{
serialize(obj, children) {
switch (obj.kind) {
switch (obj.object) {
case 'block': {
switch (obj.type) {
case 'paragraph': return React.createElement('p', {}, children)

View File

@@ -11,7 +11,7 @@ const html = new Html({
rules: [
{
serialize(obj, children) {
switch (obj.kind) {
switch (obj.object) {
case 'block': {
switch (obj.type) {
case 'paragraph': return React.createElement('p', {}, children)

View File

@@ -12,7 +12,7 @@ import { Record } from 'immutable'
*/
const String = new Record({
kind: 'string',
object: 'string',
text: ''
})
@@ -28,9 +28,9 @@ const TEXT_RULE = {
deserialize(el) {
if (el.tagName && el.tagName.toLowerCase() === 'br') {
return {
kind: 'text',
object: 'text',
leaves: [{
kind: 'leaf',
object: 'leaf',
text: '\n'
}]
}
@@ -40,9 +40,9 @@ const TEXT_RULE = {
if (el.nodeValue && el.nodeValue.match(/<!--.*?-->/)) return
return {
kind: 'text',
object: 'text',
leaves: [{
kind: 'leaf',
object: 'leaf',
text: el.nodeValue
}]
}
@@ -50,7 +50,7 @@ const TEXT_RULE = {
},
serialize(obj, children) {
if (obj.kind === 'string') {
if (obj.object === 'string') {
return children
.split('\n')
.reduce((array, text, i) => {
@@ -129,19 +129,19 @@ class Html {
// COMPAT: ensure that all top-level inline nodes are wrapped into a block.
nodes = nodes.reduce((memo, node, i, original) => {
if (node.kind == 'block') {
if (node.object == 'block') {
memo.push(node)
return memo
}
if (i > 0 && original[i - 1].kind != 'block') {
if (i > 0 && original[i - 1].object != 'block') {
const block = memo[memo.length - 1]
block.nodes.push(node)
return memo
}
const block = {
kind: 'block',
object: 'block',
data: {},
isVoid: false,
...defaultBlock,
@@ -155,16 +155,16 @@ class Html {
// TODO: pretty sure this is no longer needed.
if (nodes.length == 0) {
nodes = [{
kind: 'block',
object: 'block',
data: {},
isVoid: false,
...defaultBlock,
nodes: [
{
kind: 'text',
object: 'text',
leaves: [
{
kind: 'leaf',
object: 'leaf',
text: '',
marks: [],
}
@@ -175,9 +175,9 @@ class Html {
}
const json = {
kind: 'value',
object: 'value',
document: {
kind: 'document',
object: 'document',
data: {},
nodes,
}
@@ -257,7 +257,7 @@ class Html {
continue
} else if (ret === null) {
return null
} else if (ret.kind == 'mark') {
} else if (ret.object == 'mark') {
node = this.deserializeMark(ret)
} else {
node = ret
@@ -280,11 +280,11 @@ class Html {
const { type, data } = mark
const applyMark = (node) => {
if (node.kind == 'mark') {
if (node.object == 'mark') {
return this.deserializeMark(node)
}
else if (node.kind == 'text') {
else if (node.object == 'text') {
node.leaves = node.leaves.map((leaf) => {
leaf.marks = leaf.marks || []
leaf.marks.push({ type, data })
@@ -334,7 +334,7 @@ class Html {
*/
serializeNode = (node) => {
if (node.kind === 'text') {
if (node.object === 'text') {
const leaves = node.getLeaves()
return leaves.map(this.serializeLeaf)
}

View File

@@ -10,14 +10,14 @@ export const config = {
switch (el.tagName.toLowerCase()) {
case 'p': {
return {
kind: 'block',
object: 'block',
type: 'paragraph',
nodes: next(el.childNodes),
}
}
case 'blockquote': {
return {
kind: 'block',
object: 'block',
type: 'quote',
nodes: next(el.childNodes),
}

View File

@@ -10,7 +10,7 @@ export const config = {
switch (el.tagName.toLowerCase()) {
case 'p': {
return {
kind: 'block',
object: 'block',
type: 'paragraph',
nodes: next(el.childNodes),
}

View File

@@ -10,7 +10,7 @@ export const config = {
switch (el.tagName.toLowerCase()) {
case 'p': {
return {
kind: 'block',
object: 'block',
type: 'paragraph',
data: { thing: 'value' },
nodes: next(el.childNodes),

View File

@@ -10,7 +10,7 @@ export const config = {
switch (el.tagName.toLowerCase()) {
case 'img': {
return {
kind: 'block',
object: 'block',
type: 'image',
isVoid: true,
}

View File

@@ -10,7 +10,7 @@ export const config = {
switch (el.tagName.toLowerCase()) {
case 'p': {
return {
kind: 'block',
object: 'block',
type: 'paragraph',
nodes: next(el.childNodes),
}

View File

@@ -10,7 +10,7 @@ export const config = {
switch (el.tagName.toLowerCase()) {
case 'p': {
return {
kind: 'block',
object: 'block',
type: 'paragraph',
nodes: next(el.childNodes),
}

View File

@@ -10,7 +10,7 @@ export const config = {
switch (el.tagName.toLowerCase()) {
case 'p': {
return {
kind: 'block',
object: 'block',
type: 'paragraph',
nodes: next(el.childNodes),
}

View File

@@ -10,21 +10,21 @@ export const config = {
switch (el.tagName.toLowerCase()) {
case 'p': {
return {
kind: 'block',
object: 'block',
type: 'paragraph',
nodes: next(el.childNodes),
}
}
case 'a': {
return {
kind: 'inline',
object: 'inline',
type: 'link',
nodes: next(el.childNodes),
}
}
case 'span': {
return {
kind: 'inline',
object: 'inline',
type: 'hashtag',
nodes: next(el.childNodes),
}

View File

@@ -10,14 +10,14 @@ export const config = {
switch (el.tagName.toLowerCase()) {
case 'p': {
return {
kind: 'block',
object: 'block',
type: 'paragraph',
nodes: next(el.childNodes),
}
}
case 'a': {
return {
kind: 'inline',
object: 'inline',
type: 'link',
nodes: next(el.childNodes),
}

View File

@@ -10,14 +10,14 @@ export const config = {
switch (el.tagName.toLowerCase()) {
case 'p': {
return {
kind: 'block',
object: 'block',
type: 'paragraph',
nodes: next(el.childNodes),
}
}
case 'a': {
return {
kind: 'inline',
object: 'inline',
type: 'link',
data: { thing: 'value' },
nodes: next(el.childNodes),

View File

@@ -10,14 +10,14 @@ export const config = {
switch (el.tagName.toLowerCase()) {
case 'p': {
return {
kind: 'block',
object: 'block',
type: 'paragraph',
nodes: next(el.childNodes),
}
}
case 'img': {
return {
kind: 'inline',
object: 'inline',
type: 'emoji',
isVoid: true,
nodes: next(el.childNodes),

View File

@@ -10,14 +10,14 @@ export const config = {
switch (el.tagName.toLowerCase()) {
case 'p': {
return {
kind: 'block',
object: 'block',
type: 'paragraph',
nodes: next(el.childNodes),
}
}
case 'a': {
return {
kind: 'inline',
object: 'inline',
type: 'link',
nodes: next(el.childNodes),
}

View File

@@ -10,21 +10,21 @@ export const config = {
switch (el.tagName.toLowerCase()) {
case 'p': {
return {
kind: 'block',
object: 'block',
type: 'paragraph',
nodes: next(el.childNodes),
}
}
case 'strong': {
return {
kind: 'mark',
object: 'mark',
type: 'bold',
nodes: next(el.childNodes),
}
}
case 'em': {
return {
kind: 'mark',
object: 'mark',
type: 'italic',
nodes: next(el.childNodes),
}

View File

@@ -10,21 +10,21 @@ export const config = {
switch (el.tagName.toLowerCase()) {
case 'p': {
return {
kind: 'block',
object: 'block',
type: 'paragraph',
nodes: next(el.childNodes),
}
}
case 'strong': {
return {
kind: 'mark',
object: 'mark',
type: 'bold',
nodes: next(el.childNodes),
}
}
case 'em': {
return {
kind: 'mark',
object: 'mark',
type: 'italic',
nodes: next(el.childNodes),
}

View File

@@ -10,14 +10,14 @@ export const config = {
switch (el.tagName.toLowerCase()) {
case 'p': {
return {
kind: 'block',
object: 'block',
type: 'paragraph',
nodes: next(el.childNodes),
}
}
case 'strong': {
return {
kind: 'mark',
object: 'mark',
type: 'bold',
data: { thing: 'value' },
nodes: next(el.childNodes),

View File

@@ -10,14 +10,14 @@ export const config = {
switch (el.tagName.toLowerCase()) {
case 'p': {
return {
kind: 'block',
object: 'block',
type: 'paragraph',
nodes: next(el.childNodes),
}
}
case 'strong': {
return {
kind: 'mark',
object: 'mark',
type: 'bold',
nodes: next(el.childNodes),
}

View File

@@ -8,7 +8,7 @@ export const config = {
{
deserialize(el, next) {
return {
kind: 'block',
object: 'block',
type: 'paragraph',
}
}
@@ -16,7 +16,7 @@ export const config = {
{
deserialize(el, next) {
return {
kind: 'block',
object: 'block',
type: 'quote',
}
}

View File

@@ -10,7 +10,7 @@ export const config = {
switch (el.tagName.toLowerCase()) {
case 'p': {
return {
kind: 'block',
object: 'block',
type: 'paragraph',
nodes: next(),
}

View File

@@ -13,14 +13,14 @@ export const config = {
}
case 'p': {
return {
kind: 'block',
object: 'block',
type: 'paragraph',
nodes: next(el.childNodes),
}
}
case 'img': {
return {
kind: 'block',
object: 'block',
type: 'image',
isVoid: true,
}

View File

@@ -6,7 +6,7 @@ export const config = {
switch (el.tagName.toLowerCase()) {
case 'p': {
return {
kind: 'block',
object: 'block',
type: 'paragraph',
nodes: next(el.childNodes),
}
@@ -22,20 +22,20 @@ export const input = `
`.trim()
export const output = {
kind: 'value',
object: 'value',
document: {
kind: 'document',
object: 'document',
data: {},
nodes: [
{
kind: 'block',
object: 'block',
type: 'paragraph',
nodes: [
{
kind: 'text',
object: 'text',
leaves: [
{
kind: 'leaf',
object: 'leaf',
text: 'one',
}
]

View File

@@ -7,7 +7,7 @@ import h from '../helpers/h'
export const rules = [
{
serialize(obj, children) {
if (obj.kind != 'block') return
if (obj.object != 'block') return
switch (obj.type) {
case 'paragraph': return React.createElement('p', {}, children)
case 'quote': return React.createElement('blockquote', {}, children)

View File

@@ -7,7 +7,7 @@ import h from '../helpers/h'
export const rules = [
{
serialize(obj, children) {
if (obj.kind == 'block' && obj.type == 'paragraph') {
if (obj.object == 'block' && obj.type == 'paragraph') {
return React.createElement('p', { 'data-thing': obj.data.get('thing') }, children)
}
}

View File

@@ -7,7 +7,7 @@ import h from '../helpers/h'
export const rules = [
{
serialize(obj, children) {
if (obj.kind == 'block' && obj.type == 'image') {
if (obj.object == 'block' && obj.type == 'image') {
return React.createElement('img')
}
}

View File

@@ -7,11 +7,11 @@ import h from '../helpers/h'
export const rules = [
{
serialize(obj, children) {
if (obj.kind == 'block' && obj.type == 'paragraph') {
if (obj.object == 'block' && obj.type == 'paragraph') {
return React.createElement('p', {}, children)
}
if (obj.kind == 'mark' && obj.type == 'bold') {
if (obj.object == 'mark' && obj.type == 'bold') {
return React.createElement('strong', {}, children)
}
}

View File

@@ -7,7 +7,7 @@ import h from '../helpers/h'
export const rules = [
{
serialize(obj, children) {
if (obj.kind == 'block' && obj.type == 'paragraph') {
if (obj.object == 'block' && obj.type == 'paragraph') {
return React.createElement('p', {}, children)
}
}

View File

@@ -7,15 +7,15 @@ import h from '../helpers/h'
export const rules = [
{
serialize(obj, children) {
if (obj.kind == 'block' && obj.type == 'paragraph') {
if (obj.object == 'block' && obj.type == 'paragraph') {
return React.createElement('p', {}, children)
}
if (obj.kind == 'inline' && obj.type == 'link') {
if (obj.object == 'inline' && obj.type == 'link') {
return React.createElement('a', {}, children)
}
if (obj.kind == 'inline' && obj.type == 'hashtag') {
if (obj.object == 'inline' && obj.type == 'hashtag') {
return React.createElement('span', {}, children)
}
}

View File

@@ -7,11 +7,11 @@ import h from '../helpers/h'
export const rules = [
{
serialize(obj, children) {
if (obj.kind == 'block' && obj.type == 'paragraph') {
if (obj.object == 'block' && obj.type == 'paragraph') {
return React.createElement('p', {}, children)
}
if (obj.kind == 'inline' && obj.type == 'link') {
if (obj.object == 'inline' && obj.type == 'link') {
return React.createElement('a', { href: obj.data.get('href') }, children)
}
}

View File

@@ -7,11 +7,11 @@ import h from '../helpers/h'
export const rules = [
{
serialize(obj, children) {
if (obj.kind == 'block' && obj.type == 'paragraph') {
if (obj.object == 'block' && obj.type == 'paragraph') {
return React.createElement('p', {}, children)
}
if (obj.kind == 'inline' && obj.type == 'emoji') {
if (obj.object == 'inline' && obj.type == 'emoji') {
return React.createElement('img')
}
}

View File

@@ -7,15 +7,15 @@ import h from '../helpers/h'
export const rules = [
{
serialize(obj, children) {
if (obj.kind == 'block' && obj.type == 'paragraph') {
if (obj.object == 'block' && obj.type == 'paragraph') {
return React.createElement('p', {}, children)
}
if (obj.kind == 'inline' && obj.type == 'link') {
if (obj.object == 'inline' && obj.type == 'link') {
return React.createElement('a', {}, children)
}
if (obj.kind == 'mark' && obj.type == 'bold') {
if (obj.object == 'mark' && obj.type == 'bold') {
return React.createElement('strong', {}, children)
}
}

View File

@@ -7,11 +7,11 @@ import h from '../helpers/h'
export const rules = [
{
serialize(obj, children) {
if (obj.kind == 'block' && obj.type == 'paragraph') {
if (obj.object == 'block' && obj.type == 'paragraph') {
return React.createElement('p', {}, children)
}
if (obj.kind == 'inline' && obj.type == 'link') {
if (obj.object == 'inline' && obj.type == 'link') {
return React.createElement('a', {}, children)
}
}

View File

@@ -11,7 +11,7 @@ export const rules = [
},
{
serialize(obj, children) {
if (obj.kind == 'block' && obj.type == 'paragraph') {
if (obj.object == 'block' && obj.type == 'paragraph') {
return React.createElement('p', {}, children)
}
}

View File

@@ -270,15 +270,15 @@ function resolveCreators(options) {
}
/**
* Normalize a node creator with `key` and `value`, of `kind`.
* Normalize a node creator with `key` and `value`, of `object`.
*
* @param {String} key
* @param {Function|Object|String} value
* @param {String} kind
* @param {String} object
* @return {Function}
*/
function normalizeNode(key, value, kind) {
function normalizeNode(key, value, object) {
if (typeof value == 'function') {
return value
}
@@ -292,7 +292,7 @@ function normalizeNode(key, value, kind) {
const { key: attrKey, ...rest } = attributes
const attrs = {
...value,
kind,
object,
key: attrKey,
data: {
...(value.data || {}),
@@ -300,11 +300,11 @@ function normalizeNode(key, value, kind) {
}
}
return CREATORS[kind](tagName, attrs, children)
return CREATORS[object](tagName, attrs, children)
}
}
throw new Error(`Slate hyperscript ${kind} creators can be either functions, objects or strings, but you passed: ${value}`)
throw new Error(`Slate hyperscript ${object} creators can be either functions, objects or strings, but you passed: ${value}`)
}
/**

View File

@@ -28,22 +28,22 @@ function deserialize(string, options = {}) {
defaultMarks = defaultMarks.map(Mark.createProperties)
const json = {
kind: 'value',
object: 'value',
document: {
kind: 'document',
object: 'document',
data: {},
nodes: string.split('\n').map((line) => {
return {
...defaultBlock,
kind: 'block',
object: 'block',
isVoid: false,
data: {},
nodes: [
{
kind: 'text',
object: 'text',
leaves: [
{
kind: 'leaf',
object: 'leaf',
text: line,
marks: defaultMarks,
}
@@ -79,8 +79,8 @@ function serialize(value) {
function serializeNode(node) {
if (
(node.kind == 'document') ||
(node.kind == 'block' && Block.isBlockList(node.nodes))
(node.object == 'document') ||
(node.object == 'block' && Block.isBlockList(node.nodes))
) {
return node.nodes.map(serializeNode).join('\n')
} else {

View File

@@ -4,22 +4,22 @@ one
`.trim()
export const output = {
kind: 'value',
object: 'value',
document: {
kind: 'document',
object: 'document',
data: {},
nodes: [
{
kind: 'block',
object: 'block',
type: 'line',
isVoid: false,
data: {},
nodes: [
{
kind: 'text',
object: 'text',
leaves: [
{
kind: 'leaf',
object: 'leaf',
text: 'one',
marks: [],
}

View File

@@ -131,7 +131,7 @@ class Node extends React.Component {
// If it's a block node with inline children, add the proper `dir` attribute
// for text direction.
if (node.kind == 'block' && node.nodes.first().kind != 'block') {
if (node.object == 'block' && node.nodes.first().object != 'block') {
const direction = node.getTextDirection()
if (direction == 'rtl') attributes.dir = 'rtl'
}
@@ -170,11 +170,11 @@ class Node extends React.Component {
renderNode = (child, isSelected) => {
const { block, decorations, editor, node, readOnly } = this.props
const { stack } = editor
const Component = child.kind == 'text' ? Text : Node
const Component = child.object == 'text' ? Text : Node
const decs = decorations.concat(node.getDecorations(stack))
return (
<Component
block={node.kind == 'block' ? node : block}
block={node.object == 'block' ? node : block}
decorations={decs}
editor={editor}
isSelected={isSelected}

View File

@@ -82,7 +82,7 @@ class Text extends React.Component {
// If the node parent is a block node, and it was the last child of the
// block, re-render to cleanup extra `\n`.
if (n.parent.kind == 'block') {
if (n.parent.object == 'block') {
const pLast = p.parent.nodes.last()
const nLast = n.parent.nodes.last()
if (p.node == pLast && n.node != nLast) return true

View File

@@ -60,7 +60,7 @@ class Void extends React.Component {
render() {
const { props } = this
const { children, node, readOnly } = props
const Tag = node.kind == 'block' ? 'div' : 'span'
const Tag = node.object == 'block' ? 'div' : 'span'
const style = {
height: '0',
color: 'transparent',
@@ -114,7 +114,7 @@ class Void extends React.Component {
const child = node.getFirstText()
return (
<Text
block={node.kind == 'block' ? node : block}
block={node.object == 'block' ? node : block}
decorations={decorations}
editor={editor}
isSelected={isSelected}

View File

@@ -614,8 +614,8 @@ function AfterPlugin() {
function renderNode(props) {
const { attributes, children, node } = props
if (node.kind != 'block' && node.kind != 'inline') return
const Tag = node.kind == 'block' ? 'div' : 'span'
if (node.object != 'block' && node.object != 'inline') return
const Tag = node.object == 'block' ? 'div' : 'span'
const style = { position: 'relative' }
return <Tag {...attributes} style={style}>{children}</Tag>
}
@@ -631,7 +631,7 @@ function AfterPlugin() {
const { editor, node } = props
if (!editor.props.placeholder) return
if (editor.state.isComposing) return
if (node.kind != 'block') return
if (node.object != 'block') return
if (!Text.isTextList(node.nodes)) return
if (node.text != '') return
if (editor.value.document.getBlocks().size > 1) return

View File

@@ -30,7 +30,7 @@ function getEventRange(event, value) {
// closest to.
if (node.isVoid) {
const rect = target.getBoundingClientRect()
const isPrevious = node.kind == 'inline'
const isPrevious = node.object == 'inline'
? x - rect.left < rect.left + rect.width - x
: y - rect.top < rect.top + rect.height - y

View File

@@ -9,15 +9,15 @@ export default function (json) {
export const input = {
document: {
nodes: Array.from(Array(10)).map(() => ({
kind: 'block',
object: 'block',
type: 'quote',
nodes: [
{
kind: 'block',
object: 'block',
type: 'paragraph',
nodes: [
{
kind: 'text',
object: 'text',
leaves: [
{
text: 'This is editable ',

View File

@@ -299,7 +299,7 @@ Changes.deleteLineBackwardAtRange = (change, range, options) => {
const startWithVoidInline = (
startBlock.nodes.size > 1 &&
startBlock.nodes.get(0).text == '' &&
startBlock.nodes.get(1).kind == 'inline'
startBlock.nodes.get(1).object == 'inline'
)
let o = offset + startOffset
@@ -992,7 +992,7 @@ Changes.splitBlockAtRange = (change, range, height = 1, options = {}) => {
let parent = document.getClosestBlock(node.key)
let h = 0
while (parent && parent.kind == 'block' && h < height) {
while (parent && parent.object == 'block' && h < height) {
node = parent
parent = document.getClosestBlock(parent.key)
h++
@@ -1026,7 +1026,7 @@ Changes.splitInlineAtRange = (change, range, height = Infinity, options = {}) =>
let parent = document.getClosestInline(node.key)
let h = 0
while (parent && parent.kind == 'inline' && h < height) {
while (parent && parent.object == 'inline' && h < height) {
node = parent
parent = document.getClosestInline(parent.key)
h++
@@ -1084,7 +1084,7 @@ Changes.unwrapBlockAtRange = (change, range, properties, options = {}) => {
const wrappers = blocks
.map((block) => {
return document.getClosest(block.key, (parent) => {
if (parent.kind != 'block') return false
if (parent.object != 'block') return false
if (properties.type != null && parent.type != properties.type) return false
if (properties.isVoid != null && parent.isVoid != properties.isVoid) return false
if (properties.data != null && !parent.data.isSuperset(properties.data)) return false
@@ -1176,7 +1176,7 @@ Changes.unwrapInlineAtRange = (change, range, properties, options = {}) => {
const inlines = texts
.map((text) => {
return document.getClosest(text.key, (parent) => {
if (parent.kind != 'inline') return false
if (parent.object != 'inline') return false
if (properties.type != null && parent.type != properties.type) return false
if (properties.isVoid != null && parent.isVoid != properties.isVoid) return false
if (properties.data != null && !parent.data.isSuperset(properties.data)) return false

View File

@@ -179,7 +179,7 @@ Changes.mergeNodeByKey = (change, key, options = {}) => {
throw new Error(`Unable to merge node with key "${key}", no previous key.`)
}
const position = previous.kind == 'text' ? previous.text.length : previous.nodes.size
const position = previous.object == 'text' ? previous.text.length : previous.nodes.size
change.applyOperation({
type: 'merge_node',
@@ -300,7 +300,7 @@ Changes.removeAllMarksByKey = (change, key, options = {}) => {
const { state } = change
const { document } = state
const node = document.getNode(key)
const texts = node.kind === 'text' ? [node] : node.getTextsAsArray()
const texts = node.object === 'text' ? [node] : node.getTextsAsArray()
texts.forEach((text) => {
text.getMarksAsArray().forEach((mark) => {
@@ -711,12 +711,12 @@ Changes.wrapNodeByKey = (change, key, parent) => {
parent = Node.create(parent)
parent = parent.set('nodes', parent.nodes.clear())
if (parent.kind == 'block') {
if (parent.object == 'block') {
change.wrapBlockByKey(key, parent)
return
}
if (parent.kind == 'inline') {
if (parent.object == 'inline') {
change.wrapInlineByKey(key, parent)
return
}

View File

@@ -346,7 +346,7 @@ const DIRECTIONS = [
'Previous',
]
const KINDS = [
const OBJECTS = [
'Block',
'Inline',
'Text',
@@ -365,10 +365,10 @@ PREFIXES.forEach((prefix) => {
edges.forEach((edge) => {
const method = `${prefix}${edge}Of`
KINDS.forEach((kind) => {
const getNode = kind == 'Text' ? 'getNode' : `getClosest${kind}`
OBJECTS.forEach((object) => {
const getNode = object == 'Text' ? 'getNode' : `getClosest${object}`
Changes[`${method}${kind}`] = (change) => {
Changes[`${method}${object}`] = (change) => {
const { value } = change
const { document, selection } = value
const node = document[getNode](selection.startKey)
@@ -377,10 +377,10 @@ PREFIXES.forEach((prefix) => {
}
DIRECTIONS.forEach((direction) => {
const getDirectionNode = `get${direction}${kind}`
const getDirectionNode = `get${direction}${object}`
const directionKey = direction == 'Next' ? 'startKey' : 'endKey'
Changes[`${method}${direction}${kind}`] = (change) => {
Changes[`${method}${direction}${object}`] = (change) => {
const { value } = change
const { document, selection } = value
const node = document[getNode](selection[directionKey])

View File

@@ -63,7 +63,7 @@ Changes.normalizeNodeByKey = (change, key) => {
*/
function normalizeNodeAndChildren(change, node, schema) {
if (node.kind == 'text') {
if (node.object == 'text') {
normalizeNode(change, node, schema)
return
}
@@ -124,7 +124,7 @@ function normalizeNodeAndChildren(change, node, schema) {
function refindNode(change, node) {
const { value } = change
const { document } = value
return node.kind == 'document'
return node.object == 'document'
? document
: document.getDescendant(node.key)
}

View File

@@ -19,8 +19,8 @@ const CORE_SCHEMA_RULES = [
{
validateNode(node) {
if (node.kind != 'document') return
const invalids = node.nodes.filter(n => n.kind != 'block')
if (node.object != 'document') return
const invalids = node.nodes.filter(n => n.object != 'block')
if (!invalids.size) return
return (change) => {
@@ -39,11 +39,11 @@ const CORE_SCHEMA_RULES = [
{
validateNode(node) {
if (node.kind != 'block') return
if (node.object != 'block') return
const first = node.nodes.first()
if (!first) return
const kinds = first.kind == 'block' ? ['block'] : ['inline', 'text']
const invalids = node.nodes.filter(n => !kinds.includes(n.kind))
const objects = first.object == 'block' ? ['block'] : ['inline', 'text']
const invalids = node.nodes.filter(n => !objects.includes(n.object))
if (!invalids.size) return
return (change) => {
@@ -62,8 +62,8 @@ const CORE_SCHEMA_RULES = [
{
validateNode(node) {
if (node.kind != 'inline') return
const invalids = node.nodes.filter(n => n.kind != 'inline' && n.kind != 'text')
if (node.object != 'inline') return
const invalids = node.nodes.filter(n => n.object != 'inline' && n.object != 'text')
if (!invalids.size) return
return (change) => {
@@ -82,7 +82,7 @@ const CORE_SCHEMA_RULES = [
{
validateNode(node) {
if (node.kind != 'block' && node.kind != 'inline') return
if (node.object != 'block' && node.object != 'inline') return
if (node.nodes.size > 0) return
return (change) => {
@@ -101,7 +101,7 @@ const CORE_SCHEMA_RULES = [
{
validateNode(node) {
if (!node.isVoid) return
if (node.kind != 'block' && node.kind != 'inline') return
if (node.object != 'block' && node.object != 'inline') return
if (node.text == ' ' && node.nodes.size == 1) return
return (change) => {
@@ -130,8 +130,8 @@ const CORE_SCHEMA_RULES = [
{
validateNode(node) {
if (node.kind != 'block') return
const invalids = node.nodes.filter(n => n.kind == 'inline' && n.text == '')
if (node.object != 'block') return
const invalids = node.nodes.filter(n => n.object == 'inline' && n.text == '')
if (!invalids.size) return
return (change) => {
@@ -158,16 +158,16 @@ const CORE_SCHEMA_RULES = [
{
validateNode(node) {
if (node.kind != 'block' && node.kind != 'inline') return
if (node.object != 'block' && node.object != 'inline') return
const invalids = node.nodes.reduce((list, child, index) => {
if (child.kind !== 'inline') return list
if (child.object !== 'inline') return list
const prev = index > 0 ? node.nodes.get(index - 1) : null
const next = node.nodes.get(index + 1)
// We don't test if "prev" is inline, since it has already been processed in the loop
const insertBefore = !prev
const insertAfter = !next || (next.kind == 'inline')
const insertAfter = !next || (next.object == 'inline')
if (insertAfter || insertBefore) {
list = list.push({ insertAfter, insertBefore, index })
@@ -205,13 +205,13 @@ const CORE_SCHEMA_RULES = [
{
validateNode(node) {
if (node.kind != 'block' && node.kind != 'inline') return
if (node.object != 'block' && node.object != 'inline') return
const invalids = node.nodes
.map((child, i) => {
const next = node.nodes.get(i + 1)
if (child.kind != 'text') return
if (!next || next.kind != 'text') return
if (child.object != 'text') return
if (!next || next.object != 'text') return
return next
})
.filter(Boolean)
@@ -236,25 +236,25 @@ const CORE_SCHEMA_RULES = [
{
validateNode(node) {
if (node.kind != 'block' && node.kind != 'inline') return
if (node.object != 'block' && node.object != 'inline') return
const { nodes } = node
if (nodes.size <= 1) return
const invalids = nodes.filter((desc, i) => {
if (desc.kind != 'text') return
if (desc.object != 'text') return
if (desc.text.length > 0) return
const prev = i > 0 ? nodes.get(i - 1) : null
const next = nodes.get(i + 1)
// If it's the first node, and the next is a void, preserve it.
if (!prev && next.kind == 'inline') return
if (!prev && next.object == 'inline') return
// It it's the last node, and the previous is an inline, preserve it.
if (!next && prev.kind == 'inline') return
if (!next && prev.object == 'inline') return
// If it's surrounded by inlines, preserve it.
if (next && prev && next.kind == 'inline' && prev.kind == 'inline') return
if (next && prev && next.object == 'inline' && prev.object == 'inline') return
// Otherwise, remove it.
return true

View File

@@ -10,6 +10,7 @@ import './document'
*/
import isPlainObject from 'is-plain-object'
import logger from 'slate-dev-logger'
import { List, Map, Record } from 'immutable'
import MODEL_TYPES from '../constants/model-types'
@@ -141,15 +142,20 @@ class Block extends Record(DEFAULTS) {
}
/**
* Get the node's kind.
* Object.
*
* @return {String}
*/
get kind() {
get object() {
return 'block'
}
get kind() {
logger.deprecate('slate@0.32.0', 'The `kind` property of Slate objects has been renamed to `object`.')
return this.object
}
/**
* Check if the block is empty.
*
@@ -179,7 +185,7 @@ class Block extends Record(DEFAULTS) {
toJSON(options = {}) {
const object = {
kind: this.kind,
object: this.object,
type: this.type,
isVoid: this.isVoid,
data: this.data.toJSON(),

View File

@@ -1,6 +1,7 @@
import Debug from 'debug'
import isPlainObject from 'is-plain-object'
import logger from 'slate-dev-logger'
import pick from 'lodash/pick'
import { List } from 'immutable'
@@ -51,15 +52,20 @@ class Change {
}
/**
* Get the kind.
* Object.
*
* @return {String}
*/
get kind() {
get object() {
return 'change'
}
get kind() {
logger.deprecate('slate@0.32.0', 'The `kind` property of Slate objects has been renamed to `object`.')
return this.object
}
/**
* Apply an `operation` to the current value, saving the operation to the
* history if needed.

View File

@@ -1,5 +1,6 @@
import isPlainObject from 'is-plain-object'
import logger from 'slate-dev-logger'
import { List, Record, Set } from 'immutable'
import MODEL_TYPES from '../constants/model-types'
@@ -120,15 +121,20 @@ class Character extends Record(DEFAULTS) {
}
/**
* Get the kind.
* Object.
*
* @return {String}
*/
get kind() {
get object() {
return 'character'
}
get kind() {
logger.deprecate('slate@0.32.0', 'The `kind` property of Slate objects has been renamed to `object`.')
return this.object
}
/**
* Return a JSON representation of the character.
*
@@ -137,7 +143,7 @@ class Character extends Record(DEFAULTS) {
toJSON() {
const object = {
kind: this.kind,
object: this.object,
text: this.text,
marks: this.marks.toArray().map(m => m.toJSON()),
}

View File

@@ -11,6 +11,7 @@ import './inline'
*/
import isPlainObject from 'is-plain-object'
import logger from 'slate-dev-logger'
import { List, Map, Record } from 'immutable'
import Node from './node'
@@ -105,15 +106,20 @@ class Document extends Record(DEFAULTS) {
}
/**
* Get the node's kind.
* Object.
*
* @return {String}
*/
get kind() {
get object() {
return 'document'
}
get kind() {
logger.deprecate('slate@0.32.0', 'The `kind` property of Slate objects has been renamed to `object`.')
return this.object
}
/**
* Check if the document is empty.
*
@@ -143,7 +149,7 @@ class Document extends Record(DEFAULTS) {
toJSON(options = {}) {
const object = {
kind: this.kind,
object: this.object,
data: this.data.toJSON(),
nodes: this.nodes.toArray().map(n => n.toJSON(options)),
}

View File

@@ -2,6 +2,7 @@
import Debug from 'debug'
import isEqual from 'lodash/isEqual'
import isPlainObject from 'is-plain-object'
import logger from 'slate-dev-logger'
import { List, Record, Stack } from 'immutable'
import MODEL_TYPES from '../constants/model-types'
@@ -91,15 +92,20 @@ class History extends Record(DEFAULTS) {
}
/**
* Get the kind.
* Object.
*
* @return {String}
*/
get kind() {
get object() {
return 'history'
}
get kind() {
logger.deprecate('slate@0.32.0', 'The `kind` property of Slate objects has been renamed to `object`.')
return this.object
}
/**
* Save an `operation` into the history.
*
@@ -161,7 +167,7 @@ class History extends Record(DEFAULTS) {
toJSON() {
const object = {
kind: this.kind,
object: this.object,
redos: this.redos.toJSON(),
undos: this.undos.toJSON(),
}

View File

@@ -10,6 +10,7 @@ import './document'
*/
import isPlainObject from 'is-plain-object'
import logger from 'slate-dev-logger'
import { List, Map, Record } from 'immutable'
import Node from './node'
@@ -141,15 +142,20 @@ class Inline extends Record(DEFAULTS) {
}
/**
* Get the node's kind.
* Object.
*
* @return {String}
*/
get kind() {
get object() {
return 'inline'
}
get kind() {
logger.deprecate('slate@0.32.0', 'The `kind` property of Slate objects has been renamed to `object`.')
return this.object
}
/**
* Check if the inline is empty.
*
@@ -179,7 +185,7 @@ class Inline extends Record(DEFAULTS) {
toJSON(options = {}) {
const object = {
kind: this.kind,
object: this.object,
type: this.type,
isVoid: this.isVoid,
data: this.data.toJSON(),

View File

@@ -1,5 +1,6 @@
import isPlainObject from 'is-plain-object'
import logger from 'slate-dev-logger'
import { List, Record, Set } from 'immutable'
import MODEL_TYPES from '../constants/model-types'
@@ -114,15 +115,20 @@ class Leaf extends Record(DEFAULTS) {
}
/**
* Get the node's kind.
* Object.
*
* @return {String}
*/
get kind() {
get object() {
return 'leaf'
}
get kind() {
logger.deprecate('slate@0.32.0', 'The `kind` property of Slate objects has been renamed to `object`.')
return this.object
}
/**
* Return leaf as a list of characters
*
@@ -151,7 +157,7 @@ class Leaf extends Record(DEFAULTS) {
toJSON() {
const object = {
kind: this.kind,
object: this.object,
text: this.text,
marks: this.marks.toArray().map(m => m.toJSON()),
}

View File

@@ -1,5 +1,6 @@
import isPlainObject from 'is-plain-object'
import logger from 'slate-dev-logger'
import { Map, Record, Set } from 'immutable'
import MODEL_TYPES from '../constants/model-types'
@@ -151,13 +152,18 @@ class Mark extends Record(DEFAULTS) {
}
/**
* Get the kind.
* Object.
*/
get kind() {
get object() {
return 'mark'
}
get kind() {
logger.deprecate('slate@0.32.0', 'The `kind` property of Slate objects has been renamed to `object`.')
return this.object
}
/**
* Get the component for the node from a `schema`.
*
@@ -177,7 +183,7 @@ class Mark extends Record(DEFAULTS) {
toJSON() {
const object = {
kind: this.kind,
object: this.object,
type: this.type,
data: this.data.toJSON(),
}

View File

@@ -1,6 +1,7 @@
import direction from 'direction'
import isPlainObject from 'is-plain-object'
import logger from 'slate-dev-logger'
import { List, OrderedSet, Set } from 'immutable'
import Block from './block'
@@ -37,13 +38,20 @@ class Node {
}
if (isPlainObject(attrs)) {
switch (attrs.kind) {
let { object } = attrs
if (!object && attrs.kind) {
logger.deprecate('slate@0.32.0', 'The `kind` property of Slate objects has been renamed to `object`.')
object = attrs.kind
}
switch (object) {
case 'block': return Block.create(attrs)
case 'document': return Document.create(attrs)
case 'inline': return Inline.create(attrs)
case 'text': return Text.create(attrs)
default: {
throw new Error('`Node.create` requires a `kind` string.')
throw new Error('`Node.create` requires a `object` string.')
}
}
}
@@ -99,22 +107,27 @@ class Node {
}
/**
* Create a `Node` from a JSON `object`.
* Create a `Node` from a JSON `value`.
*
* @param {Object} object
* @param {Object} value
* @return {Node}
*/
static fromJSON(object) {
const { kind } = object
static fromJSON(value) {
let { object } = value
switch (kind) {
case 'block': return Block.fromJSON(object)
case 'document': return Document.fromJSON(object)
case 'inline': return Inline.fromJSON(object)
case 'text': return Text.fromJSON(object)
if (!object && value.kind) {
logger.deprecate('slate@0.32.0', 'The `kind` property of Slate objects has been renamed to `object`.')
object = value.kind
}
switch (object) {
case 'block': return Block.fromJSON(value)
case 'document': return Document.fromJSON(value)
case 'inline': return Inline.fromJSON(value)
case 'text': return Text.fromJSON(value)
default: {
throw new Error(`\`Node.fromJSON\` requires a \`kind\` of either 'block', 'document', 'inline' or 'text', but you passed: ${kind}`)
throw new Error(`\`Node.fromJSON\` requires an \`object\` of either 'block', 'document', 'inline' or 'text', but you passed: ${value}`)
}
}
}
@@ -297,7 +310,7 @@ class Node {
return false
}
if (child.kind != 'text') {
if (child.object != 'text') {
ret = child.forEachDescendant(iterator)
return ret
}
@@ -321,7 +334,7 @@ class Node {
let ancestors
this.nodes.find((node) => {
if (node.kind == 'text') return false
if (node.object == 'text') return false
ancestors = node.getAncestors(key)
return ancestors
})
@@ -352,7 +365,7 @@ class Node {
getBlocksAsArray() {
return this.nodes.reduce((array, child) => {
if (child.kind != 'block') return array
if (child.object != 'block') return array
if (!child.isLeafBlock()) return array.concat(child.getBlocksAsArray())
array.push(child)
return array
@@ -418,7 +431,7 @@ class Node {
getBlocksByTypeAsArray(type) {
return this.nodes.reduce((array, node) => {
if (node.kind != 'block') {
if (node.object != 'block') {
return array
} else if (node.isLeafBlock() && node.type == type) {
array.push(node)
@@ -448,7 +461,7 @@ class Node {
getCharactersAsArray() {
return this.nodes.reduce((arr, node) => {
return node.kind == 'text'
return node.object == 'text'
? arr.concat(node.characters.toArray())
: arr.concat(node.getCharactersAsArray())
}, [])
@@ -527,7 +540,7 @@ class Node {
*/
getClosestBlock(key) {
return this.getClosest(key, parent => parent.kind == 'block')
return this.getClosest(key, parent => parent.object == 'block')
}
/**
@@ -538,7 +551,7 @@ class Node {
*/
getClosestInline(key) {
return this.getClosest(key, parent => parent.kind == 'inline')
return this.getClosest(key, parent => parent.object == 'inline')
}
/**
@@ -627,7 +640,7 @@ class Node {
const found = this.nodes.find((node) => {
if (node.key === key) {
return node
} else if (node.kind !== 'text') {
} else if (node.object !== 'text') {
descendantFound = node.getDescendant(key)
return descendantFound
} else {
@@ -667,7 +680,7 @@ class Node {
let descendantFound = null
const found = this.nodes.find((node) => {
if (node.kind == 'text') return true
if (node.object == 'text') return true
descendantFound = node.getFirstText()
return descendantFound
})
@@ -700,7 +713,7 @@ class Node {
while (parent = node.getParent(child.key)) {
const index = parent.nodes.indexOf(child)
const position = child.kind == 'text'
const position = child.object == 'text'
? startOffset
: child.nodes.indexOf(previous)
@@ -714,7 +727,7 @@ class Node {
while (parent = node.getParent(child.key)) {
const index = parent.nodes.indexOf(child)
const position = child.kind == 'text'
const position = child.object == 'text'
? startKey == endKey ? endOffset - startOffset : endOffset
: child.nodes.indexOf(previous)
@@ -766,7 +779,7 @@ class Node {
*/
getFurthestBlock(key) {
return this.getFurthest(key, node => node.kind == 'block')
return this.getFurthest(key, node => node.object == 'block')
}
/**
@@ -777,7 +790,7 @@ class Node {
*/
getFurthestInline(key) {
return this.getFurthest(key, node => node.kind == 'inline')
return this.getFurthest(key, node => node.object == 'inline')
}
/**
@@ -791,7 +804,7 @@ class Node {
key = assertKey(key)
return this.nodes.find((node) => {
if (node.key == key) return true
if (node.kind == 'text') return false
if (node.object == 'text') return false
return node.hasDescendant(key)
})
}
@@ -841,7 +854,7 @@ class Node {
let array = []
this.nodes.forEach((child) => {
if (child.kind == 'text') return
if (child.object == 'text') return
if (child.isLeafInline()) {
array.push(child)
} else {
@@ -903,7 +916,7 @@ class Node {
getInlinesByTypeAsArray(type) {
return this.nodes.reduce((inlines, node) => {
if (node.kind == 'text') {
if (node.object == 'text') {
return inlines
} else if (node.isLeafInline() && node.type == type) {
inlines.push(node)
@@ -951,7 +964,7 @@ class Node {
let descendantFound = null
const found = this.nodes.findLast((node) => {
if (node.kind == 'text') return true
if (node.object == 'text') return true
descendantFound = node.getLastText()
return descendantFound
})
@@ -1142,7 +1155,7 @@ class Node {
getMarksByTypeAsArray(type) {
return this.nodes.reduce((array, node) => {
return node.kind == 'text'
return node.object == 'text'
? array.concat(node.getMarksAsArray().filter(m => m.type == type))
: array.concat(node.getMarksByTypeAsArray(type))
}, [])
@@ -1159,7 +1172,7 @@ class Node {
const child = this.assertDescendant(key)
let last
if (child.kind == 'block') {
if (child.object == 'block') {
last = child.getLastText()
} else {
const block = this.getClosestBlock(key)
@@ -1286,7 +1299,7 @@ class Node {
let node = null
this.nodes.find((child) => {
if (child.kind == 'text') {
if (child.object == 'text') {
return false
} else {
node = child.getParent(key)
@@ -1340,7 +1353,7 @@ class Node {
const child = this.assertDescendant(key)
let first
if (child.kind == 'block') {
if (child.object == 'block') {
first = child.getFirstText()
} else {
const block = this.getClosestBlock(key)
@@ -1423,7 +1436,7 @@ class Node {
let end = null
this.nodes.forEach((child, i) => {
if (child.kind == 'text') {
if (child.object == 'text') {
if (start == null && child.key == startKey) start = i
if (end == null && child.key == endKey) end = i + 1
} else {
@@ -1507,7 +1520,7 @@ class Node {
let array = []
this.nodes.forEach((node) => {
if (node.kind == 'text') {
if (node.object == 'text') {
array.push(node)
} else {
array = array.concat(node.getTextsAsArray())
@@ -1613,7 +1626,7 @@ class Node {
node = node.regenerateKey()
}
if (node.kind != 'text') {
if (node.object != 'text') {
node = node.mapDescendants((desc) => {
return keys.contains(desc.key)
? desc.regenerateKey()
@@ -1676,8 +1689,8 @@ class Node {
isLeafBlock() {
return (
this.kind == 'block' &&
this.nodes.every(n => n.kind != 'block')
this.object == 'block' &&
this.nodes.every(n => n.object != 'block')
)
}
@@ -1689,8 +1702,8 @@ class Node {
isLeafInline() {
return (
this.kind == 'inline' &&
this.nodes.every(n => n.kind != 'inline')
this.object == 'inline' &&
this.nodes.every(n => n.object != 'inline')
)
}
@@ -1709,12 +1722,12 @@ class Node {
let one = node.nodes.get(withIndex)
const two = node.nodes.get(index)
if (one.kind != two.kind) {
throw new Error(`Tried to merge two nodes of different kinds: "${one.kind}" and "${two.kind}".`)
if (one.object != two.object) {
throw new Error(`Tried to merge two nodes of different objects: "${one.object}" and "${two.object}".`)
}
// If the nodes are text nodes, concatenate their characters together.
if (one.kind == 'text') {
if (one.object == 'text') {
const characters = one.characters.concat(two.characters)
one = one.set('characters', characters)
}
@@ -1763,7 +1776,7 @@ class Node {
nodes.forEach((node, i) => {
let ret = node
if (ret.kind != 'text') ret = ret.mapDescendants(iterator)
if (ret.object != 'text') ret = ret.mapDescendants(iterator)
ret = iterator(ret, i, this.nodes)
if (ret == node) return
@@ -1835,7 +1848,7 @@ class Node {
// If the child is a text node, the `position` refers to the text offset at
// which to split it.
if (child.kind == 'text') {
if (child.object == 'text') {
const befores = child.characters.take(position)
const afters = child.characters.skip(position)
one = child.set('characters', befores)

View File

@@ -1,5 +1,6 @@
import isPlainObject from 'is-plain-object'
import logger from 'slate-dev-logger'
import { List, Record } from 'immutable'
import MODEL_TYPES from '../constants/model-types'
@@ -194,15 +195,20 @@ class Operation extends Record(DEFAULTS) {
}
/**
* Get the node's kind.
* Object.
*
* @return {String}
*/
get kind() {
get object() {
return 'operation'
}
get kind() {
logger.deprecate('slate@0.32.0', 'The `kind` property of Slate objects has been renamed to `object`.')
return this.object
}
/**
* Return a JSON representation of the operation.
*
@@ -211,8 +217,8 @@ class Operation extends Record(DEFAULTS) {
*/
toJSON(options = {}) {
const { kind, type } = this
const object = { kind, type }
const { object, type } = this
const json = { object, type }
const ATTRIBUTES = OPERATION_ATTRIBUTES[type]
for (const key of ATTRIBUTES) {
@@ -264,10 +270,10 @@ class Operation extends Record(DEFAULTS) {
value = v
}
object[key] = value
json[key] = value
}
return object
return json
}
/**

View File

@@ -151,15 +151,20 @@ class Range extends Record(DEFAULTS) {
}
/**
* Get the kind.
* Object.
*
* @return {String}
*/
get kind() {
get object() {
return 'range'
}
get kind() {
logger.deprecate('slate@0.32.0', 'The `kind` property of Slate objects has been renamed to `object`.')
return this.object
}
/**
* Check whether the range is blurred.
*
@@ -315,7 +320,7 @@ class Range extends Record(DEFAULTS) {
*/
hasAnchorIn(node) {
return node.kind == 'text'
return node.object == 'text'
? node.key == this.anchorKey
: this.anchorKey != null && node.hasDescendant(this.anchorKey)
}
@@ -371,7 +376,7 @@ class Range extends Record(DEFAULTS) {
*/
hasFocusIn(node) {
return node.kind == 'text'
return node.object == 'text'
? node.key == this.focusKey
: this.focusKey != null && node.hasDescendant(this.focusKey)
}
@@ -698,7 +703,7 @@ class Range extends Record(DEFAULTS) {
}
// If the anchor node isn't a text node, match it to one.
if (anchorNode.kind != 'text') {
if (anchorNode.object != 'text') {
logger.warn('The range anchor was set to a Node that is not a Text node. This should not happen and can degrade performance. The node in question was:', anchorNode)
const anchorText = anchorNode.getTextAtOffset(anchorOffset)
const offset = anchorNode.getOffset(anchorText.key)
@@ -707,7 +712,7 @@ class Range extends Record(DEFAULTS) {
}
// If the focus node isn't a text node, match it to one.
if (focusNode.kind != 'text') {
if (focusNode.object != 'text') {
logger.warn('The range focus was set to a Node that is not a Text node. This should not happen and can degrade performance. The node in question was:', focusNode)
const focusText = focusNode.getTextAtOffset(focusOffset)
const offset = focusNode.getOffset(focusText.key)
@@ -742,7 +747,7 @@ class Range extends Record(DEFAULTS) {
toJSON() {
const object = {
kind: this.kind,
object: this.object,
anchorKey: this.anchorKey,
anchorOffset: this.anchorOffset,
focusKey: this.focusKey,
@@ -861,7 +866,7 @@ ALIAS_METHODS.forEach(([ alias, method ]) => {
*/
function getFirst(node) {
return node.kind == 'text' ? node : node.getFirstText()
return node.object == 'text' ? node : node.getFirstText()
}
/**
@@ -872,7 +877,7 @@ function getFirst(node) {
*/
function getLast(node) {
return node.kind == 'text' ? node : node.getLastText()
return node.object == 'text' ? node : node.getLastText()
}
/**

View File

@@ -1,6 +1,7 @@
import Debug from 'debug'
import isPlainObject from 'is-plain-object'
import logger from 'slate-dev-logger'
import mergeWith from 'lodash/mergeWith'
import { Record } from 'immutable'
@@ -15,19 +16,19 @@ import memoize from '../utils/memoize'
* @type {Object}
*/
const CHILD_KIND_INVALID = 'child_kind_invalid'
const CHILD_OBJECT_INVALID = 'child_object_invalid'
const CHILD_REQUIRED = 'child_required'
const CHILD_TYPE_INVALID = 'child_type_invalid'
const CHILD_UNKNOWN = 'child_unknown'
const FIRST_CHILD_KIND_INVALID = 'first_child_kind_invalid'
const FIRST_CHILD_OBJECT_INVALID = 'first_child_object_invalid'
const FIRST_CHILD_TYPE_INVALID = 'first_child_type_invalid'
const LAST_CHILD_KIND_INVALID = 'last_child_kind_invalid'
const LAST_CHILD_OBJECT_INVALID = 'last_child_object_invalid'
const LAST_CHILD_TYPE_INVALID = 'last_child_type_invalid'
const NODE_DATA_INVALID = 'node_data_invalid'
const NODE_IS_VOID_INVALID = 'node_is_void_invalid'
const NODE_MARK_INVALID = 'node_mark_invalid'
const NODE_TEXT_INVALID = 'node_text_invalid'
const PARENT_KIND_INVALID = 'parent_kind_invalid'
const PARENT_OBJECT_INVALID = 'parent_object_invalid'
const PARENT_TYPE_INVALID = 'parent_type_invalid'
/**
@@ -128,15 +129,20 @@ class Schema extends Record(DEFAULTS) {
}
/**
* Get the kind.
* Object.
*
* @return {String}
*/
get kind() {
get object() {
return 'schema'
}
get kind() {
logger.deprecate('slate@0.32.0', 'The `kind` property of Slate objects has been renamed to `object`.')
return this.object
}
/**
* Get the rule for an `object`.
*
@@ -145,7 +151,7 @@ class Schema extends Record(DEFAULTS) {
*/
getRule(object) {
switch (object.kind) {
switch (object.object) {
case 'document': return this.document
case 'block': return this.blocks[object.type]
case 'inline': return this.inlines[object.type]
@@ -206,32 +212,32 @@ class Schema extends Record(DEFAULTS) {
normalize(change, reason, context) {
switch (reason) {
case CHILD_KIND_INVALID:
case CHILD_OBJECT_INVALID:
case CHILD_TYPE_INVALID:
case CHILD_UNKNOWN:
case FIRST_CHILD_KIND_INVALID:
case FIRST_CHILD_OBJECT_INVALID:
case FIRST_CHILD_TYPE_INVALID:
case LAST_CHILD_KIND_INVALID:
case LAST_CHILD_OBJECT_INVALID:
case LAST_CHILD_TYPE_INVALID: {
const { child, node } = context
return child.kind == 'text' && node.kind == 'block' && node.nodes.size == 1
return child.object == 'text' && node.object == 'block' && node.nodes.size == 1
? change.removeNodeByKey(node.key)
: change.removeNodeByKey(child.key)
}
case CHILD_REQUIRED:
case NODE_TEXT_INVALID:
case PARENT_KIND_INVALID:
case PARENT_OBJECT_INVALID:
case PARENT_TYPE_INVALID: {
const { node } = context
return node.kind == 'document'
return node.object == 'document'
? node.nodes.forEach(child => change.removeNodeByKey(child.key))
: change.removeNodeByKey(node.key)
}
case NODE_DATA_INVALID: {
const { node, key } = context
return node.data.get(key) === undefined && node.kind != 'document'
return node.data.get(key) === undefined && node.object != 'document'
? change.removeNodeByKey(node.key)
: change.setNodeByKey(node.key, { data: node.data.delete(key) })
}
@@ -260,7 +266,7 @@ class Schema extends Record(DEFAULTS) {
const ret = this.stack.find('validateNode', node)
if (ret) return ret
if (node.kind == 'text') return
if (node.object == 'text') return
const rule = this.getRule(node) || {}
const parents = this.getParentRules()
@@ -302,11 +308,11 @@ class Schema extends Record(DEFAULTS) {
}
if (rule.first != null) {
const { kinds, types } = rule.first
const { objects, types } = rule.first
const child = node.nodes.first()
if (child && kinds && !kinds.includes(child.kind)) {
return this.fail(FIRST_CHILD_KIND_INVALID, { ...ctx, child })
if (child && objects && !objects.includes(child.object)) {
return this.fail(FIRST_CHILD_OBJECT_INVALID, { ...ctx, child })
}
if (child && types && !types.includes(child.type)) {
@@ -315,11 +321,11 @@ class Schema extends Record(DEFAULTS) {
}
if (rule.last != null) {
const { kinds, types } = rule.last
const { objects, types } = rule.last
const child = node.nodes.last()
if (child && kinds && !kinds.includes(child.kind)) {
return this.fail(LAST_CHILD_KIND_INVALID, { ...ctx, child })
if (child && objects && !objects.includes(child.object)) {
return this.fail(LAST_CHILD_OBJECT_INVALID, { ...ctx, child })
}
if (child && types && !types.includes(child.type)) {
@@ -363,11 +369,11 @@ class Schema extends Record(DEFAULTS) {
}
while (nextChild()) {
if (parents != null && child.kind != 'text' && child.type in parents) {
if (parents != null && child.object != 'text' && child.type in parents) {
const r = parents[child.type]
if (r.parent.kinds != null && !r.parent.kinds.includes(node.kind)) {
return this.fail(PARENT_KIND_INVALID, { node: child, parent: node, rule: r })
if (r.parent.objects != null && !r.parent.objects.includes(node.object)) {
return this.fail(PARENT_OBJECT_INVALID, { node: child, parent: node, rule: r })
}
if (r.parent.types != null && !r.parent.types.includes(node.type)) {
@@ -380,12 +386,12 @@ class Schema extends Record(DEFAULTS) {
return this.fail(CHILD_UNKNOWN, { ...ctx, child, index })
}
if (def.kinds != null && !def.kinds.includes(child.kind)) {
if (def.objects != null && !def.objects.includes(child.object)) {
if (offset >= min && nextDef()) {
rewind()
continue
}
return this.fail(CHILD_KIND_INVALID, { ...ctx, child, index })
return this.fail(CHILD_OBJECT_INVALID, { ...ctx, child, index })
}
if (def.types != null && !def.types.includes(child.type)) {
@@ -418,7 +424,7 @@ class Schema extends Record(DEFAULTS) {
toJSON() {
const object = {
kind: this.kind,
object: this.object,
document: this.document,
blocks: this.blocks,
inlines: this.inlines,
@@ -501,13 +507,13 @@ function resolveDocumentRule(obj) {
/**
* Resolve a node rule with `type` from `obj`.
*
* @param {String} kind
* @param {String} object
* @param {String} type
* @param {Object} obj
* @return {Object}
*/
function resolveNodeRule(kind, type, obj) {
function resolveNodeRule(object, type, obj) {
return {
data: {},
isVoid: null,
@@ -521,7 +527,7 @@ function resolveNodeRule(kind, type, obj) {
}
/**
* A Lodash customizer for merging schema definitions. Special cases `kinds`
* A Lodash customizer for merging schema definitions. Special cases `objects`
* and `types` arrays to be unioned, and ignores new `null` values.
*
* @param {Mixed} target
@@ -530,7 +536,7 @@ function resolveNodeRule(kind, type, obj) {
*/
function customizer(target, source, key) {
if (key == 'kinds' || key == 'types') {
if (key == 'objects' || key == 'types') {
return target == null ? source : target.concat(source)
} else {
return source == null ? target : source

View File

@@ -1,4 +1,5 @@
import logger from 'slate-dev-logger'
import { Record } from 'immutable'
import MODEL_TYPES from '../constants/model-types'
@@ -46,15 +47,20 @@ class Stack extends Record(DEFAULTS) {
}
/**
* Get the kind.
* Object.
*
* @return {String}
*/
get kind() {
get object() {
return 'stack'
}
get kind() {
logger.deprecate('slate@0.32.0', 'The `kind` property of Slate objects has been renamed to `object`.')
return this.object
}
/**
* Get all plugins with `property`.
*

View File

@@ -1,5 +1,6 @@
import isPlainObject from 'is-plain-object'
import logger from 'slate-dev-logger'
import { List, OrderedSet, Record, Set, is } from 'immutable'
import Character from './character'
@@ -130,15 +131,20 @@ class Text extends Record(DEFAULTS) {
}
/**
* Get the node's kind.
* Object.
*
* @return {String}
*/
get kind() {
get object() {
return 'text'
}
get kind() {
logger.deprecate('slate@0.32.0', 'The `kind` property of Slate objects has been renamed to `object`.')
return this.object
}
/**
* Is the node empty?
*
@@ -430,7 +436,7 @@ class Text extends Record(DEFAULTS) {
toJSON(options = {}) {
const object = {
kind: this.kind,
object: this.object,
leaves: this.getLeaves().toArray().map(r => r.toJSON()),
}

View File

@@ -1,5 +1,6 @@
import isPlainObject from 'is-plain-object'
import logger from 'slate-dev-logger'
import { Record, Set, List, Map } from 'immutable'
import MODEL_TYPES from '../constants/model-types'
@@ -151,15 +152,20 @@ class Value extends Record(DEFAULTS) {
}
/**
* Get the kind.
* Object.
*
* @return {String}
*/
get kind() {
get object() {
return 'value'
}
get kind() {
logger.deprecate('slate@0.32.0', 'The `kind` property of Slate objects has been renamed to `object`.')
return this.object
}
/**
* Are there undoable events?
*
@@ -628,7 +634,7 @@ class Value extends Record(DEFAULTS) {
toJSON(options = {}) {
const object = {
kind: this.kind,
object: this.object,
document: this.document.toJSON(options),
}

View File

@@ -111,7 +111,7 @@ const APPLIERS = {
// If the nodes are text nodes and the selection is inside the second node
// update it to refer to the first node instead.
if (one.kind == 'text') {
if (one.object == 'text') {
const { anchorKey, anchorOffset, focusKey, focusOffset } = selection
let normalize = false
@@ -227,8 +227,8 @@ const APPLIERS = {
if (selection.isSet) {
const hasStartNode = node.hasNode(startKey)
const hasEndNode = node.hasNode(endKey)
const first = node.kind == 'text' ? node : node.getFirstText() || node
const last = node.kind == 'text' ? node : node.getLastText() || node
const first = node.object == 'text' ? node : node.getFirstText() || node
const last = node.object == 'text' ? node : node.getLastText() || node
const prev = document.getPreviousText(first.key)
const next = document.getNextText(last.key)

View File

@@ -3,7 +3,7 @@
import h from '../../../helpers/h'
export default function (change) {
change.replaceNodeByKey('a', { kind: 'block', type: 'quote' })
change.replaceNodeByKey('a', { object: 'block', type: 'quote' })
}
export const input = (

View File

@@ -3,7 +3,7 @@
import h from '../../../helpers/h'
export default function (change) {
change.replaceNodeByKey('a', { kind: 'inline', type: 'emoji', isVoid: true })
change.replaceNodeByKey('a', { object: 'inline', type: 'emoji', isVoid: true })
}
export const input = (

View File

@@ -3,7 +3,7 @@
import h from '../../../helpers/h'
export default function (change) {
change.replaceNodeByKey('a', { kind: 'text', leaves: [{ text: 'three' }] })
change.replaceNodeByKey('a', { object: 'text', leaves: [{ text: 'three' }] })
}
export const input = (

View File

@@ -13,22 +13,22 @@ export const input = (
)
export const output = {
kind: 'value',
object: 'value',
document: {
kind: 'document',
object: 'document',
data: {},
nodes: [
{
kind: 'block',
object: 'block',
type: 'paragraph',
isVoid: false,
data: {},
nodes: [
{
kind: 'text',
object: 'text',
leaves: [
{
kind: 'leaf',
object: 'leaf',
text: '',
marks: [],
}

View File

@@ -18,22 +18,22 @@ export const input = (
)
export const output = {
kind: 'value',
object: 'value',
document: {
kind: 'document',
object: 'document',
data: {},
nodes: [
{
kind: 'block',
object: 'block',
type: 'paragraph',
isVoid: false,
data: {},
nodes: [
{
kind: 'text',
object: 'text',
leaves: [
{
kind: 'leaf',
object: 'leaf',
text: 'two',
marks: [],
}

View File

@@ -16,22 +16,22 @@ export const input = (
)
export const output = {
kind: 'value',
object: 'value',
document: {
kind: 'document',
object: 'document',
data: {},
nodes: [
{
kind: 'block',
object: 'block',
type: 'paragraph',
isVoid: false,
data: {},
nodes: [
{
kind: 'text',
object: 'text',
leaves: [
{
kind: 'leaf',
object: 'leaf',
text: 'two',
marks: [],
}

View File

@@ -20,38 +20,38 @@ export const input = (
)
export const output = {
kind: 'value',
object: 'value',
document: {
kind: 'document',
object: 'document',
data: {},
nodes: [
{
kind: 'block',
object: 'block',
type: 'paragraph',
isVoid: false,
data: {},
nodes: [
{
kind: 'text',
object: 'text',
leaves: [
{
kind: 'leaf',
object: 'leaf',
text: '',
marks: [],
}
]
},
{
kind: 'inline',
object: 'inline',
type: 'link',
isVoid: false,
data: {},
nodes: [
{
kind: 'text',
object: 'text',
leaves: [
{
kind: 'leaf',
object: 'leaf',
text: 'two',
marks: [],
}
@@ -60,10 +60,10 @@ export const output = {
]
},
{
kind: 'text',
object: 'text',
leaves: [
{
kind: 'leaf',
object: 'leaf',
text: '',
marks: [],
}

View File

@@ -22,54 +22,54 @@ export const input = (
)
export const output = {
kind: 'value',
object: 'value',
document: {
kind: 'document',
object: 'document',
data: {},
nodes: [
{
kind: 'block',
object: 'block',
type: 'paragraph',
isVoid: false,
data: {},
nodes: [
{
kind: 'text',
object: 'text',
leaves: [
{
kind: 'leaf',
object: 'leaf',
text: '',
marks: [],
}
]
},
{
kind: 'inline',
object: 'inline',
type: 'link',
isVoid: false,
data: {},
nodes: [
{
kind: 'text',
object: 'text',
leaves: [
{
kind: 'leaf',
object: 'leaf',
text: '',
marks: [],
}
]
},
{
kind: 'inline',
object: 'inline',
type: 'link',
isVoid: false,
data: {},
nodes: [
{
kind: 'text',
object: 'text',
leaves: [
{
kind: 'leaf',
object: 'leaf',
text: 'one',
marks: [],
}
@@ -78,26 +78,26 @@ export const output = {
]
},
{
kind: 'text',
object: 'text',
leaves: [
{
kind: 'leaf',
object: 'leaf',
text: '',
marks: [],
}
]
},
{
kind: 'inline',
object: 'inline',
type: 'link',
isVoid: false,
data: {},
nodes: [
{
kind: 'text',
object: 'text',
leaves: [
{
kind: 'leaf',
object: 'leaf',
text: 'two',
marks: [],
}
@@ -106,10 +106,10 @@ export const output = {
]
},
{
kind: 'text',
object: 'text',
leaves: [
{
kind: 'leaf',
object: 'leaf',
text: '',
marks: [],
}
@@ -118,10 +118,10 @@ export const output = {
]
},
{
kind: 'text',
object: 'text',
leaves: [
{
kind: 'leaf',
object: 'leaf',
text: '',
marks: [],
}

View File

@@ -15,22 +15,22 @@ export const input = (
)
export const output = {
kind: 'value',
object: 'value',
document: {
kind: 'document',
object: 'document',
data: {},
nodes: [
{
kind: 'block',
object: 'block',
type: 'paragraph',
isVoid: false,
data: {},
nodes: [
{
kind: 'text',
object: 'text',
leaves: [
{
kind: 'leaf',
object: 'leaf',
text: '',
marks: [],
}

View File

@@ -7,11 +7,11 @@ export const schema = {
paragraph: {},
quote: {
nodes: [
{ kinds: ['block'], types: ['image'], min: 0, max: 1 },
{ kinds: ['block'], types: ['paragraph'], min: 1 }
{ objects: ['block'], types: ['image'], min: 0, max: 1 },
{ objects: ['block'], types: ['paragraph'], min: 1 }
],
normalize: (change, reason, { node, child }) => {
if (reason == 'child_kind_invalid') {
if (reason == 'child_object_invalid') {
change.wrapBlockByKey(child.key, 'paragraph')
}
}

View File

@@ -7,10 +7,10 @@ export const schema = {
paragraph: {},
quote: {
nodes: [
{ kinds: ['block'] },
{ objects: ['block'] },
],
normalize: (change, reason, { child }) => {
if (reason == 'child_kind_invalid') {
if (reason == 'child_object_invalid') {
change.wrapBlockByKey(child.key, 'paragraph')
}
}

View File

@@ -7,7 +7,7 @@ export const schema = {
paragraph: {},
quote: {
nodes: [
{ kinds: ['text'] },
{ objects: ['text'] },
]
}
}

View File

@@ -11,7 +11,7 @@ export const schema = {
],
normalize: (change, reason, { node, index }) => {
if (reason == 'child_required') {
change.insertNodeByKey(node.key, index, { kind: 'block', type: 'paragraph' })
change.insertNodeByKey(node.key, index, { object: 'block', type: 'paragraph' })
}
}
}

View File

@@ -6,9 +6,9 @@ export const schema = {
blocks: {
paragraph: {},
quote: {
first: { kinds: ['block'] },
first: { objects: ['block'] },
normalize: (change, reason, { child }) => {
if (reason == 'first_child_kind_invalid') {
if (reason == 'first_child_object_invalid') {
change.wrapBlockByKey(child.key, 'paragraph')
}
}

View File

@@ -6,7 +6,7 @@ export const schema = {
blocks: {
paragraph: {},
quote: {
first: { kinds: ['text'] },
first: { objects: ['text'] },
}
}
}

View File

@@ -6,9 +6,9 @@ export const schema = {
blocks: {
paragraph: {},
quote: {
last: { kinds: ['block'] },
last: { objects: ['block'] },
normalize: (change, reason, { child }) => {
if (reason == 'last_child_kind_invalid') {
if (reason == 'last_child_object_invalid') {
change.wrapBlockByKey(child.key, 'paragraph')
}
}

View File

@@ -6,7 +6,7 @@ export const schema = {
blocks: {
paragraph: {},
quote: {
last: { kinds: ['text'] },
last: { objects: ['text'] },
}
}
}

View File

@@ -5,9 +5,9 @@ import h from '../../helpers/h'
export const schema = {
inlines: {
link: {
parent: { kinds: ['block'] },
parent: { objects: ['block'] },
normalize: (change, reason, { node }) => {
if (reason == 'parent_kind_invalid') {
if (reason == 'parent_object_invalid') {
change.unwrapNodeByKey(node.key)
}
}

View File

@@ -5,7 +5,7 @@ import h from '../../helpers/h'
export const schema = {
inlines: {
link: {
parent: { kinds: ['block'] },
parent: { objects: ['block'] },
}
}
}

View File

@@ -3,29 +3,29 @@
import h from '../../../helpers/h'
export const input = {
kind: 'value',
object: 'value',
document: {
kind: 'document',
object: 'document',
data: {},
nodes: [
{
kind: 'block',
object: 'block',
type: 'quote',
data: {},
isVoid: false,
nodes: [
{
kind: 'block',
object: 'block',
type: 'paragraph',
data: {},
isVoid: false,
nodes: [
{
kind: 'text',
object: 'text',
leaves: [
{
text: 'one',
kind: 'leaf',
object: 'leaf',
marks: []
}
]

View File

@@ -3,13 +3,13 @@
import h from '../../../helpers/h'
export const input = {
kind: 'value',
object: 'value',
document: {
kind: 'document',
object: 'document',
data: {},
nodes: [
{
kind: 'block',
object: 'block',
type: 'paragraph',
isVoid: false,
data: {
@@ -17,10 +17,10 @@ export const input = {
},
nodes: [
{
kind: 'text',
object: 'text',
leaves: [
{
kind: 'leaf',
object: 'leaf',
text: 'one',
marks: []
}

View File

@@ -3,22 +3,22 @@
import h from '../../../helpers/h'
export const input = {
kind: 'value',
object: 'value',
document: {
kind: 'document',
object: 'document',
data: {},
nodes: [
{
kind: 'block',
object: 'block',
type: 'image',
isVoid: true,
data: {},
nodes: [
{
kind: 'text',
object: 'text',
leaves: [
{
kind: 'leaf',
object: 'leaf',
text: ' ',
marks: [],
}

View File

@@ -3,22 +3,22 @@
import h from '../../../helpers/h'
export const input = {
kind: 'value',
object: 'value',
document: {
kind: 'document',
object: 'document',
data: {},
nodes: [
{
kind: 'block',
object: 'block',
type: 'paragraph',
data: {},
isVoid: false,
nodes: [
{
kind: 'text',
object: 'text',
leaves: [
{
kind: 'leaf',
object: 'leaf',
text: 'one',
marks: [],
}

View File

@@ -3,54 +3,54 @@
import h from '../../../helpers/h'
export const input = {
kind: 'value',
object: 'value',
document: {
kind: 'document',
object: 'document',
data: {},
nodes: [
{
kind: 'block',
object: 'block',
type: 'paragraph',
data: {},
isVoid: false,
nodes: [
{
kind: 'text',
object: 'text',
leaves: [
{
kind: 'leaf',
object: 'leaf',
text: '',
marks: [],
}
]
},
{
kind: 'inline',
object: 'inline',
type: 'link',
data: {},
isVoid: false,
nodes: [
{
kind: 'text',
object: 'text',
leaves: [
{
kind: 'leaf',
object: 'leaf',
text: '',
marks: [],
}
]
},
{
kind: 'inline',
object: 'inline',
type: 'hashtag',
data: {},
isVoid: false,
nodes: [
{
kind: 'text',
object: 'text',
leaves: [
{
kind: 'leaf',
object: 'leaf',
text: 'one',
marks: [],
}
@@ -59,10 +59,10 @@ export const input = {
]
},
{
kind: 'text',
object: 'text',
leaves: [
{
kind: 'leaf',
object: 'leaf',
text: '',
marks: [],
}
@@ -71,10 +71,10 @@ export const input = {
]
},
{
kind: 'text',
object: 'text',
leaves: [
{
kind: 'leaf',
object: 'leaf',
text: '',
marks: [],
}

View File

@@ -3,29 +3,29 @@
import h from '../../../helpers/h'
export const input = {
kind: 'value',
object: 'value',
document: {
kind: 'document',
object: 'document',
data: {},
nodes: [
{
kind: 'block',
object: 'block',
type: 'paragraph',
data: {},
isVoid: false,
nodes: [
{
kind: 'text',
object: 'text',
leaves: [
{
kind: 'leaf',
object: 'leaf',
text: '',
marks: [],
}
]
},
{
kind: 'inline',
object: 'inline',
type: 'link',
isVoid: false,
data: {
@@ -33,10 +33,10 @@ export const input = {
},
nodes: [
{
kind: 'text',
object: 'text',
leaves: [
{
kind: 'leaf',
object: 'leaf',
text: 'one',
marks: [],
}
@@ -45,10 +45,10 @@ export const input = {
]
},
{
kind: 'text',
object: 'text',
leaves: [
{
kind: 'leaf',
object: 'leaf',
text: '',
marks: [],
}

View File

@@ -3,38 +3,38 @@
import h from '../../../helpers/h'
export const input = {
kind: 'value',
object: 'value',
document: {
kind: 'document',
object: 'document',
data: {},
nodes: [
{
kind: 'block',
object: 'block',
type: 'paragraph',
isVoid: false,
data: {},
nodes: [
{
kind: 'text',
object: 'text',
leaves: [
{
kind: 'leaf',
object: 'leaf',
text: '',
marks: [],
}
]
},
{
kind: 'inline',
object: 'inline',
type: 'emoji',
isVoid: true,
data: {},
nodes: [
{
kind: 'text',
object: 'text',
leaves: [
{
kind: 'leaf',
object: 'leaf',
text: ' ',
marks: [],
}
@@ -43,10 +43,10 @@ export const input = {
]
},
{
kind: 'text',
object: 'text',
leaves: [
{
kind: 'leaf',
object: 'leaf',
text: '',
marks: [],
}

View File

@@ -3,38 +3,38 @@
import h from '../../../helpers/h'
export const input = {
kind: 'value',
object: 'value',
document: {
kind: 'document',
object: 'document',
data: {},
nodes: [
{
kind: 'block',
object: 'block',
type: 'paragraph',
isVoid: false,
data: {},
nodes: [
{
kind: 'text',
object: 'text',
leaves: [
{
kind: 'leaf',
object: 'leaf',
text: '',
marks: [],
}
]
},
{
kind: 'inline',
object: 'inline',
type: 'link',
isVoid: false,
data: {},
nodes: [
{
kind: 'text',
object: 'text',
leaves: [
{
kind: 'leaf',
object: 'leaf',
text: 'one',
marks: [],
}
@@ -43,10 +43,10 @@ export const input = {
]
},
{
kind: 'text',
object: 'text',
leaves: [
{
kind: 'leaf',
object: 'leaf',
text: '',
marks: [],
}

View File

@@ -3,38 +3,38 @@
import h from '../../../helpers/h'
export const input = {
kind: 'value',
object: 'value',
document: {
kind: 'document',
object: 'document',
data: {},
nodes: [
{
kind: 'block',
object: 'block',
type: 'paragraph',
isVoid: false,
data: {},
nodes: [
{
kind: 'text',
object: 'text',
leaves: [
{
kind: 'leaves',
object: 'leaves',
text: 'o',
marks: [],
},
{
kind: 'leaves',
object: 'leaves',
text: 'n',
marks: [
{
kind: 'mark',
object: 'mark',
type: 'bold',
data: {},
}
]
},
{
kind: 'leaves',
object: 'leaves',
text: 'e',
marks: [],
}

View File

@@ -15,29 +15,29 @@ export const input = (
)
export const output = {
kind: 'value',
object: 'value',
document: {
kind: 'document',
object: 'document',
data: {},
nodes: [
{
kind: 'block',
object: 'block',
type: 'quote',
data: {},
isVoid: false,
nodes: [
{
kind: 'block',
object: 'block',
type: 'paragraph',
data: {},
isVoid: false,
nodes: [
{
kind: 'text',
object: 'text',
leaves: [
{
text: 'one',
kind: 'leaf',
object: 'leaf',
marks: []
}
]

View File

@@ -13,13 +13,13 @@ export const input = (
)
export const output = {
kind: 'value',
object: 'value',
document: {
kind: 'document',
object: 'document',
data: {},
nodes: [
{
kind: 'block',
object: 'block',
type: 'paragraph',
isVoid: false,
data: {
@@ -27,10 +27,10 @@ export const output = {
},
nodes: [
{
kind: 'text',
object: 'text',
leaves: [
{
kind: 'leaf',
object: 'leaf',
text: 'one',
marks: []
}

View File

@@ -11,22 +11,22 @@ export const input = (
)
export const output = {
kind: 'value',
object: 'value',
document: {
kind: 'document',
object: 'document',
data: {},
nodes: [
{
kind: 'block',
object: 'block',
type: 'image',
isVoid: true,
data: {},
nodes: [
{
kind: 'text',
object: 'text',
leaves: [
{
kind: 'leaf',
object: 'leaf',
text: ' ',
marks: [],
}

View File

@@ -13,22 +13,22 @@ export const input = (
)
export const output = {
kind: 'value',
object: 'value',
document: {
kind: 'document',
object: 'document',
data: {},
nodes: [
{
kind: 'block',
object: 'block',
type: 'paragraph',
data: {},
isVoid: false,
nodes: [
{
kind: 'text',
object: 'text',
leaves: [
{
kind: 'leaf',
object: 'leaf',
text: 'one',
marks: [],
}

View File

@@ -17,54 +17,54 @@ export const input = (
)
export const output = {
kind: 'value',
object: 'value',
document: {
kind: 'document',
object: 'document',
data: {},
nodes: [
{
kind: 'block',
object: 'block',
type: 'paragraph',
data: {},
isVoid: false,
nodes: [
{
kind: 'text',
object: 'text',
leaves: [
{
kind: 'leaf',
object: 'leaf',
text: '',
marks: [],
}
]
},
{
kind: 'inline',
object: 'inline',
type: 'link',
data: {},
isVoid: false,
nodes: [
{
kind: 'text',
object: 'text',
leaves: [
{
kind: 'leaf',
object: 'leaf',
text: '',
marks: [],
}
]
},
{
kind: 'inline',
object: 'inline',
type: 'hashtag',
data: {},
isVoid: false,
nodes: [
{
kind: 'text',
object: 'text',
leaves: [
{
kind: 'leaf',
object: 'leaf',
text: 'one',
marks: [],
}
@@ -73,10 +73,10 @@ export const output = {
]
},
{
kind: 'text',
object: 'text',
leaves: [
{
kind: 'leaf',
object: 'leaf',
text: '',
marks: [],
}
@@ -85,10 +85,10 @@ export const output = {
]
},
{
kind: 'text',
object: 'text',
leaves: [
{
kind: 'leaf',
object: 'leaf',
text: '',
marks: [],
}

View File

@@ -15,29 +15,29 @@ export const input = (
)
export const output = {
kind: 'value',
object: 'value',
document: {
kind: 'document',
object: 'document',
data: {},
nodes: [
{
kind: 'block',
object: 'block',
type: 'paragraph',
data: {},
isVoid: false,
nodes: [
{
kind: 'text',
object: 'text',
leaves: [
{
kind: 'leaf',
object: 'leaf',
text: '',
marks: [],
}
]
},
{
kind: 'inline',
object: 'inline',
type: 'link',
isVoid: false,
data: {
@@ -45,10 +45,10 @@ export const output = {
},
nodes: [
{
kind: 'text',
object: 'text',
leaves: [
{
kind: 'leaf',
object: 'leaf',
text: 'one',
marks: [],
}
@@ -57,10 +57,10 @@ export const output = {
]
},
{
kind: 'text',
object: 'text',
leaves: [
{
kind: 'leaf',
object: 'leaf',
text: '',
marks: [],
}

View File

@@ -13,38 +13,38 @@ export const input = (
)
export const output = {
kind: 'value',
object: 'value',
document: {
kind: 'document',
object: 'document',
data: {},
nodes: [
{
kind: 'block',
object: 'block',
type: 'paragraph',
isVoid: false,
data: {},
nodes: [
{
kind: 'text',
object: 'text',
leaves: [
{
kind: 'leaf',
object: 'leaf',
text: '',
marks: [],
}
]
},
{
kind: 'inline',
object: 'inline',
type: 'emoji',
isVoid: true,
data: {},
nodes: [
{
kind: 'text',
object: 'text',
leaves: [
{
kind: 'leaf',
object: 'leaf',
text: ' ',
marks: [],
}
@@ -53,10 +53,10 @@ export const output = {
]
},
{
kind: 'text',
object: 'text',
leaves: [
{
kind: 'leaf',
object: 'leaf',
text: '',
marks: [],
}

View File

@@ -15,38 +15,38 @@ export const input = (
)
export const output = {
kind: 'value',
object: 'value',
document: {
kind: 'document',
object: 'document',
data: {},
nodes: [
{
kind: 'block',
object: 'block',
type: 'paragraph',
isVoid: false,
data: {},
nodes: [
{
kind: 'text',
object: 'text',
leaves: [
{
kind: 'leaf',
object: 'leaf',
text: '',
marks: [],
}
]
},
{
kind: 'inline',
object: 'inline',
type: 'link',
isVoid: false,
data: {},
nodes: [
{
kind: 'text',
object: 'text',
leaves: [
{
kind: 'leaf',
object: 'leaf',
text: 'one',
marks: [],
}
@@ -55,10 +55,10 @@ export const output = {
]
},
{
kind: 'text',
object: 'text',
leaves: [
{
kind: 'leaf',
object: 'leaf',
text: '',
marks: [],
}

Some files were not shown because too many files have changed in this diff Show More