|
@@ -11,7 +11,9 @@ const findAllDrawioSection = (view?: EditorView) => {
|
|
|
}
|
|
}
|
|
|
const lineBeginPartOfDrawioRE = /^```(\s.*)drawio$/;
|
|
const lineBeginPartOfDrawioRE = /^```(\s.*)drawio$/;
|
|
|
const lineNumbers: number[] = [];
|
|
const lineNumbers: number[] = [];
|
|
|
|
|
+ // repeat the process in each line from the top to the bottom in the editor
|
|
|
for (let i = 1, e = view.state.doc.lines; i <= e; i++) {
|
|
for (let i = 1, e = view.state.doc.lines; i <= e; i++) {
|
|
|
|
|
+ // get each line text
|
|
|
const lineTxt = view.state.doc.line(i).text;
|
|
const lineTxt = view.state.doc.line(i).text;
|
|
|
const match = lineBeginPartOfDrawioRE.exec(lineTxt);
|
|
const match = lineBeginPartOfDrawioRE.exec(lineTxt);
|
|
|
if (match) {
|
|
if (match) {
|
|
@@ -26,7 +28,9 @@ const foldDrawioSection = (lineNumbers?: number[], view?: EditorView) => {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
lineNumbers.forEach((lineNumber) => {
|
|
lineNumbers.forEach((lineNumber) => {
|
|
|
|
|
+ // get the end of the lines containing '''drawio
|
|
|
const from = view.state.doc.line(lineNumber).to;
|
|
const from = view.state.doc.line(lineNumber).to;
|
|
|
|
|
+ // get the end of the lines containing '''
|
|
|
const to = view.state.doc.line(lineNumber + 2).to;
|
|
const to = view.state.doc.line(lineNumber + 2).to;
|
|
|
view?.dispatch({
|
|
view?.dispatch({
|
|
|
effects: foldEffect.of({
|
|
effects: foldEffect.of({
|