x-star-editor 0.6.0 → 0.6.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.
@@ -140,48 +140,48 @@ var headingOptions = [{
140
140
  depth: 6,
141
141
  fontSize: '0.9em'
142
142
  }];
143
- var mermaidOptions = [{
144
- label: 'Flowchart',
145
- value: "flowchart TD\n A[Start] --> B{Is it?}\n B -- Yes --> C[OK]\n C --> D[Rethink]\n D --> B\n B -- No ----> E[End]"
146
- }, {
147
- label: 'Sequence Diagram',
148
- value: "sequenceDiagram\n Alice->>John: Hello John, how are you?\n John-->>Alice: Great!\n Alice-)John: See you later!"
149
- }, {
150
- label: 'Class Diagram',
151
- value: "classDiagram\n Animal <|-- Duck\n Animal <|-- Fish\n Animal <|-- Zebra\n Animal : +int age\n Animal : +String gender\n Animal: +isMammal()\n Animal: +mate()\n class Duck{\n +String beakColor\n +swim()\n +quack()\n }\n class Fish{\n -int sizeInFeet\n -canEat()\n }\n class Zebra{\n +bool is_wild\n +run()\n }"
152
- }, {
153
- label: 'State Diagram',
154
- value: "stateDiagram-v2\n [*] --> Still\n Still --> [*]\n\n Still --> Moving\n Moving --> Still\n Moving --> Crash\n Crash --> [*]"
155
- }, {
156
- label: 'Entity Relationship Diagram',
157
- value: "erDiagram\n CUSTOMER ||--o{ ORDER : places\n ORDER ||--|{ LINE-ITEM : contains\n CUSTOMER }|..|{ DELIVERY-ADDRESS : uses"
158
- }, {
159
- label: 'User Journey',
160
- value: "journey\n title My working day\n section Go to work\n Make tea: 5: Me\n Go upstairs: 3: Me\n Do work: 1: Me, Cat\n section Go home\n Go downstairs: 5: Me\n Sit down: 5: Me"
161
- }, {
162
- label: 'Gantt',
163
- value: "gantt\n title A Gantt Diagram\n dateFormat YYYY-MM-DD\n section Section\n A task :a1, 2014-01-01, 30d\n Another task :after a1, 20d\n section Another\n Task in Another :2014-01-12, 12d\n another task :24d"
164
- }, {
165
- label: 'Pie Chart',
166
- value: "pie title Pets adopted by volunteers\n \"Dogs\" : 386\n \"Cats\" : 85\n \"Rats\" : 15"
167
- }, {
168
- label: 'Quadrant Chart',
169
- value: "quadrantChart\n title Reach and engagement of campaigns\n x-axis Low Reach --> High Reach\n y-axis Low Engagement --> High Engagement\n quadrant-1 We should expand\n quadrant-2 Need to promote\n quadrant-3 Re-evaluate\n quadrant-4 May be improved\n Campaign A: [0.3, 0.6]\n Campaign B: [0.45, 0.23]\n Campaign C: [0.57, 0.69]\n Campaign D: [0.78, 0.34]\n Campaign E: [0.40, 0.34]\n Campaign F: [0.35, 0.78]"
170
- }, {
171
- label: 'Requirement Diagram',
172
- value: "requirementDiagram\n\n requirement test_req {\n id: 1\n text: the test text.\n risk: high\n verifymethod: test\n }\n\n element test_entity {\n type: simulation\n }\n\n test_entity - satisfies -> test_req"
173
- }, {
174
- label: 'Gitgraph (Git) Diagram',
175
- value: "gitGraph\n commit\n commit\n branch develop\n checkout develop\n commit\n commit\n checkout main\n merge develop\n commit\n commit"
176
- }, {
177
- label: 'Mindmaps',
178
- value: "mindmap\n root((mindmap))\n Origins\n Long history\n ::icon(fa fa-book)\n Popularisation\n British popular psychology author Tony Buzan\n Research\n On effectiveness<br/>and features\n On Automatic creation\n Uses\n Creative techniques\n Strategic planning\n Argument mapping\n Tools\n Pen and paper\n Mermaid"
179
- }, {
180
- label: 'Timeline',
181
- value: "timeline\n title History of Social Media Platform\n 2002 : LinkedIn\n 2004 : Facebook\n : Google\n 2005 : Youtube\n 2006 : Twitter"
182
- }];
183
143
  export var getDefaultToolbarItemMap = function getDefaultToolbarItemMap(locale, onInsertFile) {
184
144
  var t = getFormat(locale, 'toolbarItem');
145
+ var mermaidOptions = [{
146
+ label: t('flowChat'),
147
+ value: "flowchart TD\n A[Start] --> B{Is it?}\n B -- Yes --> C[OK]\n C --> D[Rethink]\n D --> B\n B -- No ----> E[End]"
148
+ }, {
149
+ label: t('sequenceDiagram'),
150
+ value: "sequenceDiagram\n Alice->>John: Hello John, how are you?\n John-->>Alice: Great!\n Alice-)John: See you later!"
151
+ }, {
152
+ label: t('classDiagram'),
153
+ value: "classDiagram\n Animal <|-- Duck\n Animal <|-- Fish\n Animal <|-- Zebra\n Animal : +int age\n Animal : +String gender\n Animal: +isMammal()\n Animal: +mate()\n class Duck{\n +String beakColor\n +swim()\n +quack()\n }\n class Fish{\n -int sizeInFeet\n -canEat()\n }\n class Zebra{\n +bool is_wild\n +run()\n }"
154
+ }, {
155
+ label: t('stateDiagram'),
156
+ value: "stateDiagram-v2\n [*] --> Still\n Still --> [*]\n \n Still --> Moving\n Moving --> Still\n Moving --> Crash\n Crash --> [*]"
157
+ }, {
158
+ label: t('ERDiagram'),
159
+ value: "erDiagram\n CUSTOMER ||--o{ ORDER : places\n ORDER ||--|{ LINE-ITEM : contains\n CUSTOMER }|..|{ DELIVERY-ADDRESS : uses"
160
+ }, {
161
+ label: t('userJourney'),
162
+ value: "journey\n title My working day\n section Go to work\n Make tea: 5: Me\n Go upstairs: 3: Me\n Do work: 1: Me, Cat\n section Go home\n Go downstairs: 5: Me\n Sit down: 5: Me"
163
+ }, {
164
+ label: t('Gantt'),
165
+ value: "gantt\n title A Gantt Diagram\n dateFormat YYYY-MM-DD\n section Section\n A task :a1, 2014-01-01, 30d\n Another task :after a1, 20d\n section Another\n Task in Another :2014-01-12, 12d\n another task :24d"
166
+ }, {
167
+ label: t('pieChart'),
168
+ value: "pie title Pets adopted by volunteers\n \"Dogs\" : 386\n \"Cats\" : 85\n \"Rats\" : 15"
169
+ }, {
170
+ label: t('quadrantChart'),
171
+ value: "quadrantChart\n title Reach and engagement of campaigns\n x-axis Low Reach --> High Reach\n y-axis Low Engagement --> High Engagement\n quadrant-1 We should expand\n quadrant-2 Need to promote\n quadrant-3 Re-evaluate\n quadrant-4 May be improved\n Campaign A: [0.3, 0.6]\n Campaign B: [0.45, 0.23]\n Campaign C: [0.57, 0.69]\n Campaign D: [0.78, 0.34]\n Campaign E: [0.40, 0.34]\n Campaign F: [0.35, 0.78]"
172
+ }, {
173
+ label: t('requirementDiagram'),
174
+ value: "requirementDiagram\n \n requirement test_req {\n id: 1\n text: the test text.\n risk: high\n verifymethod: test\n }\n \n element test_entity {\n type: simulation\n }\n \n test_entity - satisfies -> test_req"
175
+ }, {
176
+ label: t('gitGraphDiagram'),
177
+ value: "gitGraph\n commit\n commit\n branch develop\n checkout develop\n commit\n commit\n checkout main\n merge develop\n commit\n commit"
178
+ }, {
179
+ label: t('mindMaps'),
180
+ value: "mindmap\n root((mindmap))\n Origins\n Long history\n ::icon(fa fa-book)\n Popularisation\n British popular psychology author Tony Buzan\n Research\n On effectiveness<br/>and features\n On Automatic creation\n Uses\n Creative techniques\n Strategic planning\n Argument mapping\n Tools\n Pen and paper\n Mermaid"
181
+ }, {
182
+ label: t('timeLine'),
183
+ value: "timeline\n title History of Social Media Platform\n 2002 : LinkedIn\n 2004 : Facebook\n : Google\n 2005 : Youtube\n 2006 : Twitter"
184
+ }];
185
185
  return {
186
186
  blockquote: {
187
187
  children: /*#__PURE__*/React.createElement(SvgBlockquote, {
@@ -34,6 +34,19 @@ declare const _default: {
34
34
  readonly undo: "Undo";
35
35
  readonly unorderedList: "Unordered List";
36
36
  readonly viewOnly: "View Only";
37
+ readonly flowChat: "Flowchart";
38
+ readonly sequenceDiagram: "sequenceDiagram";
39
+ readonly classDiagram: "Class Diagram";
40
+ readonly stateDiagram: "State Diagram";
41
+ readonly ERDiagram: "Entity Relationship Diagram";
42
+ readonly userJourney: "User Journey";
43
+ readonly Gantt: "Gantt";
44
+ readonly pieChart: "Pie Chart";
45
+ readonly quadrantChart: "Quadrant Chart";
46
+ readonly requirementDiagram: "Requirement Diagram";
47
+ readonly gitGraphDiagram: "Gitgraph (Git) Diagram";
48
+ readonly mindMaps: "Mindmaps";
49
+ readonly timeLine: "Timeline";
37
50
  };
38
51
  };
39
52
  export default _default;
@@ -33,6 +33,19 @@ export default {
33
33
  toMarkdown: 'To Markdown',
34
34
  undo: 'Undo',
35
35
  unorderedList: 'Unordered List',
36
- viewOnly: 'View Only'
36
+ viewOnly: 'View Only',
37
+ flowChat: 'Flowchart',
38
+ sequenceDiagram: 'sequenceDiagram',
39
+ classDiagram: 'Class Diagram',
40
+ stateDiagram: 'State Diagram',
41
+ ERDiagram: 'Entity Relationship Diagram',
42
+ userJourney: 'User Journey',
43
+ Gantt: 'Gantt',
44
+ pieChart: 'Pie Chart',
45
+ quadrantChart: 'Quadrant Chart',
46
+ requirementDiagram: 'Requirement Diagram',
47
+ gitGraphDiagram: 'Gitgraph (Git) Diagram',
48
+ mindMaps: 'Mindmaps',
49
+ timeLine: 'Timeline'
37
50
  }
38
51
  };
@@ -45,6 +45,19 @@ export declare const useLocale: <T extends "fileInput" | "toolbarItem">(slice: T
45
45
  readonly undo: "撤销";
46
46
  readonly unorderedList: "无序列表";
47
47
  readonly viewOnly: "仅查看";
48
+ readonly flowChat: "流程图";
49
+ readonly sequenceDiagram: "时序图";
50
+ readonly classDiagram: "类图";
51
+ readonly stateDiagram: "状态图";
52
+ readonly ERDiagram: "实体关系图";
53
+ readonly userJourney: "用户旅程图";
54
+ readonly Gantt: "甘特图";
55
+ readonly pieChart: "饼图";
56
+ readonly quadrantChart: "四象限图";
57
+ readonly requirementDiagram: "需求图";
58
+ readonly gitGraphDiagram: "Git图";
59
+ readonly mindMaps: "思维导图";
60
+ readonly timeLine: "时间线图";
48
61
  };
49
62
  } | {
50
63
  readonly fileInput: {
@@ -82,6 +95,19 @@ export declare const useLocale: <T extends "fileInput" | "toolbarItem">(slice: T
82
95
  readonly undo: "Undo";
83
96
  readonly unorderedList: "Unordered List";
84
97
  readonly viewOnly: "View Only";
98
+ readonly flowChat: "Flowchart";
99
+ readonly sequenceDiagram: "sequenceDiagram";
100
+ readonly classDiagram: "Class Diagram";
101
+ readonly stateDiagram: "State Diagram";
102
+ readonly ERDiagram: "Entity Relationship Diagram";
103
+ readonly userJourney: "User Journey";
104
+ readonly Gantt: "Gantt";
105
+ readonly pieChart: "Pie Chart";
106
+ readonly quadrantChart: "Quadrant Chart";
107
+ readonly requirementDiagram: "Requirement Diagram";
108
+ readonly gitGraphDiagram: "Gitgraph (Git) Diagram";
109
+ readonly mindMaps: "Mindmaps";
110
+ readonly timeLine: "Timeline";
85
111
  };
86
112
  })[T][U];
87
113
  };
@@ -121,6 +147,19 @@ export declare const getFormat: <T extends "fileInput" | "toolbarItem">(locale:
121
147
  readonly undo: "撤销";
122
148
  readonly unorderedList: "无序列表";
123
149
  readonly viewOnly: "仅查看";
150
+ readonly flowChat: "流程图";
151
+ readonly sequenceDiagram: "时序图";
152
+ readonly classDiagram: "类图";
153
+ readonly stateDiagram: "状态图";
154
+ readonly ERDiagram: "实体关系图";
155
+ readonly userJourney: "用户旅程图";
156
+ readonly Gantt: "甘特图";
157
+ readonly pieChart: "饼图";
158
+ readonly quadrantChart: "四象限图";
159
+ readonly requirementDiagram: "需求图";
160
+ readonly gitGraphDiagram: "Git图";
161
+ readonly mindMaps: "思维导图";
162
+ readonly timeLine: "时间线图";
124
163
  };
125
164
  } | {
126
165
  readonly fileInput: {
@@ -158,6 +197,19 @@ export declare const getFormat: <T extends "fileInput" | "toolbarItem">(locale:
158
197
  readonly undo: "Undo";
159
198
  readonly unorderedList: "Unordered List";
160
199
  readonly viewOnly: "View Only";
200
+ readonly flowChat: "Flowchart";
201
+ readonly sequenceDiagram: "sequenceDiagram";
202
+ readonly classDiagram: "Class Diagram";
203
+ readonly stateDiagram: "State Diagram";
204
+ readonly ERDiagram: "Entity Relationship Diagram";
205
+ readonly userJourney: "User Journey";
206
+ readonly Gantt: "Gantt";
207
+ readonly pieChart: "Pie Chart";
208
+ readonly quadrantChart: "Quadrant Chart";
209
+ readonly requirementDiagram: "Requirement Diagram";
210
+ readonly gitGraphDiagram: "Gitgraph (Git) Diagram";
211
+ readonly mindMaps: "Mindmaps";
212
+ readonly timeLine: "Timeline";
161
213
  };
162
214
  })[T][U];
