diff --git a/packages/lexical-playground/src/Editor.tsx b/packages/lexical-playground/src/Editor.tsx index 194e08f1fa6..f942d1f9570 100644 --- a/packages/lexical-playground/src/Editor.tsx +++ b/packages/lexical-playground/src/Editor.tsx @@ -73,6 +73,7 @@ import YouTubePlugin from './plugins/YouTubePlugin'; import ContentEditable from './ui/ContentEditable'; import Placeholder from './ui/Placeholder'; import onError from './utils/onError'; +import onWarn from './utils/onWarn'; const skipCollaborationInit = // @ts-expect-error @@ -157,6 +158,7 @@ export default function Editor(): JSX.Element { {isRichText ? ( <> diff --git a/packages/lexical-playground/src/utils/onWarn.ts b/packages/lexical-playground/src/utils/onWarn.ts new file mode 100644 index 00000000000..8a60aa2720f --- /dev/null +++ b/packages/lexical-playground/src/utils/onWarn.ts @@ -0,0 +1,11 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + */ + +export default function onWarn(message: string) { + console.warn(message); +} diff --git a/packages/lexical-react/flow/LexicalBlockNodeNormalizerPlugin__EXPERIMENTAL.js.flow b/packages/lexical-react/flow/LexicalBlockNodeNormalizerPlugin__EXPERIMENTAL.js.flow index 68b7fa97b33..f1d18171caa 100644 --- a/packages/lexical-react/flow/LexicalBlockNodeNormalizerPlugin__EXPERIMENTAL.js.flow +++ b/packages/lexical-react/flow/LexicalBlockNodeNormalizerPlugin__EXPERIMENTAL.js.flow @@ -16,7 +16,7 @@ export type BlockNodeKlass = Class>; declare export function LexicalBlockNodeNormalizerPlugin__EXPERIMENTAL(props: { onError?: (message: string) => void; - onInfo?: (message: string) => void; + onWarn?: (message: string) => void; blockNodes: Array>; }): React$Node; @@ -24,6 +24,6 @@ declare export function registerBlockNodeNormalizerPlugin__EXPERIMENTAL( editor: LexicalEditor, nodes: Array>, { onError?: (message: string) => void; - onInfo?: (message: string) => void; + onWarn?: (message: string) => void; }, ): () => void; diff --git a/packages/lexical-react/src/LexicalBlockNodeNormalizerPlugin__EXPERIMENTAL.tsx b/packages/lexical-react/src/LexicalBlockNodeNormalizerPlugin__EXPERIMENTAL.tsx index c95a5cfd20c..2e0b539ddfc 100644 --- a/packages/lexical-react/src/LexicalBlockNodeNormalizerPlugin__EXPERIMENTAL.tsx +++ b/packages/lexical-react/src/LexicalBlockNodeNormalizerPlugin__EXPERIMENTAL.tsx @@ -6,8 +6,6 @@ * */ - - import type { DecoratorNode, ElementNode, @@ -44,15 +42,15 @@ const emptyFunction = () => {}; * * @param blockNodes array of blockNode (aka elementNode.isInline() === false) * @param onError won't be fixed - * @param onInfo + * @param onWarn */ export function LexicalBlockNodeNormalizerPlugin__EXPERIMENTAL({ blockNodes, onError, - onInfo, + onWarn, }: { onError?: (message: string) => void; - onInfo?: (message: string) => void; + onWarn?: (message: string) => void; blockNodes: Array>; }): null { const [editor] = useLexicalComposerContext(); @@ -60,9 +58,9 @@ export function LexicalBlockNodeNormalizerPlugin__EXPERIMENTAL({ useEffect(() => { return registerBlockNodeNormalizerPlugin__EXPERIMENTAL(editor, blockNodes, { onError, - onInfo, + onWarn, }); - }, [editor, blockNodes, onError, onInfo]); + }, [editor, blockNodes, onError, onWarn]); return null; } @@ -72,10 +70,10 @@ export function registerBlockNodeNormalizerPlugin__EXPERIMENTAL( nodes: Array>, optional: { onError?: (message: string) => void; - onInfo?: (message: string) => void; + onWarn?: (message: string) => void; } = {}, ): () => void { - const {onError = emptyFunction, onInfo = emptyFunction} = optional; + const {onError = emptyFunction, onWarn = emptyFunction} = optional; let lastPasteCommand = 0; const nodeTransform = (node: BlockNode) => { @@ -106,7 +104,7 @@ export function registerBlockNodeNormalizerPlugin__EXPERIMENTAL( // Log structural issues only once, and then separate events if it's // related to copy-pasting const isPasting = lastPasteCommand + 250 > Date.now(); - onInfo( + onWarn( `Found top level node ${node.getKey()} ${ node.constructor.name } inside ${parent.getKey()} ${parent.constructor.name}${