@bitcobblers/wod-wiki-ui 0.51.2194 → 0.51.2196
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/{chunk-OD5VWDT7.mjs → chunk-7PGNDGU7.mjs} +426 -166
- package/dist/chunk-7PGNDGU7.mjs.map +1 -0
- package/dist/extensions/index.cjs +426 -162
- package/dist/extensions/index.cjs.map +1 -1
- package/dist/extensions/index.d.cts +1 -1
- package/dist/extensions/index.d.ts +1 -1
- package/dist/extensions/index.mjs +1 -1
- package/dist/{index-CoaeAnTJ.d.cts → index-Bo1KHv-b.d.cts} +8 -8
- package/dist/{index-CoaeAnTJ.d.ts → index-Bo1KHv-b.d.ts} +8 -8
- package/dist/index.cjs +432 -168
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -8
- package/dist/index.d.ts +8 -8
- package/dist/index.mjs +8 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
- package/dist/chunk-OD5VWDT7.mjs.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -6117,6 +6117,18 @@ var referenceIndexReload = state.StateEffect.define();
|
|
|
6117
6117
|
var frontmatterVisibility = state.Facet.define({
|
|
6118
6118
|
combine: (values2) => values2[0] ?? true
|
|
6119
6119
|
});
|
|
6120
|
+
var frontmatterDebugMode = state.Facet.define({
|
|
6121
|
+
combine: (values2) => values2[0] ?? false
|
|
6122
|
+
});
|
|
6123
|
+
var INTERNAL_FRONTMATTER_KEYS = /* @__PURE__ */ new Set([
|
|
6124
|
+
"type",
|
|
6125
|
+
"id",
|
|
6126
|
+
"registrysource",
|
|
6127
|
+
"registry-source"
|
|
6128
|
+
]);
|
|
6129
|
+
function isInternalFrontmatterKey(key) {
|
|
6130
|
+
return INTERNAL_FRONTMATTER_KEYS.has(key.trim().toLowerCase());
|
|
6131
|
+
}
|
|
6120
6132
|
var setFrontmatterDetailed = state.StateEffect.define();
|
|
6121
6133
|
var frontmatterDetailed = state.StateField.define({
|
|
6122
6134
|
create: () => false,
|
|
@@ -6145,6 +6157,45 @@ var frontmatterSource = state.StateField.define({
|
|
|
6145
6157
|
}
|
|
6146
6158
|
});
|
|
6147
6159
|
var pendingFocus = /* @__PURE__ */ new WeakMap();
|
|
6160
|
+
var persistedDetailed = /* @__PURE__ */ new WeakMap();
|
|
6161
|
+
function exitToEditorBody(view) {
|
|
6162
|
+
const { sections } = view.state.field(sectionField);
|
|
6163
|
+
const fm = sections.find((s) => s.type === "frontmatter");
|
|
6164
|
+
const targetPos = fm ? Math.min(view.state.doc.length, fm.to) : 0;
|
|
6165
|
+
view.dispatch({
|
|
6166
|
+
selection: { anchor: targetPos },
|
|
6167
|
+
scrollIntoView: true
|
|
6168
|
+
});
|
|
6169
|
+
view.focus();
|
|
6170
|
+
}
|
|
6171
|
+
function triggerAddOrEditProperty(view, root, _sectionId) {
|
|
6172
|
+
const { sections } = view.state.field(sectionField);
|
|
6173
|
+
const fm = sections.find((s) => s.type === "frontmatter");
|
|
6174
|
+
if (!fm) {
|
|
6175
|
+
pendingFocus.set(view, { kind: "key", key: "property" });
|
|
6176
|
+
patchPropertyInView(view, "new", ["property"], "", true);
|
|
6177
|
+
return;
|
|
6178
|
+
}
|
|
6179
|
+
if (!view.state.field(frontmatterDetailed)) {
|
|
6180
|
+
view.dispatch({ effects: setFrontmatterDetailed.of(true) });
|
|
6181
|
+
}
|
|
6182
|
+
const activeRoot = root ?? view.dom.querySelector(".cm-frontmatter-preview");
|
|
6183
|
+
const emptyKey = activeRoot?.querySelector(
|
|
6184
|
+
'input[data-frontmatter-field="key"]:is([value=""], [value="property"])'
|
|
6185
|
+
);
|
|
6186
|
+
if (emptyKey) {
|
|
6187
|
+
emptyKey.focus();
|
|
6188
|
+
emptyKey.select?.();
|
|
6189
|
+
return;
|
|
6190
|
+
}
|
|
6191
|
+
const addBtn = activeRoot?.querySelector('button[aria-label="Add property"]');
|
|
6192
|
+
if (addBtn) {
|
|
6193
|
+
addBtn.click();
|
|
6194
|
+
return;
|
|
6195
|
+
}
|
|
6196
|
+
pendingFocus.set(view, { kind: "key", key: "property" });
|
|
6197
|
+
patchPropertyInView(view, fm.id, ["property"], "", true);
|
|
6198
|
+
}
|
|
6148
6199
|
var widgetCleanup = /* @__PURE__ */ new WeakMap();
|
|
6149
6200
|
var helperId = 0;
|
|
6150
6201
|
var TAG_CATEGORY_SUMMARY_KEYS = {
|
|
@@ -6198,7 +6249,7 @@ function attachSuggestions(input, view, root, kind, key, excluded, commit, value
|
|
|
6198
6249
|
if (!provider || !input.parentElement) return;
|
|
6199
6250
|
const panel = new SuggestionPanel(input, {
|
|
6200
6251
|
label: kind === "key" ? "Suggested properties" : suggestionListLabel(valueKind),
|
|
6201
|
-
onPick: () => commit(),
|
|
6252
|
+
onPick: () => commit(true),
|
|
6202
6253
|
// The popup floats over the properties panel; it must never cover the
|
|
6203
6254
|
// metadata actions below it.
|
|
6204
6255
|
avoid: () => root.querySelector("[data-frontmatter-actions]")
|
|
@@ -6222,16 +6273,31 @@ function attachSuggestions(input, view, root, kind, key, excluded, commit, value
|
|
|
6222
6273
|
const entries = valueKind === "effort" ? catalog.efforts ?? [] : catalog.equipment ?? [];
|
|
6223
6274
|
candidates = entries.map((entry) => ({
|
|
6224
6275
|
value: entry.slug,
|
|
6225
|
-
label: `${entry.label} (${entry.slug})`,
|
|
6276
|
+
label: entry.label.toLowerCase() === entry.slug.toLowerCase() ? entry.label : `${entry.label} (${entry.slug})`,
|
|
6226
6277
|
haystack: [entry.label, entry.slug, ...entry.aliases].join(" ").toLowerCase()
|
|
6227
6278
|
}));
|
|
6228
6279
|
} else {
|
|
6229
|
-
|
|
6280
|
+
const normKey = key.trim().toLowerCase();
|
|
6281
|
+
const fromTags = catalog.tags.filter((tag) => isTagProperty(key) || tag.type?.toLowerCase() === normKey).map((tag) => ({ value: tag.label, label: tag.label, haystack: tag.label.toLowerCase() }));
|
|
6282
|
+
if (fromTags.length > 0) {
|
|
6283
|
+
candidates = fromTags;
|
|
6284
|
+
} else if (normKey === "discipline") {
|
|
6285
|
+
candidates = wodWikiLang.EFFORT_DISCIPLINES.map((d) => ({ value: d, label: d, haystack: d.toLowerCase() }));
|
|
6286
|
+
} else if (normKey === "intensitytier" || normKey === "intensity") {
|
|
6287
|
+
candidates = ["low", "moderate", "high"].map((t) => ({ value: t, label: t, haystack: t }));
|
|
6288
|
+
} else {
|
|
6289
|
+
candidates = [];
|
|
6290
|
+
}
|
|
6230
6291
|
}
|
|
6231
6292
|
const selected = new Set(excluded.map((label) => label.toLowerCase()));
|
|
6232
|
-
const
|
|
6233
|
-
|
|
6234
|
-
|
|
6293
|
+
const seenValues = /* @__PURE__ */ new Set();
|
|
6294
|
+
const choices = candidates.filter((candidate) => {
|
|
6295
|
+
const lower = candidate.value.toLowerCase();
|
|
6296
|
+
if (selected.has(lower) || seenValues.has(lower)) return false;
|
|
6297
|
+
if (query !== "" && !candidate.haystack.includes(query)) return false;
|
|
6298
|
+
seenValues.add(lower);
|
|
6299
|
+
return true;
|
|
6300
|
+
}).map((candidate) => ({ value: candidate.value, label: candidate.label }));
|
|
6235
6301
|
panel.setChoices(choices);
|
|
6236
6302
|
if (choices.length > 0) panel.open();
|
|
6237
6303
|
} catch {
|
|
@@ -6286,8 +6352,12 @@ function patchPropertyInView(view, _sectionId, path, value, expandDetailed = fal
|
|
|
6286
6352
|
if (expandDetailed) view.dispatch({ effects: setFrontmatterDetailed.of(true) });
|
|
6287
6353
|
return;
|
|
6288
6354
|
}
|
|
6355
|
+
const currentAnchor = view.state.selection.main.anchor;
|
|
6356
|
+
const fmEnd = next.match(/^---\r?\n[\s\S]*?\r?\n---\r?\n?/)?.[0].length ?? 0;
|
|
6357
|
+
const safeAnchor = currentAnchor <= fmEnd ? fmEnd : Math.min(currentAnchor, next.length);
|
|
6289
6358
|
view.dispatch({
|
|
6290
6359
|
changes: { from: 0, to: wholeDoc.length, insert: next },
|
|
6360
|
+
selection: { anchor: safeAnchor },
|
|
6291
6361
|
...expandDetailed ? { effects: setFrontmatterDetailed.of(true) } : {}
|
|
6292
6362
|
});
|
|
6293
6363
|
}
|
|
@@ -6300,7 +6370,13 @@ function renamePropertyInView(view, _sectionId, fromKey, toKey, value) {
|
|
|
6300
6370
|
null
|
|
6301
6371
|
);
|
|
6302
6372
|
if (next === wholeDoc) return;
|
|
6303
|
-
|
|
6373
|
+
const currentAnchor = view.state.selection.main.anchor;
|
|
6374
|
+
const fmEnd = next.match(/^---\r?\n[\s\S]*?\r?\n---\r?\n?/)?.[0].length ?? 0;
|
|
6375
|
+
const safeAnchor = currentAnchor <= fmEnd ? fmEnd : Math.min(currentAnchor, next.length);
|
|
6376
|
+
view.dispatch({
|
|
6377
|
+
changes: { from: 0, to: wholeDoc.length, insert: next },
|
|
6378
|
+
selection: { anchor: safeAnchor }
|
|
6379
|
+
});
|
|
6304
6380
|
}
|
|
6305
6381
|
function detectDefinitionKind(meta) {
|
|
6306
6382
|
const type = typeof meta.type === "string" ? meta.type.trim().toLowerCase() : "";
|
|
@@ -6309,42 +6385,9 @@ function detectDefinitionKind(meta) {
|
|
|
6309
6385
|
if (meta.registrySource !== void 0 || meta.baseAttributes !== void 0) return "effort";
|
|
6310
6386
|
return null;
|
|
6311
6387
|
}
|
|
6312
|
-
function readBaseAttributes(body, meta = {}) {
|
|
6313
|
-
const out = {};
|
|
6314
|
-
if (meta["metrics.met"] !== void 0 && !Array.isArray(meta["metrics.met"])) {
|
|
6315
|
-
out.met = String(meta["metrics.met"]);
|
|
6316
|
-
}
|
|
6317
|
-
if (meta["discipline"] !== void 0 && !Array.isArray(meta["discipline"])) {
|
|
6318
|
-
out.discipline = String(meta["discipline"]);
|
|
6319
|
-
}
|
|
6320
|
-
if (meta["intensityTier"] !== void 0 && !Array.isArray(meta["intensityTier"])) {
|
|
6321
|
-
out.intensityTier = String(meta["intensityTier"]);
|
|
6322
|
-
}
|
|
6323
|
-
let inBase = false;
|
|
6324
|
-
for (const line of body.split(/\r?\n/)) {
|
|
6325
|
-
if (/^baseAttributes:\s*(#.*)?$/.test(line)) {
|
|
6326
|
-
inBase = true;
|
|
6327
|
-
out.hasBaseBlock = true;
|
|
6328
|
-
continue;
|
|
6329
|
-
}
|
|
6330
|
-
if (!inBase) continue;
|
|
6331
|
-
if (/^\S/.test(line)) break;
|
|
6332
|
-
const match = line.match(/^\s+([\w-]+):\s*(.*)$/);
|
|
6333
|
-
if (!match) continue;
|
|
6334
|
-
if (match[1] === "met" || match[1] === "discipline" || match[1] === "intensityTier") {
|
|
6335
|
-
out[match[1]] = unquoteYamlScalar(match[2].trim());
|
|
6336
|
-
}
|
|
6337
|
-
}
|
|
6338
|
-
return out;
|
|
6339
|
-
}
|
|
6340
|
-
function unquoteYamlScalar(val) {
|
|
6341
|
-
if (val.startsWith('"') && val.endsWith('"')) return val.slice(1, -1).replace(/\\(["\\])/g, "$1");
|
|
6342
|
-
if (val.startsWith("'") && val.endsWith("'")) return val.slice(1, -1).replace(/\\'/g, "'");
|
|
6343
|
-
return val;
|
|
6344
|
-
}
|
|
6345
6388
|
function referenceValueKind(key, docKind) {
|
|
6346
6389
|
const normalized = key.trim().toLowerCase();
|
|
6347
|
-
if (normalized === "metrics.effort") return "effort";
|
|
6390
|
+
if (normalized === "metrics.effort" || normalized === "effort") return "effort";
|
|
6348
6391
|
if (normalized === "metrics.equipment" || normalized === "equipment") return "equipment";
|
|
6349
6392
|
if (normalized === "aliases" && docKind === "equipment") return "equipment";
|
|
6350
6393
|
if (normalized === "aliases" && docKind === "effort") return "effort";
|
|
@@ -6600,9 +6643,10 @@ function createSummaryDraftRow(view, commit) {
|
|
|
6600
6643
|
const settle = (doCommit) => {
|
|
6601
6644
|
if (settled) return;
|
|
6602
6645
|
settled = true;
|
|
6603
|
-
const
|
|
6646
|
+
const keyTrim = keyInput.value.trim();
|
|
6647
|
+
const rawKey = (keyTrim || "summary").replace(/^summaries\./i, "");
|
|
6604
6648
|
const rawExpr = valInput.value.trim();
|
|
6605
|
-
if (doCommit && rawExpr) {
|
|
6649
|
+
if (doCommit && (rawExpr || keyTrim)) {
|
|
6606
6650
|
commit([`summaries.${rawKey}`], rawExpr);
|
|
6607
6651
|
}
|
|
6608
6652
|
row.remove();
|
|
@@ -6634,7 +6678,7 @@ function createSummaryDraftRow(view, commit) {
|
|
|
6634
6678
|
const onBlur = () => queueMicrotask(() => {
|
|
6635
6679
|
if (!row.isConnected) return;
|
|
6636
6680
|
if (row.contains(document.activeElement)) return;
|
|
6637
|
-
settle(valInput.value.trim().length > 0);
|
|
6681
|
+
settle(keyInput.value.trim().length > 0 || valInput.value.trim().length > 0);
|
|
6638
6682
|
});
|
|
6639
6683
|
keyInput.addEventListener("blur", onBlur);
|
|
6640
6684
|
valInput.addEventListener("blur", onBlur);
|
|
@@ -6769,7 +6813,13 @@ function createFrontmatterSummary(entries, onShowDetails) {
|
|
|
6769
6813
|
{ label: "Aliases", entries: entries.filter(([key]) => isAliasProperty(key)), hash: false }
|
|
6770
6814
|
];
|
|
6771
6815
|
for (const group of groups) {
|
|
6772
|
-
const
|
|
6816
|
+
const seen = /* @__PURE__ */ new Set();
|
|
6817
|
+
const values2 = group.entries.flatMap(([, value]) => parseTagList(value)).filter((val) => {
|
|
6818
|
+
const lower = val.toLowerCase();
|
|
6819
|
+
if (seen.has(lower)) return false;
|
|
6820
|
+
seen.add(lower);
|
|
6821
|
+
return true;
|
|
6822
|
+
});
|
|
6773
6823
|
if (values2.length === 0) continue;
|
|
6774
6824
|
const row = document.createElement("div");
|
|
6775
6825
|
row.className = "flex flex-wrap items-center gap-1.5 px-3 py-2";
|
|
@@ -6821,15 +6871,17 @@ var DefaultFrontmatterWidget = class extends view.WidgetType {
|
|
|
6821
6871
|
rawContent;
|
|
6822
6872
|
readOnly;
|
|
6823
6873
|
detailed;
|
|
6824
|
-
|
|
6874
|
+
debugMode;
|
|
6875
|
+
constructor(sectionId, rawContent, readOnly = false, detailed = false, debugMode = false) {
|
|
6825
6876
|
super();
|
|
6826
6877
|
this.sectionId = sectionId;
|
|
6827
6878
|
this.rawContent = rawContent ?? "";
|
|
6828
6879
|
this.readOnly = readOnly;
|
|
6829
6880
|
this.detailed = detailed;
|
|
6881
|
+
this.debugMode = debugMode;
|
|
6830
6882
|
}
|
|
6831
6883
|
eq(other) {
|
|
6832
|
-
return this.sectionId === other.sectionId && this.rawContent === other.rawContent && this.readOnly === other.readOnly && this.detailed === other.detailed;
|
|
6884
|
+
return this.sectionId === other.sectionId && this.rawContent === other.rawContent && this.readOnly === other.readOnly && this.detailed === other.detailed && this.debugMode === other.debugMode;
|
|
6833
6885
|
}
|
|
6834
6886
|
ignoreEvent() {
|
|
6835
6887
|
return true;
|
|
@@ -6851,6 +6903,7 @@ var DefaultFrontmatterWidget = class extends view.WidgetType {
|
|
|
6851
6903
|
summaryButton.className = "ml-auto px-1 py-0.5 text-[11px] font-normal hover:text-foreground cursor-pointer";
|
|
6852
6904
|
summaryButton.textContent = "Hide details \u25B4";
|
|
6853
6905
|
summaryButton.addEventListener("click", () => {
|
|
6906
|
+
persistedDetailed.set(view.dom, false);
|
|
6854
6907
|
view.dispatch({ effects: setFrontmatterDetailed.of(false) });
|
|
6855
6908
|
});
|
|
6856
6909
|
heading.appendChild(summaryButton);
|
|
@@ -6862,12 +6915,13 @@ var DefaultFrontmatterWidget = class extends view.WidgetType {
|
|
|
6862
6915
|
root.appendChild(box);
|
|
6863
6916
|
const body = this.rawContent.replace(/^---\r?\n?/, "").replace(/\r?\n?---\r?$/, "");
|
|
6864
6917
|
const meta = wodWikiWql.parseFrontmatterBody(body);
|
|
6865
|
-
const
|
|
6918
|
+
const showInternal = this.debugMode || view.state.facet(frontmatterDebugMode);
|
|
6919
|
+
const entries = Object.entries(meta).filter(([key]) => showInternal || !isInternalFrontmatterKey(key));
|
|
6866
6920
|
const docKind = detectDefinitionKind(meta);
|
|
6867
6921
|
const referenceProvider = view.state.facet(frontmatterReferenceIndex)?.() ?? null;
|
|
6868
|
-
const base = docKind === "effort" ? readBaseAttributes(body, meta) : {};
|
|
6869
6922
|
if (!this.detailed) {
|
|
6870
6923
|
box.appendChild(createFrontmatterSummary(entries, () => {
|
|
6924
|
+
persistedDetailed.set(view.dom, true);
|
|
6871
6925
|
view.dispatch({ effects: setFrontmatterDetailed.of(true) });
|
|
6872
6926
|
}));
|
|
6873
6927
|
} else {
|
|
@@ -6878,10 +6932,13 @@ var DefaultFrontmatterWidget = class extends view.WidgetType {
|
|
|
6878
6932
|
emptyRow.textContent = "No properties";
|
|
6879
6933
|
box.appendChild(emptyRow);
|
|
6880
6934
|
}
|
|
6881
|
-
|
|
6935
|
+
const entryKeys = entries.map(([name]) => name);
|
|
6936
|
+
for (let idxInEntries = 0; idxInEntries < entries.length; idxInEntries++) {
|
|
6937
|
+
const [key, value] = entries[idxInEntries];
|
|
6882
6938
|
const isTags = isTagProperty(key);
|
|
6883
6939
|
const valueKind = referenceValueKind(key, docKind);
|
|
6884
6940
|
const isReferenceList = (isReferenceKey(key, docKind) || key === "aliases") && Array.isArray(value);
|
|
6941
|
+
const isChipList = isTags || isReferenceList || Array.isArray(value);
|
|
6885
6942
|
const nested = value === "" && ownsNestedBlock(body, key);
|
|
6886
6943
|
const row = document.createElement("div");
|
|
6887
6944
|
row.className = "flex items-center min-h-[34px] border-b border-dashed border-border last:border-b-0 group hover:bg-muted/10 transition-colors max-[479px]:flex-col max-[479px]:items-stretch";
|
|
@@ -6890,7 +6947,7 @@ var DefaultFrontmatterWidget = class extends view.WidgetType {
|
|
|
6890
6947
|
const keyCol = document.createElement("div");
|
|
6891
6948
|
keyCol.className = "flex items-center gap-2 px-3 py-1.5 w-36 shrink-0 border-r border-dashed border-border text-muted-foreground max-[479px]:w-auto max-[479px]:border-r-0 max-[479px]:border-b";
|
|
6892
6949
|
row.appendChild(keyCol);
|
|
6893
|
-
keyCol.appendChild(
|
|
6950
|
+
keyCol.appendChild(isChipList ? createTagIcon() : createListIcon());
|
|
6894
6951
|
if (this.readOnly || nested) {
|
|
6895
6952
|
const keyLabel = document.createElement("span");
|
|
6896
6953
|
keyLabel.className = "truncate font-medium text-foreground/90";
|
|
@@ -6912,16 +6969,22 @@ var DefaultFrontmatterWidget = class extends view.WidgetType {
|
|
|
6912
6969
|
).id
|
|
6913
6970
|
);
|
|
6914
6971
|
let currentKey = key;
|
|
6915
|
-
const commitKey = () => {
|
|
6972
|
+
const commitKey = (andFocusValue = false) => {
|
|
6916
6973
|
const nextKey = keyInput.value.trim();
|
|
6917
6974
|
if (!nextKey || nextKey === currentKey) {
|
|
6918
6975
|
keyInput.value = currentKey;
|
|
6976
|
+
if (andFocusValue) {
|
|
6977
|
+
row.querySelector('input[data-frontmatter-field="value"]')?.focus();
|
|
6978
|
+
}
|
|
6919
6979
|
return;
|
|
6920
6980
|
}
|
|
6921
6981
|
if (!/^[A-Za-z_][\w.-]*$/.test(nextKey) || nextKey in meta) {
|
|
6922
6982
|
keyInput.value = currentKey;
|
|
6923
6983
|
return;
|
|
6924
6984
|
}
|
|
6985
|
+
if (andFocusValue) {
|
|
6986
|
+
pendingFocus.set(view, { kind: "value", key: nextKey });
|
|
6987
|
+
}
|
|
6925
6988
|
renamePropertyInView(view, this.sectionId, currentKey, nextKey, value);
|
|
6926
6989
|
delete meta[currentKey];
|
|
6927
6990
|
meta[nextKey] = value;
|
|
@@ -6935,10 +6998,52 @@ var DefaultFrontmatterWidget = class extends view.WidgetType {
|
|
|
6935
6998
|
attachSuggestions(keyInput, view, root, "key", key, entries.map(([name]) => name), commitKey);
|
|
6936
6999
|
keyInput.addEventListener("blur", commitKeyIfAttached);
|
|
6937
7000
|
keyInput.addEventListener("keydown", (e) => {
|
|
7001
|
+
if ((e.metaKey || e.ctrlKey) && e.key === ";") {
|
|
7002
|
+
e.preventDefault();
|
|
7003
|
+
triggerAddOrEditProperty(view, root, this.sectionId);
|
|
7004
|
+
return;
|
|
7005
|
+
}
|
|
6938
7006
|
if (e.defaultPrevented) return;
|
|
7007
|
+
if (e.key === "Tab") {
|
|
7008
|
+
e.preventDefault();
|
|
7009
|
+
if (!e.shiftKey) {
|
|
7010
|
+
commitKey(true);
|
|
7011
|
+
row.querySelector('input[data-frontmatter-field="value"]')?.focus();
|
|
7012
|
+
} else if (idxInEntries > 0) {
|
|
7013
|
+
commitKey(false);
|
|
7014
|
+
const prevKey = entryKeys[idxInEntries - 1];
|
|
7015
|
+
box.querySelector(`[data-frontmatter-row="${prevKey}"] input[data-frontmatter-field="value"]`)?.focus();
|
|
7016
|
+
} else {
|
|
7017
|
+
commitKey(false);
|
|
7018
|
+
root.querySelector('button[aria-label="Show property summary"]')?.focus();
|
|
7019
|
+
}
|
|
7020
|
+
return;
|
|
7021
|
+
}
|
|
6939
7022
|
if (e.key === "Enter") {
|
|
6940
7023
|
e.preventDefault();
|
|
6941
|
-
|
|
7024
|
+
commitKey(true);
|
|
7025
|
+
row.querySelector('input[data-frontmatter-field="value"]')?.focus();
|
|
7026
|
+
return;
|
|
7027
|
+
}
|
|
7028
|
+
if (e.key === "ArrowDown") {
|
|
7029
|
+
if (keyInput.getAttribute("aria-expanded") === "true") return;
|
|
7030
|
+
e.preventDefault();
|
|
7031
|
+
if (idxInEntries < entries.length - 1) {
|
|
7032
|
+
const nextKey = entryKeys[idxInEntries + 1];
|
|
7033
|
+
box.querySelector(`[data-frontmatter-row="${nextKey}"] input[data-frontmatter-field="key"]`)?.focus();
|
|
7034
|
+
} else {
|
|
7035
|
+
root.querySelector('button[aria-label="Add property"]')?.focus();
|
|
7036
|
+
}
|
|
7037
|
+
return;
|
|
7038
|
+
}
|
|
7039
|
+
if (e.key === "ArrowUp") {
|
|
7040
|
+
if (keyInput.getAttribute("aria-expanded") === "true") return;
|
|
7041
|
+
e.preventDefault();
|
|
7042
|
+
if (idxInEntries > 0) {
|
|
7043
|
+
const prevKey = entryKeys[idxInEntries - 1];
|
|
7044
|
+
box.querySelector(`[data-frontmatter-row="${prevKey}"] input[data-frontmatter-field="key"]`)?.focus();
|
|
7045
|
+
}
|
|
7046
|
+
return;
|
|
6942
7047
|
}
|
|
6943
7048
|
});
|
|
6944
7049
|
const focus = pendingFocus.get(view);
|
|
@@ -6962,7 +7067,7 @@ var DefaultFrontmatterWidget = class extends view.WidgetType {
|
|
|
6962
7067
|
if (!referenceProvider) return null;
|
|
6963
7068
|
return valueKind === "effort" ? referenceProvider.resolveEffort(token) : valueKind === "equipment" ? referenceProvider.resolveEquipment(token) : null;
|
|
6964
7069
|
};
|
|
6965
|
-
if (
|
|
7070
|
+
if (isChipList) {
|
|
6966
7071
|
const chips = parseTagList(value);
|
|
6967
7072
|
const chipIsReference = valueKind !== "tags";
|
|
6968
7073
|
const isAliasRow = isAliasProperty(key);
|
|
@@ -6970,24 +7075,25 @@ var DefaultFrontmatterWidget = class extends view.WidgetType {
|
|
|
6970
7075
|
const chip = chips[idx];
|
|
6971
7076
|
const match = chipIsReference ? refMatch(chip) : null;
|
|
6972
7077
|
const pill = document.createElement("span");
|
|
6973
|
-
pill.className = match ? "inline-flex items-center gap-1 px-2 py-0.5 rounded-
|
|
7078
|
+
pill.className = match ? "group/pill inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium bg-muted/50 text-foreground border border-border/60" : chipIsReference ? "group/pill inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium bg-destructive/10 text-destructive border border-destructive/30" : "group/pill inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium bg-muted/40 text-foreground/90 border border-border/60";
|
|
6974
7079
|
const pillText = document.createElement("span");
|
|
6975
7080
|
pillText.textContent = isAliasRow ? chip : match ? match.label : chip;
|
|
6976
7081
|
pill.appendChild(pillText);
|
|
6977
|
-
if (match && referenceProvider) {
|
|
7082
|
+
if (match && referenceProvider && (!isAliasRow || idx === 0)) {
|
|
6978
7083
|
const openLink = document.createElement("a");
|
|
6979
7084
|
openLink.href = referenceProvider.openHref(valueKind, match.slug);
|
|
6980
7085
|
openLink.title = `Open ${match.label} page`;
|
|
6981
7086
|
openLink.setAttribute("aria-label", `Open ${match.label} page`);
|
|
6982
|
-
openLink.className = "inline-flex items-center justify-center text-muted-foreground/60 hover:text-foreground cursor-pointer";
|
|
7087
|
+
openLink.className = isAliasRow ? "inline-flex items-center justify-center text-muted-foreground/40 hover:text-foreground cursor-pointer" : "inline-flex items-center justify-center text-muted-foreground/60 hover:text-foreground cursor-pointer";
|
|
6983
7088
|
openLink.appendChild(createExternalIcon());
|
|
6984
7089
|
pill.appendChild(openLink);
|
|
6985
7090
|
}
|
|
6986
7091
|
if (!this.readOnly) {
|
|
6987
7092
|
const rmBtn = document.createElement("button");
|
|
6988
7093
|
rmBtn.type = "button";
|
|
7094
|
+
rmBtn.tabIndex = -1;
|
|
6989
7095
|
rmBtn.setAttribute("aria-label", isTags ? `Remove tag ${chip}` : `Remove ${chip}`);
|
|
6990
|
-
rmBtn.className = "inline-flex items-center justify-center text-muted-foreground/
|
|
7096
|
+
rmBtn.className = "inline-flex items-center justify-center text-muted-foreground/50 hover:text-destructive cursor-pointer transition-colors";
|
|
6991
7097
|
rmBtn.appendChild(createCloseIcon("sm"));
|
|
6992
7098
|
rmBtn.addEventListener("click", (e) => {
|
|
6993
7099
|
e.preventDefault();
|
|
@@ -7000,7 +7106,7 @@ var DefaultFrontmatterWidget = class extends view.WidgetType {
|
|
|
7000
7106
|
}
|
|
7001
7107
|
if (!this.readOnly) {
|
|
7002
7108
|
const chipInput = document.createElement("input");
|
|
7003
|
-
chipInput.className = "flex-
|
|
7109
|
+
chipInput.className = "flex-1 min-w-[96px] bg-transparent px-1 py-0.5 text-xs text-foreground outline-none placeholder:text-field-placeholder focus:bg-background/80 focus:ring-1 focus:ring-ring rounded transition-colors";
|
|
7004
7110
|
chipInput.placeholder = chips.length === 0 ? isReferenceList ? `Add ${valueKind === "effort" ? "effort" : "equipment"}\u2026` : "Add tags\u2026" : isTags ? "Add tag\u2026" : "Add\u2026";
|
|
7005
7111
|
chipInput.setAttribute("aria-label", `Value for ${key}`);
|
|
7006
7112
|
chipInput.dataset.frontmatterField = "value";
|
|
@@ -7023,21 +7129,78 @@ var DefaultFrontmatterWidget = class extends view.WidgetType {
|
|
|
7023
7129
|
valCol.appendChild(chipInput);
|
|
7024
7130
|
attachSuggestions(chipInput, view, root, "value", key, chips, commitNewChip, valueKind);
|
|
7025
7131
|
chipInput.addEventListener("keydown", (e) => {
|
|
7132
|
+
if ((e.metaKey || e.ctrlKey) && e.key === ";") {
|
|
7133
|
+
e.preventDefault();
|
|
7134
|
+
triggerAddOrEditProperty(view, root, this.sectionId);
|
|
7135
|
+
return;
|
|
7136
|
+
}
|
|
7026
7137
|
if (e.defaultPrevented) return;
|
|
7027
|
-
if (e.key === "Enter" || e.key === ",") {
|
|
7138
|
+
if ((e.key === "Enter" || e.key === ",") && chipInput.value.trim()) {
|
|
7028
7139
|
e.preventDefault();
|
|
7029
7140
|
commitNewChip();
|
|
7030
|
-
|
|
7141
|
+
return;
|
|
7142
|
+
}
|
|
7143
|
+
if (e.key === "Backspace" && !chipInput.value && chips.length > 0) {
|
|
7031
7144
|
e.preventDefault();
|
|
7032
7145
|
pendingFocus.set(view, { kind: "tag", key });
|
|
7033
7146
|
commitList(chips.slice(0, -1));
|
|
7147
|
+
return;
|
|
7148
|
+
}
|
|
7149
|
+
if (e.key === "Tab") {
|
|
7150
|
+
if (chipInput.value.trim() && !e.shiftKey) {
|
|
7151
|
+
e.preventDefault();
|
|
7152
|
+
commitNewChip();
|
|
7153
|
+
return;
|
|
7154
|
+
}
|
|
7155
|
+
e.preventDefault();
|
|
7156
|
+
if (!e.shiftKey) {
|
|
7157
|
+
if (idxInEntries < entries.length - 1) {
|
|
7158
|
+
const nextKey = entryKeys[idxInEntries + 1];
|
|
7159
|
+
box.querySelector(`[data-frontmatter-row="${nextKey}"] input[data-frontmatter-field="key"]`)?.focus();
|
|
7160
|
+
} else {
|
|
7161
|
+
root.querySelector('button[aria-label="Add property"]')?.focus();
|
|
7162
|
+
}
|
|
7163
|
+
} else {
|
|
7164
|
+
row.querySelector('input[data-frontmatter-field="key"]')?.focus();
|
|
7165
|
+
}
|
|
7166
|
+
return;
|
|
7167
|
+
}
|
|
7168
|
+
if (e.key === "Enter") {
|
|
7169
|
+
e.preventDefault();
|
|
7170
|
+
if (idxInEntries < entries.length - 1) {
|
|
7171
|
+
const nextKey = entryKeys[idxInEntries + 1];
|
|
7172
|
+
box.querySelector(`[data-frontmatter-row="${nextKey}"] input[data-frontmatter-field="key"]`)?.focus();
|
|
7173
|
+
} else {
|
|
7174
|
+
root.querySelector('button[aria-label="Add property"]')?.click();
|
|
7175
|
+
}
|
|
7176
|
+
return;
|
|
7177
|
+
}
|
|
7178
|
+
if (e.key === "ArrowDown") {
|
|
7179
|
+
if (chipInput.getAttribute("aria-expanded") === "true") return;
|
|
7180
|
+
e.preventDefault();
|
|
7181
|
+
if (idxInEntries < entries.length - 1) {
|
|
7182
|
+
const nextKey = entryKeys[idxInEntries + 1];
|
|
7183
|
+
box.querySelector(`[data-frontmatter-row="${nextKey}"] input[data-frontmatter-field="value"]`)?.focus();
|
|
7184
|
+
} else {
|
|
7185
|
+
exitToEditorBody(view);
|
|
7186
|
+
}
|
|
7187
|
+
return;
|
|
7188
|
+
}
|
|
7189
|
+
if (e.key === "ArrowUp") {
|
|
7190
|
+
if (chipInput.getAttribute("aria-expanded") === "true") return;
|
|
7191
|
+
e.preventDefault();
|
|
7192
|
+
if (idxInEntries > 0) {
|
|
7193
|
+
const prevKey = entryKeys[idxInEntries - 1];
|
|
7194
|
+
box.querySelector(`[data-frontmatter-row="${prevKey}"] input[data-frontmatter-field="value"]`)?.focus();
|
|
7195
|
+
}
|
|
7196
|
+
return;
|
|
7034
7197
|
}
|
|
7035
7198
|
});
|
|
7036
7199
|
chipInput.addEventListener("blur", () => queueMicrotask(() => {
|
|
7037
7200
|
if (chipInput.isConnected && chipInput.value.trim()) commitNewChip();
|
|
7038
7201
|
}));
|
|
7039
7202
|
const focus = pendingFocus.get(view);
|
|
7040
|
-
if (focus?.kind === "tag" && focus.key === key) {
|
|
7203
|
+
if ((focus?.kind === "tag" || focus?.kind === "value") && focus.key === key) {
|
|
7041
7204
|
setTimeout(() => {
|
|
7042
7205
|
if (chipInput.isConnected) chipInput.focus();
|
|
7043
7206
|
}, 0);
|
|
@@ -7084,8 +7247,9 @@ var DefaultFrontmatterWidget = class extends view.WidgetType {
|
|
|
7084
7247
|
valCol.appendChild(valSpan);
|
|
7085
7248
|
} else {
|
|
7086
7249
|
const valInput = document.createElement("input");
|
|
7087
|
-
valInput.className = "w-full
|
|
7250
|
+
valInput.className = "w-full bg-transparent px-1.5 py-0.5 -mx-1.5 text-xs text-foreground outline-none placeholder:text-field-placeholder hover:bg-muted/30 focus:bg-background focus:ring-1 focus:ring-ring rounded transition-colors";
|
|
7088
7251
|
valInput.value = strVal;
|
|
7252
|
+
valInput.placeholder = "Empty";
|
|
7089
7253
|
valInput.spellcheck = false;
|
|
7090
7254
|
valInput.setAttribute("aria-label", `Value for ${key}`);
|
|
7091
7255
|
valInput.dataset.frontmatterField = "value";
|
|
@@ -7095,13 +7259,18 @@ var DefaultFrontmatterWidget = class extends view.WidgetType {
|
|
|
7095
7259
|
appendFieldHelper(valCol, "Property value. Press Enter to apply.").id
|
|
7096
7260
|
);
|
|
7097
7261
|
let committedVal = strVal;
|
|
7098
|
-
const commitVal = () => {
|
|
7262
|
+
const commitVal = (pendingNextKey) => {
|
|
7099
7263
|
const cur = valInput.value.trim();
|
|
7100
7264
|
if (cur !== committedVal) {
|
|
7101
7265
|
committedVal = cur;
|
|
7102
7266
|
const num = Number(cur);
|
|
7103
7267
|
const next = cur !== "" && !isNaN(num) ? num : cur;
|
|
7104
7268
|
meta[key] = next;
|
|
7269
|
+
if (typeof pendingNextKey === "string") {
|
|
7270
|
+
pendingFocus.set(view, { kind: "key", key: pendingNextKey });
|
|
7271
|
+
} else if (pendingNextKey === true) {
|
|
7272
|
+
pendingFocus.set(view, { kind: "value", key });
|
|
7273
|
+
}
|
|
7105
7274
|
patchPropertyInView(view, this.sectionId, [key], next);
|
|
7106
7275
|
}
|
|
7107
7276
|
};
|
|
@@ -7122,29 +7291,85 @@ var DefaultFrontmatterWidget = class extends view.WidgetType {
|
|
|
7122
7291
|
);
|
|
7123
7292
|
valInput.addEventListener("blur", commitValIfAttached);
|
|
7124
7293
|
valInput.addEventListener("keydown", (e) => {
|
|
7294
|
+
if ((e.metaKey || e.ctrlKey) && e.key === ";") {
|
|
7295
|
+
e.preventDefault();
|
|
7296
|
+
triggerAddOrEditProperty(view, root, this.sectionId);
|
|
7297
|
+
return;
|
|
7298
|
+
}
|
|
7125
7299
|
if (e.defaultPrevented) return;
|
|
7300
|
+
if (e.key === "Tab") {
|
|
7301
|
+
e.preventDefault();
|
|
7302
|
+
if (!e.shiftKey) {
|
|
7303
|
+
if (idxInEntries < entries.length - 1) {
|
|
7304
|
+
const nextKey = entryKeys[idxInEntries + 1];
|
|
7305
|
+
commitVal(nextKey);
|
|
7306
|
+
box.querySelector(`[data-frontmatter-row="${nextKey}"] input[data-frontmatter-field="key"]`)?.focus();
|
|
7307
|
+
} else {
|
|
7308
|
+
commitVal();
|
|
7309
|
+
root.querySelector('button[aria-label="Add property"]')?.focus();
|
|
7310
|
+
}
|
|
7311
|
+
} else {
|
|
7312
|
+
commitVal();
|
|
7313
|
+
row.querySelector('input[data-frontmatter-field="key"]')?.focus();
|
|
7314
|
+
}
|
|
7315
|
+
return;
|
|
7316
|
+
}
|
|
7126
7317
|
if (e.key === "Enter") {
|
|
7127
7318
|
e.preventDefault();
|
|
7128
|
-
|
|
7319
|
+
if (idxInEntries < entries.length - 1) {
|
|
7320
|
+
const nextKey = entryKeys[idxInEntries + 1];
|
|
7321
|
+
commitVal(nextKey);
|
|
7322
|
+
box.querySelector(`[data-frontmatter-row="${nextKey}"] input[data-frontmatter-field="key"]`)?.focus();
|
|
7323
|
+
} else {
|
|
7324
|
+
commitVal();
|
|
7325
|
+
root.querySelector('button[aria-label="Add property"]')?.click();
|
|
7326
|
+
}
|
|
7327
|
+
return;
|
|
7328
|
+
}
|
|
7329
|
+
if (e.key === "ArrowDown") {
|
|
7330
|
+
if (valInput.getAttribute("aria-expanded") === "true") return;
|
|
7331
|
+
e.preventDefault();
|
|
7332
|
+
if (idxInEntries < entries.length - 1) {
|
|
7333
|
+
const nextKey = entryKeys[idxInEntries + 1];
|
|
7334
|
+
box.querySelector(`[data-frontmatter-row="${nextKey}"] input[data-frontmatter-field="value"]`)?.focus();
|
|
7335
|
+
} else {
|
|
7336
|
+
exitToEditorBody(view);
|
|
7337
|
+
}
|
|
7338
|
+
return;
|
|
7339
|
+
}
|
|
7340
|
+
if (e.key === "ArrowUp") {
|
|
7341
|
+
if (valInput.getAttribute("aria-expanded") === "true") return;
|
|
7342
|
+
e.preventDefault();
|
|
7343
|
+
if (idxInEntries > 0) {
|
|
7344
|
+
const prevKey = entryKeys[idxInEntries - 1];
|
|
7345
|
+
box.querySelector(`[data-frontmatter-row="${prevKey}"] input[data-frontmatter-field="value"]`)?.focus();
|
|
7346
|
+
}
|
|
7347
|
+
return;
|
|
7129
7348
|
}
|
|
7130
7349
|
});
|
|
7350
|
+
const focus = pendingFocus.get(view);
|
|
7351
|
+
if (focus?.kind === "value" && focus.key === key) {
|
|
7352
|
+
setTimeout(() => {
|
|
7353
|
+
if (!valInput.isConnected) return;
|
|
7354
|
+
valInput.focus();
|
|
7355
|
+
valInput.select?.();
|
|
7356
|
+
}, 0);
|
|
7357
|
+
pendingFocus.delete(view);
|
|
7358
|
+
}
|
|
7131
7359
|
if (key.trim().toLowerCase() === "metrics.effort" && referenceProvider) {
|
|
7132
7360
|
const match = referenceProvider.resolveEffort(strVal);
|
|
7133
7361
|
if (match) {
|
|
7134
|
-
|
|
7135
|
-
pill.className = "inline-flex items-center gap-1 px-2 py-0.5 rounded-md text-xs font-medium bg-muted/60 text-foreground border border-border/60 shrink-0";
|
|
7136
|
-
const pillText = document.createElement("span");
|
|
7137
|
-
pillText.textContent = match.label;
|
|
7138
|
-
pill.appendChild(pillText);
|
|
7362
|
+
valInput.className = "flex-1 min-w-[70px] bg-transparent px-1.5 py-0.5 -mx-1.5 text-xs text-foreground outline-none placeholder:text-field-placeholder hover:bg-muted/30 focus:bg-background focus:ring-1 focus:ring-ring rounded transition-colors";
|
|
7139
7363
|
const openLink = document.createElement("a");
|
|
7140
7364
|
openLink.href = referenceProvider.openHref("effort", match.slug);
|
|
7141
7365
|
openLink.title = `Open ${match.label} page`;
|
|
7142
7366
|
openLink.setAttribute("aria-label", `Open ${match.label} page`);
|
|
7143
|
-
openLink.className = "inline-flex items-center
|
|
7367
|
+
openLink.className = "shrink-0 inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[11px] text-muted-foreground hover:text-foreground hover:bg-muted/50 transition-colors cursor-pointer";
|
|
7368
|
+
const linkLabel = document.createElement("span");
|
|
7369
|
+
linkLabel.textContent = match.label;
|
|
7370
|
+
openLink.appendChild(linkLabel);
|
|
7144
7371
|
openLink.appendChild(createExternalIcon());
|
|
7145
|
-
|
|
7146
|
-
valCol.insertBefore(pill, valInput);
|
|
7147
|
-
valInput.className = "flex-1 min-w-[70px] rounded-md border border-field-border bg-background/60 px-2 py-1 text-xs text-foreground outline-none placeholder:text-field-placeholder focus:border-ring focus:ring-1 focus:ring-ring transition-colors";
|
|
7372
|
+
valCol.appendChild(openLink);
|
|
7148
7373
|
}
|
|
7149
7374
|
const diag = renderEffortValueDiagnostics(
|
|
7150
7375
|
referenceProvider,
|
|
@@ -7174,6 +7399,7 @@ var DefaultFrontmatterWidget = class extends view.WidgetType {
|
|
|
7174
7399
|
actionsCol.className = "flex items-center pr-2";
|
|
7175
7400
|
const delBtn = document.createElement("button");
|
|
7176
7401
|
delBtn.type = "button";
|
|
7402
|
+
delBtn.tabIndex = -1;
|
|
7177
7403
|
delBtn.setAttribute("aria-label", `Remove property ${key}`);
|
|
7178
7404
|
delBtn.className = "opacity-0 group-hover:opacity-100 focus-visible:opacity-100 text-muted-foreground/70 hover:text-destructive p-1 rounded transition-opacity cursor-pointer";
|
|
7179
7405
|
delBtn.appendChild(createCloseIcon("md"));
|
|
@@ -7187,9 +7413,6 @@ var DefaultFrontmatterWidget = class extends view.WidgetType {
|
|
|
7187
7413
|
row.appendChild(actionsCol);
|
|
7188
7414
|
}
|
|
7189
7415
|
}
|
|
7190
|
-
if (docKind === "effort" && !this.readOnly) {
|
|
7191
|
-
box.appendChild(this.buildDefinitionRows(view, base));
|
|
7192
|
-
}
|
|
7193
7416
|
}
|
|
7194
7417
|
if (!this.readOnly) {
|
|
7195
7418
|
const existingTagKey = entries.find(([key]) => key.trim().toLowerCase() === "tags")?.[0] ?? entries.find(([key]) => isTagProperty(key))?.[0];
|
|
@@ -7207,6 +7430,10 @@ var DefaultFrontmatterWidget = class extends view.WidgetType {
|
|
|
7207
7430
|
addBtn.addEventListener("click", (e) => {
|
|
7208
7431
|
e.preventDefault();
|
|
7209
7432
|
e.stopPropagation();
|
|
7433
|
+
if (!this.detailed) {
|
|
7434
|
+
persistedDetailed.set(view.dom, true);
|
|
7435
|
+
view.dispatch({ effects: setFrontmatterDetailed.of(true) });
|
|
7436
|
+
}
|
|
7210
7437
|
let newKey = "property";
|
|
7211
7438
|
let count2 = 1;
|
|
7212
7439
|
while (newKey in meta) {
|
|
@@ -7214,13 +7441,24 @@ var DefaultFrontmatterWidget = class extends view.WidgetType {
|
|
|
7214
7441
|
newKey = `property_${count2}`;
|
|
7215
7442
|
}
|
|
7216
7443
|
pendingFocus.set(view, { kind: "key", key: newKey });
|
|
7217
|
-
patchPropertyInView(view, this.sectionId, [newKey], "",
|
|
7218
|
-
const
|
|
7444
|
+
patchPropertyInView(view, this.sectionId, [newKey], "", true);
|
|
7445
|
+
const activeRoot = view.dom.querySelector(".cm-frontmatter-preview") ?? root;
|
|
7446
|
+
const keyField = activeRoot.querySelector(
|
|
7219
7447
|
`[data-frontmatter-row="${newKey}"] [data-frontmatter-field="key"]`
|
|
7220
7448
|
);
|
|
7221
7449
|
keyField?.focus();
|
|
7222
7450
|
keyField?.select();
|
|
7223
7451
|
});
|
|
7452
|
+
addBtn.addEventListener("keydown", (e) => {
|
|
7453
|
+
if (e.key === "ArrowDown" || e.key === "Tab" && !e.shiftKey) {
|
|
7454
|
+
e.preventDefault();
|
|
7455
|
+
exitToEditorBody(view);
|
|
7456
|
+
} else if (e.key === "ArrowUp" || e.key === "Tab" && e.shiftKey) {
|
|
7457
|
+
e.preventDefault();
|
|
7458
|
+
const allInputs = box.querySelectorAll("input[data-frontmatter-field]:not([disabled])");
|
|
7459
|
+
allInputs[allInputs.length - 1]?.focus();
|
|
7460
|
+
}
|
|
7461
|
+
});
|
|
7224
7462
|
actionsRow.appendChild(addBtn);
|
|
7225
7463
|
{
|
|
7226
7464
|
const addMetricBtn = document.createElement("button");
|
|
@@ -7235,6 +7473,7 @@ var DefaultFrontmatterWidget = class extends view.WidgetType {
|
|
|
7235
7473
|
addMetricBtn.addEventListener("click", (e) => {
|
|
7236
7474
|
e.preventDefault();
|
|
7237
7475
|
e.stopPropagation();
|
|
7476
|
+
persistedDetailed.set(view.dom, true);
|
|
7238
7477
|
if (!this.detailed) {
|
|
7239
7478
|
view.dispatch({ effects: setFrontmatterDetailed.of(true) });
|
|
7240
7479
|
}
|
|
@@ -7267,6 +7506,7 @@ var DefaultFrontmatterWidget = class extends view.WidgetType {
|
|
|
7267
7506
|
addSummaryBtn.addEventListener("click", (e) => {
|
|
7268
7507
|
e.preventDefault();
|
|
7269
7508
|
e.stopPropagation();
|
|
7509
|
+
persistedDetailed.set(view.dom, true);
|
|
7270
7510
|
if (!this.detailed) {
|
|
7271
7511
|
view.dispatch({ effects: setFrontmatterDetailed.of(true) });
|
|
7272
7512
|
}
|
|
@@ -7278,7 +7518,7 @@ var DefaultFrontmatterWidget = class extends view.WidgetType {
|
|
|
7278
7518
|
return;
|
|
7279
7519
|
}
|
|
7280
7520
|
const draftRow = createSummaryDraftRow(view, (path, value) => {
|
|
7281
|
-
patchPropertyInView(view, this.sectionId, path, value);
|
|
7521
|
+
patchPropertyInView(view, this.sectionId, path, value, true);
|
|
7282
7522
|
});
|
|
7283
7523
|
activeBox.appendChild(draftRow);
|
|
7284
7524
|
draftRow.querySelector("input")?.focus();
|
|
@@ -7298,6 +7538,7 @@ var DefaultFrontmatterWidget = class extends view.WidgetType {
|
|
|
7298
7538
|
addTagBtn.addEventListener("click", (e) => {
|
|
7299
7539
|
e.preventDefault();
|
|
7300
7540
|
e.stopPropagation();
|
|
7541
|
+
persistedDetailed.set(view.dom, true);
|
|
7301
7542
|
if (!this.detailed) {
|
|
7302
7543
|
view.dispatch({ effects: setFrontmatterDetailed.of(true) });
|
|
7303
7544
|
}
|
|
@@ -7347,90 +7588,18 @@ var DefaultFrontmatterWidget = class extends view.WidgetType {
|
|
|
7347
7588
|
});
|
|
7348
7589
|
view.focus();
|
|
7349
7590
|
});
|
|
7591
|
+
editYamlBtn.addEventListener("keydown", (e) => {
|
|
7592
|
+
if (e.key === "ArrowDown" || e.key === "Tab" && !e.shiftKey) {
|
|
7593
|
+
e.preventDefault();
|
|
7594
|
+
exitToEditorBody(view);
|
|
7595
|
+
}
|
|
7596
|
+
});
|
|
7350
7597
|
actionsRow.appendChild(editYamlBtn);
|
|
7351
7598
|
}
|
|
7352
7599
|
root.appendChild(actionsRow);
|
|
7353
7600
|
}
|
|
7354
7601
|
return root;
|
|
7355
7602
|
}
|
|
7356
|
-
/**
|
|
7357
|
-
* Effort-definition attribute rows (MET / discipline / intensity tier).
|
|
7358
|
-
* Values live in the nested baseAttributes block; each edit patches that
|
|
7359
|
-
* one path, so unknown sibling keys and comments elsewhere survive.
|
|
7360
|
-
*/
|
|
7361
|
-
buildDefinitionRows(view, base) {
|
|
7362
|
-
const wrap = document.createElement("div");
|
|
7363
|
-
wrap.setAttribute("data-frontmatter-definition", "true");
|
|
7364
|
-
wrap.className = "border-t border-dashed border-border/60";
|
|
7365
|
-
const header = document.createElement("div");
|
|
7366
|
-
header.className = "px-3 pt-2 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground";
|
|
7367
|
-
header.textContent = "Definition";
|
|
7368
|
-
wrap.appendChild(header);
|
|
7369
|
-
const commitField = (field, raw) => {
|
|
7370
|
-
if (field === "met") {
|
|
7371
|
-
const num = Number(raw);
|
|
7372
|
-
const path2 = base.hasBaseBlock ? ["baseAttributes", "met"] : ["metrics.met"];
|
|
7373
|
-
patchPropertyInView(view, this.sectionId, path2, raw !== "" && !Number.isNaN(num) ? num : null);
|
|
7374
|
-
return;
|
|
7375
|
-
}
|
|
7376
|
-
const path = base.hasBaseBlock ? ["baseAttributes", field] : [field];
|
|
7377
|
-
patchPropertyInView(view, this.sectionId, path, raw === "" ? null : raw);
|
|
7378
|
-
};
|
|
7379
|
-
const fieldRow = (label, child) => {
|
|
7380
|
-
const row = document.createElement("label");
|
|
7381
|
-
row.className = "flex items-center gap-2 px-3 py-1.5 min-h-[34px] border-b border-dashed border-border/60 last:border-b-0 max-[479px]:flex-col max-[479px]:items-stretch";
|
|
7382
|
-
const name = document.createElement("span");
|
|
7383
|
-
name.className = "w-28 shrink-0 text-muted-foreground";
|
|
7384
|
-
name.textContent = label;
|
|
7385
|
-
row.appendChild(name);
|
|
7386
|
-
child.className = "flex-1 min-w-0 bg-transparent text-xs text-foreground outline-none py-0.5";
|
|
7387
|
-
row.appendChild(child);
|
|
7388
|
-
wrap.appendChild(row);
|
|
7389
|
-
};
|
|
7390
|
-
const met = document.createElement("input");
|
|
7391
|
-
met.type = "number";
|
|
7392
|
-
met.step = "0.1";
|
|
7393
|
-
met.inputMode = "decimal";
|
|
7394
|
-
met.value = base.met ?? "";
|
|
7395
|
-
met.setAttribute("aria-label", "MET value");
|
|
7396
|
-
met.addEventListener("change", () => queueMicrotask(() => {
|
|
7397
|
-
if (met.isConnected) commitField("met", met.value.trim());
|
|
7398
|
-
}));
|
|
7399
|
-
fieldRow("MET", met);
|
|
7400
|
-
const discipline = document.createElement("select");
|
|
7401
|
-
discipline.setAttribute("aria-label", "Discipline");
|
|
7402
|
-
discipline.className = "flex-1 min-w-0 rounded-md border border-input bg-background px-1.5 text-[11px] text-muted-foreground outline-none";
|
|
7403
|
-
const unset = document.createElement("option");
|
|
7404
|
-
unset.value = "";
|
|
7405
|
-
unset.textContent = "Unset";
|
|
7406
|
-
discipline.appendChild(unset);
|
|
7407
|
-
for (const option of wodWikiLang.EFFORT_DISCIPLINES) {
|
|
7408
|
-
const opt = document.createElement("option");
|
|
7409
|
-
opt.value = option;
|
|
7410
|
-
opt.textContent = option;
|
|
7411
|
-
discipline.appendChild(opt);
|
|
7412
|
-
}
|
|
7413
|
-
discipline.value = base.discipline ?? "";
|
|
7414
|
-
discipline.addEventListener("change", () => commitField("discipline", discipline.value));
|
|
7415
|
-
fieldRow("Discipline", discipline);
|
|
7416
|
-
const tier = document.createElement("select");
|
|
7417
|
-
tier.setAttribute("aria-label", "Intensity tier");
|
|
7418
|
-
tier.className = "flex-1 min-w-0 rounded-md border border-input bg-background px-1.5 text-[11px] text-muted-foreground outline-none";
|
|
7419
|
-
const tierUnset = document.createElement("option");
|
|
7420
|
-
tierUnset.value = "";
|
|
7421
|
-
tierUnset.textContent = "Unset";
|
|
7422
|
-
tier.appendChild(tierUnset);
|
|
7423
|
-
for (const option of ["low", "moderate", "high"]) {
|
|
7424
|
-
const opt = document.createElement("option");
|
|
7425
|
-
opt.value = option;
|
|
7426
|
-
opt.textContent = option;
|
|
7427
|
-
tier.appendChild(opt);
|
|
7428
|
-
}
|
|
7429
|
-
tier.value = base.intensityTier ?? "";
|
|
7430
|
-
tier.addEventListener("change", () => commitField("intensityTier", tier.value));
|
|
7431
|
-
fieldRow("Intensity tier", tier);
|
|
7432
|
-
return wrap;
|
|
7433
|
-
}
|
|
7434
7603
|
destroy(dom) {
|
|
7435
7604
|
widgetCleanup.get(dom)?.forEach((close) => close());
|
|
7436
7605
|
widgetCleanup.delete(dom);
|
|
@@ -7469,14 +7638,23 @@ var EmptyFrontmatterWidget = class extends view.WidgetType {
|
|
|
7469
7638
|
addBtn.addEventListener("click", (e) => {
|
|
7470
7639
|
e.preventDefault();
|
|
7471
7640
|
e.stopPropagation();
|
|
7641
|
+
persistedDetailed.set(view.dom, true);
|
|
7642
|
+
view.dispatch({ effects: setFrontmatterDetailed.of(true) });
|
|
7472
7643
|
pendingFocus.set(view, { kind: "key", key: "property" });
|
|
7473
7644
|
patchPropertyInView(view, "new", ["property"], "", true);
|
|
7474
|
-
const
|
|
7645
|
+
const activeRoot = view.dom.querySelector(".cm-frontmatter-preview") ?? root;
|
|
7646
|
+
const keyField = activeRoot.querySelector(
|
|
7475
7647
|
'[data-frontmatter-row="property"] [data-frontmatter-field="key"]'
|
|
7476
7648
|
);
|
|
7477
7649
|
keyField?.focus();
|
|
7478
7650
|
keyField?.select();
|
|
7479
7651
|
});
|
|
7652
|
+
addBtn.addEventListener("keydown", (e) => {
|
|
7653
|
+
if (e.key === "ArrowDown" || e.key === "Tab" && !e.shiftKey) {
|
|
7654
|
+
e.preventDefault();
|
|
7655
|
+
exitToEditorBody(view);
|
|
7656
|
+
}
|
|
7657
|
+
});
|
|
7480
7658
|
actionsRow.appendChild(addBtn);
|
|
7481
7659
|
const addMetricBtn = document.createElement("button");
|
|
7482
7660
|
addMetricBtn.type = "button";
|
|
@@ -7490,6 +7668,7 @@ var EmptyFrontmatterWidget = class extends view.WidgetType {
|
|
|
7490
7668
|
addMetricBtn.addEventListener("click", (e) => {
|
|
7491
7669
|
e.preventDefault();
|
|
7492
7670
|
e.stopPropagation();
|
|
7671
|
+
persistedDetailed.set(view.dom, true);
|
|
7493
7672
|
if (!this.detailed) view.dispatch({ effects: setFrontmatterDetailed.of(true) });
|
|
7494
7673
|
const activeRoot = view.dom.querySelector(".cm-frontmatter-preview") ?? root;
|
|
7495
7674
|
const existing = activeRoot.querySelector("[data-frontmatter-metric-draft] input");
|
|
@@ -7519,6 +7698,7 @@ var EmptyFrontmatterWidget = class extends view.WidgetType {
|
|
|
7519
7698
|
addSummaryBtn.addEventListener("click", (e) => {
|
|
7520
7699
|
e.preventDefault();
|
|
7521
7700
|
e.stopPropagation();
|
|
7701
|
+
persistedDetailed.set(view.dom, true);
|
|
7522
7702
|
if (!this.detailed) view.dispatch({ effects: setFrontmatterDetailed.of(true) });
|
|
7523
7703
|
const activeRoot = view.dom.querySelector(".cm-frontmatter-preview") ?? root;
|
|
7524
7704
|
const existing = activeRoot.querySelector("[data-frontmatter-summary-draft] input");
|
|
@@ -7580,14 +7760,16 @@ function buildFrontmatterDecos(state$1) {
|
|
|
7580
7760
|
builder.add(section.from, to, view.Decoration.replace({ block: true }));
|
|
7581
7761
|
continue;
|
|
7582
7762
|
}
|
|
7583
|
-
const
|
|
7763
|
+
const detailed = state$1.field(frontmatterDetailed);
|
|
7764
|
+
const selected = !state$1.readOnly && state$1.field(frontmatterSource);
|
|
7584
7765
|
if (selected) continue;
|
|
7585
7766
|
const rawContent = state$1.doc.sliceString(section.from, section.to);
|
|
7767
|
+
const debugMode = state$1.facet(frontmatterDebugMode);
|
|
7586
7768
|
builder.add(
|
|
7587
7769
|
section.from,
|
|
7588
7770
|
section.to,
|
|
7589
7771
|
view.Decoration.replace({
|
|
7590
|
-
widget: new DefaultFrontmatterWidget(section.id, rawContent, state$1.readOnly,
|
|
7772
|
+
widget: new DefaultFrontmatterWidget(section.id, rawContent, state$1.readOnly, detailed, debugMode),
|
|
7591
7773
|
block: true
|
|
7592
7774
|
})
|
|
7593
7775
|
);
|
|
@@ -7622,7 +7804,85 @@ var frontmatterPreviewField = state.StateField.define({
|
|
|
7622
7804
|
)
|
|
7623
7805
|
]
|
|
7624
7806
|
});
|
|
7625
|
-
var
|
|
7807
|
+
var frontmatterDetailSync = view.EditorView.updateListener.of((update) => {
|
|
7808
|
+
const current = update.state.field(frontmatterDetailed);
|
|
7809
|
+
const prev = update.startState.field(frontmatterDetailed);
|
|
7810
|
+
if (current !== prev) {
|
|
7811
|
+
if (update.transactions.some((tr) => tr.effects.some((e) => e.is(setFrontmatterDetailed)))) {
|
|
7812
|
+
persistedDetailed.set(update.view.dom, current);
|
|
7813
|
+
} else if (persistedDetailed.get(update.view.dom) === true && !current) {
|
|
7814
|
+
queueMicrotask(() => {
|
|
7815
|
+
if (update.view.state.field(frontmatterDetailed) === false) {
|
|
7816
|
+
update.view.dispatch({ effects: setFrontmatterDetailed.of(true) });
|
|
7817
|
+
}
|
|
7818
|
+
});
|
|
7819
|
+
}
|
|
7820
|
+
} else if (persistedDetailed.get(update.view.dom) === true && !current) {
|
|
7821
|
+
queueMicrotask(() => {
|
|
7822
|
+
if (update.view.state.field(frontmatterDetailed) === false) {
|
|
7823
|
+
update.view.dispatch({ effects: setFrontmatterDetailed.of(true) });
|
|
7824
|
+
}
|
|
7825
|
+
});
|
|
7826
|
+
}
|
|
7827
|
+
});
|
|
7828
|
+
var frontmatterKeymap = state.Prec.highest(
|
|
7829
|
+
view.keymap.of([
|
|
7830
|
+
{
|
|
7831
|
+
key: "Mod-;",
|
|
7832
|
+
run(view) {
|
|
7833
|
+
if (view.state.readOnly) return false;
|
|
7834
|
+
triggerAddOrEditProperty(view);
|
|
7835
|
+
return true;
|
|
7836
|
+
}
|
|
7837
|
+
},
|
|
7838
|
+
{
|
|
7839
|
+
key: "ArrowUp",
|
|
7840
|
+
run(view) {
|
|
7841
|
+
if (view.state.readOnly) return false;
|
|
7842
|
+
if (view.state.field(frontmatterSource)) return false;
|
|
7843
|
+
if (!view.state.facet(frontmatterVisibility)) return false;
|
|
7844
|
+
const { head } = view.state.selection.main;
|
|
7845
|
+
const { sections } = view.state.field(sectionField);
|
|
7846
|
+
const fm = sections.find((s) => s.type === "frontmatter");
|
|
7847
|
+
if (!fm) return false;
|
|
7848
|
+
const cursorLine = view.state.doc.lineAt(head);
|
|
7849
|
+
const fmEndLine = view.state.doc.lineAt(fm.to);
|
|
7850
|
+
if (cursorLine.number > fmEndLine.number + 1) return false;
|
|
7851
|
+
const allInputs = view.dom.querySelectorAll(
|
|
7852
|
+
".cm-frontmatter-preview input[data-frontmatter-field]:not([disabled])"
|
|
7853
|
+
);
|
|
7854
|
+
if (allInputs.length === 0) {
|
|
7855
|
+
const addBtn = view.dom.querySelector(
|
|
7856
|
+
'.cm-frontmatter-preview button[aria-label="Add property"]'
|
|
7857
|
+
);
|
|
7858
|
+
if (addBtn) {
|
|
7859
|
+
addBtn.focus();
|
|
7860
|
+
return true;
|
|
7861
|
+
}
|
|
7862
|
+
const detailsBtn = view.dom.querySelector(
|
|
7863
|
+
'.cm-frontmatter-preview button[aria-label="Show property details"]'
|
|
7864
|
+
);
|
|
7865
|
+
if (detailsBtn) {
|
|
7866
|
+
detailsBtn.focus();
|
|
7867
|
+
return true;
|
|
7868
|
+
}
|
|
7869
|
+
return false;
|
|
7870
|
+
}
|
|
7871
|
+
const target = allInputs[allInputs.length - 1];
|
|
7872
|
+
target.focus();
|
|
7873
|
+
target.select?.();
|
|
7874
|
+
return true;
|
|
7875
|
+
}
|
|
7876
|
+
}
|
|
7877
|
+
])
|
|
7878
|
+
);
|
|
7879
|
+
var frontmatterPreview = [
|
|
7880
|
+
frontmatterDetailed,
|
|
7881
|
+
frontmatterSource,
|
|
7882
|
+
frontmatterPreviewField,
|
|
7883
|
+
frontmatterDetailSync,
|
|
7884
|
+
frontmatterKeymap
|
|
7885
|
+
];
|
|
7626
7886
|
var HEADING_RE = /^(#{1,6}) /;
|
|
7627
7887
|
var BOLD_RE = /\*\*([^*\n]+)\*\*/g;
|
|
7628
7888
|
var ITALIC_STAR_RE = /(?<!\*)\*([^*\n]+)\*(?!\*)/g;
|
|
@@ -14426,13 +14686,13 @@ function editorPreset(optionsOrDialect = "markdown") {
|
|
|
14426
14686
|
}
|
|
14427
14687
|
|
|
14428
14688
|
// src/version.ts
|
|
14429
|
-
var VERSION = "0.51.
|
|
14430
|
-
var GIT_SHA = "
|
|
14431
|
-
var BUILD_TIME = "2026-11-
|
|
14689
|
+
var VERSION = "0.51.2196";
|
|
14690
|
+
var GIT_SHA = "817bc28";
|
|
14691
|
+
var BUILD_TIME = "2026-11-05T23:36:56.914Z";
|
|
14432
14692
|
var SEMVER = {
|
|
14433
|
-
version: "0.51.
|
|
14434
|
-
gitSha: "
|
|
14435
|
-
buildTime: "2026-11-
|
|
14693
|
+
version: "0.51.2196",
|
|
14694
|
+
gitSha: "817bc28",
|
|
14695
|
+
buildTime: "2026-11-05T23:36:56.914Z"
|
|
14436
14696
|
};
|
|
14437
14697
|
|
|
14438
14698
|
Object.defineProperty(exports, "CONTENT_GROUPING_DIMENSIONS", {
|
|
@@ -14462,6 +14722,7 @@ exports.EditorDialog = EditorDialog;
|
|
|
14462
14722
|
exports.GIT_SHA = GIT_SHA;
|
|
14463
14723
|
exports.GROUPBY_OPTIONS = GROUPBY_OPTIONS;
|
|
14464
14724
|
exports.GoalRings = GoalRings;
|
|
14725
|
+
exports.INTERNAL_FRONTMATTER_KEYS = INTERNAL_FRONTMATTER_KEYS;
|
|
14465
14726
|
exports.KIND_OPTIONS = KIND_OPTIONS;
|
|
14466
14727
|
exports.METRIC_OPTIONS = METRIC_OPTIONS;
|
|
14467
14728
|
exports.MULTI_VALUE_TYPES = MULTI_VALUE_TYPES;
|
|
@@ -14537,7 +14798,9 @@ exports.forceSectionParse = forceSectionParse;
|
|
|
14537
14798
|
exports.formatClockTime = formatClockTime;
|
|
14538
14799
|
exports.formatMMSS = formatMMSS;
|
|
14539
14800
|
exports.formatTimestamp = formatTimestamp;
|
|
14801
|
+
exports.frontmatterDebugMode = frontmatterDebugMode;
|
|
14540
14802
|
exports.frontmatterDetailed = frontmatterDetailed;
|
|
14803
|
+
exports.frontmatterKeymap = frontmatterKeymap;
|
|
14541
14804
|
exports.frontmatterPreview = frontmatterPreview;
|
|
14542
14805
|
exports.frontmatterPreviewField = frontmatterPreviewField;
|
|
14543
14806
|
exports.frontmatterReferenceIndex = frontmatterReferenceIndex;
|
|
@@ -14556,6 +14819,7 @@ exports.handleFenceAutoWrap = handleFenceAutoWrap;
|
|
|
14556
14819
|
exports.hashCode = hashCode;
|
|
14557
14820
|
exports.inlineButtonDecoration = inlineButtonDecoration;
|
|
14558
14821
|
exports.invalidateSuggestions = invalidateSuggestions;
|
|
14822
|
+
exports.isInternalFrontmatterKey = isInternalFrontmatterKey;
|
|
14559
14823
|
exports.lineIdsExtension = lineIdsExtension;
|
|
14560
14824
|
exports.linkOpen = linkOpen;
|
|
14561
14825
|
exports.linkPreview = linkPreview;
|