163
215
  export {};
@@ -34,6 +34,19 @@ declare const _default: {
34
34
  readonly undo: "撤销";
35
35
  readonly unorderedList: "无序列表";
36
36
  readonly viewOnly: "仅查看";
37
+ readonly flowChat: "流程图";
38
+ readonly sequenceDiagram: "时序图";
39
+ readonly classDiagram: "类图";
40
+ readonly stateDiagram: "状态图";
41
+ readonly ERDiagram: "实体关系图";
42
+ readonly userJourney: "用户旅程图";
43
+ readonly Gantt: "甘特图";
44
+ readonly pieChart: "饼图";
45
+ readonly quadrantChart: "四象限图";
46
+ readonly requirementDiagram: "需求图";
47
+ readonly gitGraphDiagram: "Git图";
48
+ readonly mindMaps: "思维导图";
49
+ readonly timeLine: "时间线图";
37
50
  };
38
51
  };
39
52
  export default _default;
@@ -33,6 +33,19 @@ export default {
33
33
  toMarkdown: '转成 Markdown',
34
34
  undo: '撤销',
35
35
  unorderedList: '无序列表',
36
- viewOnly: '仅查看'
36
+ viewOnly: '仅查看',
37
+ flowChat: '流程图',
38
+ sequenceDiagram: '时序图',
39
+ classDiagram: '类图',
40
+ stateDiagram: '状态图',
41
+ ERDiagram: '实体关系图',
42
+ userJourney: '用户旅程图',
43
+ Gantt: '甘特图',
44
+ pieChart: '饼图',
45
+ quadrantChart: '四象限图',
46
+ requirementDiagram: '需求图',
47
+ gitGraphDiagram: 'Git图',
48
+ mindMaps: '思维导图',
49
+ timeLine: '时间线图'
37
50
  }
