mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-18 23:09:49 +02:00
Merge github.com:mermaid-js/mermaid into jsdoc
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import mermaidAPI from '../../mermaidAPI';
|
||||
import * as configApi from '../../config';
|
||||
import { log } from '../../logger';
|
||||
import { sanitizeText } from '../common/common';
|
||||
|
||||
let prevActor = undefined;
|
||||
let actors = {};
|
||||
@@ -219,7 +220,10 @@ export const addLinks = function (actorId, text) {
|
||||
const actor = getActor(actorId);
|
||||
// JSON.parse the text
|
||||
try {
|
||||
const links = JSON.parse(text.text);
|
||||
let sanitizedText = sanitizeText(text.text, configApi.getConfig());
|
||||
sanitizedText = sanitizedText.replace(/&/g, '&');
|
||||
sanitizedText = sanitizedText.replace(/=/g, '=');
|
||||
const links = JSON.parse(sanitizedText);
|
||||
// add the deserialized text to the actor's links field.
|
||||
insertLinks(actor, links);
|
||||
} catch (e) {
|
||||
@@ -232,9 +236,12 @@ export const addALink = function (actorId, text) {
|
||||
const actor = getActor(actorId);
|
||||
try {
|
||||
const links = {};
|
||||
var sep = text.text.indexOf('@');
|
||||
var label = text.text.slice(0, sep - 1).trim();
|
||||
var link = text.text.slice(sep + 1).trim();
|
||||
let sanitizedText = sanitizeText(text.text, configApi.getConfig());
|
||||
var sep = sanitizedText.indexOf('@');
|
||||
sanitizedText = sanitizedText.replace(/&/g, '&');
|
||||
sanitizedText = sanitizedText.replace(/=/g, '=');
|
||||
var label = sanitizedText.slice(0, sep - 1).trim();
|
||||
var link = sanitizedText.slice(sep + 1).trim();
|
||||
|
||||
links[label] = link;
|
||||
// add the deserialized text to the actor's links field.
|
||||
@@ -259,7 +266,8 @@ export const addProperties = function (actorId, text) {
|
||||
const actor = getActor(actorId);
|
||||
// JSON.parse the text
|
||||
try {
|
||||
const properties = JSON.parse(text.text);
|
||||
let sanitizedText = sanitizeText(text.text, configApi.getConfig());
|
||||
const properties = JSON.parse(sanitizedText);
|
||||
// add the deserialized text to the actor's property field.
|
||||
insertProperties(actor, properties);
|
||||
} catch (e) {
|
||||
|
@@ -976,7 +976,8 @@ link a: Tests @ https://tests.contoso.com/?svc=alice@contoso.com
|
||||
expect(actors.a.links["Tests"]).toBe("https://tests.contoso.com/?svc=alice@contoso.com");
|
||||
});
|
||||
|
||||
it('it should handle properties', function () {
|
||||
it('it should handle properties EXPERIMENTAL: USE WITH CAUTION', function () {
|
||||
//Be aware that the syntax for "properties" is likely to be changed.
|
||||
const str = `
|
||||
sequenceDiagram
|
||||
participant a as Alice
|
||||
|
@@ -1,4 +1,5 @@
|
||||
import common from '../common/common';
|
||||
import { addFunction } from '../../interactionDb';
|
||||
|
||||
export const drawRect = function (elem, rectData) {
|
||||
const rectElem = elem.append('rect');
|
||||
@@ -25,6 +26,17 @@ const sanitizeUrl = function (s) {
|
||||
.replace(/javascript:/g, '');
|
||||
};
|
||||
|
||||
const addPopupInteraction = (id, actorCnt) => {
|
||||
addFunction(() => {
|
||||
const arr = document.querySelectorAll(id);
|
||||
arr[0].addEventListener('mouseover', function () {
|
||||
popupMenuUpFunc('actor' + actorCnt + '_popup');
|
||||
});
|
||||
arr[0].addEventListener('mouseout', function () {
|
||||
popupMenuDownFunc('actor' + actorCnt + '_popup');
|
||||
});
|
||||
});
|
||||
};
|
||||
export const drawPopup = function (elem, actor, minMenuWidth, textAttrs, forceMenus) {
|
||||
if (actor.links === undefined || actor.links === null || Object.keys(actor.links).length === 0) {
|
||||
return { height: 0, width: 0 };
|
||||
@@ -43,9 +55,7 @@ export const drawPopup = function (elem, actor, minMenuWidth, textAttrs, forceMe
|
||||
g.attr('id', 'actor' + actorCnt + '_popup');
|
||||
g.attr('class', 'actorPopupMenu');
|
||||
g.attr('display', displayValue);
|
||||
g.attr('onmouseover', popupMenu('actor' + actorCnt + '_popup'));
|
||||
g.attr('onmouseout', popdownMenu('actor' + actorCnt + '_popup'));
|
||||
|
||||
addPopupInteraction('#actor' + actorCnt + '_popup', actorCnt);
|
||||
var actorClass = '';
|
||||
if (typeof rectData.class !== 'undefined') {
|
||||
actorClass = ' ' + rectData.class;
|
||||
@@ -123,6 +133,19 @@ export const popdownMenu = function (popid) {
|
||||
);
|
||||
};
|
||||
|
||||
const popupMenuUpFunc = function (popupId) {
|
||||
var pu = document.getElementById(popupId);
|
||||
if (pu != null) {
|
||||
pu.style.display = 'block';
|
||||
}
|
||||
};
|
||||
|
||||
const popupMenuDownFunc = function (popupId) {
|
||||
var pu = document.getElementById(popupId);
|
||||
if (pu != null) {
|
||||
pu.style.display = 'none';
|
||||
}
|
||||
};
|
||||
export const drawText = function (elem, textData) {
|
||||
let prevTextHeight = 0,
|
||||
textHeight = 0;
|
||||
@@ -321,9 +344,10 @@ const drawActorTypeParticipant = function (elem, actor, conf) {
|
||||
|
||||
g = boxpluslineGroup.append('g');
|
||||
actor.actorCnt = actorCnt;
|
||||
|
||||
if (actor.links != null) {
|
||||
g.attr('onmouseover', popupMenu('actor' + actorCnt + '_popup'));
|
||||
g.attr('onmouseout', popdownMenu('actor' + actorCnt + '_popup'));
|
||||
g.attr('id', 'root-' + actorCnt);
|
||||
addPopupInteraction('#root-' + actorCnt, actorCnt);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -370,6 +394,7 @@ const drawActorTypeParticipant = function (elem, actor, conf) {
|
||||
actor.height = bounds.height;
|
||||
height = bounds.height;
|
||||
}
|
||||
|
||||
return height;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user