Category : slatejs

CodeSandbox Example: https://codesandbox.io/s/slate-2-images-and-links-forked-s09wi This is basically the withLink() example from the official document. When you press backspace or cut out to remove the link, the JSON output still contains the link data with empty text. I don’t understand why it still remains in the output. Can anyone provide a solution for this? The withLink example: ..

Read more

Description Slatejs editor only in Firefox fails with text selection and caret positioning (by mouse). It always selects position before first character (path[0] offset[0]). You can still use the keyboard to select text and position caret. Recording How it doesn’t work in Firefox: https://i.imgur.com/Yem4FEz.gif How it works in Chrome: https://i.imgur.com/UdH1xM7.gif Expectation It should select text ..

Read more

So far I have been using this code, however the result is that nextTemplateNodeEntry is undefined – even though the voids option is on and it is meant to match inline template-block voids. export const findNextTemplate = (editor: Editor): void => { let nextTemplateNodeEntry = (Editor.next(editor, {match: (node: Node) => {console.log(node); return node.type === "template-block"}, ..

Read more

Within a custom element in my Slate.js editor, I have this logic for updating the properties of the element: const changeProps = ({name, opts, defaultValue}: TemplateBlockProps) => { let path = ReactEditor.findPath(editor, element) let newProps = {name, opts, defaultValue} Transforms.setNodes(editor, newProps, {at:path}) } The idea is that you can use react-select to create and select ..

Read more

Relevant code blocks: <Slate editor={editor} value={value} onChange={value => { setValue(value); const { selection } = editor; // if nothing is currently selected under the cursor if (selection && Range.isCollapsed(selection)) { const [start] = Range.edges(selection); // if the two characters beforce the cursor are {{, select them and replace with a template block const before = ..

Read more