Преглед на файлове

filter non-string elements

Yuki Takei преди 3 години
родител
ревизия
a4008bb5c5
променени са 1 файла, в които са добавени 3 реда и са изтрити 1 реда
  1. 3 1
      packages/remark-drawio/src/components/DrawioViewer.tsx

+ 3 - 1
packages/remark-drawio/src/components/DrawioViewer.tsx

@@ -84,7 +84,9 @@ export const DrawioViewer = React.memo((props: DrawioViewerProps): JSX.Element =
     }
 
     const code = children instanceof Array
-      ? children.map(e => e?.toString()).join('')
+      ? children
+        .filter(elem => (typeof elem === 'string')) // omit non-string elements (e.g. br element generated by line-breaks option)
+        .join('')
       : children.toString();
 
     let mxgraphData;