@dxos/plugin-mermaid 0.8.2-staging.7ac8446 → 0.8.2

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.
@@ -44,9 +44,7 @@ var update = (state, options) => {
44
44
  var MermaidWidget = class extends WidgetType {
45
45
  // TODO(burdon): Mermaid API requires unique id.
46
46
  constructor(_id, _source) {
47
- super();
48
- this._id = _id;
49
- this._source = _source;
47
+ super(), this._id = _id, this._source = _source;
50
48
  }
51
49
  eq(other) {
52
50
  return this._source === other._source;
@@ -102,7 +100,7 @@ var styles = EditorView.theme({
102
100
  // },
103
101
  "& .cm-mermaid-error": {
104
102
  display: "inline-block",
105
- color: "var(--dx-error)"
103
+ color: "var(--dx-errorText)"
106
104
  }
107
105
  });
108
106
 
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/MermaidPlugin.tsx", "../../../src/extensions/mermaid.ts", "../../../src/meta.ts"],
4
- "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { contributes, defineModule, definePlugin } from '@dxos/app-framework';\nimport { MarkdownCapabilities, MarkdownEvents } from '@dxos/plugin-markdown';\n\nimport { mermaid } from './extensions';\nimport { meta } from './meta';\n\nexport const MermaidPlugin = () =>\n definePlugin(meta, [\n defineModule({\n id: `${meta.id}/module/markdown`,\n activatesOn: MarkdownEvents.SetupExtensions,\n activate: () => contributes(MarkdownCapabilities.Extensions, [mermaid]),\n }),\n ]);\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { syntaxTree } from '@codemirror/language';\nimport {\n type EditorState,\n type Extension,\n type RangeSet,\n RangeSetBuilder,\n StateField,\n type Transaction,\n} from '@codemirror/state';\nimport { Decoration, EditorView, WidgetType } from '@codemirror/view';\nimport _mermaid from 'mermaid';\n\nexport type MermaidOptions = {};\n\nexport const mermaid = (options: MermaidOptions = {}): Extension => {\n return [\n StateField.define<RangeSet<Decoration>>({\n create: (state) => update(state, options),\n update: (_: RangeSet<Decoration>, tr: Transaction) => update(tr.state, options),\n provide: (field) => EditorView.decorations.from(field),\n }),\n styles,\n ];\n};\n\nconst update = (state: EditorState, options: MermaidOptions) => {\n const builder = new RangeSetBuilder<Decoration>();\n syntaxTree(state).iterate({\n enter: (node) => {\n if (node.name === 'FencedCode') {\n const cursor = state.selection.main.head;\n if (state.readOnly || cursor < node.from || cursor > node.to) {\n const info = node.node.getChild('CodeInfo');\n if (info) {\n const type = state.sliceDoc(info.from, info.to);\n const text = node.node.getChild('CodeText');\n if (type === 'mermaid' && text) {\n const content = state.sliceDoc(text.from, text.to);\n // TODO(burdon): Error if extension defined AFTER decorateMarkdown.\n // Decorations that replace line breaks may not be specified via plugins\n builder.add(\n node.from,\n node.to,\n Decoration.replace({\n widget: new MermaidWidget(`mermaid-${node.from}`, content),\n }),\n );\n }\n }\n }\n }\n },\n });\n\n return builder.finish();\n};\n\nclass MermaidWidget extends WidgetType {\n _svg: string | undefined;\n _error: string | undefined;\n\n // TODO(burdon): Mermaid API requires unique id.\n constructor(\n private readonly _id: string,\n private readonly _source: string,\n ) {\n super();\n }\n\n override eq(other: this) {\n return this._source === other._source;\n }\n\n override toDOM(view: EditorView) {\n const div = document.createElement('div');\n setTimeout(async () => {\n // https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/config.type.ts\n _mermaid.initialize({\n darkMode: view.state.facet(EditorView.darkTheme),\n theme: 'neutral',\n // TODO(burdon): Styles.\n // NOTE: Must specify 'base' in order to override.\n // theme: 'base',\n // themeVariables: {\n // primaryColor: getToken('extend.colors.red.100'),\n // primaryBorderColor: getToken('extend.colors.neutral.200'),\n // },\n // https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/diagrams/flowchart/styles.ts\n // https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/diagrams/sequence/styles.js\n // https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/diagrams/state/styles.js\n // themeCSS: '.node rect { fill: red; }',\n });\n\n // TODO(burdon): Cache?\n const svg = await this.render(div);\n if (this._error) {\n div.className = 'cm-mermaid-error';\n div.innerText = this._error;\n } else {\n div.className = 'cm-mermaid';\n div.innerHTML = svg!;\n\n // const label = document.createElement('span');\n // label.innerText = 'Mermaid';\n // label.className = 'cm-mermaid-label';\n // wrapper.appendChild(label);\n view.requestMeasure();\n }\n });\n\n return div;\n }\n\n async render(container: Element): Promise<string | undefined> {\n try {\n // https://github.com/mermaid-js/mermaid\n const valid = await _mermaid.parse(this._source);\n if (valid) {\n const result = await _mermaid.render(this._id, this._source);\n this._error = undefined;\n this._svg = result.svg;\n return result.svg;\n }\n } catch (err: any) {\n this._error = String(err);\n this._svg = undefined;\n }\n }\n\n override ignoreEvent(e: Event) {\n return !/^mouse/.test(e.type);\n }\n}\n\nconst styles = EditorView.theme({\n '& .cm-mermaid': {\n position: 'relative',\n display: 'inline-flex',\n width: '100%',\n justifyContent: 'center',\n },\n // '& .cm-mermaid-label': {\n // position: 'absolute',\n // right: 0,\n // textSize: 10,\n // },\n '& .cm-mermaid-error': {\n display: 'inline-block',\n color: 'var(--dx-error)',\n },\n});\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { type PluginMeta } from '@dxos/app-framework';\n\nexport const MERMAID_PLUGIN = 'dxos.org/plugin/mermaid';\n\nexport const meta: PluginMeta = {\n id: MERMAID_PLUGIN,\n name: 'Mermaid',\n description: 'Tool that renders text definitions to create diagrams.',\n icon: 'ph--anchor-simple--regular',\n source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-mermaid',\n};\n"],
5
- "mappings": ";AAIA,SAASA,aAAaC,cAAcC,oBAAoB;AACxD,SAASC,sBAAsBC,sBAAsB;;;ACDrD,SAASC,kBAAkB;AAC3B,SAIEC,iBACAC,kBAEK;AACP,SAASC,YAAYC,YAAYC,kBAAkB;AACnD,OAAOC,cAAc;AAId,IAAMC,UAAU,CAACC,UAA0B,CAAC,MAAC;AAClD,SAAO;IACLC,WAAWC,OAA6B;M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;",
6
- "names": ["contributes", "defineModule", "definePlugin", "MarkdownCapabilities", "MarkdownEvents", "syntaxTree", "RangeSetBuilder", "StateField", "Decoration", "EditorView", "WidgetType", "_mermaid", "mermaid", "options", "StateField", "define", "create", "state", "update", "_", "tr", "provide", "field", "EditorView", "decorations", "from", "styles", "builder", "RangeSetBuilder", "syntaxTree", "iterate", "enter", "node", "name", "cursor", "selection", "main", "head", "readOnly", "to", "info", "getChild", "type", "sliceDoc", "text", "content", "add", "Decoration", "replace", "widget", "MermaidWidget", "finish", "WidgetType", "constructor", "_id", "_source", "eq", "other", "toDOM", "view", "div", "document", "createElement", "setTimeout", "_mermaid", "initialize", "darkMode", "facet", "darkTheme", "theme", "svg", "render", "_error", "className", "innerText", "innerHTML", "requestMeasure", "container", "valid", "parse", "result", "undefined", "_svg", "err", "String", "ignoreEvent", "e", "test", "position", "display", "width", "justifyContent", "color", "MERMAID_PLUGIN", "meta", "id", "name", "description", "icon", "source", "MermaidPlugin", "definePlugin", "meta", "defineModule", "id", "activatesOn", "MarkdownEvents", "SetupExtensions", "activate", "contributes", "MarkdownCapabilities", "Extensions", "mermaid"]
4
+ "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { contributes, defineModule, definePlugin } from '@dxos/app-framework';\nimport { MarkdownCapabilities, MarkdownEvents } from '@dxos/plugin-markdown';\n\nimport { mermaid } from './extensions';\nimport { meta } from './meta';\n\nexport const MermaidPlugin = () =>\n definePlugin(meta, [\n defineModule({\n id: `${meta.id}/module/markdown`,\n activatesOn: MarkdownEvents.SetupExtensions,\n activate: () => contributes(MarkdownCapabilities.Extensions, [mermaid]),\n }),\n ]);\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { syntaxTree } from '@codemirror/language';\nimport {\n type EditorState,\n type Extension,\n type RangeSet,\n RangeSetBuilder,\n StateField,\n type Transaction,\n} from '@codemirror/state';\nimport { Decoration, EditorView, WidgetType } from '@codemirror/view';\nimport _mermaid from 'mermaid';\n\nexport type MermaidOptions = {};\n\nexport const mermaid = (options: MermaidOptions = {}): Extension => {\n return [\n StateField.define<RangeSet<Decoration>>({\n create: (state) => update(state, options),\n update: (_: RangeSet<Decoration>, tr: Transaction) => update(tr.state, options),\n provide: (field) => EditorView.decorations.from(field),\n }),\n styles,\n ];\n};\n\nconst update = (state: EditorState, options: MermaidOptions) => {\n const builder = new RangeSetBuilder<Decoration>();\n syntaxTree(state).iterate({\n enter: (node) => {\n if (node.name === 'FencedCode') {\n const cursor = state.selection.main.head;\n if (state.readOnly || cursor < node.from || cursor > node.to) {\n const info = node.node.getChild('CodeInfo');\n if (info) {\n const type = state.sliceDoc(info.from, info.to);\n const text = node.node.getChild('CodeText');\n if (type === 'mermaid' && text) {\n const content = state.sliceDoc(text.from, text.to);\n // TODO(burdon): Error if extension defined AFTER decorateMarkdown.\n // Decorations that replace line breaks may not be specified via plugins\n builder.add(\n node.from,\n node.to,\n Decoration.replace({\n widget: new MermaidWidget(`mermaid-${node.from}`, content),\n }),\n );\n }\n }\n }\n }\n },\n });\n\n return builder.finish();\n};\n\nclass MermaidWidget extends WidgetType {\n _svg: string | undefined;\n _error: string | undefined;\n\n // TODO(burdon): Mermaid API requires unique id.\n constructor(\n private readonly _id: string,\n private readonly _source: string,\n ) {\n super();\n }\n\n override eq(other: this): boolean {\n return this._source === other._source;\n }\n\n override toDOM(view: EditorView): HTMLDivElement {\n const div = document.createElement('div');\n setTimeout(async () => {\n // https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/config.type.ts\n _mermaid.initialize({\n darkMode: view.state.facet(EditorView.darkTheme),\n theme: 'neutral',\n // TODO(burdon): Styles.\n // NOTE: Must specify 'base' in order to override.\n // theme: 'base',\n // themeVariables: {\n // primaryColor: getToken('extend.colors.red.100'),\n // primaryBorderColor: getToken('extend.colors.neutral.200'),\n // },\n // https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/diagrams/flowchart/styles.ts\n // https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/diagrams/sequence/styles.js\n // https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/diagrams/state/styles.js\n // themeCSS: '.node rect { fill: red; }',\n });\n\n // TODO(burdon): Cache?\n const svg = await this.render(div);\n if (this._error) {\n div.className = 'cm-mermaid-error';\n div.innerText = this._error;\n } else {\n div.className = 'cm-mermaid';\n div.innerHTML = svg!;\n\n // const label = document.createElement('span');\n // label.innerText = 'Mermaid';\n // label.className = 'cm-mermaid-label';\n // wrapper.appendChild(label);\n view.requestMeasure();\n }\n });\n\n return div;\n }\n\n async render(container: Element): Promise<string | undefined> {\n try {\n // https://github.com/mermaid-js/mermaid\n const valid = await _mermaid.parse(this._source);\n if (valid) {\n const result = await _mermaid.render(this._id, this._source);\n this._error = undefined;\n this._svg = result.svg;\n return result.svg;\n }\n } catch (err: any) {\n this._error = String(err);\n this._svg = undefined;\n }\n }\n\n override ignoreEvent(e: Event): boolean {\n return !/^mouse/.test(e.type);\n }\n}\n\nconst styles = EditorView.theme({\n '& .cm-mermaid': {\n position: 'relative',\n display: 'inline-flex',\n width: '100%',\n justifyContent: 'center',\n },\n // '& .cm-mermaid-label': {\n // position: 'absolute',\n // right: 0,\n // textSize: 10,\n // },\n '& .cm-mermaid-error': {\n display: 'inline-block',\n color: 'var(--dx-errorText)',\n },\n});\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { type PluginMeta } from '@dxos/app-framework';\n\nexport const MERMAID_PLUGIN = 'dxos.org/plugin/mermaid';\n\nexport const meta: PluginMeta = {\n id: MERMAID_PLUGIN,\n name: 'Mermaid',\n description: 'Tool that renders text definitions to create diagrams.',\n icon: 'ph--anchor-simple--regular',\n source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-mermaid',\n};\n"],
5
+ "mappings": ";AAIA,SAASA,aAAaC,cAAcC,oBAAoB;AACxD,SAASC,sBAAsBC,sBAAsB;;;ACDrD,SAASC,kBAAkB;AAC3B,SAIEC,iBACAC,kBAEK;AACP,SAASC,YAA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a;IACXC,IAAI,GAAGF,KAAKE,EAAE;IACdC,aAAaC,eAAeC;IAC5BC,UAAU,MAAMC,YAAYC,qBAAqBC,YAAY;MAACC;KAAQ;EACxE,CAAA;CACD;",
6
+ "names": ["contributes", "defineModule", "definePlugin", "MarkdownCapabilities", "MarkdownEvents", "syntaxTree", "RangeSetBuilder", "StateField", "Decoration", "EditorView", "WidgetType", "_mermaid", "mermaid", "options", "StateField", "define", "create", "state", "update", "_", "tr", "provide", "field", "EditorView", "decorations", "from", "styles", "builder", "RangeSetBuilder", "syntaxTree", "iterate", "enter", "node", "name", "cursor", "selection", "main", "head", "readOnly", "to", "info", "getChild", "type", "sliceDoc", "text", "content", "add", "Decoration", "replace", "widget", "MermaidWidget", "finish", "WidgetType", "_id", "_source", "eq", "other", "toDOM", "view", "div", "document", "createElement", "setTimeout", "_mermaid", "initialize", "darkMode", "facet", "darkTheme", "theme", "svg", "render", "_error", "className", "innerText", "innerHTML", "requestMeasure", "container", "valid", "parse", "result", "undefined", "_svg", "err", "String", "ignoreEvent", "e", "test", "position", "display", "width", "justifyContent", "color", "MERMAID_PLUGIN", "meta", "id", "name", "description", "icon", "source", "MermaidPlugin", "definePlugin", "meta", "defineModule", "id", "activatesOn", "MarkdownEvents", "SetupExtensions", "activate", "contributes", "MarkdownCapabilities", "Extensions", "mermaid"]
7
7
  }
