@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.
Files changed (37) hide show
  1. package/out/md/md-execution.d.ts +16 -0
  2. package/out/md/md-executor.d.ts +1 -0
  3. package/out/md/md-executor.js +219 -35
  4. package/out/md/md-executor.js.map +1 -1
  5. package/out/renderers/diagram-renderer.js +160 -1
  6. package/out/renderers/diagram-renderer.js.map +1 -1
  7. package/out/renderers/graph-renderer.js +452 -18
  8. package/out/renderers/graph-renderer.js.map +1 -1
  9. package/out/renderers/matrix-renderer.d.ts +0 -2
  10. package/out/renderers/matrix-renderer.js +45 -40
  11. package/out/renderers/matrix-renderer.js.map +1 -1
  12. package/out/renderers/renderer.d.ts +4 -1
  13. package/out/renderers/renderer.js +98 -0
  14. package/out/renderers/renderer.js.map +1 -1
  15. package/out/renderers/table-renderer.d.ts +4 -2
  16. package/out/renderers/table-renderer.js +104 -38
  17. package/out/renderers/table-renderer.js.map +1 -1
  18. package/out/renderers/types.d.ts +16 -0
  19. package/out/renderers/wikilink-utils.d.ts +1 -0
  20. package/out/renderers/wikilink-utils.js +60 -32
  21. package/out/renderers/wikilink-utils.js.map +1 -1
  22. package/out/static/browser-runtime.bundle.js +7452 -1297
  23. package/out/static/browser-runtime.bundle.js.map +4 -4
  24. package/out/static/browser-runtime.js +15 -2
  25. package/out/static/browser-runtime.js.map +1 -1
  26. package/package.json +2 -2
  27. package/src/md/md-execution.ts +20 -0
  28. package/src/md/md-executor.ts +268 -40
  29. package/src/renderers/diagram-renderer.ts +167 -1
  30. package/src/renderers/graph-renderer.ts +512 -12
  31. package/src/renderers/matrix-renderer.ts +57 -44
  32. package/src/renderers/renderer.ts +105 -1
  33. package/src/renderers/table-renderer.ts +151 -39
  34. package/src/renderers/types.ts +20 -0
  35. package/src/renderers/wikilink-utils.ts +66 -31
  36. package/src/static/browser-runtime.ts +20 -2
  37. package/src/static/markdown-webview.css +44 -15
@@ -109,7 +109,7 @@ const TYPE_IRIS: Readonly<Record<NodeKind | 'Edge', string>> = {
109
109
  };
110
110
  const LIST_ITEM_IRI = `${D}ListItem`;
111
111
  const CSS_EDITOR_FOREGROUND = 'var(--vscode-editor-foreground, var(--oml-static-foreground, #24292f))';
112
- const CSS_EDITOR_BACKGROUND = 'var(--vscode-editor-background, transparent)';
112
+ const CSS_EDITOR_BACKGROUND = 'var(--vscode-editor-background, var(--oml-static-background, #ffffff))';
113
113
  const CSS_CANVAS_BACKGROUND = 'var(--vscode-editor-background, var(--oml-static-background, #ffffff))';
114
114
  const CSS_FOCUS_BORDER = 'var(--vscode-focusBorder, var(--oml-static-link, #0969da))';
115
115
 
@@ -242,6 +242,7 @@ async function renderWithX6(
242
242
  minScale: 0.4,
243
243
  maxScale: 2.5,
244
244
  factor: 1.1,
245
+ modifiers: ['meta', 'ctrl'],
245
246
  },
