remark-mind-elixir 0.1.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "remark-mind-elixir",
3
- "version": "0.1.0",
3
+ "version": "0.2.1",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "remark",
@@ -24,15 +24,17 @@
24
24
  "types": "./src/index.d.ts"
25
25
  },
26
26
  "./client": {
27
- "import": "./src/index.js",
28
- "types": "./src/index.d.ts"
27
+ "import": "./src/client.js"
28
+ },
29
+ "./style": {
30
+ "import": "./src/style.css"
29
31
  }
30
32
  },
31
33
  "license": "MIT",
32
34
  "author": "zakaria elalaoui",
33
35
  "type": "module",
34
36
  "dependencies": {
35
- "@zikojs/mind-elixir": "^0.6.1",
37
+ "@zikojs/mind-elixir": "^0.6.2",
36
38
  "hast-util-from-html-isomorphic": "^2.0.0",
37
39
  "mind-elixir": "6.0.0-next.4",
38
40
  "unist-util-visit": "^5.1.0",
package/src/client.js ADDED
@@ -0,0 +1,19 @@
1
+ import { MindMap } from '@zikojs/mind-elixir/no-css'
2
+
3
+ console.log('.... CLIENT ....')
4
+
5
+ document.addEventListener('DOMContentLoaded', () => {
6
+ document.querySelectorAll('[data-elixir-mind]').forEach((element) => {
7
+ const raw = element.dataset.xmindBody
8
+ // const config = element.dataset?.xmindConfig
9
+
10
+ if (!raw) return
11
+
12
+ const nodeData = JSON.parse(raw)
13
+ // const nodeConfig = JSON.parse(config)
14
+
15
+ const map = MindMap({}, nodeData)
16
+
17
+ map.mount(element)
18
+ })
19
+ })
package/src/index.js CHANGED
@@ -3,7 +3,9 @@ import { parse } from 'yaml'
3
3
 
4
4
  import { yaml2MindElixirData } from '@zikojs/mind-elixir/utils'
5
5
 
6
- const remarkElixirMind = () => {
6
+ const remarkElixirMind = ({
7
+ useCdn = true,
8
+ } = {}) => () => {
7
9
  return function transformer(tree) {
8
10
  let hasElixirMind = false
9
11
 
@@ -36,7 +38,7 @@ const remarkElixirMind = () => {
36
38
 
37
39
  if (!hasElixirMind) return
38
40
 
39
- tree.children.push({
41
+ useCdn && tree.children.push({
40
42
  type: 'html',
41
43
  value: `
42
44
  <style>
@@ -44,6 +46,7 @@ const remarkElixirMind = () => {
44
46
  </style>
45
47
 
46
48
  <script type="module">
49
+ import 'https://esm.sh/remark-mind-elixir/client'
47
50
  import { MindMap } from 'https://esm.sh/@zikojs/mind-elixir@latest/src/mind/main.js'
48
51
 
49
52
  document.querySelectorAll('[data-elixir-mind]').forEach((element) => {
package/src/style.css ADDED
@@ -0,0 +1 @@
1
+ @import 'mind-elixir/style.css';