@@ -1 +1 @@
1
- {"inputs":{"packages/plugins/plugin-mermaid/src/extensions/mermaid.ts":{"bytes":15376,"imports":[{"path":"@codemirror/language","kind":"import-statement","external":true},{"path":"@codemirror/state","kind":"import-statement","external":true},{"path":"@codemirror/view","kind":"import-statement","external":true},{"path":"mermaid","kind":"import-statement","external":true}],"format":"esm"},"packages/plugins/plugin-mermaid/src/extensions/index.ts":{"bytes":513,"imports":[{"path":"packages/plugins/plugin-mermaid/src/extensions/mermaid.ts","kind":"import-statement","original":"./mermaid"}],"format":"esm"},"packages/plugins/plugin-mermaid/src/meta.ts":{"bytes":1529,"imports":[],"format":"esm"},"packages/plugins/plugin-mermaid/src/MermaidPlugin.tsx":{"bytes":2371,"imports":[{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/plugin-markdown","kind":"import-statement","external":true},{"path":"packages/plugins/plugin-mermaid/src/extensions/index.ts","kind":"import-statement","original":"./extensions"},{"path":"packages/plugins/plugin-mermaid/src/meta.ts","kind":"import-statement","original":"./meta"}],"format":"esm"},"packages/plugins/plugin-mermaid/src/index.ts":{"bytes":596,"imports":[{"path":"packages/plugins/plugin-mermaid/src/MermaidPlugin.tsx","kind":"import-statement","original":"./MermaidPlugin"},{"path":"packages/plugins/plugin-mermaid/src/meta.ts","kind":"import-statement","original":"./meta"}],"format":"esm"}},"outputs":{"packages/plugins/plugin-mermaid/dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":9610},"packages/plugins/plugin-mermaid/dist/lib/browser/index.mjs":{"imports":[{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/plugin-markdown","kind":"import-statement","external":true},{"path":"@codemirror/language","kind":"import-statement","external":true},{"path":"@codemirror/state","kind":"import-statement","external":true},{"path":"@codemirror/view","kind":"import-statement","external":true},{"path":"mermaid","kind":"import-statement","external":true}],"exports":["MERMAID_PLUGIN","MermaidPlugin","meta"],"entryPoint":"packages/plugins/plugin-mermaid/src/index.ts","inputs":{"packages/plugins/plugin-mermaid/src/MermaidPlugin.tsx":{"bytesInOutput":405},"packages/plugins/plugin-mermaid/src/extensions/mermaid.ts":{"bytesInOutput":2874},"packages/plugins/plugin-mermaid/src/extensions/index.ts":{"bytesInOutput":0},"packages/plugins/plugin-mermaid/src/meta.ts":{"bytesInOutput":299},"packages/plugins/plugin-mermaid/src/index.ts":{"bytesInOutput":0}},"bytes":3892}}}
1
+ {"inputs":{"packages/plugins/plugin-mermaid/src/extensions/mermaid.ts":{"bytes":15208,"imports":[{"path":"@codemirror/language","kind":"import-statement","external":true},{"path":"@codemirror/state","kind":"import-statement","external":true},{"path":"@codemirror/view","kind":"import-statement","external":true},{"path":"mermaid","kind":"import-statement","external":true}],"format":"esm"},"packages/plugins/plugin-mermaid/src/extensions/index.ts":{"bytes":481,"imports":[{"path":"packages/plugins/plugin-mermaid/src/extensions/mermaid.ts","kind":"import-statement","original":"./mermaid"}],"format":"esm"},"packages/plugins/plugin-mermaid/src/meta.ts":{"bytes":1489,"imports":[],"format":"esm"},"packages/plugins/plugin-mermaid/src/MermaidPlugin.tsx":{"bytes":2315,"imports":[{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/plugin-markdown","kind":"import-statement","external":true},{"path":"packages/plugins/plugin-mermaid/src/extensions/index.ts","kind":"import-statement","original":"./extensions"},{"path":"packages/plugins/plugin-mermaid/src/meta.ts","kind":"import-statement","original":"./meta"}],"format":"esm"},"packages/plugins/plugin-mermaid/src/index.ts":{"bytes":564,"imports":[{"path":"packages/plugins/plugin-mermaid/src/MermaidPlugin.tsx","kind":"import-statement","original":"./MermaidPlugin"},{"path":"packages/plugins/plugin-mermaid/src/meta.ts","kind":"import-statement","original":"./meta"}],"format":"esm"}},"outputs":{"packages/plugins/plugin-mermaid/dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":9645},"packages/plugins/plugin-mermaid/dist/lib/browser/index.mjs":{"imports":[{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/plugin-markdown","kind":"import-statement","external":true},{"path":"@codemirror/language","kind":"import-statement","external":true},{"path":"@codemirror/state","kind":"import-statement","external":true},{"path":"@codemirror/view","kind":"import-statement","external":true},{"path":"mermaid","kind":"import-statement","external":true}],"exports":["MERMAID_PLUGIN","MermaidPlugin","meta"],"entryPoint":"packages/plugins/plugin-mermaid/src/index.ts","inputs":{"packages/plugins/plugin-mermaid/src/MermaidPlugin.tsx":{"bytesInOutput":405},"packages/plugins/plugin-mermaid/src/extensions/mermaid.ts":{"bytesInOutput":2870},"packages/plugins/plugin-mermaid/src/extensions/index.ts":{"bytesInOutput":0},"packages/plugins/plugin-mermaid/src/meta.ts":{"bytesInOutput":299},"packages/plugins/plugin-mermaid/src/index.ts":{"bytesInOutput":0}},"bytes":3888}}}
@@ -1 +1 @@
1
- {"version":3,"file":"mermaid.d.ts","sourceRoot":"","sources":["../../../../src/extensions/mermaid.ts"],"names":[],"mappings":"AAKA,OAAO,EAEL,KAAK,SAAS,EAKf,MAAM,mBAAmB,CAAC;AAI3B,MAAM,MAAM,cAAc,GAAG,EAAE,CAAC;AAEhC,eAAO,MAAM,OAAO,aAAa,cAAc,KAAQ,SAStD,CAAC"}
1
+ {"version":3,"file":"mermaid.d.ts","sourceRoot":"","sources":["../../../../src/extensions/mermaid.ts"],"names":[],"mappings":"AAKA,OAAO,EAEL,KAAK,SAAS,EAKf,MAAM,mBAAmB,CAAC;AAI3B,MAAM,MAAM,cAAc,GAAG,EAAE,CAAC;AAEhC,eAAO,MAAM,OAAO,GAAI,UAAS,cAAmB,KAAG,SAStD,CAAC"}
@@ -1 +1 @@
1
- {"version":"5.7.3"}
1
+ {"version":"5.8.3"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/plugin-mermaid",
3
- "version": "0.8.2-staging.7ac8446",
3
+ "version": "0.8.2",
4
4
  "description": "Mermaid markdown plugin",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -26,31 +26,33 @@
26
26
  "@codemirror/language": "^6.10.3",
27
27
  "@codemirror/state": "^6.4.1",
28
28
  "@codemirror/view": "^6.34.1",
29
+ "@preact-signals/safe-react": "^0.9.0",
30
+ "effect": "^3.13.3",
29
31
  "mermaid": "^10.6.1",
30
- "@dxos/app-framework": "0.8.2-staging.7ac8446",
31
- "@dxos/plugin-space": "0.8.2-staging.7ac8446",
32
- "@dxos/plugin-markdown": "0.8.2-staging.7ac8446",
33
- "@dxos/react-ui-editor": "0.8.2-staging.7ac8446"
32
+ "@dxos/app-framework": "0.8.2",
33
+ "@dxos/plugin-markdown": "0.8.2",
34
+ "@dxos/plugin-space": "0.8.2",
35
+ "@dxos/react-ui-editor": "0.8.2"
34
36
  },
