Created
November 15, 2021 13:12
-
-
Save vnugent/d8df85ec4e22ca9c6f78dc5fb2658c1b to your computer and use it in GitHub Desktop.
Revisions
-
vnugent created this gist
Nov 15, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,44 @@ // createCustomNormalizingPlugin.js import { getChildren } from "@udecode/plate-common"; import { getPlatePluginWithOverrides, isElement } from "@udecode/plate-core"; const withCustomNormalizing = (options) => (editor) => { const { normalizeNode } = editor; editor.normalizeNode = ([node, path]) => { //console.log("#foos ", node); if (node.type === "p") { for (const child of node.children) { console.log("# node", child); //return; } } // if ( ) { // // do some transformations // return // if transformed // } normalizeNode([node, path]); // continue the normalization chain if not transformed }; return editor; }; export const createCustomNormalizingPlugin = getPlatePluginWithOverrides( withCustomNormalizing ); // PlateEditor.js import { createCustomNormalizingPlugin } from "./createCustomNormalizingPlugin"; const plugins = [ // ... other plugins createCustomNormalizingPlugin(), ]; return <Plate plugins={plugins} // other props />