0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-28 00:43:08 +00:00

add the concept of widgets and widget fields

This commit is contained in:
Charlie Humphreys
2023-06-10 13:02:13 -05:00
parent 7d30abc4d9
commit b6d37dd825
9 changed files with 485 additions and 6 deletions

View File

@@ -0,0 +1,26 @@
module.exports = {
registerHomebreweryHelper : function(CodeMirror) {
CodeMirror.registerHelper('fold', 'homebrewery', function(cm, start) {
const matcher = /^\\page.*/;
const prevLine = cm.getLine(start.line - 1);
if(start.line === cm.firstLine() || prevLine.match(matcher)) {
const lastLineNo = cm.lastLine();
let end = start.line;
while (end < lastLineNo) {
if(cm.getLine(end + 1).match(matcher))
break;
++end;
}
return {
from : CodeMirror.Pos(start.line, 0),
to : CodeMirror.Pos(end, cm.getLine(end).length)
};
}
return null;
});
}
};