1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-28 17:39:57 +02:00

Remove commands (#3351)

* remove commands in favor of editor-level functions

* update examples

* fix lint
This commit is contained in:
Ian Storm Taylor
2019-12-18 15:00:42 -05:00
committed by GitHub
parent c2d7905e19
commit 0bbe121d76
578 changed files with 3532 additions and 3370 deletions

View File

@@ -147,7 +147,7 @@ const App = () => {
// Prevent the "`" from being inserted by default.
event.preventDefault()
// Otherwise, set the currently selected blocks type to "code".
Editor.setNodes(
Transforms.setNodes(
editor,
{ type: 'code' },
{ match: n => Editor.isBlock(editor, n) }
@@ -208,7 +208,7 @@ const App = () => {
match: n => n.type === 'code',
})
// Toggle the block type depending on whether there's already a match.
Editor.setNodes(
Transforms.setNodes(
editor,
{ type: match ? 'paragraph' : 'code' },
{ match: n => Editor.isBlock(editor, n) }

View File

@@ -36,7 +36,7 @@ const App = () => {
const [match] = Editor.nodes(editor, {
match: n => n.type === 'code',
})
Editor.setNodes(
Transforms.setNodes(
editor,
{ type: match ? 'paragraph' : 'code' },
{ match: n => Editor.isBlock(editor, n) }
@@ -86,7 +86,7 @@ const App = () => {
const [match] = Editor.nodes(editor, {
match: n => n.type === 'code',
})
Editor.setNodes(
Transforms.setNodes(
editor,
{ type: match ? 'paragraph' : 'code' },
{ match: n => Editor.isBlock(editor, n) }
@@ -97,7 +97,7 @@ const App = () => {
// When "B" is pressed, bold the text in the selection.
case 'b': {
event.preventDefault()
Editor.setNodes(
Transforms.setNodes(
editor,
{ bold: true },
// Apply it to text nodes, and split the text node up if the
@@ -177,7 +177,7 @@ const App = () => {
const [match] = Editor.nodes(editor, {
match: n => n.type === 'code',
})
Editor.setNodes(
Transforms.setNodes(
editor,
{ type: match ? null : 'code' },
{ match: n => Editor.isBlock(editor, n) }
@@ -187,7 +187,7 @@ const App = () => {
case 'b': {
event.preventDefault()
Editor.setNodes(
Transforms.setNodes(
editor,
{ bold: true },
{ match: n => Text.isText(n), split: true }

View File

@@ -49,7 +49,7 @@ const App = () => {
const [match] = Editor.nodes(editor, {
match: n => n.type === 'code',
})
Editor.setNodes(
Transforms.setNodes(
editor,
{ type: match ? null : 'code' },
{ match: n => Editor.isBlock(editor, n) }
@@ -59,7 +59,7 @@ const App = () => {
case 'b': {
event.preventDefault()
Editor.setNodes(
Transforms.setNodes(
editor,
{ bold: true },
{ match: n => Text.isText(n), split: true }
@@ -124,7 +124,7 @@ const App = () => {
match: n => n.type === 'code',
})
const isCodeActive = !!match
Editor.setNodes(
Transforms.setNodes(
editor,
{ type: isCodeActive ? null : 'code' },
{ match: n => Editor.isBlock(editor, n) }
@@ -134,7 +134,7 @@ const App = () => {
case 'b': {
event.preventDefault()
Editor.setNodes(
Transforms.setNodes(
editor,
{ bold: true },
{ match: n => Text.isText(n), split: true }
@@ -161,7 +161,7 @@ const withCustom = editor => {
// Define a command to toggle the bold formatting.
if (command.type === 'toggle_bold_mark') {
const isActive = CustomEditor.isBoldMarkActive(editor)
Editor.setNodes(
Transforms.setNodes(
editor,
{ bold: isActive ? null : true },
{ match: n => Text.isText(n), split: true }
@@ -171,7 +171,7 @@ const withCustom = editor => {
// Define a command to toggle the code block formatting.
else if (command.type === 'toggle_code_block') {
const isActive = CustomEditor.isCodeBlockActive(editor)
Editor.setNodes(
Transforms.setNodes(
editor,
{ type: isActive ? null : 'code' },
{ match: n => Editor.isBlock(editor, n) }