@oml/markdown 0.11.0 → 0.13.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/out/md/md-execution.d.ts +16 -0
- package/out/md/md-executor.d.ts +1 -0
- package/out/md/md-executor.js +219 -35
- package/out/md/md-executor.js.map +1 -1
- package/out/renderers/diagram-renderer.js +160 -1
- package/out/renderers/diagram-renderer.js.map +1 -1
- package/out/renderers/graph-renderer.js +452 -18
- package/out/renderers/graph-renderer.js.map +1 -1
- package/out/renderers/matrix-renderer.d.ts +0 -2
- package/out/renderers/matrix-renderer.js +45 -40
- package/out/renderers/matrix-renderer.js.map +1 -1
- package/out/renderers/renderer.d.ts +4 -1
- package/out/renderers/renderer.js +98 -0
- package/out/renderers/renderer.js.map +1 -1
- package/out/renderers/table-renderer.d.ts +4 -2
- package/out/renderers/table-renderer.js +104 -38
- package/out/renderers/table-renderer.js.map +1 -1
- package/out/renderers/types.d.ts +16 -0
- package/out/renderers/wikilink-utils.d.ts +1 -0
- package/out/renderers/wikilink-utils.js +60 -32
- package/out/renderers/wikilink-utils.js.map +1 -1
- package/out/static/browser-runtime.bundle.js +7452 -1297
- package/out/static/browser-runtime.bundle.js.map +4 -4
- package/out/static/browser-runtime.js +15 -2
- package/out/static/browser-runtime.js.map +1 -1
- package/package.json +2 -2
- package/src/md/md-execution.ts +20 -0
- package/src/md/md-executor.ts +268 -40
- package/src/renderers/diagram-renderer.ts +167 -1
- package/src/renderers/graph-renderer.ts +512 -12
- package/src/renderers/matrix-renderer.ts +57 -44
- package/src/renderers/renderer.ts +105 -1
- package/src/renderers/table-renderer.ts +151 -39
- package/src/renderers/types.ts +20 -0
- package/src/renderers/wikilink-utils.ts +66 -31
- package/src/static/browser-runtime.ts +20 -2
- package/src/static/markdown-webview.css +44 -15
|
@@ -11,7 +11,7 @@ const TYPE_IRIS = {
|
|
|
11
11
|
};
|
|
12
12
|
const LIST_ITEM_IRI = `${D}ListItem`;
|
|
13
13
|
const CSS_EDITOR_FOREGROUND = 'var(--vscode-editor-foreground, var(--oml-static-foreground, #24292f))';
|
|
14
|
-
const CSS_EDITOR_BACKGROUND = 'var(--vscode-editor-background,
|
|
14
|
+
const CSS_EDITOR_BACKGROUND = 'var(--vscode-editor-background, var(--oml-static-background, #ffffff))';
|
|
15
15
|
const CSS_CANVAS_BACKGROUND = 'var(--vscode-editor-background, var(--oml-static-background, #ffffff))';
|
|
16
16
|
const CSS_FOCUS_BORDER = 'var(--vscode-focusBorder, var(--oml-static-link, #0969da))';
|
|
17
17
|
let diagramCanvasSeq = 0;
|
|
@@ -114,6 +114,7 @@ async function renderWithX6(canvas, baseId, graph, layoutOptions, actions) {
|
|
|
114
114
|
minScale: 0.4,
|
|
115
115
|
maxScale: 2.5,
|
|
116
116
|
factor: 1.1,
|
|
117
|
+
modifiers: ['meta', 'ctrl'],
|
|
117
118
|
},
|
|
118
119
|
connecting: {
|
|
119
120
|
router: 'normal',
|
|
@@ -147,9 +148,75 @@ async function renderWithX6(canvas, baseId, graph, layoutOptions, actions) {
|
|
|
147
148
|
return;
|
|
148
149
|
}
|
|
149
150
|
boundPortContainers.add(container);
|
|
151
|
+
const portIri = String(port.id ?? '').trim();
|
|
152
|
+
const applyPortNativeTitle = () => {
|
|
153
|
+
if (!portIri) {
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
container.setAttribute('title', portIri);
|
|
157
|
+
for (const element of Array.from(container.querySelectorAll('*'))) {
|
|
158
|
+
element.setAttribute('title', portIri);
|
|
159
|
+
if (element instanceof SVGElement) {
|
|
160
|
+
let titleNode = null;
|
|
161
|
+
for (const child of Array.from(element.children)) {
|
|
162
|
+
if (child instanceof SVGTitleElement) {
|
|
163
|
+
titleNode = child;
|
|
164
|
+
break;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
if (!titleNode) {
|
|
168
|
+
titleNode = document.createElementNS('http://www.w3.org/2000/svg', 'title');
|
|
169
|
+
element.insertBefore(titleNode, element.firstChild);
|
|
170
|
+
}
|
|
171
|
+
titleNode.textContent = portIri;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
};
|
|
150
175
|
container.setAttribute('data-port-id', String(port.id));
|
|
176
|
+
applyPortNativeTitle();
|
|
151
177
|
container.style.cursor = 'grab';
|
|
152
178
|
container.style.touchAction = 'none';
|
|
179
|
+
container.addEventListener('mouseenter', (event) => {
|
|
180
|
+
const iri = portIri;
|
|
181
|
+
if (!iri) {
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
applyPortNativeTitle();
|
|
185
|
+
const rect = container.getBoundingClientRect();
|
|
186
|
+
liveCanvas.dispatchEvent(new CustomEvent('md-show-iri-hover', {
|
|
187
|
+
bubbles: true,
|
|
188
|
+
detail: {
|
|
189
|
+
iri,
|
|
190
|
+
previewEnabled: /^Mac/i.test(navigator.platform) ? event.metaKey : event.ctrlKey,
|
|
191
|
+
anchorRect: {
|
|
192
|
+
left: rect.left,
|
|
193
|
+
right: rect.right,
|
|
194
|
+
top: rect.top,
|
|
195
|
+
bottom: rect.bottom,
|
|
196
|
+
width: rect.width,
|
|
197
|
+
height: rect.height,
|
|
198
|
+
},
|
|
199
|
+
},
|
|
200
|
+
}));
|
|
201
|
+
});
|
|
202
|
+
container.addEventListener('mouseleave', () => {
|
|
203
|
+
liveCanvas.dispatchEvent(new CustomEvent('md-hide-iri-hover', { bubbles: true }));
|
|
204
|
+
});
|
|
205
|
+
container.addEventListener('dblclick', (event) => {
|
|
206
|
+
const iri = String(port.id ?? '').trim();
|
|
207
|
+
if (!iri) {
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
event.preventDefault();
|
|
211
|
+
event.stopPropagation();
|
|
212
|
+
if (typeof event.stopImmediatePropagation === 'function') {
|
|
213
|
+
event.stopImmediatePropagation();
|
|
214
|
+
}
|
|
215
|
+
liveCanvas.dispatchEvent(new CustomEvent('md-navigate-iri', {
|
|
216
|
+
bubbles: true,
|
|
217
|
+
detail: { iri },
|
|
218
|
+
}));
|
|
219
|
+
});
|
|
153
220
|
container.addEventListener('pointerdown', (event) => {
|
|
154
221
|
if (typeof graphView.cleanSelection === 'function') {
|
|
155
222
|
graphView.cleanSelection();
|
|
@@ -1101,8 +1168,100 @@ async function renderWithX6(canvas, baseId, graph, layoutOptions, actions) {
|
|
|
1101
1168
|
resizeHandle.addEventListener('pointermove', onResizePointerMove);
|
|
1102
1169
|
resizeHandle.addEventListener('pointerup', onResizePointerEnd);
|
|
1103
1170
|
resizeHandle.addEventListener('pointercancel', onResizePointerEnd);
|
|
1171
|
+
installDiagramNodeInteractions(liveCanvas, graphView);
|
|
1104
1172
|
installDiagramToolbar(liveCanvas, graphView, graph, actions);
|
|
1105
1173
|
}
|
|
1174
|
+
function installDiagramNodeInteractions(canvas, graphView) {
|
|
1175
|
+
const ensureSvgNativeTitle = (element, iri) => {
|
|
1176
|
+
let titleNode = null;
|
|
1177
|
+
for (const child of Array.from(element.children)) {
|
|
1178
|
+
if (child instanceof SVGTitleElement) {
|
|
1179
|
+
titleNode = child;
|
|
1180
|
+
break;
|
|
1181
|
+
}
|
|
1182
|
+
}
|
|
1183
|
+
if (!titleNode) {
|
|
1184
|
+
titleNode = document.createElementNS('http://www.w3.org/2000/svg', 'title');
|
|
1185
|
+
element.insertBefore(titleNode, element.firstChild);
|
|
1186
|
+
}
|
|
1187
|
+
titleNode.textContent = iri;
|
|
1188
|
+
};
|
|
1189
|
+
const applyNativeTooltipTitle = (container, iri, eventTarget) => {
|
|
1190
|
+
if (!iri) {
|
|
1191
|
+
return;
|
|
1192
|
+
}
|
|
1193
|
+
if (container instanceof HTMLElement || container instanceof SVGElement) {
|
|
1194
|
+
container.setAttribute('title', iri);
|
|
1195
|
+
}
|
|
1196
|
+
if (container instanceof Element) {
|
|
1197
|
+
for (const element of Array.from(container.querySelectorAll('*'))) {
|
|
1198
|
+
element.setAttribute('title', iri);
|
|
1199
|
+
if (element instanceof SVGElement) {
|
|
1200
|
+
ensureSvgNativeTitle(element, iri);
|
|
1201
|
+
}
|
|
1202
|
+
}
|
|
1203
|
+
if (container instanceof SVGElement) {
|
|
1204
|
+
ensureSvgNativeTitle(container, iri);
|
|
1205
|
+
}
|
|
1206
|
+
}
|
|
1207
|
+
if (eventTarget instanceof HTMLElement || eventTarget instanceof SVGElement) {
|
|
1208
|
+
eventTarget.setAttribute('title', iri);
|
|
1209
|
+
if (eventTarget instanceof SVGElement) {
|
|
1210
|
+
ensureSvgNativeTitle(eventTarget, iri);
|
|
1211
|
+
}
|
|
1212
|
+
}
|
|
1213
|
+
};
|
|
1214
|
+
const clearHover = () => {
|
|
1215
|
+
canvas.dispatchEvent(new CustomEvent('md-hide-iri-hover', { bubbles: true }));
|
|
1216
|
+
};
|
|
1217
|
+
graphView.on('node:mouseenter', ({ node, e }) => {
|
|
1218
|
+
const iri = String(node?.id ?? '');
|
|
1219
|
+
if (iri) {
|
|
1220
|
+
const view = graphView.findViewByCell?.(node);
|
|
1221
|
+
const bbox = view?.container?.getBoundingClientRect?.();
|
|
1222
|
+
applyNativeTooltipTitle(view?.container, iri, e?.target ?? null);
|
|
1223
|
+
if (!bbox) {
|
|
1224
|
+
return;
|
|
1225
|
+
}
|
|
1226
|
+
canvas.dispatchEvent(new CustomEvent('md-show-iri-hover', {
|
|
1227
|
+
bubbles: true,
|
|
1228
|
+
detail: {
|
|
1229
|
+
iri,
|
|
1230
|
+
previewEnabled: !!e && (/^Mac/i.test(navigator.platform) ? e.metaKey : e.ctrlKey),
|
|
1231
|
+
anchorRect: {
|
|
1232
|
+
left: bbox.left,
|
|
1233
|
+
right: bbox.right,
|
|
1234
|
+
top: bbox.top,
|
|
1235
|
+
bottom: bbox.bottom,
|
|
1236
|
+
width: bbox.width,
|
|
1237
|
+
height: bbox.height,
|
|
1238
|
+
},
|
|
1239
|
+
},
|
|
1240
|
+
}));
|
|
1241
|
+
}
|
|
1242
|
+
});
|
|
1243
|
+
graphView.on('node:mouseleave', () => {
|
|
1244
|
+
clearHover();
|
|
1245
|
+
});
|
|
1246
|
+
graphView.on('blank:mousemove', () => {
|
|
1247
|
+
clearHover();
|
|
1248
|
+
});
|
|
1249
|
+
graphView.on('node:dblclick', ({ node, e }) => {
|
|
1250
|
+
const iri = String(node?.id ?? '');
|
|
1251
|
+
if (!iri) {
|
|
1252
|
+
return;
|
|
1253
|
+
}
|
|
1254
|
+
e.preventDefault();
|
|
1255
|
+
e.stopPropagation();
|
|
1256
|
+
if (typeof e.stopImmediatePropagation === 'function') {
|
|
1257
|
+
e.stopImmediatePropagation();
|
|
1258
|
+
}
|
|
1259
|
+
canvas.dispatchEvent(new CustomEvent('md-navigate-iri', {
|
|
1260
|
+
bubbles: true,
|
|
1261
|
+
detail: { iri },
|
|
1262
|
+
}));
|
|
1263
|
+
});
|
|
1264
|
+
}
|
|
1106
1265
|
function installDiagramToolbar(graphRoot, graphView, graph, actions) {
|
|
1107
1266
|
const hotspot = document.createElement('div');
|
|
1108
1267
|
hotspot.className = 'graph-corner-hotspot';
|