@polyipseity/obsidian-plugin-library 1.26.0 → 1.27.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 +114 -100
- package/dist/index.js.map +3 -3
- package/dist/sources/@types/obsidian.d.ts.map +1 -1
- package/dist/sources/components/find.d.svelte.ts +21 -0
- package/dist/sources/components/find.svelte +79 -44
- package/dist/sources/components/index.d.ts +2 -1
- package/dist/sources/components/index.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1495,9 +1495,9 @@ function cloneAsFrozen(obj, cloner = structuredClone) {
|
|
|
1495
1495
|
function cloneAsWritable(obj, cloner = structuredClone) {
|
|
1496
1496
|
return cloner(obj);
|
|
1497
1497
|
}
|
|
1498
|
-
function consumeEvent(
|
|
1499
|
-
|
|
1500
|
-
|
|
1498
|
+
function consumeEvent(event) {
|
|
1499
|
+
event.preventDefault();
|
|
1500
|
+
event.stopPropagation();
|
|
1501
1501
|
}
|
|
1502
1502
|
function copyOnWrite(obj, mutator) {
|
|
1503
1503
|
const ret = simplifyType(cloneAsWritable(obj));
|
|
@@ -1549,18 +1549,18 @@ function extname(path) {
|
|
|
1549
1549
|
const base = basename(path), idx = base.lastIndexOf(".");
|
|
1550
1550
|
return idx === -1 ? "" : base.slice(idx);
|
|
1551
1551
|
}
|
|
1552
|
-
function getKeyModifiers(
|
|
1552
|
+
function getKeyModifiers(event) {
|
|
1553
1553
|
const ret = [];
|
|
1554
|
-
if (
|
|
1554
|
+
if (event.altKey) {
|
|
1555
1555
|
ret.push("Alt");
|
|
1556
1556
|
}
|
|
1557
|
-
if (
|
|
1557
|
+
if (event.ctrlKey) {
|
|
1558
1558
|
ret.push("Ctrl");
|
|
1559
1559
|
}
|
|
1560
|
-
if (
|
|
1560
|
+
if (event.metaKey) {
|
|
1561
1561
|
ret.push("Meta");
|
|
1562
1562
|
}
|
|
1563
|
-
if (
|
|
1563
|
+
if (event.shiftKey) {
|
|
1564
1564
|
ret.push("Shift");
|
|
1565
1565
|
}
|
|
1566
1566
|
return deepFreeze(ret);
|
|
@@ -1620,7 +1620,7 @@ function lazyInit(initializer) {
|
|
|
1620
1620
|
};
|
|
1621
1621
|
}
|
|
1622
1622
|
function lazyProxy(initializer) {
|
|
1623
|
-
const lazy = lazyInit(initializer), functions = /* @__PURE__ */ new Map(),
|
|
1623
|
+
const lazy = lazyInit(initializer), functions = /* @__PURE__ */ new Map(), proxy2 = new Proxy(lazy, {
|
|
1624
1624
|
apply(target, thisArg, argArray) {
|
|
1625
1625
|
const target0 = target();
|
|
1626
1626
|
if (typeof target0 !== "function") {
|
|
@@ -1683,7 +1683,7 @@ function lazyProxy(initializer) {
|
|
|
1683
1683
|
}
|
|
1684
1684
|
return Reflect.apply(
|
|
1685
1685
|
ret0,
|
|
1686
|
-
this ===
|
|
1686
|
+
this === proxy2 ? target() : this,
|
|
1687
1687
|
args
|
|
1688
1688
|
);
|
|
1689
1689
|
}
|
|
@@ -1736,7 +1736,7 @@ function lazyProxy(initializer) {
|
|
|
1736
1736
|
return Reflect.setPrototypeOf(target(), proto);
|
|
1737
1737
|
}
|
|
1738
1738
|
});
|
|
1739
|
-
return
|
|
1739
|
+
return proxy2;
|
|
1740
1740
|
}
|
|
1741
1741
|
function logFormat(options, ...args) {
|
|
1742
1742
|
if (isEmpty(args)) {
|
|
@@ -2130,139 +2130,153 @@ var LibraryLocales;
|
|
|
2130
2130
|
})(LibraryLocales || (LibraryLocales = {}));
|
|
2131
2131
|
|
|
2132
2132
|
// sources/components/find.svelte
|
|
2133
|
-
var find_exports = {};
|
|
2134
|
-
__export(find_exports, {
|
|
2135
|
-
default: () => Find
|
|
2136
|
-
});
|
|
2137
2133
|
import "svelte/internal/disclose-version";
|
|
2138
|
-
import "svelte/internal/flags/legacy";
|
|
2139
2134
|
import * as $ from "svelte/internal/client";
|
|
2140
2135
|
import { t as i18nt } from "i18next";
|
|
2141
2136
|
import { isEmpty as isEmpty2 } from "lodash-es";
|
|
2142
2137
|
import { setIcon } from "obsidian";
|
|
2143
2138
|
import { slide } from "svelte/transition";
|
|
2139
|
+
var on_click = (event, stateParams) => {
|
|
2140
|
+
stateParams.caseSensitive = !stateParams.caseSensitive;
|
|
2141
|
+
consumeEvent(event);
|
|
2142
|
+
};
|
|
2143
|
+
var on_click_1 = (event, stateParams) => {
|
|
2144
|
+
stateParams.wholeWord = !stateParams.wholeWord;
|
|
2145
|
+
consumeEvent(event);
|
|
2146
|
+
};
|
|
2147
|
+
var on_click_2 = (event, stateParams) => {
|
|
2148
|
+
stateParams.regex = !stateParams.regex;
|
|
2149
|
+
consumeEvent(event);
|
|
2150
|
+
};
|
|
2151
|
+
var on_keydown = (event, onClose) => {
|
|
2152
|
+
if (event.key === "Escape" && isEmpty2(getKeyModifiers(event))) {
|
|
2153
|
+
onClose()();
|
|
2154
|
+
consumeEvent(event);
|
|
2155
|
+
}
|
|
2156
|
+
};
|
|
2157
|
+
var on_click_3 = (event, onFind, stateParams) => {
|
|
2158
|
+
onFind()("previous", stateParams);
|
|
2159
|
+
consumeEvent(event);
|
|
2160
|
+
};
|
|
2161
|
+
var on_click_4 = (event, onFind, stateParams) => {
|
|
2162
|
+
onFind()("next", stateParams);
|
|
2163
|
+
consumeEvent(event);
|
|
2164
|
+
};
|
|
2165
|
+
var on_click_5 = (event, onClose) => {
|
|
2166
|
+
onClose()();
|
|
2167
|
+
consumeEvent(event);
|
|
2168
|
+
};
|
|
2144
2169
|
var root = $.template(`<div class="document-search-container" role="search"><div class="document-search _polyipseity_obsidian-plugin-library-svelte-find"><div class="document-search-buttons"><button></button> <button></button> <button></button></div> <input class="document-search-input" type="text" role="searchbox"> <div class="document-search-buttons"><button class="document-search-button"></button> <button class="document-search-button"></button> <div class="document-search-results"> </div> <button class="document-search-close-button"></button></div></div></div>`);
|
|
2145
2170
|
var $$css = {
|
|
2146
2171
|
hash: "_polyipseity_obsidian-plugin-library-svelte-find",
|
|
2147
2172
|
code: ".document-search._polyipseity_obsidian-plugin-library-svelte-find {flex-wrap:wrap;}.is-mobile .document-search._polyipseity_obsidian-plugin-library-svelte-find .document-search-button.mod-cta:where(._polyipseity_obsidian-plugin-library-svelte-find) {background-color:var(--interactive-accent);color:var(--text-on-accent);}"
|
|
2148
2173
|
};
|
|
2149
2174
|
function Find($$anchor, $$props) {
|
|
2150
|
-
$.push($$props,
|
|
2175
|
+
$.push($$props, true);
|
|
2151
2176
|
$.append_styles($$anchor, $$css);
|
|
2152
|
-
|
|
2153
|
-
let params = $.prop($$props, "params", 28, () => ({
|
|
2177
|
+
const i18n = $.prop($$props, "i18n", 3, i18nt), params = $.prop($$props, "params", 19, () => ({
|
|
2154
2178
|
caseSensitive: false,
|
|
2155
2179
|
findText: "",
|
|
2156
2180
|
regex: false,
|
|
2157
2181
|
wholeWord: false
|
|
2158
|
-
}))
|
|
2159
|
-
|
|
2160
|
-
})
|
|
2161
|
-
|
|
2182
|
+
})), onClose = $.prop($$props, "onClose", 3, () => {
|
|
2183
|
+
}), onFind = $.prop($$props, "onFind", 3, (_direction, _params) => {
|
|
2184
|
+
}), onParamsChanged = $.prop($$props, "onParamsChanged", 3, (_params) => {
|
|
2185
|
+
}), results = $.prop($$props, "results", 3, "");
|
|
2186
|
+
let stateI18n = $.state(i18n());
|
|
2187
|
+
const stateParams = $.proxy(cloneAsWritable(params()));
|
|
2188
|
+
let stateResults = $.state(results());
|
|
2189
|
+
$.user_effect(() => {
|
|
2190
|
+
onParamsChanged()(stateParams);
|
|
2162
2191
|
});
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2192
|
+
function setI18n(i18n0) {
|
|
2193
|
+
$.set(stateI18n, i18n0);
|
|
2194
|
+
}
|
|
2195
|
+
function getParamsRef() {
|
|
2196
|
+
return stateParams;
|
|
2197
|
+
}
|
|
2198
|
+
function setResults(results0) {
|
|
2199
|
+
$.set(stateResults, results0);
|
|
2200
|
+
}
|
|
2201
|
+
let inputElement = null;
|
|
2167
2202
|
function focus() {
|
|
2168
|
-
|
|
2203
|
+
inputElement?.focus();
|
|
2169
2204
|
}
|
|
2170
2205
|
function blur() {
|
|
2171
|
-
|
|
2206
|
+
inputElement?.blur();
|
|
2172
2207
|
}
|
|
2173
|
-
$.legacy_pre_effect(
|
|
2174
|
-
() => ($.deep_read_state(onParamsChanged()), $.deep_read_state(params())),
|
|
2175
|
-
() => {
|
|
2176
|
-
onParamsChanged()(params());
|
|
2177
|
-
}
|
|
2178
|
-
);
|
|
2179
|
-
$.legacy_pre_effect_reset();
|
|
2180
|
-
$.init();
|
|
2181
2208
|
var div = root();
|
|
2182
2209
|
var div_1 = $.child(div);
|
|
2183
2210
|
var div_2 = $.child(div_1);
|
|
2184
2211
|
var button = $.child(div_2);
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
}))));
|
|
2188
|
-
$.action(button, ($$node, $$action_arg) => setIcon?.($$node, $$action_arg), () => i18n()("asset:components.find.case-sensitive-icon"));
|
|
2212
|
+
button.__click = [on_click, stateParams];
|
|
2213
|
+
$.action(button, ($$node, $$action_arg) => setIcon?.($$node, $$action_arg), () => $.get(stateI18n)("asset:components.find.case-sensitive-icon"));
|
|
2189
2214
|
var button_1 = $.sibling(button, 2);
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
}))));
|
|
2193
|
-
$.action(button_1, ($$node, $$action_arg) => setIcon?.($$node, $$action_arg), () => i18n()("asset:components.find.whole-word-icon"));
|
|
2215
|
+
button_1.__click = [on_click_1, stateParams];
|
|
2216
|
+
$.action(button_1, ($$node, $$action_arg) => setIcon?.($$node, $$action_arg), () => $.get(stateI18n)("asset:components.find.whole-word-icon"));
|
|
2194
2217
|
var button_2 = $.sibling(button_1, 2);
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
}))));
|
|
2198
|
-
$.action(button_2, ($$node, $$action_arg) => setIcon?.($$node, $$action_arg), () => i18n()("asset:components.find.regex-icon"));
|
|
2218
|
+
button_2.__click = [on_click_2, stateParams];
|
|
2219
|
+
$.action(button_2, ($$node, $$action_arg) => setIcon?.($$node, $$action_arg), () => $.get(stateI18n)("asset:components.find.regex-icon"));
|
|
2199
2220
|
$.reset(div_2);
|
|
2200
2221
|
var input = $.sibling(div_2, 2);
|
|
2201
2222
|
$.remove_input_defaults(input);
|
|
2202
|
-
|
|
2223
|
+
input.__keydown = [on_keydown, onClose];
|
|
2224
|
+
$.bind_this(input, ($$value) => inputElement = $$value, () => inputElement);
|
|
2203
2225
|
var div_3 = $.sibling(input, 2);
|
|
2204
2226
|
var button_3 = $.child(div_3);
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
}))));
|
|
2208
|
-
$.action(button_3, ($$node, $$action_arg) => setIcon?.($$node, $$action_arg), () => i18n()("asset:components.find.previous-icon"));
|
|
2227
|
+
button_3.__click = [on_click_3, onFind, stateParams];
|
|
2228
|
+
$.action(button_3, ($$node, $$action_arg) => setIcon?.($$node, $$action_arg), () => $.get(stateI18n)("asset:components.find.previous-icon"));
|
|
2209
2229
|
var button_4 = $.sibling(button_3, 2);
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
}))));
|
|
2213
|
-
$.action(button_4, ($$node, $$action_arg) => setIcon?.($$node, $$action_arg), () => i18n()("asset:components.find.next-icon"));
|
|
2230
|
+
button_4.__click = [on_click_4, onFind, stateParams];
|
|
2231
|
+
$.action(button_4, ($$node, $$action_arg) => setIcon?.($$node, $$action_arg), () => $.get(stateI18n)("asset:components.find.next-icon"));
|
|
2214
2232
|
var div_4 = $.sibling(button_4, 2);
|
|
2215
2233
|
var text = $.child(div_4, true);
|
|
2216
2234
|
$.reset(div_4);
|
|
2217
2235
|
var button_5 = $.sibling(div_4, 2);
|
|
2236
|
+
button_5.__click = [on_click_5, onClose];
|
|
2218
2237
|
$.reset(div_3);
|
|
2219
2238
|
$.reset(div_1);
|
|
2220
2239
|
$.reset(div);
|
|
2221
2240
|
$.template_effect(
|
|
2222
2241
|
($0, $1, $2, $3, $4, $5, $6) => {
|
|
2223
|
-
$.set_class(button, 1, `document-search-button${
|
|
2242
|
+
$.set_class(button, 1, `document-search-button${stateParams.caseSensitive ? " mod-cta" : ""}`, "_polyipseity_obsidian-plugin-library-svelte-find");
|
|
2224
2243
|
$.set_attribute(button, "aria-label", $0);
|
|
2225
|
-
$.set_class(button_1, 1, `document-search-button${
|
|
2244
|
+
$.set_class(button_1, 1, `document-search-button${stateParams.wholeWord ? " mod-cta" : ""}`, "_polyipseity_obsidian-plugin-library-svelte-find");
|
|
2226
2245
|
$.set_attribute(button_1, "aria-label", $1);
|
|
2227
|
-
$.set_class(button_2, 1, `document-search-button${
|
|
2246
|
+
$.set_class(button_2, 1, `document-search-button${stateParams.regex ? " mod-cta" : ""}`, "_polyipseity_obsidian-plugin-library-svelte-find");
|
|
2228
2247
|
$.set_attribute(button_2, "aria-label", $2);
|
|
2229
2248
|
$.set_attribute(input, "placeholder", $3);
|
|
2230
2249
|
$.set_attribute(button_3, "aria-label", $4);
|
|
2231
2250
|
$.set_attribute(button_4, "aria-label", $5);
|
|
2232
|
-
$.set_text(text,
|
|
2251
|
+
$.set_text(text, $.get(stateResults));
|
|
2233
2252
|
$.set_attribute(button_5, "aria-label", $6);
|
|
2234
2253
|
},
|
|
2235
2254
|
[
|
|
2236
|
-
() =>
|
|
2237
|
-
() =>
|
|
2238
|
-
() =>
|
|
2239
|
-
() =>
|
|
2240
|
-
() =>
|
|
2241
|
-
() =>
|
|
2242
|
-
() =>
|
|
2243
|
-
]
|
|
2244
|
-
$.derived_safe_equal
|
|
2255
|
+
() => $.get(stateI18n)("components.find.case-sensitive"),
|
|
2256
|
+
() => $.get(stateI18n)("components.find.whole-word"),
|
|
2257
|
+
() => $.get(stateI18n)("components.find.regex"),
|
|
2258
|
+
() => $.get(stateI18n)("components.find.input-placeholder"),
|
|
2259
|
+
() => $.get(stateI18n)("components.find.previous"),
|
|
2260
|
+
() => $.get(stateI18n)("components.find.next"),
|
|
2261
|
+
() => $.get(stateI18n)("components.find.close")
|
|
2262
|
+
]
|
|
2245
2263
|
);
|
|
2246
|
-
$.bind_value(input, () =>
|
|
2247
|
-
$.event("keydown", input, (event2) => {
|
|
2248
|
-
if (event2.key === "Escape" && isEmpty2(getKeyModifiers(event2))) {
|
|
2249
|
-
onClose()();
|
|
2250
|
-
consumeEvent(event2);
|
|
2251
|
-
}
|
|
2252
|
-
});
|
|
2253
|
-
$.event("click", button_5, $.preventDefault($.stopPropagation(function(...$$args) {
|
|
2254
|
-
onClose()?.apply(this, $$args);
|
|
2255
|
-
})));
|
|
2264
|
+
$.bind_value(input, () => stateParams.findText, ($$value) => stateParams.findText = $$value);
|
|
2256
2265
|
$.transition(3, div, () => slide);
|
|
2257
2266
|
$.append($$anchor, div);
|
|
2258
|
-
$.
|
|
2259
|
-
|
|
2260
|
-
|
|
2267
|
+
return $.pop({
|
|
2268
|
+
setI18n,
|
|
2269
|
+
getParamsRef,
|
|
2270
|
+
setResults,
|
|
2271
|
+
focus,
|
|
2272
|
+
blur
|
|
2273
|
+
});
|
|
2261
2274
|
}
|
|
2275
|
+
$.delegate(["click", "keydown"]);
|
|
2262
2276
|
|
|
2263
2277
|
// sources/components/find.ts
|
|
2264
|
-
var
|
|
2265
|
-
__export(
|
|
2278
|
+
var find_exports = {};
|
|
2279
|
+
__export(find_exports, {
|
|
2266
2280
|
DIRECTIONS: () => DIRECTIONS
|
|
2267
2281
|
});
|
|
2268
2282
|
var DIRECTIONS = deepFreeze(["next", "previous"]);
|
|
@@ -2693,8 +2707,8 @@ ${error.name}: ${error.message}`,
|
|
|
2693
2707
|
activeSelf(noticeEl).console.error(`${message()}
|
|
2694
2708
|
`, error);
|
|
2695
2709
|
}
|
|
2696
|
-
function readStateCollabratively(implType,
|
|
2697
|
-
return launderUnchecked(
|
|
2710
|
+
function readStateCollabratively(implType, state2) {
|
|
2711
|
+
return launderUnchecked(state2)[implType];
|
|
2698
2712
|
}
|
|
2699
2713
|
function recordViewStateHistory(context, result) {
|
|
2700
2714
|
revealPrivate(context, [result], (result0) => {
|
|
@@ -2756,8 +2770,8 @@ function useSubsettings(element) {
|
|
|
2756
2770
|
}
|
|
2757
2771
|
return ret;
|
|
2758
2772
|
}
|
|
2759
|
-
function writeStateCollabratively(
|
|
2760
|
-
return Object.assign(launderUnchecked(
|
|
2773
|
+
function writeStateCollabratively(state2, implType, implState) {
|
|
2774
|
+
return Object.assign(launderUnchecked(state2), { [implType]: implState });
|
|
2761
2775
|
}
|
|
2762
2776
|
|
|
2763
2777
|
// sources/documentation.ts
|
|
@@ -2818,15 +2832,15 @@ var DocumentationMarkdownView = class _DocumentationMarkdownView extends ItemVie
|
|
|
2818
2832
|
} = this;
|
|
2819
2833
|
return key === null ? super.getIcon() : String(i18n.t(key));
|
|
2820
2834
|
}
|
|
2821
|
-
async setState(
|
|
2835
|
+
async setState(state2, result) {
|
|
2822
2836
|
const { context: plugin, element } = this, ownState = readStateCollabratively(
|
|
2823
2837
|
_DocumentationMarkdownView.type.namespaced(plugin),
|
|
2824
|
-
|
|
2838
|
+
state2
|
|
2825
2839
|
), { value, valid } = _DocumentationMarkdownView.State.fix(ownState);
|
|
2826
2840
|
if (!valid) {
|
|
2827
2841
|
printMalformedData(plugin, ownState, value);
|
|
2828
2842
|
}
|
|
2829
|
-
await super.setState(
|
|
2843
|
+
await super.setState(state2, result);
|
|
2830
2844
|
const { data } = value;
|
|
2831
2845
|
this.state = value;
|
|
2832
2846
|
await MarkdownRenderer.render(this.app, data, element, "", this);
|
|
@@ -2851,7 +2865,7 @@ var Registered0 = class {
|
|
|
2851
2865
|
constructor(context) {
|
|
2852
2866
|
this.context = context;
|
|
2853
2867
|
}
|
|
2854
|
-
async open(active,
|
|
2868
|
+
async open(active, state2) {
|
|
2855
2869
|
const { context, context: { app: { workspace } } } = this;
|
|
2856
2870
|
return new Promise((resolve) => {
|
|
2857
2871
|
workspace.onLayoutReady(() => {
|
|
@@ -2862,7 +2876,7 @@ var Registered0 = class {
|
|
|
2862
2876
|
/* @__PURE__ */ new Map([
|
|
2863
2877
|
[
|
|
2864
2878
|
DocumentationMarkdownView.type,
|
|
2865
|
-
|
|
2879
|
+
state2
|
|
2866
2880
|
]
|
|
2867
2881
|
])
|
|
2868
2882
|
),
|
|
@@ -3644,18 +3658,18 @@ var DialogModal = class extends Modal {
|
|
|
3644
3658
|
}
|
|
3645
3659
|
confirmButton = button;
|
|
3646
3660
|
}).addButton((button) => button.setIcon(i18n.t("asset:components.dialog.cancel-icon")).setTooltip(i18n.t("components.dialog.cancel")).onClick(async () => this.cancel(this.#close)));
|
|
3647
|
-
}).new(() => scope.register([], "enter", async (
|
|
3661
|
+
}).new(() => scope.register([], "enter", async (event) => {
|
|
3648
3662
|
if (preconfirmed) {
|
|
3649
3663
|
await this.confirm(this.#close);
|
|
3650
3664
|
} else {
|
|
3651
|
-
activeSelf(
|
|
3665
|
+
activeSelf(event).setTimeout(() => {
|
|
3652
3666
|
preconfirmed = false;
|
|
3653
3667
|
confirmButton?.removeCta().setWarning();
|
|
3654
3668
|
}, doubleConfirmTimeout * SI_PREFIX_SCALE);
|
|
3655
3669
|
preconfirmed = true;
|
|
3656
3670
|
confirmButton?.setCta().buttonEl.classList.remove(DOMClasses.MOD_WARNING);
|
|
3657
3671
|
}
|
|
3658
|
-
consumeEvent(
|
|
3672
|
+
consumeEvent(event);
|
|
3659
3673
|
}), null, (ele) => {
|
|
3660
3674
|
scope.unregister(ele);
|
|
3661
3675
|
});
|
|
@@ -4643,8 +4657,8 @@ export {
|
|
|
4643
4657
|
EditDataModal,
|
|
4644
4658
|
EventEmitterLite,
|
|
4645
4659
|
FileExtensions,
|
|
4646
|
-
|
|
4647
|
-
|
|
4660
|
+
Find as FindComponent,
|
|
4661
|
+
find_exports as FindComponent$,
|
|
4648
4662
|
Functions,
|
|
4649
4663
|
JSON_STRINGIFY_SPACE,
|
|
4650
4664
|
LambdaComponent,
|