246
247
  connecting: {
247
248
  router: 'normal',
@@ -275,9 +276,75 @@ async function renderWithX6(
275
276
  return;
276
277
  }
277
278
  boundPortContainers.add(container);
279
+ const portIri = String(port.id ?? '').trim();
280
+ const applyPortNativeTitle = (): void => {
281
+ if (!portIri) {
282
+ return;
283
+ }
284
+ container.setAttribute('title', portIri);
285
+ for (const element of Array.from(container.querySelectorAll<HTMLElement | SVGElement>('*'))) {
286
+ element.setAttribute('title', portIri);
287
+ if (element instanceof SVGElement) {
288
+ let titleNode: SVGTitleElement | null = null;
289
+ for (const child of Array.from(element.children)) {
290
+ if (child instanceof SVGTitleElement) {
291
+ titleNode = child;
292
+ break;
293
+ }
294
+ }
295
+ if (!titleNode) {
296
+ titleNode = document.createElementNS('http://www.w3.org/2000/svg', 'title');
297
+ element.insertBefore(titleNode, element.firstChild);
298
+ }
299
+ titleNode.textContent = portIri;
300
+ }
301
+ }
302
+ };
278
303
  container.setAttribute('data-port-id', String(port.id));
304
+ applyPortNativeTitle();
279
305
  container.style.cursor = 'grab';
280
306
  container.style.touchAction = 'none';
307
+ container.addEventListener('mouseenter', (event: MouseEvent) => {
308
+ const iri = portIri;
309
+ if (!iri) {
310
+ return;
311
+ }
312
+ applyPortNativeTitle();
313
+ const rect = container.getBoundingClientRect();
314
+ liveCanvas.dispatchEvent(new CustomEvent('md-show-iri-hover', {
315
+ bubbles: true,
316
+ detail: {
317
+ iri,
318
+ previewEnabled: /^Mac/i.test(navigator.platform) ? event.metaKey : event.ctrlKey,
319
+ anchorRect: {
320
+ left: rect.left,
321
+ right: rect.right,
322
+ top: rect.top,
323
+ bottom: rect.bottom,
324
+ width: rect.width,
325
+ height: rect.height,
326
+ },
327
+ },
328
+ }));
329
+ });
330
+ container.addEventListener('mouseleave', () => {
331
+ liveCanvas.dispatchEvent(new CustomEvent('md-hide-iri-hover', { bubbles: true }));
332
+ });
333
+ container.addEventListener('dblclick', (event: MouseEvent) => {
334
+ const iri = String(port.id ?? '').trim();
335
+ if (!iri) {
336
+ return;
337
+ }
338
+ event.preventDefault();
339
+ event.stopPropagation();
340
+ if (typeof event.stopImmediatePropagation === 'function') {
341
+ event.stopImmediatePropagation();
342
+ }
343
+ liveCanvas.dispatchEvent(new CustomEvent('md-navigate-iri', {
344
+ bubbles: true,
345
+ detail: { iri },
346
+ }));
347
+ });
281
348
  container.addEventListener('pointerdown', (event: PointerEvent) => {
282
349
  if (typeof graphView.cleanSelection === 'function') {
283
350
  graphView.cleanSelection();
@@ -1208,10 +1275,109 @@ async function renderWithX6(
1208
1275
  resizeHandle.addEventListener('pointerup', onResizePointerEnd);
1209
1276
  resizeHandle.addEventListener('pointercancel', onResizePointerEnd);
1210
1277
 
1278
+ installDiagramNodeInteractions(liveCanvas, graphView);
1211
1279
  installDiagramToolbar(liveCanvas, graphView, graph, actions);
1212
1280
 
1213
1281
  }
1214
1282
 
1283
+ function installDiagramNodeInteractions(canvas: HTMLElement, graphView: any): void {
1284
+ const ensureSvgNativeTitle = (element: SVGElement, iri: string): void => {
1285
+ let titleNode: SVGTitleElement | null = null;
1286
+ for (const child of Array.from(element.children)) {
1287
+ if (child instanceof SVGTitleElement) {
1288
+ titleNode = child;
1289
+ break;
1290
+ }
1291
+ }
1292
+ if (!titleNode) {
1293
+ titleNode = document.createElementNS('http://www.w3.org/2000/svg', 'title');
1294
+ element.insertBefore(titleNode, element.firstChild);
1295
+ }
1296
+ titleNode.textContent = iri;
1297
+ };
1298
+
1299
+ const applyNativeTooltipTitle = (container: Element | undefined, iri: string, eventTarget?: EventTarget | null): void => {
1300
+ if (!iri) {
1301
+ return;
1302
+ }
1303
+ if (container instanceof HTMLElement || container instanceof SVGElement) {
1304
+ container.setAttribute('title', iri);
1305
+ }
1306
+ if (container instanceof Element) {
1307
+ for (const element of Array.from(container.querySelectorAll<HTMLElement | SVGElement>('*'))) {
1308
+ element.setAttribute('title', iri);
1309
+ if (element instanceof SVGElement) {
1310
+ ensureSvgNativeTitle(element, iri);
1311
+ }
1312
+ }
1313
+ if (container instanceof SVGElement) {
1314
+ ensureSvgNativeTitle(container, iri);
1315
+ }
1316
+ }
1317
+ if (eventTarget instanceof HTMLElement || eventTarget instanceof SVGElement) {
1318
+ eventTarget.setAttribute('title', iri);
1319
+ if (eventTarget instanceof SVGElement) {
1320
+ ensureSvgNativeTitle(eventTarget, iri);
1321
+ }
1322
+ }
1323
+ };
1324
+
1325
+ const clearHover = (): void => {
1326
+ canvas.dispatchEvent(new CustomEvent('md-hide-iri-hover', { bubbles: true }));
1327
+ };
1328
+
1329
+ graphView.on('node:mouseenter', ({ node, e }: { node: any; e?: MouseEvent }) => {
1330
+ const iri = String(node?.id ?? '');
1331
+ if (iri) {
1332
+ const view = graphView.findViewByCell?.(node);
1333
+ const bbox = view?.container?.getBoundingClientRect?.();
1334
+ applyNativeTooltipTitle(view?.container as Element | undefined, iri, e?.target ?? null);
1335
+ if (!bbox) {
1336
+ return;
1337
+ }
1338
+ canvas.dispatchEvent(new CustomEvent('md-show-iri-hover', {
1339
+ bubbles: true,
1340
+ detail: {
1341
+ iri,
1342
+ previewEnabled: !!e && (/^Mac/i.test(navigator.platform) ? e.metaKey : e.ctrlKey),
1343
+ anchorRect: {
1344
+ left: bbox.left,
1345
+ right: bbox.right,
1346
+ top: bbox.top,
1347
+ bottom: bbox.bottom,
1348
+ width: bbox.width,
1349
+ height: bbox.height,
1350
+ },
1351
+ },
1352
+ }));
1353
+ }
1354
+ });
1355
+
1356
+ graphView.on('node:mouseleave', () => {
1357
+ clearHover();
1358
+ });
1359
+
1360
+ graphView.on('blank:mousemove', () => {
1361
+ clearHover();
1362
+ });
1363
+
1364
+ graphView.on('node:dblclick', ({ node, e }: { node: any; e: MouseEvent }) => {
1365
+ const iri = String(node?.id ?? '');
1366
+ if (!iri) {
1367
+ return;
1368
+ }
1369
+ e.preventDefault();
1370
+ e.stopPropagation();
1371
+ if (typeof (e as any).stopImmediatePropagation === 'function') {
1372
+ (e as any).stopImmediatePropagation();
1373
+ }
1374
+ canvas.dispatchEvent(new CustomEvent('md-navigate-iri', {
1375
+ bubbles: true,
1376
+ detail: { iri },
1377
+ }));
1378
+ });
1379
+ }
1380
+
1215
1381
  function installDiagramToolbar(
1216
1382
  graphRoot: HTMLElement,
1217
1383
  graphView: any,