mrmd-editor 0.7.1 → 0.8.0
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/package.json +3 -1
- package/src/commands.js +112 -4
- package/src/comment-syntax.js +364 -39
- package/src/config/handlers.js +1 -2
- package/src/config/schema.js +46 -4
- package/src/document-template.js +2236 -0
- package/src/frontmatter-updater.js +204 -74
- package/src/grammar.js +758 -0
- package/src/index.js +1074 -55
- package/src/keymap.js +11 -2
- package/src/markdown/block-decorations.js +108 -5
- package/src/markdown/facets.js +37 -0
- package/src/markdown/html-inline.js +9 -5
- package/src/markdown/index.js +13 -3
- package/src/markdown/inline-commands.js +256 -0
- package/src/markdown/inline-model.js +578 -0
- package/src/markdown/inline-state.js +103 -0
- package/src/markdown/renderer.js +219 -12
- package/src/markdown/styles.js +290 -3
- package/src/markdown/widgets/alert-title.js +10 -8
- package/src/markdown/widgets/frontmatter.js +0 -6
- package/src/markdown/widgets/index.js +1 -0
- package/src/markdown/widgets/list-marker.js +29 -0
- package/src/markdown/wysiwyg.js +1158 -0
- package/src/mrp-types.js +2 -0
- package/src/output-widget.js +532 -18
- package/src/page-view-pagination.js +127 -0
- package/src/runtime-lsp.js +1757 -150
- package/src/section-controls/commands.js +617 -0
- package/src/section-controls/index.js +63 -0
- package/src/section-controls/plugin.js +165 -0
- package/src/section-controls/widgets.js +936 -0
- package/src/shell/ai-menu.js +11 -0
- package/src/shell/components/context-panel.js +572 -0
- package/src/shell/components/status-bar.js +10 -2
- package/src/shell/layouts/studio.js +206 -14
- package/src/shell/orchestrator-client.js +69 -0
- package/src/spellcheck.js +166 -0
- package/src/tables/README.md +97 -0
- package/src/tables/commands/insert-linked-table.js +122 -0
- package/src/tables/commands/open-table-workspace.js +43 -0
- package/src/tables/index.js +24 -0
- package/src/tables/jobs/client.js +158 -0
- package/src/tables/parsing/anchors.js +82 -0
- package/src/tables/parsing/linked-table-blocks.js +61 -0
- package/src/tables/state/linked-table-state.js +68 -0
- package/src/tables/widgets/linked-table-source-banner.js +77 -0
- package/src/tables/widgets/linked-table-widget.js +256 -0
- package/src/tables/workspace/controller.js +616 -0
- package/src/term-pty-client.js +51 -2
- package/src/term-widget.js +43 -3
- package/src/widgets/theme-utils.js +24 -16
- package/src/widgets/theme.js +1015 -1
- package/src/runtime-codelens/detector.js +0 -279
- package/src/runtime-codelens/index.js +0 -76
- package/src/runtime-codelens/plugin.js +0 -142
- package/src/runtime-codelens/styles.js +0 -184
- package/src/runtime-codelens/widgets.js +0 -216
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Page View Pagination
|
|
3
|
+
*
|
|
4
|
+
* Adds per-line bottom padding so content is pushed to the next visual page.
|
|
5
|
+
* This uses Decoration.line (not block widgets), because CodeMirror does not
|
|
6
|
+
* allow block decorations from ViewPlugins.
|
|
7
|
+
*
|
|
8
|
+
* @module page-view-pagination
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { ViewPlugin, Decoration } from '@codemirror/view';
|
|
12
|
+
|
|
13
|
+
const PAGE_BREAK_RE = /^\\(pagebreak|newpage)$/;
|
|
14
|
+
const HTML_PAGE_BREAK_RE = /^<div\s+style\s*=\s*["']page-break-after:\s*always;?["']\s*>\s*<\/div>$/i;
|
|
15
|
+
|
|
16
|
+
function getPageDimensions(view) {
|
|
17
|
+
if (!document.body.classList.contains('page-view-active')) return null;
|
|
18
|
+
if (!document.body.classList.contains('page-breaks-active')) return null;
|
|
19
|
+
|
|
20
|
+
const el = document.getElementById('editor-container');
|
|
21
|
+
if (!el) return null;
|
|
22
|
+
|
|
23
|
+
const read = (prop, fallback) => {
|
|
24
|
+
const inline = parseFloat(el.style.getPropertyValue(prop));
|
|
25
|
+
if (inline > 0) return inline;
|
|
26
|
+
const computed = parseFloat(getComputedStyle(el).getPropertyValue(prop));
|
|
27
|
+
return computed > 0 ? computed : fallback;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const pageHeight = read('--page-view-height', 0);
|
|
31
|
+
if (!pageHeight) return null;
|
|
32
|
+
|
|
33
|
+
return {
|
|
34
|
+
pageHeight,
|
|
35
|
+
gap: read('--page-view-gap', 40),
|
|
36
|
+
marginTop: read('--page-view-margin-top', 96),
|
|
37
|
+
marginBottom: read('--page-view-margin-bottom', 96),
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function buildPageBreaks(view) {
|
|
42
|
+
const dims = getPageDimensions(view);
|
|
43
|
+
if (!dims) return Decoration.none;
|
|
44
|
+
|
|
45
|
+
const { pageHeight, gap, marginTop, marginBottom } = dims;
|
|
46
|
+
const contentArea = pageHeight - marginTop - marginBottom;
|
|
47
|
+
if (contentArea <= 0) return Decoration.none;
|
|
48
|
+
|
|
49
|
+
const doc = view.state.doc;
|
|
50
|
+
const decorations = [];
|
|
51
|
+
let used = 0;
|
|
52
|
+
let pos = 0;
|
|
53
|
+
let previousLineFrom = null;
|
|
54
|
+
|
|
55
|
+
while (pos <= doc.length) {
|
|
56
|
+
const block = view.lineBlockAt(pos);
|
|
57
|
+
const height = block.height;
|
|
58
|
+
const text = doc.sliceString(block.from, block.to).trim();
|
|
59
|
+
const isManualBreak = PAGE_BREAK_RE.test(text) || HTML_PAGE_BREAK_RE.test(text);
|
|
60
|
+
|
|
61
|
+
if (isManualBreak) {
|
|
62
|
+
const padding = Math.max(0, pageHeight + gap - used - height);
|
|
63
|
+
decorations.push(
|
|
64
|
+
Decoration.line({
|
|
65
|
+
attributes: {
|
|
66
|
+
class: 'cm-page-break-padding-line',
|
|
67
|
+
style: `padding-bottom: ${padding}px`,
|
|
68
|
+
},
|
|
69
|
+
}).range(block.from),
|
|
70
|
+
);
|
|
71
|
+
used = 0;
|
|
72
|
+
previousLineFrom = block.from;
|
|
73
|
+
} else if (used > 0 && used + height > contentArea && previousLineFrom != null) {
|
|
74
|
+
const padding = Math.max(0, pageHeight + gap - used);
|
|
75
|
+
decorations.push(
|
|
76
|
+
Decoration.line({
|
|
77
|
+
attributes: {
|
|
78
|
+
class: 'cm-page-break-padding-line',
|
|
79
|
+
style: `padding-bottom: ${padding}px`,
|
|
80
|
+
},
|
|
81
|
+
}).range(previousLineFrom),
|
|
82
|
+
);
|
|
83
|
+
used = height;
|
|
84
|
+
previousLineFrom = block.from;
|
|
85
|
+
} else {
|
|
86
|
+
used += height;
|
|
87
|
+
previousLineFrom = block.from;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (block.to >= doc.length) break;
|
|
91
|
+
pos = block.to + 1;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return Decoration.set(decorations, true);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export const pageViewPagination = ViewPlugin.fromClass(
|
|
98
|
+
class {
|
|
99
|
+
constructor(view) {
|
|
100
|
+
this.pageBreaksEnabled = document.body.classList.contains('page-breaks-active');
|
|
101
|
+
this.pageViewEnabled = document.body.classList.contains('page-view-active');
|
|
102
|
+
this.decorations = buildPageBreaks(view);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
update(update) {
|
|
106
|
+
const pageBreaksEnabled = document.body.classList.contains('page-breaks-active');
|
|
107
|
+
const pageViewEnabled = document.body.classList.contains('page-view-active');
|
|
108
|
+
const modeChanged =
|
|
109
|
+
pageBreaksEnabled !== this.pageBreaksEnabled || pageViewEnabled !== this.pageViewEnabled;
|
|
110
|
+
|
|
111
|
+
if (
|
|
112
|
+
modeChanged ||
|
|
113
|
+
update.docChanged ||
|
|
114
|
+
update.geometryChanged ||
|
|
115
|
+
update.viewportChanged ||
|
|
116
|
+
update.selectionSet
|
|
117
|
+
) {
|
|
118
|
+
this.pageBreaksEnabled = pageBreaksEnabled;
|
|
119
|
+
this.pageViewEnabled = pageViewEnabled;
|
|
120
|
+
this.decorations = buildPageBreaks(update.view);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
decorations: (v) => v.decorations,
|
|
126
|
+
},
|
|
127
|
+
);
|