@mnaoumov/obsidian-lib 10.4.1 → 10.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -0
- package/codemirror/incremental-parse-state-field/package.json +6 -0
- package/codemirror/markdown-editor-views/package.json +6 -0
- package/codemirror/range-set/package.json +6 -0
- package/command-handlers/open-bug-report-command-handler/package.json +6 -0
- package/components/embeddable-markdown-editor-component/package.json +6 -0
- package/components/reconfigurable-editor-extension-component/package.json +6 -0
- package/dist/lib/cjs/__merged.cjs +54 -1
- package/dist/lib/cjs/__merged.d.cts +14 -3
- package/dist/lib/cjs/attachment-path.cjs +3 -2
- package/dist/lib/cjs/backlink-index.cjs +44 -8
- package/dist/lib/cjs/backlink-index.d.cts +23 -0
- package/dist/lib/cjs/bug-report.cjs +241 -0
- package/dist/lib/cjs/bug-report.d.cts +161 -0
- package/dist/lib/cjs/bulk-operation-progress.cjs +16 -1
- package/dist/lib/cjs/bulk-operation-progress.d.cts +22 -0
- package/dist/lib/cjs/case-insensitive-file-index.cjs +9 -1
- package/dist/lib/cjs/codemirror/incremental-parse-state-field.cjs +162 -0
- package/dist/lib/cjs/codemirror/incremental-parse-state-field.d.cts +37 -0
- package/dist/lib/cjs/codemirror/index.cjs +10 -1
- package/dist/lib/cjs/codemirror/index.d.cts +3 -0
- package/dist/lib/cjs/codemirror/markdown-editor-views.cjs +142 -0
- package/dist/lib/cjs/codemirror/markdown-editor-views.d.cts +34 -0
- package/dist/lib/cjs/codemirror/range-set.cjs +106 -0
- package/dist/lib/cjs/codemirror/range-set.d.cts +35 -0
- package/dist/lib/cjs/command-handlers/index.cjs +4 -1
- package/dist/lib/cjs/command-handlers/index.d.cts +1 -0
- package/dist/lib/cjs/command-handlers/open-bug-report-command-handler.cjs +139 -0
- package/dist/lib/cjs/command-handlers/open-bug-report-command-handler.d.cts +53 -0
- package/dist/lib/cjs/command-handlers/open-settings-command-handler.cjs +6 -3
- package/dist/lib/cjs/community-plugins.cjs +19 -2
- package/dist/lib/cjs/community-plugins.d.cts +14 -0
- package/dist/lib/cjs/components/bulk-operation-commit-component.cjs +5 -2
- package/dist/lib/cjs/components/embeddable-markdown-editor-component.cjs +374 -0
- package/dist/lib/cjs/components/embeddable-markdown-editor-component.d.cts +221 -0
- package/dist/lib/cjs/components/index.cjs +7 -1
- package/dist/lib/cjs/components/index.d.cts +2 -0
- package/dist/lib/cjs/components/plugin-gate-component.cjs +6 -3
- package/dist/lib/cjs/components/reconfigurable-editor-extension-component.cjs +200 -0
- package/dist/lib/cjs/components/reconfigurable-editor-extension-component.d.cts +96 -0
- package/dist/lib/cjs/components/rename-delete-handler-component.cjs +105 -2
- package/dist/lib/cjs/desktop-bulk-operation-git.cjs +38 -13
- package/dist/lib/cjs/desktop-bulk-operation-git.d.cts +21 -1
- package/dist/lib/cjs/desktop-operating-system.cjs +101 -0
- package/dist/lib/cjs/desktop-operating-system.d.cts +15 -0
- package/dist/lib/cjs/generated-during-build.cjs +1 -1
- package/dist/lib/cjs/i18n/locales/en.cjs +2 -1
- package/dist/lib/cjs/i18n/locales/en.d.cts +1 -0
- package/dist/lib/cjs/i18n/locales/translations-map.d.cts +1 -0
- package/dist/lib/cjs/index.cjs +16 -1
- package/dist/lib/cjs/index.d.cts +5 -0
- package/dist/lib/cjs/menu.cjs +118 -0
- package/dist/lib/cjs/menu.d.cts +65 -0
- package/dist/lib/cjs/mobile-app-info.cjs +167 -0
- package/dist/lib/cjs/mobile-app-info.d.cts +32 -0
- package/dist/lib/cjs/modals/modal.cjs +8 -5
- package/dist/lib/cjs/modals/modal.d.cts +4 -0
- package/dist/lib/cjs/obsidian-settings.cjs +2 -2
- package/dist/lib/cjs/plugin/plugin.cjs +5 -2
- package/dist/lib/cjs/plugin/plugin.d.cts +2 -0
- package/dist/lib/cjs/settings-modal.cjs +103 -0
- package/dist/lib/cjs/settings-modal.d.cts +33 -0
- package/dist/lib/esm/__merged.d.mts +14 -3
- package/dist/lib/esm/__merged.mjs +50 -2
- package/dist/lib/esm/attachment-path.mjs +3 -2
- package/dist/lib/esm/backlink-index.d.mts +23 -0
- package/dist/lib/esm/backlink-index.mjs +42 -7
- package/dist/lib/esm/bug-report.d.mts +161 -0
- package/dist/lib/esm/bug-report.mjs +141 -0
- package/dist/lib/esm/bulk-operation-progress.d.mts +22 -0
- package/dist/lib/esm/bulk-operation-progress.mjs +14 -1
- package/dist/lib/esm/case-insensitive-file-index.mjs +9 -1
- package/dist/lib/esm/codemirror/incremental-parse-state-field.d.mts +37 -0
- package/dist/lib/esm/codemirror/incremental-parse-state-field.mjs +74 -0
- package/dist/lib/esm/codemirror/index.d.mts +3 -0
- package/dist/lib/esm/codemirror/index.mjs +7 -1
- package/dist/lib/esm/codemirror/markdown-editor-views.d.mts +34 -0
- package/dist/lib/esm/codemirror/markdown-editor-views.mjs +53 -0
- package/dist/lib/esm/codemirror/range-set.d.mts +35 -0
- package/dist/lib/esm/codemirror/range-set.mjs +18 -0
- package/dist/lib/esm/command-handlers/index.d.mts +1 -0
- package/dist/lib/esm/command-handlers/index.mjs +3 -1
- package/dist/lib/esm/command-handlers/open-bug-report-command-handler.d.mts +53 -0
- package/dist/lib/esm/command-handlers/open-bug-report-command-handler.mjs +51 -0
- package/dist/lib/esm/command-handlers/open-settings-command-handler.mjs +6 -3
- package/dist/lib/esm/community-plugins.d.mts +14 -0
- package/dist/lib/esm/community-plugins.mjs +18 -2
- package/dist/lib/esm/components/bulk-operation-commit-component.mjs +5 -2
- package/dist/lib/esm/components/embeddable-markdown-editor-component.d.mts +221 -0
- package/dist/lib/esm/components/embeddable-markdown-editor-component.mjs +293 -0
- package/dist/lib/esm/components/index.d.mts +2 -0
- package/dist/lib/esm/components/index.mjs +5 -1
- package/dist/lib/esm/components/plugin-gate-component.mjs +6 -3
- package/dist/lib/esm/components/reconfigurable-editor-extension-component.d.mts +96 -0
- package/dist/lib/esm/components/reconfigurable-editor-extension-component.mjs +112 -0
- package/dist/lib/esm/components/rename-delete-handler-component.mjs +105 -2
- package/dist/lib/esm/desktop-bulk-operation-git.d.mts +21 -1
- package/dist/lib/esm/desktop-bulk-operation-git.mjs +38 -13
- package/dist/lib/esm/desktop-operating-system.d.mts +15 -0
- package/dist/lib/esm/desktop-operating-system.mjs +16 -0
- package/dist/lib/esm/generated-during-build.mjs +1 -1
- package/dist/lib/esm/i18n/locales/en.d.mts +1 -0
- package/dist/lib/esm/i18n/locales/en.mjs +2 -1
- package/dist/lib/esm/i18n/locales/translations-map.d.mts +1 -0
- package/dist/lib/esm/index.d.mts +5 -0
- package/dist/lib/esm/index.mjs +11 -1
- package/dist/lib/esm/menu.d.mts +65 -0
- package/dist/lib/esm/menu.mjs +30 -0
- package/dist/lib/esm/mobile-app-info.d.mts +32 -0
- package/dist/lib/esm/mobile-app-info.mjs +84 -0
- package/dist/lib/esm/modals/modal.d.mts +4 -0
- package/dist/lib/esm/modals/modal.mjs +8 -5
- package/dist/lib/esm/obsidian-settings.mjs +6 -3
- package/dist/lib/esm/plugin/plugin.d.mts +2 -0
- package/dist/lib/esm/plugin/plugin.mjs +5 -2
- package/dist/lib/esm/settings-modal.d.mts +33 -0
- package/dist/lib/esm/settings-modal.mjs +15 -0
- package/package.json +9 -8
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
/*
|
|
2
|
+
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
|
|
3
|
+
if you want to view the source, please visit the github repository of this plugin
|
|
4
|
+
*/
|
|
5
|
+
(function () {
|
|
6
|
+
function ensureBrowserProcess() {
|
|
7
|
+
const browserProcess = {
|
|
8
|
+
browser: true,
|
|
9
|
+
cwd() {
|
|
10
|
+
return "/";
|
|
11
|
+
},
|
|
12
|
+
env: {},
|
|
13
|
+
platform: "android"
|
|
14
|
+
};
|
|
15
|
+
const existingProcess = globalThis.process;
|
|
16
|
+
if (!existingProcess) {
|
|
17
|
+
globalThis.process = browserProcess;
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
if (existingProcess.versions?.node) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
const existingProcessRecord = existingProcess;
|
|
24
|
+
for (const [key, value] of Object.entries(browserProcess)) {
|
|
25
|
+
existingProcessRecord[key] ??= value;
|
|
26
|
+
}
|
|
27
|
+
existingProcessRecord["browser"] = true;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
ensureBrowserProcess();
|
|
31
|
+
})();
|
|
32
|
+
(function patchObsidianRequire() {
|
|
33
|
+
const originalRequire = require;
|
|
34
|
+
if (!originalRequire || originalRequire.__isPatched) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
require = Object.assign(
|
|
38
|
+
(id) => requirePatched(id),
|
|
39
|
+
originalRequire,
|
|
40
|
+
{
|
|
41
|
+
__isPatched: true
|
|
42
|
+
}
|
|
43
|
+
);
|
|
44
|
+
function extractDefault($module) {
|
|
45
|
+
return $module && $module.__esModule && "default" in $module ? $module.default : $module;
|
|
46
|
+
}
|
|
47
|
+
const OBSIDIAN_BUILT_IN_MODULE_NAMES = /* @__PURE__ */ new Set([
|
|
48
|
+
"@codemirror/autocomplete",
|
|
49
|
+
"@codemirror/collab",
|
|
50
|
+
"@codemirror/commands",
|
|
51
|
+
"@codemirror/language",
|
|
52
|
+
"@codemirror/lint",
|
|
53
|
+
"@codemirror/search",
|
|
54
|
+
"@codemirror/state",
|
|
55
|
+
"@codemirror/text",
|
|
56
|
+
"@codemirror/view",
|
|
57
|
+
"@lezer/common",
|
|
58
|
+
"@lezer/highlight",
|
|
59
|
+
"@lezer/lr",
|
|
60
|
+
"obsidian"
|
|
61
|
+
]);
|
|
62
|
+
const DEPRECATED_OBSIDIAN_BUILT_IN_MODULE_NAMES = /* @__PURE__ */ new Set([
|
|
63
|
+
"@codemirror/closebrackets",
|
|
64
|
+
"@codemirror/comment",
|
|
65
|
+
"@codemirror/fold",
|
|
66
|
+
"@codemirror/gutter",
|
|
67
|
+
"@codemirror/highlight",
|
|
68
|
+
"@codemirror/history",
|
|
69
|
+
"@codemirror/matchbrackets",
|
|
70
|
+
"@codemirror/panel",
|
|
71
|
+
"@codemirror/rangeset",
|
|
72
|
+
"@codemirror/rectangular-selection",
|
|
73
|
+
"@codemirror/stream-parser",
|
|
74
|
+
"@codemirror/tooltip"
|
|
75
|
+
]);
|
|
76
|
+
function requirePatched(id) {
|
|
77
|
+
if (OBSIDIAN_BUILT_IN_MODULE_NAMES.has(id) || DEPRECATED_OBSIDIAN_BUILT_IN_MODULE_NAMES.has(id)) {
|
|
78
|
+
return originalRequire?.(id);
|
|
79
|
+
}
|
|
80
|
+
const app = globalThis.app;
|
|
81
|
+
if (app?.isMobile) {
|
|
82
|
+
if (id === "process" || id === "node:process") {
|
|
83
|
+
console.debug(`The most likely you can safely ignore this error. Module not found: ${id}. Fake process object is returned instead.`);
|
|
84
|
+
return process;
|
|
85
|
+
}
|
|
86
|
+
} else {
|
|
87
|
+
const $module = originalRequire?.(id);
|
|
88
|
+
if ($module) {
|
|
89
|
+
return extractDefault($module);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
console.debug(`The most likely you can safely ignore this error. Module not found: ${id}. Empty object is returned instead.`);
|
|
93
|
+
return {};
|
|
94
|
+
}
|
|
95
|
+
})();
|
|
96
|
+
|
|
97
|
+
"use strict";
|
|
98
|
+
var __defProp = Object.defineProperty;
|
|
99
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
100
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
101
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
102
|
+
var __export = (target, all) => {
|
|
103
|
+
for (var name in all)
|
|
104
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
105
|
+
};
|
|
106
|
+
var __copyProps = (to, from, except, desc) => {
|
|
107
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
108
|
+
for (let key of __getOwnPropNames(from))
|
|
109
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
110
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
111
|
+
}
|
|
112
|
+
return to;
|
|
113
|
+
};
|
|
114
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
115
|
+
var reconfigurable_editor_extension_component_exports = {};
|
|
116
|
+
__export(reconfigurable_editor_extension_component_exports, {
|
|
117
|
+
ReconfigurableEditorExtensionComponent: () => ReconfigurableEditorExtensionComponent
|
|
118
|
+
});
|
|
119
|
+
module.exports = __toCommonJS(reconfigurable_editor_extension_component_exports);
|
|
120
|
+
var import_state = require('@codemirror/state');
|
|
121
|
+
var import_markdown_editor_views = require('../codemirror/markdown-editor-views.cjs');
|
|
122
|
+
var import_component_ex = require('./component-ex.cjs');
|
|
123
|
+
class ReconfigurableEditorExtensionComponent extends import_component_ex.ComponentEx {
|
|
124
|
+
/**
|
|
125
|
+
* The extension the editors currently carry, or the one they will carry once the component loads.
|
|
126
|
+
*
|
|
127
|
+
* @returns The current extension.
|
|
128
|
+
*/
|
|
129
|
+
get extension() {
|
|
130
|
+
return this._extension;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* The Obsidian app instance.
|
|
134
|
+
*/
|
|
135
|
+
app;
|
|
136
|
+
/**
|
|
137
|
+
* The compartment the extension lives in, in every editor.
|
|
138
|
+
*/
|
|
139
|
+
compartment = new import_state.Compartment();
|
|
140
|
+
/**
|
|
141
|
+
* The registrar the extension is registered through, once, on the first load.
|
|
142
|
+
*/
|
|
143
|
+
editorExtensionRegistrar;
|
|
144
|
+
_extension;
|
|
145
|
+
isRegistered = false;
|
|
146
|
+
registeredExtensions = [];
|
|
147
|
+
/**
|
|
148
|
+
* Creates a new instance of the {@link ReconfigurableEditorExtensionComponent} class.
|
|
149
|
+
*
|
|
150
|
+
* @param params - The constructor parameters.
|
|
151
|
+
*/
|
|
152
|
+
constructor(params) {
|
|
153
|
+
super();
|
|
154
|
+
this.app = params.app;
|
|
155
|
+
this.editorExtensionRegistrar = params.editorExtensionRegistrar;
|
|
156
|
+
this._extension = params.extension ?? [];
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Registers the extension on the first load, or restores it into every editor on a later one.
|
|
160
|
+
*/
|
|
161
|
+
onload() {
|
|
162
|
+
super.onload();
|
|
163
|
+
if (this.isRegistered) {
|
|
164
|
+
this.apply(this._extension);
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
this.registeredExtensions.push(this.compartment.of(this._extension));
|
|
168
|
+
this.editorExtensionRegistrar.registerEditorExtension(this.registeredExtensions);
|
|
169
|
+
this.isRegistered = true;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Empties the extension in every editor, since Obsidian cannot unregister it.
|
|
173
|
+
*/
|
|
174
|
+
onunload() {
|
|
175
|
+
super.onunload();
|
|
176
|
+
this.apply([]);
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Swaps the extension in every open editor and in every editor opened later.
|
|
180
|
+
*
|
|
181
|
+
* Before the component loads, this only records the extension the editors will start with.
|
|
182
|
+
*
|
|
183
|
+
* @param extension - The new extension.
|
|
184
|
+
*/
|
|
185
|
+
reconfigure(extension) {
|
|
186
|
+
this._extension = extension;
|
|
187
|
+
if (this.isRegistered && this._loaded) {
|
|
188
|
+
this.apply(extension);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
apply(extension) {
|
|
192
|
+
this.registeredExtensions.splice(0, this.registeredExtensions.length, this.compartment.of(extension));
|
|
193
|
+
(0, import_markdown_editor_views.dispatchToAllMarkdownEditorViews)(this.app, { effects: this.compartment.reconfigure(extension) });
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
197
|
+
0 && (module.exports = {
|
|
198
|
+
ReconfigurableEditorExtensionComponent
|
|
199
|
+
});
|
|
200
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2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ekM7QUFBQTtBQUFBO0FBQUE7QUFBQSxFQUtnQixTQUFlO0FBQzdCLFVBQU0sT0FBTztBQUNiLFFBQUksS0FBSyxjQUFjO0FBQ3JCLFdBQUssTUFBTSxLQUFLLFVBQVU7QUFDMUI7QUFBQSxJQUNGO0FBQ0EsU0FBSyxxQkFBcUIsS0FBSyxLQUFLLFlBQVksR0FBRyxLQUFLLFVBQVUsQ0FBQztBQUNuRSxTQUFLLHlCQUF5Qix3QkFBd0IsS0FBSyxvQkFBb0I7QUFDL0UsU0FBSyxlQUFlO0FBQUEsRUFDdEI7QUFBQTtBQUFBO0FBQUE7QUFBQSxFQUtnQixXQUFpQjtBQUMvQixVQUFNLFNBQVM7QUFDZixTQUFLLE1BQU0sQ0FBQyxDQUFDO0FBQUEsRUFDZjtBQUFBO0FBQUE7QUFBQTtBQUFBO0FBQUE7QUFBQTtBQUFBO0FBQUEsRUFTTyxZQUFZLFdBQTRCO0FBQzdDLFNBQUssYUFBYTtBQUNsQixRQUFJLEtBQUssZ0JBQWdCLEtBQUssU0FBUztBQUNyQyxXQUFLLE1BQU0sU0FBUztBQUFBLElBQ3RCO0FBQUEsRUFDRjtBQUFBLEVBRVEsTUFBTSxXQUE0QjtBQUN4QyxTQUFLLHFCQUFxQixPQUFPLEdBQUcsS0FBSyxxQkFBcUIsUUFBUSxLQUFLLFlBQVksR0FBRyxTQUFTLENBQUM7QUFDcEcsdUVBQWlDLEtBQUssS0FBSyxFQUFFLFNBQVMsS0FBSyxZQUFZLFlBQVksU0FBUyxFQUFFLENBQUM7QUFBQSxFQUNqRztBQUNGOyIsIm5hbWVzIjpbXX0=
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/// <reference path="../library-references.d.cts" />
|
|
2
|
+
/**
|
|
3
|
+
* @file
|
|
4
|
+
*
|
|
5
|
+
* Contains class {@link ReconfigurableEditorExtensionComponent}: an editor extension that can be swapped at runtime,
|
|
6
|
+
* in every open editor and in every editor opened later.
|
|
7
|
+
*
|
|
8
|
+
* Obsidian's documented route is to mutate the array handed to `registerEditorExtension` and call
|
|
9
|
+
* `workspace.updateOptions()`, which Obsidian itself calls "fairly expensive". This component instead wraps the
|
|
10
|
+
* extension in a {@link Compartment}: it swaps the entry in the array it registered, which future editors read, and
|
|
11
|
+
* dispatches the compartment's reconfigure effect to the open ones, which touches nothing else in their configuration.
|
|
12
|
+
* A later `updateOptions()` from anywhere re-reads the array and so lands on the same extension.
|
|
13
|
+
*
|
|
14
|
+
* Obsidian offers no way to unregister an editor extension, so unloading reconfigures the compartment to an empty
|
|
15
|
+
* extension, and loading the component again restores the current one into the array it already registered.
|
|
16
|
+
*/
|
|
17
|
+
import type { Extension } from '@codemirror/state' with { 'resolution-mode': 'import' };
|
|
18
|
+
import type { App } from 'obsidian' with { 'resolution-mode': 'import' };
|
|
19
|
+
import { Compartment } from '@codemirror/state';
|
|
20
|
+
import type { EditorExtensionRegistrar } from '../editor-extension-registrar.cjs';
|
|
21
|
+
import { ComponentEx } from './component-ex.cjs';
|
|
22
|
+
/**
|
|
23
|
+
* Parameters for the {@link ReconfigurableEditorExtensionComponent} constructor.
|
|
24
|
+
*/
|
|
25
|
+
export interface ReconfigurableEditorExtensionComponentConstructorParams {
|
|
26
|
+
/**
|
|
27
|
+
* The Obsidian app instance.
|
|
28
|
+
*/
|
|
29
|
+
readonly app: App;
|
|
30
|
+
/**
|
|
31
|
+
* The registrar the extension is registered through, once, on the first load.
|
|
32
|
+
*/
|
|
33
|
+
readonly editorExtensionRegistrar: EditorExtensionRegistrar;
|
|
34
|
+
/**
|
|
35
|
+
* The extension the editors start with. Defaults to an empty extension.
|
|
36
|
+
*/
|
|
37
|
+
readonly extension?: Extension;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* An editor extension that can be swapped at runtime, in every open editor and in every editor opened later.
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```ts
|
|
44
|
+
* const highlighting = this.addChild(new ReconfigurableEditorExtensionComponent({
|
|
45
|
+
* app: this.app,
|
|
46
|
+
* editorExtensionRegistrar: new PluginEditorExtensionRegistrar(this)
|
|
47
|
+
* }));
|
|
48
|
+
* highlighting.reconfigure(settings.shouldHighlight ? highlightExtension : []);
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
export declare class ReconfigurableEditorExtensionComponent extends ComponentEx {
|
|
52
|
+
/**
|
|
53
|
+
* The extension the editors currently carry, or the one they will carry once the component loads.
|
|
54
|
+
*
|
|
55
|
+
* @returns The current extension.
|
|
56
|
+
*/
|
|
57
|
+
get extension(): Extension;
|
|
58
|
+
/**
|
|
59
|
+
* The Obsidian app instance.
|
|
60
|
+
*/
|
|
61
|
+
protected readonly app: App;
|
|
62
|
+
/**
|
|
63
|
+
* The compartment the extension lives in, in every editor.
|
|
64
|
+
*/
|
|
65
|
+
protected readonly compartment: Compartment;
|
|
66
|
+
/**
|
|
67
|
+
* The registrar the extension is registered through, once, on the first load.
|
|
68
|
+
*/
|
|
69
|
+
protected readonly editorExtensionRegistrar: EditorExtensionRegistrar;
|
|
70
|
+
private _extension;
|
|
71
|
+
private isRegistered;
|
|
72
|
+
private readonly registeredExtensions;
|
|
73
|
+
/**
|
|
74
|
+
* Creates a new instance of the {@link ReconfigurableEditorExtensionComponent} class.
|
|
75
|
+
*
|
|
76
|
+
* @param params - The constructor parameters.
|
|
77
|
+
*/
|
|
78
|
+
constructor(params: ReconfigurableEditorExtensionComponentConstructorParams);
|
|
79
|
+
/**
|
|
80
|
+
* Registers the extension on the first load, or restores it into every editor on a later one.
|
|
81
|
+
*/
|
|
82
|
+
onload(): void;
|
|
83
|
+
/**
|
|
84
|
+
* Empties the extension in every editor, since Obsidian cannot unregister it.
|
|
85
|
+
*/
|
|
86
|
+
onunload(): void;
|
|
87
|
+
/**
|
|
88
|
+
* Swaps the extension in every open editor and in every editor opened later.
|
|
89
|
+
*
|
|
90
|
+
* Before the component loads, this only records the extension the editors will start with.
|
|
91
|
+
*
|
|
92
|
+
* @param extension - The new extension.
|
|
93
|
+
*/
|
|
94
|
+
reconfigure(extension: Extension): void;
|
|
95
|
+
private apply;
|
|
96
|
+
}
|