summaryrefslogtreecommitdiff
path: root/static/js/codemirror/tablist.js
diff options
context:
space:
mode:
authorAnson Bridges <bridges.anson@gmail.com>2025-08-11 22:24:05 -0700
committerAnson Bridges <bridges.anson@gmail.com>2025-08-11 22:24:05 -0700
commit02284958a1189ffcb10b34a4c3a02417f8136a4d (patch)
tree837aac77184a3435ee686dd33878b9f2715c94b1 /static/js/codemirror/tablist.js
Initialize git repo from local project filesHEADmaster
Diffstat (limited to 'static/js/codemirror/tablist.js')
-rw-r--r--static/js/codemirror/tablist.js44
1 files changed, 44 insertions, 0 deletions
diff --git a/static/js/codemirror/tablist.js b/static/js/codemirror/tablist.js
new file mode 100644
index 0000000..e6cf2d4
--- /dev/null
+++ b/static/js/codemirror/tablist.js
@@ -0,0 +1,44 @@
+// CodeMirror, copyright (c) by Marijn Haverbeke and others
+// Distributed under an MIT license: http://codemirror.net/LICENSE
+
+var CodeMirror = require("codemirror");
+
+CodeMirror.commands.tabAndIndentMarkdownList = function (cm) {
+ var ranges = cm.listSelections();
+ var pos = ranges[0].head;
+ var eolState = cm.getStateAfter(pos.line);
+ var inList = eolState.list !== false;
+
+ if (inList) {
+ cm.execCommand("indentMore");
+ return;
+ }
+
+ if (cm.options.indentWithTabs) {
+ cm.execCommand("insertTab");
+ }
+ else {
+ var spaces = Array(cm.options.tabSize + 1).join(" ");
+ cm.replaceSelection(spaces);
+ }
+};
+
+CodeMirror.commands.shiftTabAndUnindentMarkdownList = function (cm) {
+ var ranges = cm.listSelections();
+ var pos = ranges[0].head;
+ var eolState = cm.getStateAfter(pos.line);
+ var inList = eolState.list !== false;
+
+ if (inList) {
+ cm.execCommand("indentLess");
+ return;
+ }
+
+ if (cm.options.indentWithTabs) {
+ cm.execCommand("insertTab");
+ }
+ else {
+ var spaces = Array(cm.options.tabSize + 1).join(" ");
+ cm.replaceSelection(spaces);
+ }
+};