问题标签 [react-slate]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
reactjs - 使用示例中的 isBlockActive 的 Slate 编辑器活动状态始终为 false
我通过将几个 slates 示例组合在一起创建了一个编辑器,即https://www.slatejs.org/examples/richtext和https://www.slatejs.org/examples/links
但是,当我为所有块级节点添加这些活动状态时,它根本不起作用,这意味着我无法打开和关闭列表项,锚链接最终会嵌套等。
损坏的代码似乎是这些行,来自所有示例中的 isBlockActive 函数:
match
无论我的光标位于何处,它始终是未定义的。
我目前正在运行所有软件包的最新版本0.58.1
。
下面是我的toggleBlock
函数,我也从使用 isBlockActive 函数来计算切换逻辑的示例中获取。
以前有没有人遇到过这个问题,也许代码库与示例不同步并且Editor.nodes
不再推荐?
由于示例使用不同的方法,所有内联格式选项都起作用:
如果有帮助,这里还有我的工具栏和 renderElement 功能:
javascript - TypeError:Text.isText 不是函数
我正在关注https://docs.slatejs.org/walkthroughs/04-applying-custom-formatting上的石板教程
有一个函数调用 Text.isText(n),我不断收到 Type:Error Text.isText is not a function
reactjs - 在反应板编辑器中移动光标
我正在尝试在 react slate-editor 中移动光标。
我尝试以两种方式做到这一点。
第一的:
第二:
不幸的是,似乎select
并moveTo
没有影响光标位置。有人可以帮忙吗?
javascript - 在 onCopy 钩子(插件)中获取复制的内容
我试图onCopy
徒劳地将复制的片段放入钩子中。
我一直在尝试event.clipboardData...
但它似乎是空的。我也尝试过使用getEventTransfer
utils。但它返回{type: 'unknow'}
这是我一直在测试的CodeSandBox 。
reactjs - 在当前块之后添加新块的问题
我正在尝试在光标所在的块/我单击按钮的块之后添加一个新块。
我的问题是:
- 如何确定当前块的路径?
- 之后我可以使用哪种方法添加块?我使用
insertNode
但你不能在调用它时指定路径......所以该块被添加到块列表的最后。
我看到该insertNode
方法有一个可选参数,但它没有记录并且似乎不起作用:
谢谢,蒂埃里
slatejs - why does slatejs image-upload example crash after uploading an image
I am using the same code as in slate's documentation (https://github.com/ianstormtaylor/slate/blob/master/site/examples/images.tsx), however, when I open the prompt and close it a small div appears below your cursor and when I click it the app crashes and I receive error "Unhandled Rejection (Error): Cannot resolve a DOM point from Slate point: {"path":[3,0],"offset":1}". Here is a live example from their documentation: https://www.slatejs.org/examples/images Notice that when you choose close there is small white space appearing. How do you come around this behavior?
reactjs - 错误:编辑器'未从'slate-react'导出
我正在尝试在 React 中构建简单的 slate 编辑器。
我正在使用 create-react-app 并且我制作了简单的组件来表示编辑器
这是我的包 json 文件
我有错误无法编译。
./src/components/SlateEditor.js 尝试导入错误:“编辑器”未从“slate-react”导出
如您所见,我从 slate-react 导出了编辑器,请问您知道如何解决这个问题吗?谢谢