|
1 |
| -import { Grid } from 'https://unpkg.com/gridjs/dist/gridjs.production.es.min.js' |
2 |
| -import parseStylesheet from 'https://unpkg.com/parse-css-stylesheet/index.js' |
| 1 | +import { Grid } from 'https://unpkg.com/gridjs@5.0.1/dist/gridjs.module.js' |
| 2 | +import { injectStyle } from 'https://unpkg.com/[email protected]/dist/es2015/index.js' |
3 | 3 | import { uid } from 'https://unpkg.com/uid/single/index.mjs'
|
4 | 4 |
|
5 | 5 | const waitForSelector = selector => {
|
@@ -194,28 +194,13 @@ export default {
|
194 | 194 | const head = document.getElementsByTagName('head')[0]
|
195 | 195 |
|
196 | 196 | let styles = document.createElement('style')
|
197 |
| - styles.title = `${this.divId}__theme` |
| 197 | + styles.id = `${this.divId}__theme` |
198 | 198 | styles.type = 'text/css'
|
199 | 199 | head.appendChild(styles)
|
200 | 200 |
|
201 |
| - for (let index in document.styleSheets) { |
202 |
| - if (document.styleSheets[index].title === styles.title) { |
203 |
| - styles = document.styleSheets[index] |
204 |
| - } |
205 |
| - } |
206 |
| - |
207 |
| - let theme = await fetch(`https://unpkg.com/gridjs/dist/theme/${this.activeTheme}.css`) |
| 201 | + let theme = await fetch(`https://unpkg.com/gridjs/dist/theme/mermaid.css`) |
208 | 202 | theme = await theme.text()
|
209 |
| - theme = parseStylesheet(theme) |
210 |
| - |
211 |
| - if (styles instanceof CSSStyleSheet) { |
212 |
| - for (const index in theme.cssRules) { |
213 |
| - let css = theme.cssRules[index].cssText |
214 |
| - if (css && !/^@/g.test(css)) { |
215 |
| - styles.insertRule(`#${this.divId} ${css}`) |
216 |
| - } |
217 |
| - } |
218 |
| - } |
| 203 | + injectStyle(theme, styles.id) |
219 | 204 | } catch (error) {
|
220 | 205 | console.error(error)
|
221 | 206 | }
|
|
0 commit comments