38
51
  };
@@ -1847,8 +1847,8 @@ body {
1847
1847
  background-color: #c1def1;
1848
1848
  }
1849
1849
  .x-star-editor-slide-viewer .x-star-editor-slide {
1850
- width: 960px;
1851
- height: 540px;
1850
+ width: 1280px;
1851
+ height: 720px;
1852
1852
  padding: 0 32px;
1853
1853
  display: flex;
1854
1854
  flex-direction: column;
@@ -1889,7 +1889,7 @@ body {
1889
1889
  .x-star-editor-slide-viewer .x-star-editor-slide pre {
1890
1890
  width: 70%;
1891
1891
  }
1892
- .x-star-editor-slide-viewer .x-star-editor-slide img {
1892
+ .x-star-editor-slide-viewer .x-star-editor-slide img[id^=user-content-mermaid-] {
1893
1893
  width: 100%;
1894
1894
  max-height: 100%;
1895
1895
  }
@@ -43,7 +43,7 @@ export declare const toHTML: (sourceCode: string) => string;
43
43
  * @returns Markdown 文本
44
44
  */
45
45
  export declare const toMarkdown: (sourceCode: string) => string;
46
- export interface ToTextOptions extends ToStringOptions {
46
+ interface ToTextOptions extends ToStringOptions {
47
47
  /**
48
48
  * 替换图片的 alt 文本
49
49
  */
@@ -56,3 +56,4 @@ export interface ToTextOptions extends ToStringOptions {
56
56
  * @returns 纯文本
57
57
  */
58
58
  export declare const toText: (sourceCode: string, options?: ToTextOptions) => string;
59
+ export {};
@@ -8,7 +8,7 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
8
8
  var _excluded = ["checked"];
9
9
  import { toJsxRuntime } from 'hast-util-to-jsx-runtime';
10
10
  import { toText as hastToText } from 'hast-util-to-text';
11
- import { toString } from 'mdast-util-to-string';
11
+ import { toString as mdastToString } from 'mdast-util-to-string';
12
12
  import { Fragment, jsx, jsxs } from 'react/jsx-runtime';
13
13
  import rehypeKatex from 'rehype-katex';
14
14
  import rehypeMermaid from 'rehype-mermaidjs';
@@ -273,15 +273,28 @@ var toHastProcessor = unified().use(remarkBreaks).use(remarkRehype, {
273
273
  image: function image(h, node) {
274
274
  try {
275
275
  var _node$alt;
276
- var styles = (_node$alt = node.alt) === null || _node$alt === void 0 ? void 0 : _node$alt.split(' ');
276
+ var alts = [];
277
+ var styles = [];
278
+ (_node$alt = node.alt) === null || _node$alt === void 0 ? void 0 : _node$alt.split(' ').forEach(function (word) {
279
+ var s = word.split(':');
280
+ if (s.length !== 2) {
281
+ alts.push(word);
282
+ } else {
283
+ if (s[0] === 'w') {
284
+ s[0] = 'width';
285
+ } else if (s[0] === 'h') {
286
+ s[0] = 'height';
287
+ }
288
+ if ((s[0] === 'width' || s[0] === 'height') && /^\d+$/.test(s[1])) {
289
+ s[1] += 'px';
290
+ }
291
+ styles.push(s.join(':'));
292
+ }
293
+ });
277
294
  return h(node, 'img', {
278
295
  src: node.url,
279
- alt: styles === null || styles === void 0 ? void 0 : styles.filter(function (i) {
280
- return !i.includes(':');
281
- }).join(' '),
282
- style: styles === null || styles === void 0 ? void 0 : styles.filter(function (i) {
283
- return i.includes(':');
284
- }).join(';')
296
+ alt: alts.join(' '),
297
+ style: styles.join(';')
285
298
  });
286
299
  } catch (_unused) {
287
300
  return h(node, 'img', {
@@ -453,5 +466,5 @@ export var toText = function toText(sourceCode, options) {
453
466
  node.alt = options.replaceImageAlt;
454
467
  });
455
468
  }
456
- return toString(root, options);
469
+ return mdastToString(root, options);
457
470
  };
@@ -1,5 +1,5 @@
1
1
  // import _ from 'lodash';
2
- // import { CanvasData } from 'x-star-editor/x-star-slide-viewer';
2
+ // import { CanvasData } from '../../x-star-slide-viewer';
3
3
 
4
4
  // /**
5
5
  // *
@@ -104,17 +104,14 @@ var XStarMdEditor = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
104
104
  return sourceCodeLatest.current;
105
105
  },
106
106
  setValue: function setValue(value) {
107
- return exec(function (_ref2) {
108
- var selection = _ref2.selection,
109
- dispatch = _ref2.dispatch;
110
- return dispatch({
111
- type: 'set',
112
- payload: {
113
- sourceCode: value,
114
- selection: selection
115
- },
107
+ var selection = getSelection();
108
+ dispatch({
109
+ type: 'set',
110
+ payload: {
111
+ sourceCode: value,
116
112
  selection: selection
117
- });
113
+ },
114
+ selection: selection
118
115
  });
119
116
  }
120
117
  };
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { ViewerOptions } from "../x-star-md-viewer/index.js";
2
+ import type { ViewerOptions } from '../x-star-md-viewer';
3
3
  export interface XStarSlideViewerPlugin {
4
4
  (ctx: ViewerOptions): void;
5
5
  }