35
37
  "devDependencies": {
36
38
  "@phosphor-icons/react": "^2.1.5",
37
- "@types/lodash.get": "^4.4.7",
38
39
  "@types/react": "~18.2.0",
39
40
  "@types/react-dom": "~18.2.0",
40
41
  "react": "~18.2.0",
41
42
  "react-dom": "~18.2.0",
42
43
  "vite": "5.4.7",
43
- "@dxos/echo-schema": "0.8.2-staging.7ac8446",
44
- "@dxos/react-ui": "0.8.2-staging.7ac8446",
45
- "@dxos/react-ui-theme": "0.8.2-staging.7ac8446",
46
- "@dxos/storybook-utils": "0.8.2-staging.7ac8446"
44
+ "@dxos/react-ui-theme": "0.8.2",
45
+ "@dxos/react-ui": "0.8.2",
46
+ "@dxos/echo-schema": "0.8.2",
47
+ "@dxos/storybook-utils": "0.8.2"
47
48
  },
48
49
  "peerDependencies": {
49
50
  "@phosphor-icons/react": "^2.1.5",
51
+ "effect": "^3.13.3",
50
52
  "react": "~18.2.0",
51
53
  "react-dom": "~18.2.0",
52
- "@dxos/react-ui": "0.8.2-staging.7ac8446",
53
- "@dxos/react-ui-theme": "0.8.2-staging.7ac8446"
54
+ "@dxos/react-ui": "0.8.2",
55
+ "@dxos/react-ui-theme": "0.8.2"
54
56
  },
55
57
  "publishConfig": {
56
58
  "access": "public"
@@ -71,11 +71,11 @@ class MermaidWidget extends WidgetType {
71
71
  super();
72
72
  }
73
73
 
74
- override eq(other: this) {
74
+ override eq(other: this): boolean {
75
75
  return this._source === other._source;
76
76
  }
77
77
 
78
- override toDOM(view: EditorView) {
78
+ override toDOM(view: EditorView): HTMLDivElement {
79
79
  const div = document.createElement('div');
80
80
  setTimeout(async () => {
81
81
  // https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/config.type.ts
@@ -131,7 +131,7 @@ class MermaidWidget extends WidgetType {
131
131
  }
132
132
  }
133
133
 
134
- override ignoreEvent(e: Event) {
134
+ override ignoreEvent(e: Event): boolean {
135
135
  return !/^mouse/.test(e.type);
136
136
  }
137
137
  }
@@ -150,6 +150,6 @@ const styles = EditorView.theme({
150
150
  // },
151
151
  '& .cm-mermaid-error': {
152
152
  display: 'inline-block',
153
- color: 'var(--dx-error)',
153
+ color: 'var(--dx-errorText)',
154
154
  },
155
155
  });