Direct Slate path to the element. If not provided, the method will search for the element in the current selection (for inline elements) or at the root (for block elements).
// Update link at current selectioneditor.updateElement({ blockId: 'paragraph-1', type: 'link', props: { url: 'https://example.com', target: '_blank' }, // If path not specified, finds link in current selection});// Update link text and URLeditor.updateElement({ blockId: 'paragraph-1', type: 'link', props: { url: 'https://new-url.com' }, text: 'New link text', // Updates the displayed text});// Update link by patheditor.updateElement({ blockId: 'paragraph-1', type: 'link', props: { url: 'https://example.com' }, path: [0, 2], // Direct path to link element});
Properties are merged with existing props. To remove a property, set it to undefined or null.
For inline elements (like link, mention), if path is not specified, the method will
automatically search for the element in the current selection. This makes it easy to update links
or mentions where the cursor is positioned.
The text parameter is only supported for inline elements. For block elements, use
insertElement or updateBlock to modify content.
If the element is not found (no match for type, path, or matcher), the operation will fail with a
console warning. Always check if the element exists before updating if you’re unsure.
When using a custom match function, it searches for the element in the current selection. The
function receives each element and should return true for the element you want to update.