]> BookStack Code Mirror - bookstack/commitdiff
WYSIWYG: Fixed filtering issue causing broken page edits
authorDan Brown <redacted>
Mon, 4 Sep 2023 10:25:05 +0000 (11:25 +0100)
committerDan Brown <redacted>
Mon, 4 Sep 2023 10:25:05 +0000 (11:25 +0100)
Could error upon div elements without classes, including drawings.

Related to #4510 and #4509

resources/js/wysiwyg/filters.js

index 4dd60063048285f3dbd51ade2d5ca35c90517fce..dee5df4c28b68e3193ddf23691dd50581dc2a623 100644 (file)
@@ -24,7 +24,9 @@ function setupBrFilter(editor) {
 function setupPointerFilter(editor) {
     editor.parser.addNodeFilter('div', nodes => {
         for (const node of nodes) {
-            if (node.attr('id') === 'pointer' || node.attr('class').includes('pointer')) {
+            const id = node.attr('id') || '';
+            const nodeClass = node.attr('class') || '';
+            if (id === 'pointer' || nodeClass.includes('pointer')) {
                 node.remove();
             }
         }