@diagrammo/dgmo 0.2.8 → 0.2.9

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/dist/index.cjs CHANGED
@@ -218,6 +218,7 @@ function measureIndent(line3) {
218
218
  function parseSequenceDgmo(content) {
219
219
  const result = {
220
220
  title: null,
221
+ titleLineNumber: null,
221
222
  participants: [],
222
223
  messages: [],
223
224
  elements: [],
@@ -321,6 +322,7 @@ function parseSequenceDgmo(content) {
321
322
  }
322
323
  if (key === "title") {
323
324
  result.title = value;
325
+ result.titleLineNumber = lineNumber;
324
326
  continue;
325
327
  }
326
328
  result.options[key] = value;
@@ -989,6 +991,7 @@ function parseFlowchart(content, palette) {
989
991
  }
990
992
  if (key === "title") {
991
993
  result.title = value;
994
+ result.titleLineNumber = lineNumber;
992
995
  continue;
993
996
  }
994
997
  if (key === "direction") {
@@ -2425,7 +2428,7 @@ function renderFlowchart(container, graph, layout, palette, isDark, onClickItem,
2425
2428
  const scaledH = diagramH * scale;
2426
2429
  const offsetX = (width - scaledW) / 2;
2427
2430
  const offsetY = (height - scaledH) / 2;
2428
- const svg = d3Selection.select(container).append("svg").attr("width", width).attr("height", height).style("background", palette.bg).style("font-family", FONT_FAMILY);
2431
+ const svg = d3Selection.select(container).append("svg").attr("width", width).attr("height", height).style("font-family", FONT_FAMILY);
2429
2432
  const defs = svg.append("defs");
2430
2433
  defs.append("marker").attr("id", "fc-arrow").attr("viewBox", `0 0 ${ARROWHEAD_W} ${ARROWHEAD_H}`).attr("refX", ARROWHEAD_W).attr("refY", ARROWHEAD_H / 2).attr("markerWidth", ARROWHEAD_W).attr("markerHeight", ARROWHEAD_H).attr("orient", "auto").append("polygon").attr("points", `0,0 ${ARROWHEAD_W},${ARROWHEAD_H / 2} 0,${ARROWHEAD_H}`).attr("fill", palette.textMuted);
2431
2434
  const edgeColors = /* @__PURE__ */ new Set();
@@ -2438,7 +2441,17 @@ function renderFlowchart(container, graph, layout, palette, isDark, onClickItem,
2438
2441
  }
2439
2442
  const mainG = svg.append("g").attr("transform", `translate(${offsetX}, ${offsetY}) scale(${scale})`);
2440
2443
  if (graph.title) {
2441
- mainG.append("text").attr("x", diagramW / 2).attr("y", TITLE_FONT_SIZE).attr("text-anchor", "middle").attr("fill", palette.text).attr("font-size", TITLE_FONT_SIZE).attr("font-weight", "bold").attr("class", "fc-title").text(graph.title);
2444
+ const titleEl = mainG.append("text").attr("x", diagramW / 2).attr("y", TITLE_FONT_SIZE).attr("text-anchor", "middle").attr("fill", palette.text).attr("font-size", TITLE_FONT_SIZE).attr("font-weight", "bold").attr("class", "fc-title chart-title").style("cursor", onClickItem && graph.titleLineNumber ? "pointer" : "default").text(graph.title);
2445
+ if (graph.titleLineNumber) {
2446
+ titleEl.attr("data-line-number", graph.titleLineNumber);
2447
+ if (onClickItem) {
2448
+ titleEl.on("click", () => onClickItem(graph.titleLineNumber)).on("mouseenter", function() {
2449
+ d3Selection.select(this).attr("opacity", 0.7);
2450
+ }).on("mouseleave", function() {
2451
+ d3Selection.select(this).attr("opacity", 1);
2452
+ });
2453
+ }
2454
+ }
2442
2455
  }
2443
2456
  const contentG = mainG.append("g").attr("transform", `translate(0, ${titleOffset})`);
2444
2457
  for (const group of layout.groups) {
@@ -2472,7 +2485,7 @@ function renderFlowchart(container, graph, layout, palette, isDark, onClickItem,
2472
2485
  }
2473
2486
  }
2474
2487
  for (const node of layout.nodes) {
2475
- const nodeG = contentG.append("g").attr("transform", `translate(${node.x}, ${node.y})`).attr("class", "fc-node").attr("data-line-number", String(node.lineNumber));
2488
+ const nodeG = contentG.append("g").attr("transform", `translate(${node.x}, ${node.y})`).attr("class", "fc-node").attr("data-line-number", String(node.lineNumber)).attr("data-node-id", node.id);
2476
2489
  if (onClickItem) {
2477
2490
  nodeG.style("cursor", "pointer").on("click", () => {
2478
2491
  onClickItem(node.lineNumber);
@@ -3164,7 +3177,10 @@ function renderSequenceDiagram(container, parsed, palette, isDark, _onNavigateTo
3164
3177
  `0,0 ${ARROWHEAD_SIZE},${ARROWHEAD_SIZE / 2} 0,${ARROWHEAD_SIZE}`
3165
3178
  ).attr("fill", "none").attr("stroke", palette.text).attr("stroke-width", 1.2);
3166
3179
  if (title) {
3167
- svg.append("text").attr("x", svgWidth / 2).attr("y", 30).attr("text-anchor", "middle").attr("fill", palette.text).attr("font-size", 20).attr("font-weight", "bold").text(title);
3180
+ const titleEl = svg.append("text").attr("class", "chart-title").attr("x", svgWidth / 2).attr("y", 30).attr("text-anchor", "middle").attr("fill", palette.text).attr("font-size", 20).attr("font-weight", "bold").text(title);
3181
+ if (parsed.titleLineNumber) {
3182
+ titleEl.attr("data-line-number", parsed.titleLineNumber);
3183
+ }
3168
3184
  }
3169
3185
  for (const group of groups) {
3170
3186
  if (group.participantIds.length === 0) continue;
@@ -3754,6 +3770,7 @@ function parseChart(content, palette) {
3754
3770
  }
3755
3771
  if (key === "title") {
3756
3772
  result.title = value;
3773
+ result.titleLineNumber = lineNumber;
3757
3774
  continue;
3758
3775
  }
3759
3776
  if (key === "xlabel") {
@@ -3895,6 +3912,7 @@ function parseEChart(content, palette) {
3895
3912
  }
3896
3913
  if (key === "title") {
3897
3914
  result.title = value;
3915
+ result.titleLineNumber = lineNumber;
3898
3916
  continue;
3899
3917
  }
3900
3918
  if (key === "series") {
@@ -5256,6 +5274,7 @@ function parseD3(content, palette) {
5256
5274
  const result = {
5257
5275
  type: null,
5258
5276
  title: null,
5277
+ titleLineNumber: null,
5259
5278
  orientation: "horizontal",
5260
5279
  periods: [],
5261
5280
  data: [],
@@ -5517,6 +5536,7 @@ function parseD3(content, palette) {
5517
5536
  }
5518
5537
  if (key === "title") {
5519
5538
  result.title = line3.substring(colonIndex + 1).trim();
5539
+ result.titleLineNumber = lineNumber;
5520
5540
  if (result.type === "quadrant") {
5521
5541
  result.quadrantTitleLineNumber = lineNumber;
5522
5542
  }
@@ -5879,7 +5899,17 @@ function renderSlopeChart(container, parsed, palette, isDark, onClickItem, expor
5879
5899
  const g = svg.append("g").attr("transform", `translate(${SLOPE_MARGIN.left},${SLOPE_MARGIN.top})`);
5880
5900
  const tooltip = createTooltip(container, palette, isDark);
5881
5901
  if (title) {
5882
- svg.append("text").attr("x", width / 2).attr("y", 30).attr("text-anchor", "middle").attr("fill", textColor).attr("font-size", "20px").attr("font-weight", "700").text(title);
5902
+ const titleEl = svg.append("text").attr("class", "chart-title").attr("x", width / 2).attr("y", 30).attr("text-anchor", "middle").attr("fill", textColor).attr("font-size", "20px").attr("font-weight", "700").style("cursor", onClickItem && parsed.titleLineNumber ? "pointer" : "default").text(title);
5903
+ if (parsed.titleLineNumber) {
5904
+ titleEl.attr("data-line-number", parsed.titleLineNumber);
5905
+ if (onClickItem) {
5906
+ titleEl.on("click", () => onClickItem(parsed.titleLineNumber)).on("mouseenter", function() {
5907
+ d3Selection3.select(this).attr("opacity", 0.7);
5908
+ }).on("mouseleave", function() {
5909
+ d3Selection3.select(this).attr("opacity", 1);
5910
+ });
5911
+ }
5912
+ }
5883
5913
  }
5884
5914
  for (const period of periods) {
5885
5915
  const x = xScale(period);
@@ -6088,7 +6118,17 @@ function renderArcDiagram(container, parsed, palette, _isDark, onClickItem, expo
6088
6118
  const svg = d3Selection3.select(container).append("svg").attr("width", width).attr("height", height).style("background", bgColor);
6089
6119
  const g = svg.append("g").attr("transform", `translate(${margin.left},${margin.top})`);
6090
6120
  if (title) {
6091
- svg.append("text").attr("x", width / 2).attr("y", 30).attr("text-anchor", "middle").attr("fill", textColor).attr("font-size", "20px").attr("font-weight", "700").text(title);
6121
+ const titleEl = svg.append("text").attr("class", "chart-title").attr("x", width / 2).attr("y", 30).attr("text-anchor", "middle").attr("fill", textColor).attr("font-size", "20px").attr("font-weight", "700").style("cursor", onClickItem && parsed.titleLineNumber ? "pointer" : "default").text(title);
6122
+ if (parsed.titleLineNumber) {
6123
+ titleEl.attr("data-line-number", parsed.titleLineNumber);
6124
+ if (onClickItem) {
6125
+ titleEl.on("click", () => onClickItem(parsed.titleLineNumber)).on("mouseenter", function() {
6126
+ d3Selection3.select(this).attr("opacity", 0.7);
6127
+ }).on("mouseleave", function() {
6128
+ d3Selection3.select(this).attr("opacity", 1);
6129
+ });
6130
+ }
6131
+ }
6092
6132
  }
6093
6133
  const neighbors = /* @__PURE__ */ new Map();
6094
6134
  for (const node of nodes) neighbors.set(node, /* @__PURE__ */ new Set());
@@ -6640,7 +6680,17 @@ function renderTimeline(container, parsed, palette, isDark, onClickItem, exportD
6640
6680
  const svg = d3Selection3.select(container).append("svg").attr("width", width).attr("height", height).style("background", bgColor);
6641
6681
  const g = svg.append("g").attr("transform", `translate(${margin.left},${margin.top})`);
6642
6682
  if (title) {
6643
- svg.append("text").attr("x", width / 2).attr("y", 30).attr("text-anchor", "middle").attr("fill", textColor).attr("font-size", "20px").attr("font-weight", "700").text(title);
6683
+ const titleEl = svg.append("text").attr("class", "chart-title").attr("x", width / 2).attr("y", 30).attr("text-anchor", "middle").attr("fill", textColor).attr("font-size", "20px").attr("font-weight", "700").style("cursor", onClickItem && parsed.titleLineNumber ? "pointer" : "default").text(title);
6684
+ if (parsed.titleLineNumber) {
6685
+ titleEl.attr("data-line-number", parsed.titleLineNumber);
6686
+ if (onClickItem) {
6687
+ titleEl.on("click", () => onClickItem(parsed.titleLineNumber)).on("mouseenter", function() {
6688
+ d3Selection3.select(this).attr("opacity", 0.7);
6689
+ }).on("mouseleave", function() {
6690
+ d3Selection3.select(this).attr("opacity", 1);
6691
+ });
6692
+ }
6693
+ }
6644
6694
  }
6645
6695
  renderEras(
6646
6696
  g,
@@ -6734,7 +6784,17 @@ function renderTimeline(container, parsed, palette, isDark, onClickItem, exportD
6734
6784
  const svg = d3Selection3.select(container).append("svg").attr("width", width).attr("height", height).style("background", bgColor);
6735
6785
  const g = svg.append("g").attr("transform", `translate(${margin.left},${margin.top})`);
6736
6786
  if (title) {
6737
- svg.append("text").attr("x", width / 2).attr("y", 30).attr("text-anchor", "middle").attr("fill", textColor).attr("font-size", "20px").attr("font-weight", "700").text(title);
6787
+ const titleEl = svg.append("text").attr("class", "chart-title").attr("x", width / 2).attr("y", 30).attr("text-anchor", "middle").attr("fill", textColor).attr("font-size", "20px").attr("font-weight", "700").style("cursor", onClickItem && parsed.titleLineNumber ? "pointer" : "default").text(title);
6788
+ if (parsed.titleLineNumber) {
6789
+ titleEl.attr("data-line-number", parsed.titleLineNumber);
6790
+ if (onClickItem) {
6791
+ titleEl.on("click", () => onClickItem(parsed.titleLineNumber)).on("mouseenter", function() {
6792
+ d3Selection3.select(this).attr("opacity", 0.7);
6793
+ }).on("mouseleave", function() {
6794
+ d3Selection3.select(this).attr("opacity", 1);
6795
+ });
6796
+ }
6797
+ }
6738
6798
  }
6739
6799
  renderEras(
6740
6800
  g,
@@ -6857,7 +6917,17 @@ function renderTimeline(container, parsed, palette, isDark, onClickItem, exportD
6857
6917
  const svg = d3Selection3.select(container).append("svg").attr("width", width).attr("height", height).style("background", bgColor);
6858
6918
  const g = svg.append("g").attr("transform", `translate(${margin.left},${margin.top})`);
6859
6919
  if (title) {
6860
- svg.append("text").attr("x", width / 2).attr("y", 30).attr("text-anchor", "middle").attr("fill", textColor).attr("font-size", "20px").attr("font-weight", "700").text(title);
6920
+ const titleEl = svg.append("text").attr("class", "chart-title").attr("x", width / 2).attr("y", 30).attr("text-anchor", "middle").attr("fill", textColor).attr("font-size", "20px").attr("font-weight", "700").style("cursor", onClickItem && parsed.titleLineNumber ? "pointer" : "default").text(title);
6921
+ if (parsed.titleLineNumber) {
6922
+ titleEl.attr("data-line-number", parsed.titleLineNumber);
6923
+ if (onClickItem) {
6924
+ titleEl.on("click", () => onClickItem(parsed.titleLineNumber)).on("mouseenter", function() {
6925
+ d3Selection3.select(this).attr("opacity", 0.7);
6926
+ }).on("mouseleave", function() {
6927
+ d3Selection3.select(this).attr("opacity", 1);
6928
+ });
6929
+ }
6930
+ }
6861
6931
  }
6862
6932
  renderEras(
6863
6933
  g,
@@ -7002,7 +7072,17 @@ function renderTimeline(container, parsed, palette, isDark, onClickItem, exportD
7002
7072
  const svg = d3Selection3.select(container).append("svg").attr("width", width).attr("height", height).style("background", bgColor);
7003
7073
  const g = svg.append("g").attr("transform", `translate(${margin.left},${margin.top})`);
7004
7074
  if (title) {
7005
- svg.append("text").attr("x", width / 2).attr("y", 30).attr("text-anchor", "middle").attr("fill", textColor).attr("font-size", "20px").attr("font-weight", "700").text(title);
7075
+ const titleEl = svg.append("text").attr("class", "chart-title").attr("x", width / 2).attr("y", 30).attr("text-anchor", "middle").attr("fill", textColor).attr("font-size", "20px").attr("font-weight", "700").style("cursor", onClickItem && parsed.titleLineNumber ? "pointer" : "default").text(title);
7076
+ if (parsed.titleLineNumber) {
7077
+ titleEl.attr("data-line-number", parsed.titleLineNumber);
7078
+ if (onClickItem) {
7079
+ titleEl.on("click", () => onClickItem(parsed.titleLineNumber)).on("mouseenter", function() {
7080
+ d3Selection3.select(this).attr("opacity", 0.7);
7081
+ }).on("mouseleave", function() {
7082
+ d3Selection3.select(this).attr("opacity", 1);
7083
+ });
7084
+ }
7085
+ }
7006
7086
  }
7007
7087
  renderEras(
7008
7088
  g,
@@ -7153,7 +7233,17 @@ function renderWordCloud(container, parsed, palette, _isDark, onClickItem, expor
7153
7233
  const rotateFn = getRotateFn(cloudOptions.rotate);
7154
7234
  const svg = d3Selection3.select(container).append("svg").attr("width", width).attr("height", height).style("background", bgColor);
7155
7235
  if (title) {
7156
- svg.append("text").attr("x", width / 2).attr("y", 30).attr("text-anchor", "middle").attr("fill", textColor).attr("font-size", "20px").attr("font-weight", "700").text(title);
7236
+ const titleEl = svg.append("text").attr("class", "chart-title").attr("x", width / 2).attr("y", 30).attr("text-anchor", "middle").attr("fill", textColor).attr("font-size", "20px").attr("font-weight", "700").style("cursor", onClickItem && parsed.titleLineNumber ? "pointer" : "default").text(title);
7237
+ if (parsed.titleLineNumber) {
7238
+ titleEl.attr("data-line-number", parsed.titleLineNumber);
7239
+ if (onClickItem) {
7240
+ titleEl.on("click", () => onClickItem(parsed.titleLineNumber)).on("mouseenter", function() {
7241
+ d3Selection3.select(this).attr("opacity", 0.7);
7242
+ }).on("mouseleave", function() {
7243
+ d3Selection3.select(this).attr("opacity", 1);
7244
+ });
7245
+ }
7246
+ }
7157
7247
  }
7158
7248
  const g = svg.append("g").attr(
7159
7249
  "transform",
@@ -7203,7 +7293,10 @@ function renderWordCloudAsync(container, parsed, palette, _isDark, exportDims) {
7203
7293
  const rotateFn = getRotateFn(cloudOptions.rotate);
7204
7294
  const svg = d3Selection3.select(container).append("svg").attr("width", width).attr("height", height).style("background", bgColor);
7205
7295
  if (title) {
7206
- svg.append("text").attr("x", width / 2).attr("y", 30).attr("text-anchor", "middle").attr("fill", textColor).attr("font-size", "20px").attr("font-weight", "700").text(title);
7296
+ const titleEl = svg.append("text").attr("class", "chart-title").attr("x", width / 2).attr("y", 30).attr("text-anchor", "middle").attr("fill", textColor).attr("font-size", "20px").attr("font-weight", "700").text(title);
7297
+ if (parsed.titleLineNumber) {
7298
+ titleEl.attr("data-line-number", parsed.titleLineNumber);
7299
+ }
7207
7300
  }
7208
7301
  const g = svg.append("g").attr(
7209
7302
  "transform",
@@ -7413,7 +7506,17 @@ function renderVenn(container, parsed, palette, isDark, onClickItem, exportDims)
7413
7506
  const svg = d3Selection3.select(container).append("svg").attr("width", width).attr("height", height).style("background", bgColor);
7414
7507
  const tooltip = createTooltip(container, palette, isDark);
7415
7508
  if (title) {
7416
- svg.append("text").attr("x", width / 2).attr("y", 30).attr("text-anchor", "middle").attr("fill", textColor).attr("font-size", "20px").attr("font-weight", "700").text(title);
7509
+ const titleEl = svg.append("text").attr("class", "chart-title").attr("x", width / 2).attr("y", 30).attr("text-anchor", "middle").attr("fill", textColor).attr("font-size", "20px").attr("font-weight", "700").style("cursor", onClickItem && parsed.titleLineNumber ? "pointer" : "default").text(title);
7510
+ if (parsed.titleLineNumber) {
7511
+ titleEl.attr("data-line-number", parsed.titleLineNumber);
7512
+ if (onClickItem) {
7513
+ titleEl.on("click", () => onClickItem(parsed.titleLineNumber)).on("mouseenter", function() {
7514
+ d3Selection3.select(this).attr("opacity", 0.7);
7515
+ }).on("mouseleave", function() {
7516
+ d3Selection3.select(this).attr("opacity", 1);
7517
+ });
7518
+ }
7519
+ }
7417
7520
  }
7418
7521
  const defs = svg.append("defs");
7419
7522
  const pad = 20;
@@ -7591,10 +7694,13 @@ function renderQuadrant(container, parsed, palette, isDark, onClickItem, exportD
7591
7694
  const svg = d3Selection3.select(container).append("svg").attr("width", width).attr("height", height).style("background", bgColor);
7592
7695
  const tooltip = createTooltip(container, palette, isDark);
7593
7696
  if (title) {
7594
- const titleText = svg.append("text").attr("x", width / 2).attr("y", 30).attr("text-anchor", "middle").attr("fill", textColor).attr("font-size", "20px").attr("font-weight", "700").style(
7697
+ const titleText = svg.append("text").attr("class", "chart-title").attr("x", width / 2).attr("y", 30).attr("text-anchor", "middle").attr("fill", textColor).attr("font-size", "20px").attr("font-weight", "700").style(
7595
7698
  "cursor",
7596
7699
  onClickItem && quadrantTitleLineNumber ? "pointer" : "default"
7597
7700
  ).text(title);
7701
+ if (quadrantTitleLineNumber) {
7702
+ titleText.attr("data-line-number", quadrantTitleLineNumber);
7703
+ }
7598
7704
  if (onClickItem && quadrantTitleLineNumber) {
7599
7705
  titleText.on("click", () => onClickItem(quadrantTitleLineNumber)).on("mouseenter", function() {
7600
7706
  d3Selection3.select(this).attr("opacity", 0.7);