pyegeria 5.3.4.4.dev2__py3-none-any.whl → 5.3.4.4.dev4__py3-none-any.whl
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.
- pyegeria/mermaid_utilities.py +133 -2
- {pyegeria-5.3.4.4.dev2.dist-info → pyegeria-5.3.4.4.dev4.dist-info}/METADATA +1 -1
- {pyegeria-5.3.4.4.dev2.dist-info → pyegeria-5.3.4.4.dev4.dist-info}/RECORD +6 -6
- {pyegeria-5.3.4.4.dev2.dist-info → pyegeria-5.3.4.4.dev4.dist-info}/LICENSE +0 -0
- {pyegeria-5.3.4.4.dev2.dist-info → pyegeria-5.3.4.4.dev4.dist-info}/WHEEL +0 -0
- {pyegeria-5.3.4.4.dev2.dist-info → pyegeria-5.3.4.4.dev4.dist-info}/entry_points.txt +0 -0
pyegeria/mermaid_utilities.py
CHANGED
@@ -93,7 +93,7 @@ def parse_mermaid_code(mermaid_code):
|
|
93
93
|
return title, guid, mermaid_code
|
94
94
|
|
95
95
|
|
96
|
-
def
|
96
|
+
def old_construct_mermaid_html(mermaid_str: str) -> str:
|
97
97
|
"""Function to display a HTML code in a Jupyter notebook"""
|
98
98
|
title_label, guid, mermaid_code = parse_mermaid_code(mermaid_str)
|
99
99
|
|
@@ -131,7 +131,7 @@ def construct_mermaid_html(mermaid_str: str) -> str:
|
|
131
131
|
<script type="module">
|
132
132
|
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@11/dist/mermaid.esm.min.mjs';
|
133
133
|
|
134
|
-
mermaid.initialize({startOnLoad:
|
134
|
+
mermaid.initialize({startOnLoad: false});
|
135
135
|
await mermaid.run({
|
136
136
|
querySelector: '.mermaid',
|
137
137
|
postRenderCallback: (id) => {
|
@@ -218,6 +218,137 @@ def construct_mermaid_html(mermaid_str: str) -> str:
|
|
218
218
|
return html_section1 + html_section2 + html_section3 + mermaid_code + html_section4
|
219
219
|
|
220
220
|
|
221
|
+
def construct_mermaid_html(mermaid_str: str) -> str:
|
222
|
+
"""Function to display a HTML code in a Jupyter notebook
|
223
|
+
|
224
|
+
Constructs HTML for a single Mermaid graph with pan and zoom support.
|
225
|
+
Each call overwrites the previous graph.
|
226
|
+
|
227
|
+
:param mermaid_code: The Mermaid code for the graph.
|
228
|
+
:param graph_id: An optional unique graph ID (default is 'mermaid-graph').
|
229
|
+
:return: The HTML content for the Mermaid graph with pan and zoom enabled.
|
230
|
+
|
231
|
+
"""
|
232
|
+
title_label, guid, mermaid_code = parse_mermaid_code(mermaid_str)
|
233
|
+
|
234
|
+
graph_id = title_label.replace(" ", "_")
|
235
|
+
# Construct the HTML content with Mermaid.js initialization and zoom/pan support
|
236
|
+
mermaid_html = f"""
|
237
|
+
<!DOCTYPE html>
|
238
|
+
<html>
|
239
|
+
<head>
|
240
|
+
<script src="https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js"></script>
|
241
|
+
<script>
|
242
|
+
// Initialize Mermaid.js
|
243
|
+
window.mermaid.initialize({{
|
244
|
+
startOnLoad: true,
|
245
|
+
securityLevel: "loose",
|
246
|
+
theme: "default",
|
247
|
+
flowchart: {{
|
248
|
+
useMaxWidth: false,
|
249
|
+
htmlLabels: true,
|
250
|
+
wrap: true
|
251
|
+
}}
|
252
|
+
}});
|
253
|
+
</script>
|
254
|
+
<style>
|
255
|
+
/* Pan and zoom container styles */
|
256
|
+
.pan-zoom-container {{
|
257
|
+
overflow: hidden;
|
258
|
+
position: relative;
|
259
|
+
width: 100%;
|
260
|
+
height: 100vh;
|
261
|
+
background-color: #f4f4f4;
|
262
|
+
}}
|
263
|
+
.pan-zoom-content {{
|
264
|
+
transform-origin: 0 0;
|
265
|
+
cursor: grab;
|
266
|
+
}}
|
267
|
+
.pan-zoom-content:active {{
|
268
|
+
cursor: grabbing;
|
269
|
+
}}
|
270
|
+
</style>
|
271
|
+
</head>
|
272
|
+
<body>
|
273
|
+
<div class="pan-zoom-container">
|
274
|
+
<div id="{graph_id}" class="mermaid pan-zoom-content">
|
275
|
+
{mermaid_code}
|
276
|
+
</div>
|
277
|
+
</div>
|
278
|
+
<script>
|
279
|
+
// Enable pan and zoom
|
280
|
+
const container = document.querySelector('.pan-zoom-container');
|
281
|
+
const content = document.querySelector('.pan-zoom-content');
|
282
|
+
|
283
|
+
let scale = 1; // Current zoom level
|
284
|
+
let panX = 0; // Current x-axis pan position
|
285
|
+
let panY = 0; // Current y-axis pan position
|
286
|
+
let isDragging = false; // Mouse dragging state
|
287
|
+
let startX, startY; // Mouse starting point for dragging
|
288
|
+
|
289
|
+
// Mouse wheel zoom with cursor as focal point
|
290
|
+
container.addEventListener('wheel', function(event) {{
|
291
|
+
event.preventDefault();
|
292
|
+
const zoomSpeed = 0.1; // Speed of zoom
|
293
|
+
const zoomDelta = event.deltaY > 0 ? -zoomSpeed : zoomSpeed;
|
294
|
+
const previousScale = scale;
|
295
|
+
|
296
|
+
// Clamp zoom level between 50% and 400%
|
297
|
+
scale = Math.min(Math.max(0.5, scale + zoomDelta), 4);
|
298
|
+
|
299
|
+
// Calculate the focal point for zoom using mouse position
|
300
|
+
const rect = content.getBoundingClientRect();
|
301
|
+
const offsetX = event.clientX - rect.left; // Mouse X relative to content
|
302
|
+
const offsetY = event.clientY - rect.top; // Mouse Y relative to content
|
303
|
+
|
304
|
+
// Adjust pan values to focus zoom on cursor
|
305
|
+
panX -= (offsetX / previousScale - offsetX / scale);
|
306
|
+
panY -= (offsetY / previousScale - offsetY / scale);
|
307
|
+
|
308
|
+
// Apply transformations
|
309
|
+
content.style.transform = `translate(${{
|
310
|
+
panX
|
311
|
+
}}px, ${{panY}}px) scale(${{scale}})`;
|
312
|
+
}});
|
313
|
+
|
314
|
+
// Handle panning with mouse drag
|
315
|
+
container.addEventListener('mousedown', function(event) {{
|
316
|
+
isDragging = true;
|
317
|
+
startX = event.clientX - panX;
|
318
|
+
startY = event.clientY - panY;
|
319
|
+
container.style.cursor = "grabbing";
|
320
|
+
}});
|
321
|
+
|
322
|
+
container.addEventListener('mousemove', function(event) {{
|
323
|
+
if (!isDragging) return;
|
324
|
+
panX = event.clientX - startX;
|
325
|
+
panY = event.clientY - startY;
|
326
|
+
|
327
|
+
// Apply transformations
|
328
|
+
content.style.transform = `translate(${{
|
329
|
+
panX
|
330
|
+
}}px, ${{panY}}px) scale(${{scale}})`;
|
331
|
+
}});
|
332
|
+
|
333
|
+
// Stop dragging on mouseup
|
334
|
+
container.addEventListener('mouseup', function() {{
|
335
|
+
isDragging = false;
|
336
|
+
container.style.cursor = "grab";
|
337
|
+
}});
|
338
|
+
|
339
|
+
// Stop dragging if mouse leaves the container
|
340
|
+
container.addEventListener('mouseleave', function() {{
|
341
|
+
isDragging = false;
|
342
|
+
container.style.cursor = "grab";
|
343
|
+
}});
|
344
|
+
</script>
|
345
|
+
</body>
|
346
|
+
</html>
|
347
|
+
"""
|
348
|
+
return mermaid_html
|
349
|
+
|
350
|
+
|
351
|
+
|
221
352
|
def save_mermaid_html(
|
222
353
|
title: str, mermaid_str: str, folder: str = EGERIA_MERMAID_FOLDER
|
223
354
|
):
|
@@ -502,7 +502,7 @@ pyegeria/feedback_manager_omvs.py,sha256=B66e3ZCaC_dirb0mcb2Nz3PYh2ZKsoMAYNOb3eu
|
|
502
502
|
pyegeria/full_omag_server_config.py,sha256=CQqLCy_3DZFvJZEOcGf50HWdFaWpiAIs6z-kKyjvpDA,47464
|
503
503
|
pyegeria/glossary_browser_omvs.py,sha256=RCvZ1l2xg6uZ1o4xGJUkIVJQO9NZG00F_jGSc4fAERU,93538
|
504
504
|
pyegeria/glossary_manager_omvs.py,sha256=CN04lhnAFk_g4soE5V_jZ0GDrLPClhX5yX9iE0t6NDk,132440
|
505
|
-
pyegeria/mermaid_utilities.py,sha256=
|
505
|
+
pyegeria/mermaid_utilities.py,sha256=qSF3Ye5QhH3YHTTLfsxwRozrjstWNVHzT8mQ3nMJyRQ,22957
|
506
506
|
pyegeria/metadata_explorer_omvs.py,sha256=u66o4IOhSo-i75KYeHogGql-gECBzZPT-RYbvfYuzoI,86932
|
507
507
|
pyegeria/my_profile_omvs.py,sha256=i0e29KXRKZzZGgxuQI7c2_w7dyDuQWFIykky1Nqc0_8,34673
|
508
508
|
pyegeria/platform_services.py,sha256=xlF5p5HPKDGTFFDsuxm2RLhr8vjZPv4T7e2qCkDgKXE,41654
|
@@ -515,8 +515,8 @@ pyegeria/template_manager_omvs.py,sha256=o_qCIFTRLK8b9C3N99taLji8VkDygo1Ss0fua35
|
|
515
515
|
pyegeria/utils.py,sha256=GCt1C0bp0Xng1ahzbZhzV9qQwH7Dj93IaCt2dvWb-sg,5417
|
516
516
|
pyegeria/valid_metadata_omvs.py,sha256=UyIT4DfB1_QIG55Hmop7ozbsq8cNdrpYB7Tb6EOFiN8,65035
|
517
517
|
pyegeria/x_action_author_omvs.py,sha256=6b725SPsC52AI7ols7Qq8MsBlZuAXr_BgJ_-ychVRCw,6386
|
518
|
-
pyegeria-5.3.4.4.
|
519
|
-
pyegeria-5.3.4.4.
|
520
|
-
pyegeria-5.3.4.4.
|
521
|
-
pyegeria-5.3.4.4.
|
522
|
-
pyegeria-5.3.4.4.
|
518
|
+
pyegeria-5.3.4.4.dev4.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
519
|
+
pyegeria-5.3.4.4.dev4.dist-info/METADATA,sha256=cJiHDO5vOT9xLMaGhW0zX3_9pWPalLdj01XBKf7MvWc,2740
|
520
|
+
pyegeria-5.3.4.4.dev4.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
|
521
|
+
pyegeria-5.3.4.4.dev4.dist-info/entry_points.txt,sha256=E83aZ9RhrxffYGmHgBwhLdS5fvEeYhrIPp0FZRvaFOI,6180
|
522
|
+
pyegeria-5.3.4.4.dev4.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|