mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-07-31 12:30:11 +02:00
Fix check list example (#3232)
* Fix check list example * Fix lint errors
This commit is contained in:
committed by
Ian Storm Taylor
parent
75e5015cc5
commit
31df397930
@@ -1,5 +1,12 @@
|
|||||||
import React, { useMemo, useCallback } from 'react'
|
import React, { useMemo, useCallback } from 'react'
|
||||||
import { Slate, Editable, withReact, useEditor, useReadOnly } from 'slate-react'
|
import {
|
||||||
|
Slate,
|
||||||
|
Editable,
|
||||||
|
withReact,
|
||||||
|
useEditor,
|
||||||
|
useReadOnly,
|
||||||
|
ReactEditor,
|
||||||
|
} from 'slate-react'
|
||||||
import { Editor, Range, Point, createEditor } from 'slate'
|
import { Editor, Range, Point, createEditor } from 'slate'
|
||||||
import { css } from 'emotion'
|
import { css } from 'emotion'
|
||||||
import { withHistory } from 'slate-history'
|
import { withHistory } from 'slate-history'
|
||||||
@@ -96,8 +103,12 @@ const CheckListItemElement = ({ attributes, children, element }) => {
|
|||||||
type="checkbox"
|
type="checkbox"
|
||||||
checked={checked}
|
checked={checked}
|
||||||
onChange={event => {
|
onChange={event => {
|
||||||
const path = editor.findPath(element)
|
const path = ReactEditor.findPath(editor, element)
|
||||||
editor.setNodes({ checked: event.target.checked }, { at: path })
|
Editor.setNodes(
|
||||||
|
editor,
|
||||||
|
{ checked: event.target.checked },
|
||||||
|
{ at: path }
|
||||||
|
)
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</span>
|
</span>
|
||||||
|
Reference in New Issue
Block a user