@bitcobblers/wod-wiki-ui 0.35.2116 → 0.35.2117
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-GUN6PZNI.mjs → chunk-4WX7YECS.mjs} +190 -251
- package/dist/chunk-4WX7YECS.mjs.map +1 -0
- package/dist/extensions/index.cjs +192 -247
- 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-DMTXLSJ0.d.cts → index-WiNbi7d3.d.cts} +29 -10
- package/dist/{index-DMTXLSJ0.d.ts → index-WiNbi7d3.d.ts} +29 -10
- package/dist/index.cjs +197 -252
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -9
- package/dist/index.d.ts +9 -9
- package/dist/index.mjs +8 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
- package/dist/chunk-GUN6PZNI.mjs.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -2757,7 +2757,7 @@ function mergeTagSuggestions(userLabels, corpusLabels) {
|
|
|
2757
2757
|
[]
|
|
2758
2758
|
).map((item) => item.value);
|
|
2759
2759
|
}
|
|
2760
|
-
var CANONICAL_BLOCK_TYPES = ["wod", "
|
|
2760
|
+
var CANONICAL_BLOCK_TYPES = ["wod", "query", "widget", "embed"];
|
|
2761
2761
|
function canonicalSuggestionItems(values2) {
|
|
2762
2762
|
return values2.map((value) => ({ value, label: value.charAt(0).toUpperCase() + value.slice(1) }));
|
|
2763
2763
|
}
|
|
@@ -4815,255 +4815,202 @@ var linkOpen = [
|
|
|
4815
4815
|
ctrlClickPlugin,
|
|
4816
4816
|
linkCursorTheme
|
|
4817
4817
|
];
|
|
4818
|
-
var
|
|
4818
|
+
var sectionIdentity = state.Facet.define({ combine: (values2) => values2[0] });
|
|
4819
|
+
var registeredSectionWidgets = state.Facet.define({ combine: (values2) => values2.length ? values2.flat() : void 0 });
|
|
4819
4820
|
var forceSectionParse = state.StateEffect.define();
|
|
4820
|
-
|
|
4821
|
-
|
|
4822
|
-
|
|
4823
|
-
|
|
4824
|
-
|
|
4825
|
-
const
|
|
4826
|
-
|
|
4827
|
-
|
|
4828
|
-
|
|
4829
|
-
|
|
4830
|
-
}
|
|
4831
|
-
|
|
4832
|
-
const match = wodWikiCore.matchDialectFence(trimmed);
|
|
4833
|
-
if (!match) return null;
|
|
4834
|
-
return { dialect: match.dialect, sport: match.sport };
|
|
4835
|
-
}
|
|
4836
|
-
function matchWidgetFence(trimmed) {
|
|
4837
|
-
const match = trimmed.match(/^```\s*widget:([\w-]+)\s*$/);
|
|
4838
|
-
return match ? match[1] : null;
|
|
4839
|
-
}
|
|
4840
|
-
function matchContentFence(trimmed) {
|
|
4841
|
-
const match = trimmed.match(/^```\s*query(?:[:\s](.*))?$/i);
|
|
4842
|
-
if (!match) return null;
|
|
4843
|
-
const rawSuffix = (match[1] ?? "").trim();
|
|
4844
|
-
if (rawSuffix === "") return { kind: "query" };
|
|
4845
|
-
const parsed = wodWikiWql.parseQueryWidgetSuffix(rawSuffix.replace(/^:/, ""));
|
|
4846
|
-
return {
|
|
4847
|
-
kind: "query",
|
|
4848
|
-
widgetType: parsed.type,
|
|
4849
|
-
widgetError: parsed.error
|
|
4850
|
-
};
|
|
4851
|
-
}
|
|
4852
|
-
function matchGenericFence(trimmed) {
|
|
4853
|
-
const match = trimmed.match(/^```\s*(\S+)\s*$/);
|
|
4854
|
-
if (!match) return null;
|
|
4855
|
-
const tag = match[1].toLowerCase();
|
|
4856
|
-
if (VALID_DIALECTS.includes(tag)) return null;
|
|
4857
|
-
if (tag.startsWith("widget:")) return null;
|
|
4858
|
-
if (tag.startsWith("query")) return null;
|
|
4859
|
-
return match[1];
|
|
4860
|
-
}
|
|
4861
|
-
function matchMarkdownEmbed(trimmed) {
|
|
4862
|
-
const imgMatch = trimmed.match(/^!\[([^\]]*)\]\(([^)]+)\)$/);
|
|
4863
|
-
if (imgMatch) {
|
|
4864
|
-
const label = imgMatch[1];
|
|
4865
|
-
const url = imgMatch[2];
|
|
4866
|
-
return { type: "image", url, label };
|
|
4867
|
-
}
|
|
4868
|
-
const linkMatch = trimmed.match(/^\[([^\]]+)\]\(([^)]+)\)$/);
|
|
4869
|
-
if (linkMatch) {
|
|
4870
|
-
const label = linkMatch[1];
|
|
4871
|
-
const url = linkMatch[2];
|
|
4872
|
-
return { type: "link", url, label };
|
|
4821
|
+
var sectionSaved = state.StateEffect.define();
|
|
4822
|
+
var sectionRestore = state.StateEffect.define();
|
|
4823
|
+
var sectionMove = state.StateEffect.define();
|
|
4824
|
+
var restoreHistoryIdentity = state.StateEffect.define({
|
|
4825
|
+
map(value, changes) {
|
|
4826
|
+
const blocks = {};
|
|
4827
|
+
for (const block of Object.values(value.blocks)) {
|
|
4828
|
+
const from = changes.mapPos(block.from, 1);
|
|
4829
|
+
const to = changes.mapPos(block.to, -1);
|
|
4830
|
+
if (from < to) blocks[block.id] = { ...block, from, to };
|
|
4831
|
+
}
|
|
4832
|
+
return { rawContent: value.rawContent, blocks };
|
|
4873
4833
|
}
|
|
4874
|
-
|
|
4834
|
+
});
|
|
4835
|
+
function sourceCoordinates(rawContent) {
|
|
4836
|
+
const rawStarts = [0];
|
|
4837
|
+
const editorStarts = [0];
|
|
4838
|
+
let removed = 0;
|
|
4839
|
+
for (const match of rawContent.matchAll(/\r\n|\r|\n/g)) {
|
|
4840
|
+
removed += match[0].length - 1;
|
|
4841
|
+
rawStarts.push(match.index + match[0].length);
|
|
4842
|
+
editorStarts.push(match.index + match[0].length - removed);
|
|
4843
|
+
}
|
|
4844
|
+
return { rawStarts, editorStarts };
|
|
4845
|
+
}
|
|
4846
|
+
function toSourcePosition(state, rawStarts, position) {
|
|
4847
|
+
const line = state.doc.lineAt(position);
|
|
4848
|
+
return rawStarts[line.number - 1] + position - line.from;
|
|
4849
|
+
}
|
|
4850
|
+
function toEditorBlocks(state) {
|
|
4851
|
+
const blocks = {};
|
|
4852
|
+
for (const block of Object.values(state.noteBlocks)) {
|
|
4853
|
+
const section = state.sections.find((section2) => section2.id === block.id);
|
|
4854
|
+
if (section) blocks[block.id] = { ...block, from: section.from, to: section.to };
|
|
4855
|
+
}
|
|
4856
|
+
return blocks;
|
|
4857
|
+
}
|
|
4858
|
+
function deriveState(state, rawContent, sourceRevision, lineage, savedVersions, previousSections = []) {
|
|
4859
|
+
const registeredWidgets = state.facet(registeredSectionWidgets);
|
|
4860
|
+
const noteBlocks = wodWikiCore.reconcileNoteBlocks(rawContent, { sourceRevision, blocks: lineage, registeredWidgets });
|
|
4861
|
+
const coordinates = sourceCoordinates(rawContent);
|
|
4862
|
+
const sections = wodWikiCore.parseDocumentSections(rawContent, { registeredWidgets }).map((section) => {
|
|
4863
|
+
const start = coordinates.editorStarts[section.startLine];
|
|
4864
|
+
const end = coordinates.editorStarts[section.endLine] + section.to - coordinates.rawStarts[section.endLine];
|
|
4865
|
+
const block = wodWikiCore.actionableSectionKind(section) ? Object.values(noteBlocks).find((block2) => block2.from === section.from && block2.to === section.to) : void 0;
|
|
4866
|
+
const prior = previousSections.find((prior2) => prior2.from === start && prior2.to === end && prior2.type === (section.type === "title" ? "markdown" : section.type));
|
|
4867
|
+
const query = section.querySuffix ? wodWikiWql.parseQueryWidgetSuffix(section.querySuffix) : void 0;
|
|
4868
|
+
const subtype = section.subtype;
|
|
4869
|
+
return {
|
|
4870
|
+
id: block?.id ?? prior?.id ?? section.id,
|
|
4871
|
+
type: section.type === "title" ? "markdown" : section.type,
|
|
4872
|
+
...subtype === "heading" || subtype === "paragraph" || subtype === "list" || subtype === "blockquote" || subtype === "table" ? { subtype } : {},
|
|
4873
|
+
from: start,
|
|
4874
|
+
to: end,
|
|
4875
|
+
startLine: section.startLine + 1,
|
|
4876
|
+
endLine: section.endLine + 1,
|
|
4877
|
+
...section.contentFrom !== void 0 ? { contentFrom: coordinates.editorStarts[section.startLine + 1] ?? end } : {},
|
|
4878
|
+
...section.contentTo !== void 0 ? { contentTo: coordinates.editorStarts[section.endLine] - (section.type === "frontmatter" ? 1 : 0) } : {},
|
|
4879
|
+
sport: section.sport,
|
|
4880
|
+
widgetName: section.widgetName,
|
|
4881
|
+
contentId: section.contentId,
|
|
4882
|
+
queryType: query?.type,
|
|
4883
|
+
queryError: query?.error,
|
|
4884
|
+
embed: section.embed
|
|
4885
|
+
};
|
|
4886
|
+
});
|
|
4887
|
+
for (const block of Object.values(noteBlocks)) block.version = savedVersions[block.id] ?? block.version;
|
|
4888
|
+
return { sections, rawContent, sourceRevision, noteBlocks, savedVersions };
|
|
4875
4889
|
}
|
|
4876
|
-
|
|
4877
|
-
|
|
4878
|
-
|
|
4879
|
-
|
|
4880
|
-
|
|
4881
|
-
|
|
4882
|
-
|
|
4883
|
-
}
|
|
4884
|
-
|
|
4885
|
-
|
|
4886
|
-
|
|
4887
|
-
|
|
4888
|
-
|
|
4889
|
-
|
|
4890
|
-
|
|
4891
|
-
|
|
4892
|
-
|
|
4893
|
-
|
|
4894
|
-
|
|
4895
|
-
|
|
4896
|
-
|
|
4897
|
-
|
|
4898
|
-
|
|
4899
|
-
|
|
4900
|
-
|
|
4901
|
-
|
|
4902
|
-
|
|
4903
|
-
|
|
4904
|
-
|
|
4905
|
-
|
|
4906
|
-
|
|
4907
|
-
|
|
4908
|
-
|
|
4909
|
-
|
|
4910
|
-
|
|
4911
|
-
|
|
4912
|
-
|
|
4913
|
-
|
|
4914
|
-
|
|
4915
|
-
|
|
4916
|
-
|
|
4917
|
-
|
|
4918
|
-
|
|
4919
|
-
|
|
4920
|
-
|
|
4921
|
-
|
|
4922
|
-
|
|
4923
|
-
|
|
4924
|
-
endLine
|
|
4925
|
-
});
|
|
4926
|
-
}
|
|
4927
|
-
}
|
|
4928
|
-
currentMdLines = [];
|
|
4929
|
-
}
|
|
4930
|
-
let lineNum = 1;
|
|
4931
|
-
while (lineNum <= state.doc.lines) {
|
|
4932
|
-
const line = state.doc.line(lineNum);
|
|
4933
|
-
const trimmed = line.text.trim();
|
|
4934
|
-
const dialectMatch = matchDialectFence(trimmed);
|
|
4935
|
-
const widgetMatch = matchWidgetFence(trimmed);
|
|
4936
|
-
const contentMatch = matchContentFence(trimmed);
|
|
4937
|
-
const genericFence = matchGenericFence(trimmed);
|
|
4938
|
-
if (dialectMatch || widgetMatch || contentMatch || genericFence) {
|
|
4939
|
-
flushMarkdown(lineNum - 1, line.from);
|
|
4940
|
-
const { closeLine, contentFrom, contentTo } = scanFenced(state, lineNum);
|
|
4941
|
-
const closeLineObj = state.doc.line(closeLine);
|
|
4942
|
-
const innerContent = state.doc.sliceString(contentFrom, contentTo);
|
|
4943
|
-
if (dialectMatch) {
|
|
4944
|
-
sections.push({
|
|
4945
|
-
id: generateSectionId(dialectMatch.dialect, lineNum, innerContent),
|
|
4946
|
-
type: dialectMatch.dialect,
|
|
4947
|
-
from: line.from,
|
|
4948
|
-
to: closeLineObj.to,
|
|
4949
|
-
startLine: lineNum,
|
|
4950
|
-
endLine: closeLine,
|
|
4951
|
-
contentFrom,
|
|
4952
|
-
contentTo,
|
|
4953
|
-
sport: dialectMatch.sport,
|
|
4954
|
-
contentId: wodWikiCore.blockContentId(innerContent)
|
|
4955
|
-
});
|
|
4956
|
-
} else if (widgetMatch) {
|
|
4957
|
-
sections.push({
|
|
4958
|
-
id: generateSectionId("widget", lineNum, innerContent),
|
|
4959
|
-
type: "widget",
|
|
4960
|
-
widgetName: widgetMatch,
|
|
4961
|
-
from: line.from,
|
|
4962
|
-
to: closeLineObj.to,
|
|
4963
|
-
startLine: lineNum,
|
|
4964
|
-
endLine: closeLine,
|
|
4965
|
-
contentFrom,
|
|
4966
|
-
contentTo
|
|
4967
|
-
});
|
|
4968
|
-
} else if (contentMatch) {
|
|
4969
|
-
sections.push({
|
|
4970
|
-
id: generateSectionId("query", lineNum, innerContent),
|
|
4971
|
-
type: "query",
|
|
4972
|
-
from: line.from,
|
|
4973
|
-
to: closeLineObj.to,
|
|
4974
|
-
startLine: lineNum,
|
|
4975
|
-
endLine: closeLine,
|
|
4976
|
-
contentFrom,
|
|
4977
|
-
contentTo,
|
|
4978
|
-
queryType: contentMatch.widgetType,
|
|
4979
|
-
queryError: contentMatch.widgetError
|
|
4980
|
-
});
|
|
4981
|
-
} else if (genericFence) {
|
|
4982
|
-
sections.push({
|
|
4983
|
-
id: generateSectionId("code", lineNum, innerContent),
|
|
4984
|
-
type: "code",
|
|
4985
|
-
from: line.from,
|
|
4986
|
-
to: closeLineObj.to,
|
|
4987
|
-
startLine: lineNum,
|
|
4988
|
-
endLine: closeLine,
|
|
4989
|
-
contentFrom,
|
|
4990
|
-
contentTo
|
|
4991
|
-
});
|
|
4992
|
-
}
|
|
4993
|
-
lineNum = closeLine + 1;
|
|
4994
|
-
mdStartLine = lineNum;
|
|
4995
|
-
mdStartPos = lineNum <= state.doc.lines ? state.doc.line(lineNum).from : state.doc.length;
|
|
4996
|
-
continue;
|
|
4997
|
-
}
|
|
4998
|
-
if (trimmed === "---") {
|
|
4999
|
-
const lineCount = state.doc.lines;
|
|
5000
|
-
const nextLineText = lineNum < lineCount ? state.doc.line(lineNum + 1).text.trim() : "";
|
|
5001
|
-
if (nextLineText !== "") {
|
|
5002
|
-
let foundClose = false;
|
|
5003
|
-
let closeLine = lineNum;
|
|
5004
|
-
let hasKeyValueLine = false;
|
|
5005
|
-
for (let j = lineNum + 1; j <= lineCount; j++) {
|
|
5006
|
-
const jTrimmed = state.doc.line(j).text.trim();
|
|
5007
|
-
if (matchDialectFence(jTrimmed) || matchGenericFence(jTrimmed)) break;
|
|
5008
|
-
if (jTrimmed === "---") {
|
|
5009
|
-
closeLine = j;
|
|
5010
|
-
foundClose = true;
|
|
5011
|
-
break;
|
|
5012
|
-
}
|
|
5013
|
-
if (/^[A-Za-z_][\w-]*\s*:/.test(jTrimmed)) {
|
|
5014
|
-
hasKeyValueLine = true;
|
|
4890
|
+
var sectionField = state.StateField.define({
|
|
4891
|
+
create(state) {
|
|
4892
|
+
const initial = state.facet(sectionIdentity);
|
|
4893
|
+
const rawContent = initial?.rawContent ?? state.doc.toString();
|
|
4894
|
+
if (rawContent.replace(/\r\n|\r/g, "\n") !== state.doc.toString()) throw new Error("Editor source and identity map disagree");
|
|
4895
|
+
if (initial) wodWikiCore.validateNoteBlocks(rawContent, initial.blocks, initial.sourceRevision, { registeredWidgets: state.facet(registeredSectionWidgets) });
|
|
4896
|
+
const savedVersions = Object.fromEntries(Object.values(initial?.blocks ?? {}).map((block) => [block.id, block.version]));
|
|
4897
|
+
return deriveState(state, rawContent, initial?.sourceRevision ?? 1, initial?.blocks ?? {}, savedVersions);
|
|
4898
|
+
},
|
|
4899
|
+
update(value, tr) {
|
|
4900
|
+
let rawContent = value.rawContent;
|
|
4901
|
+
let lineage = value.noteBlocks;
|
|
4902
|
+
let sourceRevision = value.sourceRevision;
|
|
4903
|
+
let savedVersions = value.savedVersions;
|
|
4904
|
+
if (tr.docChanged) {
|
|
4905
|
+
const { rawStarts } = sourceCoordinates(rawContent);
|
|
4906
|
+
const changes = [];
|
|
4907
|
+
const lineBreak = rawContent.includes("\r\n") ? "\r\n" : rawContent.includes("\r") ? "\r" : "\n";
|
|
4908
|
+
tr.changes.iterChanges((fromA, toA, fromB, toB) => changes.push({
|
|
4909
|
+
from: toSourcePosition(tr.startState, rawStarts, fromA),
|
|
4910
|
+
to: toSourcePosition(tr.startState, rawStarts, toA),
|
|
4911
|
+
insert: tr.newDoc.sliceString(fromB, toB, lineBreak)
|
|
4912
|
+
}));
|
|
4913
|
+
lineage = wodWikiCore.mapNoteBlockChanges(lineage, changes);
|
|
4914
|
+
for (let i = changes.length - 1; i >= 0; i--) {
|
|
4915
|
+
const change = changes[i];
|
|
4916
|
+
rawContent = rawContent.slice(0, change.from) + change.insert + rawContent.slice(change.to);
|
|
4917
|
+
}
|
|
4918
|
+
if (tr.isUserEvent("move.drop")) {
|
|
4919
|
+
const moves = [];
|
|
4920
|
+
tr.changes.iterChanges((fromA, toA, fromB, toB) => moves.push({ fromA, toA, fromB, toB }));
|
|
4921
|
+
const deletion = moves.filter((change) => change.toA > change.fromA && change.fromB === change.toB);
|
|
4922
|
+
const insertion = moves.filter((change) => change.fromA === change.toA && change.toB > change.fromB);
|
|
4923
|
+
if (deletion.length === 1 && insertion.length === 1) {
|
|
4924
|
+
const removed = deletion[0];
|
|
4925
|
+
const added = insertion[0];
|
|
4926
|
+
if (tr.startState.doc.sliceString(removed.fromA, removed.toA) === tr.newDoc.sliceString(added.fromB, added.toB)) {
|
|
4927
|
+
const currentStarts = sourceCoordinates(rawContent).rawStarts;
|
|
4928
|
+
for (const section of value.sections) {
|
|
4929
|
+
const block = value.noteBlocks[section.id];
|
|
4930
|
+
if (block && section.from >= removed.fromA && section.to <= removed.toA) {
|
|
4931
|
+
lineage[block.id] = {
|
|
4932
|
+
...block,
|
|
4933
|
+
from: toSourcePosition(tr.state, currentStarts, added.fromB + section.from - removed.fromA),
|
|
4934
|
+
to: toSourcePosition(tr.state, currentStarts, added.fromB + section.to - removed.fromA)
|
|
4935
|
+
};
|
|
4936
|
+
}
|
|
4937
|
+
}
|
|
5015
4938
|
}
|
|
5016
4939
|
}
|
|
5017
|
-
|
|
5018
|
-
|
|
5019
|
-
|
|
5020
|
-
|
|
5021
|
-
|
|
5022
|
-
|
|
5023
|
-
|
|
5024
|
-
|
|
5025
|
-
|
|
5026
|
-
|
|
5027
|
-
|
|
5028
|
-
|
|
5029
|
-
|
|
5030
|
-
|
|
5031
|
-
|
|
5032
|
-
|
|
5033
|
-
|
|
5034
|
-
|
|
4940
|
+
}
|
|
4941
|
+
if (tr.isUserEvent("move.line")) {
|
|
4942
|
+
const currentStarts = sourceCoordinates(rawContent).rawStarts;
|
|
4943
|
+
for (let i = 0; i < tr.startState.selection.ranges.length; i++) {
|
|
4944
|
+
const before = tr.startState.selection.ranges[i];
|
|
4945
|
+
const after = tr.newSelection.ranges[i];
|
|
4946
|
+
if (!after) continue;
|
|
4947
|
+
const firstLine = tr.startState.doc.lineAt(before.from);
|
|
4948
|
+
const lastLine = tr.startState.doc.lineAt(before.to > before.from && tr.startState.doc.lineAt(before.to).from === before.to ? before.to - 1 : before.to);
|
|
4949
|
+
const delta = after.anchor - before.anchor;
|
|
4950
|
+
for (const section of value.sections) {
|
|
4951
|
+
const block = value.noteBlocks[section.id];
|
|
4952
|
+
if (block && section.from >= firstLine.from && section.to <= lastLine.to) {
|
|
4953
|
+
lineage[block.id] = {
|
|
4954
|
+
...block,
|
|
4955
|
+
from: toSourcePosition(tr.state, currentStarts, section.from + delta),
|
|
4956
|
+
to: toSourcePosition(tr.state, currentStarts, section.to + delta)
|
|
4957
|
+
};
|
|
4958
|
+
}
|
|
4959
|
+
}
|
|
5035
4960
|
}
|
|
5036
4961
|
}
|
|
5037
4962
|
}
|
|
5038
|
-
|
|
5039
|
-
|
|
5040
|
-
|
|
5041
|
-
|
|
5042
|
-
|
|
5043
|
-
|
|
5044
|
-
|
|
5045
|
-
|
|
5046
|
-
|
|
5047
|
-
|
|
5048
|
-
|
|
5049
|
-
|
|
5050
|
-
|
|
5051
|
-
|
|
5052
|
-
|
|
5053
|
-
|
|
5054
|
-
|
|
5055
|
-
|
|
4963
|
+
for (const effect of tr.effects) {
|
|
4964
|
+
if (effect.is(sectionSaved)) {
|
|
4965
|
+
sourceRevision = Math.max(sourceRevision, effect.value.sourceRevision);
|
|
4966
|
+
savedVersions = { ...savedVersions };
|
|
4967
|
+
for (const block of Object.values(effect.value.blocks)) savedVersions[block.id] = Math.max(savedVersions[block.id] ?? 1, block.version);
|
|
4968
|
+
}
|
|
4969
|
+
if (effect.is(sectionRestore)) {
|
|
4970
|
+
if (effect.value.rawContent.replace(/\r\n|\r/g, "\n") !== tr.newDoc.toString()) throw new Error("Restored source does not match editor");
|
|
4971
|
+
wodWikiCore.validateNoteBlocks(effect.value.rawContent, effect.value.blocks, effect.value.sourceRevision, { registeredWidgets: tr.state.facet(registeredSectionWidgets) });
|
|
4972
|
+
rawContent = effect.value.rawContent;
|
|
4973
|
+
lineage = effect.value.blocks;
|
|
4974
|
+
sourceRevision = effect.value.sourceRevision;
|
|
4975
|
+
savedVersions = { ...savedVersions, ...Object.fromEntries(Object.values(lineage).map((block) => [block.id, block.version])) };
|
|
4976
|
+
}
|
|
4977
|
+
if (effect.is(restoreHistoryIdentity)) {
|
|
4978
|
+
const exactHistory = tr.effects.some((candidate) => candidate.is(restoreHistoryIdentity) && candidate.value.rawContent.replace(/\r\n|\r/g, "\n") === tr.newDoc.toString());
|
|
4979
|
+
if (exactHistory && effect.value.rawContent.replace(/\r\n|\r/g, "\n") !== tr.newDoc.toString()) continue;
|
|
4980
|
+
if (effect.value.rawContent.replace(/\r\n|\r/g, "\n") === tr.newDoc.toString()) rawContent = effect.value.rawContent;
|
|
4981
|
+
const { rawStarts } = sourceCoordinates(rawContent);
|
|
4982
|
+
lineage = Object.fromEntries(Object.values(effect.value.blocks).map((block) => [block.id, {
|
|
4983
|
+
...block,
|
|
4984
|
+
from: toSourcePosition(tr.state, rawStarts, block.from),
|
|
4985
|
+
to: toSourcePosition(tr.state, rawStarts, block.to)
|
|
4986
|
+
}]));
|
|
4987
|
+
}
|
|
4988
|
+
if (effect.is(sectionMove)) {
|
|
4989
|
+
const prior = value.noteBlocks[effect.value.id];
|
|
4990
|
+
if (!prior || lineage[prior.id]) throw new Error("Explicit move must remove the original occurrence");
|
|
4991
|
+
const { rawStarts } = sourceCoordinates(rawContent);
|
|
4992
|
+
const from = toSourcePosition(tr.state, rawStarts, effect.value.from);
|
|
4993
|
+
const to = toSourcePosition(tr.state, rawStarts, effect.value.to);
|
|
4994
|
+
if (rawContent.slice(from, to) !== value.rawContent.slice(prior.from, prior.to)) throw new Error("Explicit move changed source");
|
|
4995
|
+
lineage = { ...lineage, [prior.id]: { ...prior, from, to } };
|
|
4996
|
+
}
|
|
4997
|
+
}
|
|
4998
|
+
if (tr.docChanged || tr.effects.some((effect) => effect.is(forceSectionParse) || effect.is(sectionRestore) || effect.is(sectionSaved) || effect.is(restoreHistoryIdentity))) {
|
|
4999
|
+
const previous = value.sections.map((section) => ({ ...section, from: tr.changes.mapPos(section.from, 1), to: tr.changes.mapPos(section.to, -1) }));
|
|
5000
|
+
return deriveState(tr.state, rawContent, sourceRevision, lineage, savedVersions, previous);
|
|
5056
5001
|
}
|
|
5057
5002
|
return value;
|
|
5058
5003
|
}
|
|
5059
5004
|
});
|
|
5005
|
+
var sectionIdentityHistory = commands.invertedEffects.of((tr) => {
|
|
5006
|
+
const value = tr.startState.field(sectionField, false);
|
|
5007
|
+
return value && tr.docChanged ? [restoreHistoryIdentity.of({ rawContent: value.rawContent, blocks: toEditorBlocks(value) })] : [];
|
|
5008
|
+
});
|
|
5060
5009
|
function sectionAtPos(state, pos) {
|
|
5061
|
-
|
|
5062
|
-
return sections.find((s) => pos >= s.from && pos <= s.to) ?? null;
|
|
5010
|
+
return state.field(sectionField).sections.find((section) => pos >= section.from && pos <= section.to) ?? null;
|
|
5063
5011
|
}
|
|
5064
5012
|
function activeCursorSection(state) {
|
|
5065
|
-
|
|
5066
|
-
return sectionAtPos(state, pos);
|
|
5013
|
+
return sectionAtPos(state, state.selection.main.head);
|
|
5067
5014
|
}
|
|
5068
5015
|
|
|
5069
5016
|
// src/extensions/whiteboard-linter.ts
|
|
@@ -6937,18 +6884,9 @@ function dispatchExpandRuntimePanel(view, sectionId, expanded) {
|
|
|
6937
6884
|
function sessionQueryWql(resultId) {
|
|
6938
6885
|
return `:session{result:${resultId}}`;
|
|
6939
6886
|
}
|
|
6940
|
-
function sessionQueryInsert(state, blockId, resultId
|
|
6887
|
+
function sessionQueryInsert(state, blockId, resultId) {
|
|
6941
6888
|
const sections = state.field(sectionField).sections;
|
|
6942
|
-
|
|
6943
|
-
if (!section && runBlock?.contentId) {
|
|
6944
|
-
section = sections.find((s) => s.contentId === runBlock.contentId);
|
|
6945
|
-
}
|
|
6946
|
-
if (!section && runBlock?.id) {
|
|
6947
|
-
section = sections.find((s) => s.id === runBlock.id);
|
|
6948
|
-
}
|
|
6949
|
-
if (!section && runBlock) {
|
|
6950
|
-
section = sections.find((s) => s.type === "time" || s.type === "log");
|
|
6951
|
-
}
|
|
6889
|
+
const section = sections.find((s) => s.id === blockId);
|
|
6952
6890
|
if (!section || section.type !== "time" && section.type !== "log") {
|
|
6953
6891
|
return null;
|
|
6954
6892
|
}
|
|
@@ -13056,6 +12994,7 @@ function editorPreset(optionsOrDialect = "markdown") {
|
|
|
13056
12994
|
extensions.push(
|
|
13057
12995
|
markdown({ codeLanguages: resolveCodeLanguage }),
|
|
13058
12996
|
sectionField,
|
|
12997
|
+
sectionIdentityHistory,
|
|
13059
12998
|
previewDecorations,
|
|
13060
12999
|
wodLinter,
|
|
13061
13000
|
wodAutocompletion,
|
|
@@ -13075,13 +13014,13 @@ function editorPreset(optionsOrDialect = "markdown") {
|
|
|
13075
13014
|
}
|
|
13076
13015
|
|
|
13077
13016
|
// src/version.ts
|
|
13078
|
-
var VERSION = "0.35.
|
|
13079
|
-
var GIT_SHA = "
|
|
13080
|
-
var BUILD_TIME = "2026-10-
|
|
13017
|
+
var VERSION = "0.35.2117";
|
|
13018
|
+
var GIT_SHA = "03d1dfc";
|
|
13019
|
+
var BUILD_TIME = "2026-10-12T20:08:12.374Z";
|
|
13081
13020
|
var SEMVER = {
|
|
13082
|
-
version: "0.35.
|
|
13083
|
-
gitSha: "
|
|
13084
|
-
buildTime: "2026-10-
|
|
13021
|
+
version: "0.35.2117",
|
|
13022
|
+
gitSha: "03d1dfc",
|
|
13023
|
+
buildTime: "2026-10-12T20:08:12.374Z"
|
|
13085
13024
|
};
|
|
13086
13025
|
|
|
13087
13026
|
Object.defineProperty(exports, "CONTENT_GROUPING_DIMENSIONS", {
|
|
@@ -13219,6 +13158,7 @@ exports.queryBlockPreview = queryBlockPreview;
|
|
|
13219
13158
|
exports.readSessionRpe = readSessionRpe;
|
|
13220
13159
|
exports.readStoredUnit = readStoredUnit;
|
|
13221
13160
|
exports.registerCustomCompletionSource = registerCustomCompletionSource;
|
|
13161
|
+
exports.registeredSectionWidgets = registeredSectionWidgets;
|
|
13222
13162
|
exports.removeRuntimePanel = removeRuntimePanel;
|
|
13223
13163
|
exports.resolveQueryDraft = resolveQueryDraft;
|
|
13224
13164
|
exports.runtimePanelField = runtimePanelField;
|
|
@@ -13226,6 +13166,11 @@ exports.saveBlockQuerySource = saveBlockQuerySource;
|
|
|
13226
13166
|
exports.sectionAtPos = sectionAtPos;
|
|
13227
13167
|
exports.sectionField = sectionField;
|
|
13228
13168
|
exports.sectionGeometry = sectionGeometry;
|
|
13169
|
+
exports.sectionIdentity = sectionIdentity;
|
|
13170
|
+
exports.sectionIdentityHistory = sectionIdentityHistory;
|
|
13171
|
+
exports.sectionMove = sectionMove;
|
|
13172
|
+
exports.sectionRestore = sectionRestore;
|
|
13173
|
+
exports.sectionSaved = sectionSaved;
|
|
13229
13174
|
exports.sessionQueryInsert = sessionQueryInsert;
|
|
13230
13175
|
exports.sessionQueryWql = sessionQueryWql;
|
|
13231
13176
|
exports.setGutterHighlights = setGutterHighlights;
|