Skip to content

Commit 0b170d0

Browse files
fix: using textarea for editor, insert formula when clicking on matht… (#1124)
* fix: using textarea for editor, insert formula when clicking on mathtype icon after reloading website. * Update packages/ckeditor5/src/integration.js Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]>
1 parent e46dcda commit 0b170d0

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

packages/ckeditor5/src/integration.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,15 @@ export default class CKEditor5Integration extends IntegrationModel {
244244
this.editorObject.model.change((writer) => {
245245
const { latexRange } = this.core.editionProperties;
246246

247+
// Add null check for latexRange.
248+
// When the editor is initialized in a textarea element, latexRange may not be set on initial load.
249+
// This check ensures formulas can still be inserted by falling back to MathML insertion if latexRange is not available.
250+
if (!latexRange) {
251+
// Fallback to regular MathML insertion if latexRange is not available
252+
this.insertMathml(mathml);
253+
return;
254+
}
255+
247256
const startNode = this.findText(latexRange.startContainer);
248257
const endNode = this.findText(latexRange.endContainer);
249258

0 commit comments

Comments
 (0)