stable
Clone or download
Instead of relying on default `pre > code.language-mermaid`, we now define a custom element `tlp-mermaid-diagram`. This offers at leaste two advantages: 1. No need to manually query the dom for potential candidates, it's the browser duty 2. No more conflicts with PrismJS (which rely on `pre > code.language-*`, git repositories now display mermaid diagrams \o/ 3. Async content sent to the browser doesn't need external parsing. (For example when you edit a follow-up comment in an artifact) (However we loose the "markdownish" advantage of the syntax in HTML context outside of tuleap, for example in email notifications.) If there are Tuleap pages where the `<tlp-mermaid-diagram>` component is displayed while its definition is not loaded yet, the source content is displayed as a pre element. The diagram is still lazy loaded: call to mermaid.render to display the svg is done only if the element enters in the viewport. In the meantime a spinner is displayed over the source content. Note: Attempts to use requestIdleCallback to initialize the component (eg: display the spinner and start observing the viewport) were not successful: there were too much flickering at the display of the diagram. I think that IntersectionObserver usage is good enough though. Note: Ugly singleton for code block features has been moved to tracker namespace as we hope to not need it elsewhere 🤞. Part of request #19739: Add support of mermaid js diagrams Change-Id: I7c9a6f885c76a9b040a78e0715006e95cb8e9432
Modified Files
Name | ||||
---|---|---|---|---|
M | plugins/git/include/GitPHP/controller/Controller_Blob.php | +11 | −1 | Go to diff View file |
M | plugins/git/include/GitPHP/controller/Controller_Tree.php | +11 | −1 | Go to diff View file |
R | src/common/Markdown/CodeBlockFeaturesOnPage.php | Go to diff View file | ||
M | plugins/tracker/include/Tracker/Artifact/Renderer/EditRenderer.class.php | +2 | −1 | Go to diff View file |
M | plugins/tracker/include/Tracker/Artifact/Tracker_Artifact_ChangesetValue_Text.class.php | +3 | −4 | Go to diff View file |
M | plugins/tracker/include/Tracker/Artifact/Tracker_Artifact_Changeset_Comment.class.php | +3 | −4 | Go to diff View file |
R | tests/unit/Tuleap/Markdown/CodeBlockFeaturesOnPageTest.php | Go to diff View file | ||
A | src/common/Markdown/BlockRenderer/MermaidBlockRenderer.php | +71 | −0 | Go to diff View file |
M | src/common/Markdown/CodeBlockFeatures.php | +15 | −3 | Go to diff View file |
D | src/common/Markdown/CodeBlockFeaturesExtension.php | +0 | −69 | Go to diff View file |
A | src/common/Markdown/CodeBlockFeaturesInterface.php | +29 | −0 | Go to diff View file |
M | src/common/Markdown/CommonMarkInterpreter.php | +31 | −0 | Go to diff View file |
A | src/common/Markdown/CustomBlockRenderer.php | +53 | −0 | Go to diff View file |
M | src/common/include/Codendi_HTMLPurifier.class.php | +15 | −1 | Go to diff View file |
A | src/scripts/mermaid/__snapshots__/mermaid-diagram-element.test.ts.snap | +40 | −0 | Go to diff View file |
D | src/scripts/mermaid/__snapshots__/replace-code-blocks-by-mermaid-diagrams.test.ts.snap | +0 | −22 | Go to diff View file |
M | src/scripts/mermaid/index.ts | +4 | −4 | Go to diff View file |
A | src/scripts/mermaid/initialize-mermaid.test.ts | +54 | −0 | Go to diff View file |
A | src/scripts/mermaid/initialize-mermaid.ts | +40 | −0 | Go to diff View file |
A | src/scripts/mermaid/mermaid-diagram-element.test.ts | +115 | −0 | Go to diff View file |
A | src/scripts/mermaid/mermaid-diagram-element.ts | +94 | −0 | Go to diff View file |
D | src/scripts/mermaid/replace-code-blocks-by-mermaid-diagrams.test.ts | +0 | −160 | Go to diff View file |
D | src/scripts/mermaid/replace-code-blocks-by-mermaid-diagrams.ts | +0 | −100 | Go to diff View file |
M | src/themes/BurningParrot/css/_includes.scss | +1 | −0 | Go to diff View file |
A | src/themes/BurningParrot/css/includes/_mermaid.scss | +62 | −0 | Go to diff View file |
M | src/themes/FlamingParrot/css/utils/_mermaid.scss | +21 | −0 | Go to diff View file |
R | tests/unit/Tuleap/Markdown/CodeBlockFeaturesExtensionTest.php | Go to diff View file | ||
M | tests/unit/common/Include/Codendi_HTMLPurifierTest.php | +21 | −0 | Go to diff View file |