Просмотр исходного кода

Merge pull request #5894 from weseek/support/omit-appcontainer

fix: Memory leak by EditorSettings and InterceptorManager
Yuki Takei 3 лет назад
Родитель
Сommit
50a89bd4d4

+ 1 - 1
packages/app/src/client/util/interceptor/drawio-interceptor.js

@@ -104,7 +104,7 @@ export class DrawioInterceptor extends BasicInterceptor {
    */
   drawioPostRender(contextName, context) {
     const isPreview = (contextName === 'postRenderPreviewHtml');
-    const renderDrawioInRealtime = context.editorSettings?.renderDrawioInRealtime;
+    const renderDrawioInRealtime = context.renderDrawioInRealtime;
 
     Object.keys(context.DrawioMap).forEach((domId) => {
       const elem = document.getElementById(domId);

+ 2 - 2
packages/app/src/components/Page/RevisionRenderer.jsx

@@ -33,7 +33,7 @@ class LegacyRevisionRenderer extends React.PureComponent {
     this.currentRenderingContext = {
       markdown: this.props.markdown,
       pagePath: this.props.pagePath,
-      editorSettings: this.editorSettings,
+      renderDrawioInRealtime: this.props.editorSettings.renderDrawioInRealtime,
       currentPathname: decodeURIComponent(window.location.pathname),
     };
   }
@@ -178,7 +178,7 @@ LegacyRevisionRenderer.propTypes = {
   pagePath: PropTypes.string.isRequired,
   highlightKeywords: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.string)]),
   additionalClassName: PropTypes.string,
-  editorSettings: PropTypes.any,
+  editorSettings: PropTypes.any.isRequired,
 };
 
 /**

+ 1 - 1
packages/app/src/components/PageEditor/CodeMirrorEditor.jsx

@@ -514,7 +514,7 @@ class CodeMirrorEditor extends AbstractEditor {
     const context = {
       handlers: [], // list of handlers which process enter key
       editor: this,
-      editorSettings: this.props.editorSettings,
+      autoFormatMarkdownTable: this.props.editorSettings.autoFormatMarkdownTable,
     };
 
     const interceptorManager = this.interceptorManager;

+ 1 - 1
packages/app/src/components/PageEditor/MarkdownTableInterceptor.js

@@ -58,7 +58,7 @@ export default class MarkdownTableInterceptor extends BasicInterceptor {
     const context = Object.assign(args[0]); // clone
     const editor = context.editor; // AbstractEditor instance
     // "autoFormatMarkdownTable" may be undefined, so it is compared to true and converted to bool.
-    const noIntercept = (context.editorSettings?.autoFormatMarkdownTable === false);
+    const noIntercept = (context.autoFormatMarkdownTable === false);
 
     // do nothing if editor is not a CodeMirrorEditor or no intercept
     if (editor == null || editor.getCodeMirror() == null || noIntercept) {

+ 2 - 2
packages/app/src/components/PageEditor/Preview.tsx

@@ -42,11 +42,11 @@ const Preview = (props: Props): JSX.Element => {
     return {
       markdown,
       pagePath,
-      editorSettings,
+      renderDrawioInRealtime: editorSettings?.renderDrawioInRealtime,
       currentPathname: decodeURIComponent(window.location.pathname),
       parsedHTML: null,
     };
-  }, [markdown, pagePath, editorSettings]);
+  }, [markdown, pagePath, editorSettings?.renderDrawioInRealtime]);
 
   const renderPreview = useCallback(async() => {
     if (interceptorManager != null) {