mirror of
https://github.com/facebook/lexical.git
synced 2025-05-18 07:36:37 +08:00
[lexical-code] Bug Fix: Allow Code Highlighter to be working in headless mode (#7538)
Co-authored-by: Baptiste Jamin <baptiste@crisp.chat>
This commit is contained in:
@ -813,7 +813,11 @@ export function registerCodeHighlighting(
|
||||
tokenizer = PrismTokenizer;
|
||||
}
|
||||
|
||||
return mergeRegister(
|
||||
const registrations = [];
|
||||
|
||||
// Only register the mutation listener if not in headless mode
|
||||
if (editor._headless !== true) {
|
||||
registrations.push(
|
||||
editor.registerMutationListener(
|
||||
CodeNode,
|
||||
(mutations) => {
|
||||
@ -830,6 +834,11 @@ export function registerCodeHighlighting(
|
||||
},
|
||||
{skipInitialization: false},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// Add the rest of the registrations
|
||||
registrations.push(
|
||||
editor.registerNodeTransform(CodeNode, (node) =>
|
||||
codeNodeTransform(node, editor, tokenizer as Tokenizer),
|
||||
),
|
||||
@ -937,4 +946,6 @@ export function registerCodeHighlighting(
|
||||
COMMAND_PRIORITY_LOW,
|
||||
),
|
||||
);
|
||||
|
||||
return mergeRegister(...registrations);
|
||||
}
|
||||
|
Reference in New Issue
Block a user