Folding outliner commands #13
parent
e682e13dab
commit
6b0bf3c960
|
@ -68,7 +68,8 @@ const WikiLink: MarkdownConfig = {
|
|||
],
|
||||
};
|
||||
|
||||
export const commandLinkRegex = /^\{\[([^\]\|]+)(\|([^\]]+))?\](\(([^\)]+)\))?\}/;
|
||||
export const commandLinkRegex =
|
||||
/^\{\[([^\]\|]+)(\|([^\]]+))?\](\(([^\)]+)\))?\}/;
|
||||
|
||||
const CommandLink: MarkdownConfig = {
|
||||
defineNodes: [
|
||||
|
@ -107,7 +108,8 @@ const CommandLink: MarkdownConfig = {
|
|||
|
||||
let argsElts: any[] = [];
|
||||
if (argsPart) {
|
||||
const argsStartPos = pos + 2 + command.length + (pipePart?.length ?? 0);
|
||||
const argsStartPos = pos + 2 + command.length +
|
||||
(pipePart?.length ?? 0);
|
||||
argsElts = [
|
||||
cx.elt("CommandLinkMark", argsStartPos, argsStartPos + 2),
|
||||
cx.elt(
|
||||
|
@ -270,6 +272,8 @@ const directiveEnd = /^\s*<!--\s*\/(.*?)-->\s*/;
|
|||
import { parser as directiveParser } from "./parse-query.js";
|
||||
import { parser as expressionParser } from "./parse-expression.js";
|
||||
import { Table } from "./table_parser.ts";
|
||||
import { foldNodeProp } from "@codemirror/language";
|
||||
import { lezerToParseTree } from "./parse_tree.ts";
|
||||
|
||||
export const highlightingDirectiveParser = directiveParser.configure({
|
||||
props: [
|
||||
|
@ -453,9 +457,19 @@ export default function buildMarkdown(mdExtensions: MDExt[]): Language {
|
|||
Strikethrough,
|
||||
Table,
|
||||
...mdExtensions.map(mdExtensionSyntaxConfig),
|
||||
|
||||
{
|
||||
props: [
|
||||
foldNodeProp.add({
|
||||
// Don't fold at the list level
|
||||
BulletList: () => null,
|
||||
OrderedList: () => null,
|
||||
// Fold list items
|
||||
ListItem: (tree, state) => ({
|
||||
from: state.doc.lineAt(tree.from).to,
|
||||
to: tree.to,
|
||||
}),
|
||||
}),
|
||||
|
||||
styleTags({
|
||||
Task: ct.TaskTag,
|
||||
TaskMark: ct.TaskMarkTag,
|
||||
|
|
|
@ -146,35 +146,6 @@ functions:
|
|||
path: ./embed.ts:embedWidget
|
||||
codeWidget: embed
|
||||
|
||||
# Folding commands
|
||||
foldCommand:
|
||||
path: ./editor.ts:foldCommand
|
||||
command:
|
||||
name: "Fold: Fold"
|
||||
mac: "Cmd-Alt-["
|
||||
key: "Ctrl-Shift-["
|
||||
unfoldCommand:
|
||||
path: ./editor.ts:unfoldCommand
|
||||
command:
|
||||
name: "Fold: Unfold"
|
||||
mac: "Cmd-Alt-]"
|
||||
key: "Ctrl-Shift-]"
|
||||
toggleFoldCommand:
|
||||
path: ./editor.ts:toggleFoldCommand
|
||||
command:
|
||||
name: "Fold: Toggle Fold"
|
||||
mac: "Cmd-Alt-f"
|
||||
key: "Ctrl-Alt-f"
|
||||
foldAllCommand:
|
||||
path: ./editor.ts:foldAllCommand
|
||||
command:
|
||||
name: "Fold: Fold All"
|
||||
key: "Ctrl-Alt-["
|
||||
unfoldAllCommand:
|
||||
path: ./editor.ts:unfoldAllCommand
|
||||
command:
|
||||
name: "Fold: Unfold All"
|
||||
key: "Ctrl-Alt-]"
|
||||
|
||||
# Vim
|
||||
toggleVimMode:
|
||||
|
@ -227,6 +198,7 @@ functions:
|
|||
command:
|
||||
name: "Upload: File"
|
||||
|
||||
# Outline commands
|
||||
outlineMoveUp:
|
||||
path: ./outline.ts:moveItemUp
|
||||
command:
|
||||
|
@ -251,6 +223,36 @@ functions:
|
|||
name: "Outline: Move Left"
|
||||
key: "Alt-ArrowLeft"
|
||||
|
||||
# Outline folding commands
|
||||
foldCommand:
|
||||
path: ./outline.ts:foldCommand
|
||||
command:
|
||||
name: "Outline: Fold"
|
||||
key: "Alt-Shift-ArrowLeft"
|
||||
unfoldCommand:
|
||||
path: ./outline.ts:unfoldCommand
|
||||
command:
|
||||
name: "Outline: Unfold"
|
||||
key: "Alt-Shift-ArrowRight"
|
||||
toggleFoldCommand:
|
||||
path: ./outline.ts:toggleFoldCommand
|
||||
command:
|
||||
name: "Outline: Toggle Fold"
|
||||
mac: "Alt-Shift-f"
|
||||
key: "Alt-Shift-f"
|
||||
foldAllCommand:
|
||||
path: ./outline.ts:foldAllCommand
|
||||
command:
|
||||
name: "Outline: Fold All"
|
||||
key: "Alt-Shift-ArrowUp"
|
||||
unfoldAllCommand:
|
||||
path: ./outline.ts:unfoldAllCommand
|
||||
command:
|
||||
name: "Outline: Unfold All"
|
||||
key: "Alt-Shift-ArrowDown"
|
||||
|
||||
|
||||
# Demo
|
||||
customFlashMessage:
|
||||
path: editor.ts:customFlashMessage
|
||||
command:
|
||||
|
|
|
@ -17,26 +17,6 @@ export async function toggleDarkMode() {
|
|||
await editor.reloadUI();
|
||||
}
|
||||
|
||||
export async function foldCommand() {
|
||||
await editor.fold();
|
||||
}
|
||||
|
||||
export async function unfoldCommand() {
|
||||
await editor.unfold();
|
||||
}
|
||||
|
||||
export async function toggleFoldCommand() {
|
||||
await editor.toggleFold();
|
||||
}
|
||||
|
||||
export async function foldAllCommand() {
|
||||
await editor.foldAll();
|
||||
}
|
||||
|
||||
export async function unfoldAllCommand() {
|
||||
await editor.unfoldAll();
|
||||
}
|
||||
|
||||
export async function centerCursorCommand() {
|
||||
const pos = await editor.getCursor();
|
||||
await editor.moveCursor(pos, true);
|
||||
|
|
|
@ -223,3 +223,23 @@ function determineItemBounds(
|
|||
indentLevel,
|
||||
};
|
||||
}
|
||||
|
||||
export async function foldCommand() {
|
||||
await editor.fold();
|
||||
}
|
||||
|
||||
export async function unfoldCommand() {
|
||||
await editor.unfold();
|
||||
}
|
||||
|
||||
export async function toggleFoldCommand() {
|
||||
await editor.toggleFold();
|
||||
}
|
||||
|
||||
export async function foldAllCommand() {
|
||||
await editor.foldAll();
|
||||
}
|
||||
|
||||
export async function unfoldAllCommand() {
|
||||
await editor.unfoldAll();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue