Skip to content

Clearing Element Attributes #2434

Answered by jelling
jelling asked this question in Q&A
Discussion options

You must be logged in to vote

As @12joan noted, overriding the split_node operation is the right direction.

To do that, when creating my plugin I passed in a custom function for the withOverrides:

export const descriptionPlugin = createPluginFactory<HotkeyPlugin>({
  key: ELEMENT_DESCRIPTION,
  isElement: true,
  component: Description,
  withOverrides: withoutAsset, // this tells the plugin to override the default editor behaviors
});

And then my override looks like this:

export const withoutAsset = <
  V extends Value = Value,
  E extends PlateEditor<V> = PlateEditor<V>
>(
  editor: E
) => {
  const { apply } = editor;

  editor.apply = (operation) => {
    if (operation.type === "split_node") {
      if ("assetId"…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by jelling
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants