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:
parent
5aba1e38a2
commit
9a10cd4bec
@ -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);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -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) {
|
||||||
|
Loading…
Reference in New Issue
Block a user