Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
57 lines
1.4 KiB
Plaintext
57 lines
1.4 KiB
Plaintext
/**
|
|
* 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.
|
|
*
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
var list = require('@lexical/list');
|
|
var LexicalComposerContext = require('@lexical/react/LexicalComposerContext');
|
|
var react = require('react');
|
|
|
|
/**
|
|
* 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.
|
|
*
|
|
*/
|
|
|
|
function useList(editor) {
|
|
react.useEffect(() => {
|
|
return list.registerList(editor);
|
|
}, [editor]);
|
|
}
|
|
|
|
/**
|
|
* 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.
|
|
*
|
|
*/
|
|
|
|
function ListPlugin({
|
|
hasStrictIndent = false
|
|
}) {
|
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
react.useEffect(() => {
|
|
if (!editor.hasNodes([list.ListNode, list.ListItemNode])) {
|
|
throw new Error('ListPlugin: ListNode and/or ListItemNode not registered on editor');
|
|
}
|
|
}, [editor]);
|
|
react.useEffect(() => {
|
|
if (!hasStrictIndent) {
|
|
return;
|
|
}
|
|
return list.registerListStrictIndentTransform(editor);
|
|
}, [editor, hasStrictIndent]);
|
|
useList(editor);
|
|
return null;
|
|
}
|
|
|
|
exports.ListPlugin = ListPlugin;
|