@polyipseity/obsidian-plugin-library 1.29.1 → 1.30.0
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/dist/index.js +87 -15
- package/dist/index.js.map +4 -4
- package/dist/src/@types/obsidian.d.ts +34 -3
- package/dist/src/@types/obsidian.d.ts.map +1 -1
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/keys.d.ts +4 -0
- package/dist/src/keys.d.ts.map +1 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3099,11 +3099,82 @@ function importable(...args) {
|
|
|
3099
3099
|
}
|
|
3100
3100
|
}
|
|
3101
3101
|
|
|
3102
|
+
// src/keys.ts
|
|
3103
|
+
import { constant as constant2, noop as noop3 } from "lodash-es";
|
|
3104
|
+
import { around as around2 } from "monkey-around";
|
|
3105
|
+
function newHotkeyListener(context, ids) {
|
|
3106
|
+
const { app, app: { keymap } } = context;
|
|
3107
|
+
return revealPrivate(context, [app], (app0) => {
|
|
3108
|
+
const { hotkeyManager } = app0;
|
|
3109
|
+
let bakedHotkeys = cloneAsWritable(hotkeyManager.bakedHotkeys), bakedIds = cloneAsWritable(hotkeyManager.bakedIds);
|
|
3110
|
+
context.register(around2(hotkeyManager, {
|
|
3111
|
+
bake(next) {
|
|
3112
|
+
return function fn(...args) {
|
|
3113
|
+
revealPrivate(context, [this], (this0) => {
|
|
3114
|
+
if (this0.baked) {
|
|
3115
|
+
return;
|
|
3116
|
+
}
|
|
3117
|
+
try {
|
|
3118
|
+
const defaultKeysOld = this0.defaultKeys;
|
|
3119
|
+
try {
|
|
3120
|
+
this0.defaultKeys = Object.fromEntries(
|
|
3121
|
+
Object.entries(defaultKeysOld).filter(([id]) => !ids || ids.has(id))
|
|
3122
|
+
);
|
|
3123
|
+
const customKeysOld = cloneAsWritable(this0.customKeys);
|
|
3124
|
+
try {
|
|
3125
|
+
for (const id of Object.keys(customKeysOld)) {
|
|
3126
|
+
if (!ids || ids.has(id)) {
|
|
3127
|
+
continue;
|
|
3128
|
+
}
|
|
3129
|
+
this0.removeHotkeys(id);
|
|
3130
|
+
}
|
|
3131
|
+
this0.baked = false;
|
|
3132
|
+
next.apply(this0, args);
|
|
3133
|
+
bakedHotkeys = cloneAsWritable(this0.bakedHotkeys);
|
|
3134
|
+
bakedIds = cloneAsWritable(this0.bakedIds);
|
|
3135
|
+
} finally {
|
|
3136
|
+
for (const [id, hotkey] of Object.entries(customKeysOld)) {
|
|
3137
|
+
if (!ids || ids.has(id)) {
|
|
3138
|
+
continue;
|
|
3139
|
+
}
|
|
3140
|
+
this0.setHotkeys(id, hotkey);
|
|
3141
|
+
}
|
|
3142
|
+
}
|
|
3143
|
+
} finally {
|
|
3144
|
+
this0.defaultKeys = defaultKeysOld;
|
|
3145
|
+
}
|
|
3146
|
+
} finally {
|
|
3147
|
+
this0.baked = false;
|
|
3148
|
+
}
|
|
3149
|
+
}, noop3);
|
|
3150
|
+
next.apply(this, args);
|
|
3151
|
+
};
|
|
3152
|
+
}
|
|
3153
|
+
}));
|
|
3154
|
+
return (evt, ctx) => {
|
|
3155
|
+
revealPrivate(context, [app, keymap], (app1, keymap0) => {
|
|
3156
|
+
app1.hotkeyManager.bake();
|
|
3157
|
+
let idx = 0;
|
|
3158
|
+
for (const hotkey of bakedHotkeys) {
|
|
3159
|
+
if (keymap0.constructor.isMatch(hotkey, ctx)) {
|
|
3160
|
+
const id = bakedIds[idx], command = app1.commands.findCommand(id);
|
|
3161
|
+
if (command && (!evt.repeat || (command.repeatable ?? false)) && app1.commands.executeCommand(command)) {
|
|
3162
|
+
return false;
|
|
3163
|
+
}
|
|
3164
|
+
}
|
|
3165
|
+
++idx;
|
|
3166
|
+
}
|
|
3167
|
+
return true;
|
|
3168
|
+
}, noop3);
|
|
3169
|
+
};
|
|
3170
|
+
}, constant2(noop3));
|
|
3171
|
+
}
|
|
3172
|
+
|
|
3102
3173
|
// src/modals.ts
|
|
3103
3174
|
import {
|
|
3104
3175
|
Modal
|
|
3105
3176
|
} from "obsidian";
|
|
3106
|
-
import { constant as
|
|
3177
|
+
import { constant as constant3, noop as noop4 } from "lodash-es";
|
|
3107
3178
|
|
|
3108
3179
|
// src/settings-widgets.ts
|
|
3109
3180
|
function closeSetting(container) {
|
|
@@ -3258,7 +3329,7 @@ var ListModal = class _ListModal extends Modal {
|
|
|
3258
3329
|
#presets;
|
|
3259
3330
|
#presetPlaceholder;
|
|
3260
3331
|
#dynamicWidth;
|
|
3261
|
-
#setupListSubUI =
|
|
3332
|
+
#setupListSubUI = noop4;
|
|
3262
3333
|
static stringInputter(transformer) {
|
|
3263
3334
|
return (setting, editable, getter, setter, input = (setting0, callback) => {
|
|
3264
3335
|
setting0.addTextArea(callback);
|
|
@@ -3281,7 +3352,7 @@ var ListModal = class _ListModal extends Modal {
|
|
|
3281
3352
|
makeModalDynamicWidth(modalUI, modalEl);
|
|
3282
3353
|
}
|
|
3283
3354
|
if (title) {
|
|
3284
|
-
modalUI.new(
|
|
3355
|
+
modalUI.new(constant3(titleEl), (ele) => {
|
|
3285
3356
|
ele.textContent = title();
|
|
3286
3357
|
}, (ele) => {
|
|
3287
3358
|
ele.textContent = null;
|
|
@@ -3467,7 +3538,7 @@ var EditDataModal = class _EditDataModal extends Modal {
|
|
|
3467
3538
|
const ret = createChildElement(contentEl, "div", (ele) => {
|
|
3468
3539
|
ele.classList.add(DOMClasses.MOD_WARNING);
|
|
3469
3540
|
});
|
|
3470
|
-
ui.new(
|
|
3541
|
+
ui.new(constant3(ret), null, (ele) => {
|
|
3471
3542
|
ele.remove();
|
|
3472
3543
|
});
|
|
3473
3544
|
return ret;
|
|
@@ -3484,7 +3555,7 @@ var EditDataModal = class _EditDataModal extends Modal {
|
|
|
3484
3555
|
makeModalDynamicWidth(modalUI, modalEl);
|
|
3485
3556
|
}
|
|
3486
3557
|
if (title) {
|
|
3487
|
-
modalUI.new(
|
|
3558
|
+
modalUI.new(constant3(titleEl), (ele) => {
|
|
3488
3559
|
ele.textContent = title();
|
|
3489
3560
|
}, (ele) => {
|
|
3490
3561
|
ele.textContent = null;
|
|
@@ -3617,7 +3688,7 @@ var DialogModal = class extends Modal {
|
|
|
3617
3688
|
});
|
|
3618
3689
|
this.#title = options?.title;
|
|
3619
3690
|
this.#description = options?.description;
|
|
3620
|
-
this.#draw = options?.draw ??
|
|
3691
|
+
this.#draw = options?.draw ?? noop4;
|
|
3621
3692
|
this.#dynamicWidth = options?.dynamicWidth ?? false;
|
|
3622
3693
|
}
|
|
3623
3694
|
modalUI = new UpdatableUI();
|
|
@@ -3642,7 +3713,7 @@ var DialogModal = class extends Modal {
|
|
|
3642
3713
|
makeModalDynamicWidth(modalUI, modalEl);
|
|
3643
3714
|
}
|
|
3644
3715
|
if (title) {
|
|
3645
|
-
modalUI.new(
|
|
3716
|
+
modalUI.new(constant3(titleEl), (ele) => {
|
|
3646
3717
|
ele.textContent = title();
|
|
3647
3718
|
}, (ele) => {
|
|
3648
3719
|
ele.textContent = null;
|
|
@@ -3713,14 +3784,14 @@ var DialogModal = class extends Modal {
|
|
|
3713
3784
|
};
|
|
3714
3785
|
|
|
3715
3786
|
// src/patch.ts
|
|
3716
|
-
import { constant as
|
|
3717
|
-
import { around as
|
|
3787
|
+
import { constant as constant4, noop as noop5 } from "lodash-es";
|
|
3788
|
+
import { around as around3 } from "monkey-around";
|
|
3718
3789
|
async function patchPlugin(context, id, patcher) {
|
|
3719
3790
|
return revealPrivateAsync(context, [context.app], async (app2) => {
|
|
3720
3791
|
const unpatch = new Functions({ async: false, settled: true });
|
|
3721
3792
|
try {
|
|
3722
3793
|
const { plugins } = app2;
|
|
3723
|
-
unpatch.push(
|
|
3794
|
+
unpatch.push(around3(plugins, {
|
|
3724
3795
|
loadPlugin(next) {
|
|
3725
3796
|
return function fn(...args) {
|
|
3726
3797
|
return (async () => {
|
|
@@ -3765,7 +3836,7 @@ async function patchPlugin(context, id, patcher) {
|
|
|
3765
3836
|
unpatch.call();
|
|
3766
3837
|
throw error;
|
|
3767
3838
|
}
|
|
3768
|
-
},
|
|
3839
|
+
}, constant4(noop5));
|
|
3769
3840
|
}
|
|
3770
3841
|
function patchWindows(workspace, patcher) {
|
|
3771
3842
|
const ret = new Functions({ async: false, settled: true });
|
|
@@ -3835,7 +3906,7 @@ var Platform;
|
|
|
3835
3906
|
})(Platform || (Platform = {}));
|
|
3836
3907
|
|
|
3837
3908
|
// src/settings.ts
|
|
3838
|
-
import { constant as
|
|
3909
|
+
import { constant as constant5, isEmpty as isEmpty3, isNil as isNil3, throttle } from "lodash-es";
|
|
3839
3910
|
import deepEqual2 from "deep-equal";
|
|
3840
3911
|
var AbstractSettingsManager = class extends ResourceComponent {
|
|
3841
3912
|
constructor(fixer) {
|
|
@@ -3903,7 +3974,7 @@ var StorageSettingsManager = class _StorageSettingsManager extends AbstractSetti
|
|
|
3903
3974
|
context,
|
|
3904
3975
|
[app],
|
|
3905
3976
|
(app2) => `${app2.appId}.${id}.${_StorageSettingsManager.KEY}`,
|
|
3906
|
-
|
|
3977
|
+
constant5(null)
|
|
3907
3978
|
);
|
|
3908
3979
|
});
|
|
3909
3980
|
get key() {
|
|
@@ -4146,7 +4217,7 @@ var PluginContext;
|
|
|
4146
4217
|
})(PluginContext || (PluginContext = {}));
|
|
4147
4218
|
|
|
4148
4219
|
// src/rules.ts
|
|
4149
|
-
import { constant as
|
|
4220
|
+
import { constant as constant6, escapeRegExp as escapeRegExp2, identity as identity2 } from "lodash-es";
|
|
4150
4221
|
import { normalizePath } from "obsidian";
|
|
4151
4222
|
var Rules;
|
|
4152
4223
|
((Rules2) => {
|
|
@@ -4227,7 +4298,7 @@ function rulesList(context, data, options = {}) {
|
|
|
4227
4298
|
return new ListModal(
|
|
4228
4299
|
context,
|
|
4229
4300
|
ListModal.stringInputter({ back: identity2, forth: identity2 }),
|
|
4230
|
-
|
|
4301
|
+
constant6(""),
|
|
4231
4302
|
data,
|
|
4232
4303
|
{
|
|
4233
4304
|
description: () => i18n.t("components.rules-list.description"),
|
|
@@ -4772,6 +4843,7 @@ export {
|
|
|
4772
4843
|
mergeResources,
|
|
4773
4844
|
multireplace,
|
|
4774
4845
|
newCollabrativeState,
|
|
4846
|
+
newHotkeyListener,
|
|
4775
4847
|
notice,
|
|
4776
4848
|
notice2,
|
|
4777
4849
|
onResize,
|