mermaid-js / zenuml-core Goto Github PK
View Code? Open in Web Editor NEWThis project forked from zenuml/core
The ZenUML renderer
Home Page: https://embed.zenuml.com
License: MIT License
This project forked from zenuml/core
The ZenUML renderer
Home Page: https://embed.zenuml.com
License: MIT License
https://www.uml-diagrams.org/sequence-diagrams-combined-fragment.html#operator-break
Please first create the DSL and have it reviewed together with me.
We will release a version from this repo, then add that as mermaid's dependency and open a smaller PR.
In our current implementation, we use the following syntax to control the style for both comments and messages. However, it would be good (?) that we could control them separately.
// [red] comments
A.method
The proposed solution:
<red>
controls comment only;(red)
controls message only;[red]
controls both comment and message.There is a bit of a problem when rendering line 15 ( "space in name"->"bg color".syncMethod(from, to) ):
Sample DSL code: src/demo1.js:
// comments at the beginning should be ignored
title This is a title
@Lambda <<stereotype>> ParticipantName
group "B C" {@EC2 B @ECS C}
"bg color" #FF0000
@Starter("OptionalStarter")
new B
ReturnType ret = ParticipantName.methodA(a, b) {
// Customised style for RESTFul API - \`POST /order\` <br>
ReturnType ret2 = selfCall() {
B.syncCallWithinSelfCall() {
ParticipantName.rightToLeftCall()
return B
}
**_"space in name"->"bg color".syncMethod(from, to)_**
}
// A comment for alt
if (condition) {
// A comment for creation
ret = new CreatAndAssign()
"ret:CreatAndAssign".method(create, and, assign)
// A comment for async self
B->B: Self Async
// A comment for async message
B->C: Async Message within fragment
new Creation() {
return from_creation
}
return "from if to original source"
try {
new AHasAVeryLongNameLongNameLongNameLongName() {
new CreatWithinCreat()
C.rightToLeftFromCreation() {
B.FurtherRightToLeftFromCreation()
}
}
} catch (Exception) {
self {
return C
}
} finally {
C: async call from implied source
}
=====divider can be anywhere=====
} else if ("another condition") {
par {
B.method
C.method
}
} else {
// A comment for loop
forEach(Z) {
Z.method() {
return Z
}
}
}
}
WIP
Code to reproduce this issue:
// Issue #88
A->A.method {
// [bold, red]Issue #89
B:async message
}
This issue may be related to #88 .
There are two types of shortcut keys: Navigation and Operation.
Commonly, the active selection is emphasized in a certain way. For instance, the subsequent diagram employs a ring for highlighting.
The sequence of selection should naturally align with the visual arrangement of the elements, enabling user navigation via arrow keys.
It is a lot more complex. Here are some ideas:
select and start typing
or double click
Enter
ESC
Shift_Enter
(DSL update needed)Tab
will going into next participant and enters editing mode; if that is the last participant, create a new participantZenUML DSL is designed to be intuitive. However, due to the complexity of nature of sequence diagram, it is hard for users to grasp all syntax quickly.
Tooltips is to provide in-context help to end users. Those tooltips can be display at the bottom of the canvas. It can also link to our documents specifically created for the component.
Component | Tooltip |
---|---|
Participant | You can orders of participants by declaring them at the beginning. Click here for more information. |
Sync Method | You can comment a method with // . Click here for more details. |
Alt Fragment | You can use if/else if/else to render an Alt fragment. Click here for more information. |
Loop Fragment | You can use for/while/loop to render an Alt fragment. Click here for more details. |
Provide more information include typical syntax in the tooltip.
// [red, bold]
A.method()
Should render the message in red and message text in bold. It must only style the current message and should not have impact on its children or siblings.
We can do a lot more with this syntax.
tailwind css and s
hortcuts can be used:
text-red-900
text-red
red
font-bold
bold
zenuml
title Async Messages (SPA Authentication)
// ```
// GET https://${account.namespace}/authorize/?
// response_type=token
// &client_id=${account.clientId}
// &redirect_url=YOUR_CALLBACK_URL
// &state=VALUE_THAT_SURVIVES_REDIRECTS
// &scope=openid
// ```
Browser->Auth0: 1. initiate the authentication
Auth0->"Identity Provider": 2. OAuth2 / SAML, etc
"Identity Provider"->"Identity Provider": 3. user gets authenticated
Auth0->Browser: 4. redirect to ${YOUR_CALLBACK_URL}/#id_token=e68...
Browser->Auth0: 5. validate id_token and get user profile
Browser->"Your API": 6. call API sending JWT in Authorization header
"Your API"->"Your API": 7. validate token
Icons are used in sequence diagrams to represent certain elements (e.g. Actor) or to add notes for clarification(e.g. Boundary, or Entity), show that an participant belongs to a type (e.g. Service).
In ZenUML, we use the following syntax to link an icon to a participant:
@IconName participantName
We already support a list of icons. This issue is to add more icons to the support list.
Checklist
They have been split into groups so we don't have to finish all in one release.
This is to understand how often a feature is used. Features are listed here: https://zenuml.atlassian.net/wiki/spaces/Doc/pages/518848513/Sequence+diagram+syntax.
title Order Service (Demonstration only)
// Styling participants with background colors is an experimental feature.
// This feature is available for users to test and provide feedback.
@Actor Client #FFEBE6
@Boundary OrderController #0747A6
@EC2 <<BFF>> OrderService #E3FCEF
group BusinessService {
@Lambda PurchaseService
@AzureFunction InvoiceService
}
@Starter(Client)
//`POST /orders`
OrderController.post(payload) {
OrderService.create(payload) {
order = new Order(payload)
if(order != null) {
par {
PurchaseService.createPO(order)
InvoiceService.createInvoice(order)
}
}
}
}
Currently when you click Zoom in or out button, the button will move away.
Moved to here from ZenUml#435
I'm importing mermaid-zenuml into a kotlinjs project, and get an error when passing it to registerExternalDiagrams:
r2 is not a function', message: 'detector2 is not a function', hash: 'TypeError', error: TypeError: detector2 is not a function
at detectType (webpack-internal:///../../node_modules/me…}error: TypeError: detector2 is not a function
at detectType (webpack-internal:///../../node_modules/mermaid/dist/mermaid-934d9bea.js:2420:22)
at getDiagramFromText (webpack-internal:///../../node_modules/mermaid/dist/mermaid-934d9bea.js:3724:17)
at Object.render$1 [as render] (webpack-internal:///../../node_modules/mermaid/dist/mermaid-934d9bea.js:6044:18)
at eval (webpack-internal:///../../node_modules/mermaid/dist/mermaid-934d9bea.js:6346:18)
at new Promise (<anonymous>)
at performCall (webpack-internal:///../../node_modules/mermaid/dist/mermaid-934d9bea.js:6345:31)
at executeQueue (webpack-internal:///../../node_modules/mermaid/dist/mermaid-934d9bea.js:6314:15)
at eval (webpack-internal:///../../node_modules/mermaid/dist/mermaid-934d9bea.js:6361:5)
at new Promise (<anonymous>)
at render (webpack-internal:///../../node_modules/mermaid/dist/mermaid-934d9bea.js:6344:10)hash: "TypeError"message: "detector2 is not a function"str: "detector2 is not a function"[[Prototype]]: Objectconstructor: ƒ Object()hasOwnProperty: ƒ hasOwnProperty()isPrototypeOf: ƒ isPrototypeOf()propertyIsEnumerable: ƒ propertyIsEnumerable()toLocaleString: ƒ toLocaleString()toString: ƒ toString()valueOf: ƒ valueOf()__defineGetter__: ƒ __defineGetter__()__defineSetter__: ƒ __defineSetter__()__lookupGetter__: ƒ __lookupGetter__()__lookupSetter__: ƒ __lookupSetter__()__proto__: (...)get __proto__: ƒ __proto__()set __proto__: ƒ __proto__()
Dumping out what I'm registering to console.log right before the call, I get:
{id: 'zenuml', detector: ƒ, loader: ƒ}
detector : (txt) => { return /^\s*zenuml/.test(txt); }
id : "zenuml"
loader : async () => {…}
[[Prototype]] : Object
...so I'm pretty sure it's not a case of mangled names.
Is https://www.npmjs.com/package/@mermaid-js/mermaid-zenuml up to date enough?
One note is that I had to mangle the import path to get a clean module mapping:
@JsModule("@mermaid-js/mermaid-zenuml/dist/mermaid-zenuml.core.mjs")
@JsNonModule
external val ZenUML: ExternalDiagram
https://www.uml-diagrams.org/sequence-diagrams-combined-fragment.html#operator-critical
Please first create the DSL and have it reviewed together with me.
Currently, the core renderer will always render a simple diagram with only one participant ZenUML
. It is a workaround. In the future, it should show a loading icon.
A constraint on a duration.
#Notion
A duration constraint on a sequence diagram may be show by drawing a vertical line with open arrowheads at both ends between the vertical position of two events. An expression for the duration is placed in braces over the center of the arrow. The constraint may also be shown as a text expression in braces.
Source: https://www.oreilly.com/api/v2/epubs/0321245628/files/0321245628_ch14lev1sec193_image01.jpeg
Consider this simple HTML page. Adding the ZenUML diagram affects rendering of the <h1>
element: the font changes and the text becomes small.
It seems that the <style>
added by the JS is affecting the entire page? Am I doing something wrong here?
<!DOCTYPE html>
<html lang="en">
<head>
</head>
<body>
<h1>H1 Header</h1>
<pre class="mermaid">
zenuml
Alice->John: Hello John, how are you?
John->Alice: Great!
Alice->John: See you later!
</pre>
<script type="module">
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.esm.min.mjs';
import zenuml from 'https://cdn.jsdelivr.net/npm/@mermaid-js/[email protected]/dist/mermaid-zenuml.esm.min.mjs';
await mermaid.registerExternalDiagrams([zenuml]);
</script>
</body>
</html>
A.method1 {
B->B: Self Async
}
This is a regression issue possibly introduced by #98. However, the related PR fixed a lot of other issues and this case is rare and less impactful. I have created this issue to track it.
Emojis are considered characters on the web and in digital text. They are encoded as part of the Unicode standard. In Unicode, emojis have their own code points, just like letters, numbers, and special characters. For example, the emoji 😊 has the Unicode code point U+1F60A.
When you include an emoji in a text message, email, tweet, or any other form of digital text, it is treated as a single character, even though it may visually appear more complex than a letter or number. However, it’s worth noting that some emojis are made up of multiple Unicode code points, such as emojis that combine a base emoji with a skin tone modifier.
The syntax :unicorn:
(🦄) is a type of shortcode used by certain platforms and applications to represent emojis. This particular syntax, where an emoji is represented by a short string of text enclosed in colons, is commonly used in Slack, GitHub, Discourse, and some other communication and collaboration tools.
To support ZenUML, we will add emoji support to the following areas:
Syntax must support two ways of embedding emojis: 1. use the emoji directly; 2. use shortcut.
:unicorn:OrderService
The main challenge in implementing this is to resolve ambiguity between an emoji and an async message which also use :
.
An async message is like: A->B:async message
. An emoji can be used like :unicorn:A->:butterfly:B: :cry: some more messages
.
When the DSL was first designed, it was heavily inspired by main stream OO languages such as Java, C++. In those languages, it is the case. The reason is explained (thanks to GPT) in comments below.
// @fieldName FieldValue
Example:
// @author MrCoder
// @last-update 2023/07/11
// @description Order submitting process
DSL:
title FireWeb on LaraSite Backend
FireWeb -> LaraSite.save(token, diagram) {
FirebaseIdProvider.authenticate(token)
save(diagram)
return diagram_link
}
You can view the diagram at here.
So there is less distraction.
This card is to revert this commit: 861c706.
The above commit increases the minimum direct gap between Participants from an aesthetic standpoint. Horizontal space is a very scarce resource in sequence diagrams compared to vertical space. Our layout algorithm should try to minimize the horizontal width as much as possible. Only when the number of Participants is less than or equal to three, should consider enhancing the aesthetic by increasing the width.
When viewing a Sequence Diagram, sometimes, some details (be it messages, fragments or branches) become distractions. Users may want to temporarily hide it.
We have already implemented this on fragments.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.