1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +02:00

Desktop: Fixes #10023: Beta editor plugins: Fix opening and closing settings can break some plugins with legacy code (#10024)

This commit is contained in:
Henry Heino 2024-03-04 02:34:33 -08:00 committed by GitHub
parent 5aba1e38a2
commit 9a10cd4bec
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 19 additions and 1 deletions

View File

@ -108,4 +108,22 @@ describe('CodeMirror5Emulation', () => {
// additional times if its option hasn't updated. // additional times if its option hasn't updated.
expect(onOtherOptionUpdate).toHaveBeenCalledTimes(1); expect(onOtherOptionUpdate).toHaveBeenCalledTimes(1);
}); });
it('defineExtension should override previous extensions with the same name', () => {
const codeMirror = makeCodeMirrorEmulation('Test...');
const testExtensionFn1 = jest.fn();
const testExtensionFn2 = jest.fn();
codeMirror.defineExtension('defineExtensionShouldOverride', testExtensionFn1);
(codeMirror as any).defineExtensionShouldOverride();
expect(testExtensionFn1).toHaveBeenCalledTimes(1);
expect(testExtensionFn2).toHaveBeenCalledTimes(0);
codeMirror.defineExtension('defineExtensionShouldOverride', testExtensionFn2);
(codeMirror as any).defineExtensionShouldOverride();
expect(testExtensionFn1).toHaveBeenCalledTimes(1);
expect(testExtensionFn2).toHaveBeenCalledTimes(1);
});
}); });

View File

@ -272,7 +272,7 @@ export default class CodeMirror5Emulation extends BaseCodeMirror5Emulation {
} }
public defineExtension(name: string, value: any) { public defineExtension(name: string, value: any) {
(CodeMirror5Emulation.prototype as any)[name] ??= value; (CodeMirror5Emulation.prototype as any)[name] = value;
} }
public defineOption(name: string, defaultValue: any, onUpdate: OptionUpdateCallback) { public defineOption(name: string, defaultValue: any, onUpdate: OptionUpdateCallback) {