mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-22 08:50:13 +02:00
#1676 Adding click support to the new rendering engine and classDiagram-v2
This commit is contained in:
@@ -7,8 +7,6 @@ import mermaidAPI from '../../mermaidAPI';
|
||||
|
||||
const MERMAID_DOM_ID_PREFIX = 'classid-';
|
||||
|
||||
const config = configApi.getConfig();
|
||||
|
||||
let relations = [];
|
||||
let classes = {};
|
||||
let classCounter = 0;
|
||||
@@ -176,6 +174,7 @@ export const setCssClass = function(ids, className) {
|
||||
* @param tooltip Tooltip for the clickable element
|
||||
*/
|
||||
export const setLink = function(ids, linkStr, tooltip) {
|
||||
const config = configApi.getConfig();
|
||||
ids.split(',').forEach(function(_id) {
|
||||
let id = _id;
|
||||
if (_id[0].match(/\d/)) id = MERMAID_DOM_ID_PREFIX + id;
|
||||
@@ -199,11 +198,13 @@ export const setLink = function(ids, linkStr, tooltip) {
|
||||
export const setClickEvent = function(ids, functionName, tooltip) {
|
||||
ids.split(',').forEach(function(id) {
|
||||
setClickFunc(id, functionName, tooltip);
|
||||
classes[id].haveCallback = true;
|
||||
});
|
||||
setCssClass(ids, 'clickable');
|
||||
};
|
||||
|
||||
const setClickFunc = function(domId, functionName, tooltip) {
|
||||
const config = configApi.getConfig();
|
||||
let id = domId;
|
||||
let elemId = lookUpDomId(id);
|
||||
|
||||
|
@@ -34,6 +34,7 @@ export const addClasses = function(classes, g) {
|
||||
logger.info('keys:', keys);
|
||||
logger.info(classes);
|
||||
|
||||
let cnt = 0;
|
||||
// Iterate through each item in the vertex object (containing all the vertices found) in the graph definition
|
||||
keys.forEach(function(id) {
|
||||
const vertex = classes[id];
|
||||
@@ -101,11 +102,16 @@ export const addClasses = function(classes, g) {
|
||||
class: classStr,
|
||||
style: styles.style,
|
||||
id: vertex.id,
|
||||
domId: vertex.domId,
|
||||
haveCallback: vertex.haveCallback,
|
||||
link: vertex.link,
|
||||
width: vertex.type === 'group' ? 500 : undefined,
|
||||
type: vertex.type,
|
||||
padding: getConfig().flowchart.padding
|
||||
});
|
||||
|
||||
cnt++;
|
||||
|
||||
logger.info('setNode', {
|
||||
labelStyle: styles.labelStyle,
|
||||
shape: _shape,
|
||||
|
@@ -5,11 +5,11 @@ const getStyles = options =>
|
||||
stroke: none;
|
||||
font-family: ${options.fontFamily};
|
||||
font-size: 10px;
|
||||
|
||||
|
||||
.title {
|
||||
font-weight: bolder;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
.classTitle {
|
||||
|
Reference in New Issue
Block a user