Skip to content

Commit

Permalink
Add id as css scope
Browse files Browse the repository at this point in the history
  • Loading branch information
tylerlong committed Mar 11, 2018
1 parent b093f9f commit 2ed5150
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
"graphlibrary": "^2.2.0",
"he": "^1.1.1",
"lodash": "^4.17.5",
"moment": "^2.21.0"
"moment": "^2.21.0",
"scope-css": "^1.0.5"
},
"devDependencies": {
"babel-core": "^6.26.0",
Expand Down
3 changes: 2 additions & 1 deletion src/mermaidAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* somewhere in the page or something completely different.
*/
import * as d3 from 'd3'
import scope from 'scope-css'

import { logger, setLogLevel } from './logger'
import graph from './diagrams/flowchart/graphDb'
Expand Down Expand Up @@ -438,7 +439,7 @@ const render = function (id, txt, cb, container) {
// insert inline style into svg
const svg = element.firstChild
const s = document.createElement('style')
s.innerHTML = themes[config.theme] || defaultTheme
s.innerHTML = scope(themes[config.theme] || defaultTheme, `#${id}`)
svg.insertBefore(s, svg.firstChild)

d3.select('#d' + id).selectAll('foreignobject div').attr('xmlns', 'http://www.w3.org/1999/xhtml')
Expand Down
2 changes: 0 additions & 2 deletions src/themes/mermaid.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
.mermaid {
@import 'flow';
@import 'sequenceDiagram';
@import 'gantt';
Expand All @@ -23,4 +22,3 @@
pointer-events: none;
z-index: 100;
}
}
4 changes: 4 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7135,6 +7135,10 @@ schema-utils@^0.4.2:
ajv "^6.1.0"
ajv-keywords "^3.1.0"

scope-css@^1.0.5:
version "1.0.5"
resolved "https://registry.yarnpkg.com/scope-css/-/scope-css-1.0.5.tgz#9a40a959231ecf683dbef3dedae6a26ab091e1fd"

scoped-regex@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/scoped-regex/-/scoped-regex-1.0.0.tgz#a346bb1acd4207ae70bd7c0c7ca9e566b6baddb8"
Expand Down

0 comments on commit 2ed5150

Please sign in to comment.