标签: react-slate

类型错误:Text.isText 不是函数

我正在关注https://docs.slatejs.org/walkthroughs/04-applying-custom-formatting上的石板教程

有一个函数调用 Text.isText(n),我不断收到 Type:Error Text.isText is not a function

toggleBoldMark(editor) {
    const isActive = CustomEditor.isBoldMarkActive(editor)
    Transforms.setNodes(
      editor,
      { bold: isActive ? null : true },
      { match: n => Text.isText(n), split: true }
    )
  },
Run Code Online (Sandbox Code Playgroud)

javascript reactjs slatejs react-slate

6
推荐指数
1
解决办法
559
查看次数

在 onCopy 钩子(插件)中获取复制的内容

我试图将复制的片段onCopy徒劳地放入钩子中。

我一直在尝试 event.clipboardData...

const { clipboardData } = event;
const encoded = clipboardData.getData("application/x-slate-fragment");
Run Code Online (Sandbox Code Playgroud)

但它似乎是空的。我也尝试过使用getEventTransferutils。但它返回{type: 'unknow'}

这是我一直在测试的CodeSandBox

javascript reactjs react-native slatejs react-slate

5
推荐指数
1
解决办法
245
查看次数

Moving cursor in react slate-editor

I'm trying to move the cursor in react slate-editor.

I tried to do it in 2 ways.

First:

// This code saving key in offset in variables
const nativeSelection = this.getSelectedText();
const nativeRange = nativeSelection.getRangeAt(0);
    const range = findRange(nativeRange, this.editor);
const offset = nativeRange.endOffset;
const key = range.anchor.key;

// OnChange is triggered by running the next line and cursor moves back
this.editor.blur();

// Trying to move to the cursor
this.editor.moveTo(key, offset);
Run Code Online (Sandbox Code Playgroud)

Second:

const nativeSelection = this.getSelectedText();
const nativeRange = nativeSelection.getRangeAt(0); …
Run Code Online (Sandbox Code Playgroud)

reactjs react-slate

4
推荐指数
1
解决办法
5260
查看次数

标签 统计

react-slate ×3

reactjs ×3

javascript ×2

slatejs ×2

react-native ×1