fix: Various compounding memory leaks in editor (#5950)

This commit is contained in:
Tom Moor
2023-10-05 20:01:27 -04:00
committed by GitHub
parent a2f037531a
commit eb71a8f933
5 changed files with 46 additions and 50 deletions

View File

@@ -302,6 +302,7 @@ export class Editor extends React.PureComponent<
public componentWillUnmount(): void {
window.removeEventListener("theme-changed", this.dispatchThemeChanged);
this.view.destroy();
this.mutationObserver?.disconnect();
}
@@ -349,27 +350,26 @@ export class Editor extends React.PureComponent<
private createNodeViews() {
return this.extensions.extensions
.filter((extension: ReactNode) => extension.component)
.reduce((nodeViews, extension: ReactNode) => {
const nodeView = (
node: ProsemirrorNode,
view: EditorView,
getPos: () => number,
decorations: Decoration[]
) =>
new ComponentView(extension.component, {
editor: this,
extension,
node,
view,
getPos,
decorations,
});
return {
.reduce(
(nodeViews, extension: ReactNode) => ({
...nodeViews,
[extension.name]: nodeView,
};
}, {});
[extension.name]: (
node: ProsemirrorNode,
view: EditorView,
getPos: () => number,
decorations: Decoration[]
) =>
new ComponentView(extension.component, {
editor: this,
extension,
node,
view,
getPos,
decorations,
}),
}),
{}
);
}
private createCommands() {