Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Directives, sequenceDiagram refactor, config normalization, many tweaks #1523

Merged
merged 38 commits into from
Jul 2, 2020

Conversation

cmmoran
Copy link
Collaborator

@cmmoran cmmoran commented Jul 1, 2020

📑 Summary

This PR is much larger than I would typically expect.

Reworked directives

Directives %%{...}%% are now processed in mermaidAPI. The default/base directive is init or initialize. There is another directive to support wrap or wrapping. The init directive's purpose is essentially to give some control to the graph implementor. This control is guarded by a single field: secure. The graph implementor can direct config changes to any keys in the configuration except those defined in the secure array. By default the secure array consists of: ['secure', 'securityLevel', 'startOnLoad', 'maxTextSize']. The init directive cannot make changes to those keys in the configuration as they are reserved for the site/host/owner. Further, the site/host/owner is able to expand the secure array to further lock down which keys cannot be modified by graph implementors by simply modifying the secure array in the options object passed to mermaidAPI.initialize(). The configuration resolved by the init directive is passed to mermaidAPI.reinitialize(). This function applies the configuration defensively with respect to the site configuration.

Config normalization

Configuration has changed quite a bit as well. There are now three main states of configuration: global default, site, and current. The global default configuration is the basic configuration shipped with mermaid. Site operators may set their own base configuration (called site configuration) which will likely be based on the global configuration with various site-specific changes. This site configuration become the base configuration available to graph implementors. This gives graph implementors freedom to make various changes to the configuration without breaking the site owners core configuration. The secure key defines fields that graph implementors may not change. (Directives attempting to make changes to those keys simply drop the attempted change). Sneaky attempts to update the config are also blocked defensively.

The hope is that site owners and graph implementors will be able to configure graphs within the parameters defined by the site owner.

knsv and others added 30 commits June 19, 2020 10:57
msgModel generated during calculation of loop bounds
simplifies draw messages loop
noteModel generated during calculation of loop bounds
addition: bounds.init will clear models
addition: added loop model widths id instead of using title as the id
removed parseMessage debug message
addition: added configuration labelBoxWidth and labelBoxHeight for loop label box width/height
change: adjusted svgDraw drawText to support anchor and valign and whether to output a tspan
change: drawText returns an array regardless of array size
change: hardcoded label width/height uses conf.labelBoxWidth and conf.labelBoxHeight
change: Math.round() on many of the calculations to clean up bounds values
change: getTextObj anchor, width, height start as undefined
Updated config to match a conversation knut and i had about the relationship between global, site, and integrator configuration
(Will update docs)
Renamed wrapEnabled to wrap
Poor man's caching for calculateTextDimensions, wrapLabel, and breakString (actually makes a huge difference)
Missed `activationWidth` new configuration option for sequence diagrams
…fying the sequence object

take into account width of message over single actor for actors' max message width
…Key calculations done in this particular branch. This will be normalized with the memoize PR about to be created.
conf.messageFont() would have a different cacheKey based on the cache…
Fixed a few of the text rendering issues
Ensure a minimum amount of space between wrapped / non-wrapped title text and the next element
cmmoran added 6 commits July 1, 2020 05:36
Merging changes from develop into feature/1483_long_messages
updated parseMessage to set wrap: true when breaks are detected
added hasBreaks and splitBreaks to common.js
Fixed dark theme (sequenceDiagram) sequenceNumbers color
@github-actions github-actions bot added the Type: Enhancement New feature or request label Jul 1, 2020
@cmmoran cmmoran requested a review from knsv July 1, 2020 18:22
@knsv knsv merged commit b6d6d3c into develop Jul 2, 2020
@knsv knsv deleted the feature/1483_long_messages branch July 5, 2021 08:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants