mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-05 23:07:27 +02:00
Switch initialValue type in examples to Descendant
This commit is contained in:
@@ -19,7 +19,7 @@ import {
|
|||||||
import { css } from 'emotion'
|
import { css } from 'emotion'
|
||||||
import { withHistory } from 'slate-history'
|
import { withHistory } from 'slate-history'
|
||||||
|
|
||||||
const initialValue: SlateElement[] = [
|
const initialValue: Descendant[] = [
|
||||||
{
|
{
|
||||||
type: 'paragraph',
|
type: 'paragraph',
|
||||||
children: [
|
children: [
|
||||||
|
@@ -142,7 +142,7 @@ const Leaf = ({ attributes, children, leaf }) => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const initialValue: SlateElement[] = [
|
const initialValue: Descendant[] = [
|
||||||
{
|
{
|
||||||
type: 'paragraph',
|
type: 'paragraph',
|
||||||
children: [
|
children: [
|
||||||
|
@@ -1,10 +1,5 @@
|
|||||||
import React, { useState, useMemo } from 'react'
|
import React, { useState, useMemo } from 'react'
|
||||||
import {
|
import { Transforms, createEditor, Descendant } from 'slate'
|
||||||
Transforms,
|
|
||||||
createEditor,
|
|
||||||
Element as SlateElement,
|
|
||||||
Descendant,
|
|
||||||
} from 'slate'
|
|
||||||
import { Slate, Editable, useSlateStatic, withReact } from 'slate-react'
|
import { Slate, Editable, useSlateStatic, withReact } from 'slate-react'
|
||||||
import { withHistory } from 'slate-history'
|
import { withHistory } from 'slate-history'
|
||||||
import { css } from 'emotion'
|
import { css } from 'emotion'
|
||||||
@@ -136,7 +131,7 @@ const InsertEditableVoidButton = () => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const initialValue: SlateElement[] = [
|
const initialValue: Descendant[] = [
|
||||||
{
|
{
|
||||||
type: 'paragraph',
|
type: 'paragraph',
|
||||||
children: [
|
children: [
|
||||||
|
@@ -2,7 +2,6 @@ import React, { useState, useMemo } from 'react'
|
|||||||
import {
|
import {
|
||||||
Transforms,
|
Transforms,
|
||||||
createEditor,
|
createEditor,
|
||||||
Node,
|
|
||||||
Element as SlateElement,
|
Element as SlateElement,
|
||||||
Descendant,
|
Descendant,
|
||||||
} from 'slate'
|
} from 'slate'
|
||||||
@@ -12,8 +11,6 @@ import {
|
|||||||
withReact,
|
withReact,
|
||||||
useSlateStatic,
|
useSlateStatic,
|
||||||
ReactEditor,
|
ReactEditor,
|
||||||
useFocused,
|
|
||||||
useSelected,
|
|
||||||
} from 'slate-react'
|
} from 'slate-react'
|
||||||
|
|
||||||
const EmbedsExample = () => {
|
const EmbedsExample = () => {
|
||||||
@@ -104,7 +101,7 @@ const UrlInput = ({ url, onChange }) => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const initialValue: SlateElement[] = [
|
const initialValue: Descendant[] = [
|
||||||
{
|
{
|
||||||
type: 'paragraph',
|
type: 'paragraph',
|
||||||
children: [
|
children: [
|
||||||
|
@@ -75,7 +75,7 @@ const Element = ({ attributes, children, element }) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const initialValue: SlateElement[] = [
|
const initialValue: Descendant[] = [
|
||||||
{
|
{
|
||||||
type: 'title',
|
type: 'title',
|
||||||
children: [{ text: 'Enforce Your Layout!' }],
|
children: [{ text: 'Enforce Your Layout!' }],
|
||||||
|
@@ -147,7 +147,7 @@ const FormatButton = ({ format, icon }) => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const initialValue: Element[] = [
|
const initialValue: Descendant[] = [
|
||||||
{
|
{
|
||||||
type: 'paragraph',
|
type: 'paragraph',
|
||||||
children: [
|
children: [
|
||||||
|
@@ -1,11 +1,11 @@
|
|||||||
import React, { useState, useMemo, useCallback } from 'react'
|
import React, { useState, useMemo, useCallback } from 'react'
|
||||||
import faker from 'faker'
|
import faker from 'faker'
|
||||||
import { Element as SlateElement, Node, createEditor, Descendant } from 'slate'
|
import { createEditor, Descendant } from 'slate'
|
||||||
import { Slate, Editable, withReact } from 'slate-react'
|
import { Slate, Editable, withReact } from 'slate-react'
|
||||||
|
|
||||||
const HEADINGS = 100
|
const HEADINGS = 100
|
||||||
const PARAGRAPHS = 7
|
const PARAGRAPHS = 7
|
||||||
const initialValue: SlateElement[] = []
|
const initialValue: Descendant[] = []
|
||||||
|
|
||||||
for (let h = 0; h < HEADINGS; h++) {
|
for (let h = 0; h < HEADINGS; h++) {
|
||||||
initialValue.push({
|
initialValue.push({
|
||||||
|
@@ -2,12 +2,7 @@ import React, { useCallback, useMemo, useState } from 'react'
|
|||||||
import { createPortal } from 'react-dom'
|
import { createPortal } from 'react-dom'
|
||||||
import isHotkey from 'is-hotkey'
|
import isHotkey from 'is-hotkey'
|
||||||
import { Editable, withReact, useSlate, Slate, ReactEditor } from 'slate-react'
|
import { Editable, withReact, useSlate, Slate, ReactEditor } from 'slate-react'
|
||||||
import {
|
import { Editor, createEditor, Descendant } from 'slate'
|
||||||
Editor,
|
|
||||||
Element as SlateElement,
|
|
||||||
createEditor,
|
|
||||||
Descendant,
|
|
||||||
} from 'slate'
|
|
||||||
import { withHistory } from 'slate-history'
|
import { withHistory } from 'slate-history'
|
||||||
|
|
||||||
import { Button, Icon, Toolbar } from '../components'
|
import { Button, Icon, Toolbar } from '../components'
|
||||||
@@ -122,7 +117,7 @@ const IFrame = ({ children, ...props }) => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const initialValue: SlateElement[] = [
|
const initialValue: Descendant[] = [
|
||||||
{
|
{
|
||||||
type: 'paragraph',
|
type: 'paragraph',
|
||||||
children: [
|
children: [
|
||||||
|
@@ -1,12 +1,7 @@
|
|||||||
import React, { useState, useMemo } from 'react'
|
import React, { useState, useMemo } from 'react'
|
||||||
import imageExtensions from 'image-extensions'
|
import imageExtensions from 'image-extensions'
|
||||||
import isUrl from 'is-url'
|
import isUrl from 'is-url'
|
||||||
import {
|
import { Transforms, createEditor, Descendant } from 'slate'
|
||||||
Transforms,
|
|
||||||
createEditor,
|
|
||||||
Element as SlateElement,
|
|
||||||
Descendant,
|
|
||||||
} from 'slate'
|
|
||||||
import {
|
import {
|
||||||
Slate,
|
Slate,
|
||||||
Editable,
|
Editable,
|
||||||
@@ -137,7 +132,7 @@ const isImageUrl = url => {
|
|||||||
return imageExtensions.includes(ext)
|
return imageExtensions.includes(ext)
|
||||||
}
|
}
|
||||||
|
|
||||||
const initialValue: SlateElement[] = [
|
const initialValue: Descendant[] = [
|
||||||
{
|
{
|
||||||
type: 'paragraph',
|
type: 'paragraph',
|
||||||
children: [
|
children: [
|
||||||
|
@@ -134,7 +134,7 @@ const LinkButton = () => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const initialValue: SlateElement[] = [
|
const initialValue: Descendant[] = [
|
||||||
{
|
{
|
||||||
type: 'paragraph',
|
type: 'paragraph',
|
||||||
children: [
|
children: [
|
||||||
|
@@ -109,7 +109,7 @@ const Leaf = ({ attributes, children, leaf }) => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const initialValue: Element[] = [
|
const initialValue: Descendant[] = [
|
||||||
{
|
{
|
||||||
type: 'paragraph',
|
type: 'paragraph',
|
||||||
children: [
|
children: [
|
||||||
|
@@ -160,7 +160,7 @@ const Element = ({ attributes, children, element }) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const initialValue: SlateElement[] = [
|
const initialValue: Descendant[] = [
|
||||||
{
|
{
|
||||||
type: 'paragraph',
|
type: 'paragraph',
|
||||||
children: [
|
children: [
|
||||||
|
@@ -1,12 +1,5 @@
|
|||||||
import React, { useMemo, useCallback, useRef, useEffect, useState } from 'react'
|
import React, { useMemo, useCallback, useRef, useEffect, useState } from 'react'
|
||||||
import {
|
import { Editor, Transforms, Range, createEditor, Descendant } from 'slate'
|
||||||
Editor,
|
|
||||||
Transforms,
|
|
||||||
Range,
|
|
||||||
createEditor,
|
|
||||||
Element as SlateElement,
|
|
||||||
Descendant,
|
|
||||||
} from 'slate'
|
|
||||||
import { withHistory } from 'slate-history'
|
import { withHistory } from 'slate-history'
|
||||||
import {
|
import {
|
||||||
Slate,
|
Slate,
|
||||||
@@ -205,7 +198,7 @@ const Mention = ({ attributes, children, element }) => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const initialValue: SlateElement[] = [
|
const initialValue: Descendant[] = [
|
||||||
{
|
{
|
||||||
type: 'paragraph',
|
type: 'paragraph',
|
||||||
children: [
|
children: [
|
||||||
|
@@ -1,11 +1,6 @@
|
|||||||
import React, { useState, useCallback, useMemo } from 'react'
|
import React, { useState, useCallback, useMemo } from 'react'
|
||||||
import { jsx } from 'slate-hyperscript'
|
import { jsx } from 'slate-hyperscript'
|
||||||
import {
|
import { Transforms, createEditor, Descendant } from 'slate'
|
||||||
Transforms,
|
|
||||||
createEditor,
|
|
||||||
Element as SlateElement,
|
|
||||||
Descendant,
|
|
||||||
} from 'slate'
|
|
||||||
import { withHistory } from 'slate-history'
|
import { withHistory } from 'slate-history'
|
||||||
import { css } from 'emotion'
|
import { css } from 'emotion'
|
||||||
import {
|
import {
|
||||||
@@ -216,7 +211,7 @@ const Leaf = ({ attributes, children, leaf }) => {
|
|||||||
return <span {...attributes}>{children}</span>
|
return <span {...attributes}>{children}</span>
|
||||||
}
|
}
|
||||||
|
|
||||||
const initialValue: SlateElement[] = [
|
const initialValue: Descendant[] = [
|
||||||
{
|
{
|
||||||
type: 'paragraph',
|
type: 'paragraph',
|
||||||
children: [
|
children: [
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import React, { useState, useMemo } from 'react'
|
import React, { useState, useMemo } from 'react'
|
||||||
import { createEditor, Element, Descendant } from 'slate'
|
import { createEditor, Descendant } from 'slate'
|
||||||
import { Slate, Editable, withReact } from 'slate-react'
|
import { Slate, Editable, withReact } from 'slate-react'
|
||||||
import { withHistory } from 'slate-history'
|
import { withHistory } from 'slate-history'
|
||||||
|
|
||||||
@@ -13,7 +13,7 @@ const PlainTextExample = () => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const initialValue: Element[] = [
|
const initialValue: Descendant[] = [
|
||||||
{
|
{
|
||||||
type: 'paragraph',
|
type: 'paragraph',
|
||||||
children: [
|
children: [
|
||||||
|
@@ -12,7 +12,7 @@ const ReadOnlyExample = () => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const initialValue: Element[] = [
|
const initialValue: Descendant[] = [
|
||||||
{
|
{
|
||||||
type: 'paragraph',
|
type: 'paragraph',
|
||||||
children: [
|
children: [
|
||||||
|
@@ -175,7 +175,7 @@ const MarkButton = ({ format, icon }) => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const initialValue: SlateElement[] = [
|
const initialValue: Descendant[] = [
|
||||||
{
|
{
|
||||||
type: 'paragraph',
|
type: 'paragraph',
|
||||||
children: [
|
children: [
|
||||||
|
Reference in New Issue
Block a user