ronds-metadata 1.2.29 → 1.2.31

Sign up to get free protection for your applications and to get access to all the features.
@@ -32,7 +32,10 @@ var Settings = function Settings() {
32
32
  }); // 处理默认数据
33
33
 
34
34
  var processDefaultValue = React.useCallback(function (data) {
35
+ var _data$settings;
36
+
35
37
  settingValueRef.current = data.settings;
38
+ formRef.current.setFieldsValue(_objectSpread({}, (data === null || data === void 0 ? void 0 : (_data$settings = data.settings) === null || _data$settings === void 0 ? void 0 : _data$settings.formSetting) || {}));
36
39
  fGCtx.fgStream && fGCtx.fgStream.next({
37
40
  type: streamEventType.onSettingValueChange,
38
41
  payload: _objectSpread(_objectSpread({}, data.settings), {}, {
@@ -4,7 +4,7 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
4
4
  /*
5
5
  * @Author: wangxian
6
6
  * @Date: 2023-02-04 13:45:31
7
- * @LastEditTime: 2023-04-01 09:37:13
7
+ * @LastEditTime: 2023-04-06 10:38:34
8
8
  */
9
9
  import React from 'react';
10
10
  import { DndProvider } from 'react-dnd';
@@ -32,18 +32,19 @@ var FormGenerator = function FormGenerator(props) {
32
32
 
33
33
  var typesRef = React.useRef({});
34
34
  React.useEffect(function () {
35
- var robot = new FormRobot();
35
+ var robot = new FormRobot(); // const name = robot.input('name').label('名称').require().placeholder('请输入名称').valueOf();
36
+ // const age = robot.input('age').label('年龄').defaultValue(1).valueOf();
37
+ // const address = robot.textarea('address').label('地址').help('详细地址').valueOf();
38
+ // const sex = robot.select('sex').label('性别').valueOf();
39
+ // const birthday = robot.date('birthday').label('出身年月').require().valueOf();
40
+ // const detail = robot.object([name, age], 'detail').valueOf();
41
+ // const arr = robot.create([name, age, address, sex, birthday, detail]).grid(2).toString();
36
42
 
37
- var name = robot.input('name').label('名称').require().placeholder('请输入名称').valueOf();
43
+ var project = robot.select('project').label('归档标签库').valueOf();
44
+ var group = robot.select('group').label('标签组').valueOf();
45
+ var label = robot.select('label').label('标签').valueOf();
38
46
 
39
- var age = robot.input('age').label('年龄').defaultValue(1).valueOf();
40
- var address = robot.textarea('address').label('地址').help('详细地址').valueOf();
41
- var sex = robot.select('sex').label('性别').valueOf();
42
-
43
- var birthday = robot.date('birthday').label('出身年月').require().valueOf();
44
-
45
- var detail = robot.object([name, age], 'detail').valueOf();
46
- var arr = robot.create([name, age, address, sex, birthday, detail]).grid(2).toString();
47
+ var _res = robot.create([project, group, label]).toString();
47
48
  }, []);
48
49
  React.useEffect(function () {
49
50
  if (defaultSchema) {
@@ -4,7 +4,7 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
4
4
  /*
5
5
  * @Author: wangxian
6
6
  * @Date: 2023-02-08 14:45:46
7
- * @LastEditTime: 2023-03-25 11:33:24
7
+ * @LastEditTime: 2023-04-06 10:38:43
8
8
  */
9
9
  import { deepClone } from '../../utils';
10
10
  import { basicComps, complexComps, layoutComps } from './settings';
@@ -85,7 +85,7 @@ export var transFG2Schema = function transFG2Schema(nodes, settings, _types, sch
85
85
  };
86
86
  }
87
87
 
88
- var _prop = renderProp(nodes[i], settings ? settings[nodes[i].id] : nodes[i].param.setting);
88
+ var _prop = renderProp(nodes[i], settings[nodes[i].id] ? settings[nodes[i].id] : nodes[i].param.setting);
89
89
 
90
90
  props.push(_prop);
91
91
  }
@@ -272,14 +272,22 @@ var getTypeParent = function getTypeParent(refId, _props) {
272
272
 
273
273
 
274
274
  export var transSchema2FG = function transSchema2FG(schema) {
275
- var _schema$;
275
+ var _schema$, _schema$2;
276
276
 
277
277
  var res = {
278
278
  nodes: [],
279
279
  settings: {},
280
280
  types: {}
281
281
  };
282
- var _props = schema[0].properties;
282
+ var _props = schema[0].properties; // 表单扩展规则
283
+
284
+ var _formFields = (_schema$ = schema[0]) === null || _schema$ === void 0 ? void 0 : _schema$.fields;
285
+
286
+ if (_formFields) {
287
+ res.settings = _objectSpread(_objectSpread({}, res.settings), {}, {
288
+ formSetting: _formFields[0].value
289
+ });
290
+ }
283
291
 
284
292
  for (var i = 0; i < _props.length; i++) {
285
293
  var obj = processProps(_props[i]);
@@ -287,7 +295,7 @@ export var transSchema2FG = function transSchema2FG(schema) {
287
295
  res.settings = _objectSpread(_objectSpread({}, res.settings), obj.setting);
288
296
  }
289
297
 
290
- var _types = (_schema$ = schema[0]) === null || _schema$ === void 0 ? void 0 : _schema$.types;
298
+ var _types = (_schema$2 = schema[0]) === null || _schema$2 === void 0 ? void 0 : _schema$2.types;
291
299
 
292
300
  if (_types && _types.length > 0) {
293
301
  for (var _i2 = 0; _i2 < _types.length; _i2++) {
@@ -1,13 +1,13 @@
1
1
  /*
2
2
  * @Author: your name
3
3
  * @Date: 2021-12-15 15:29:51
4
- * @LastEditTime: 2022-09-02 16:52:09
4
+ * @LastEditTime: 2023-04-12 16:19:26
5
5
  */
6
6
  import React from 'react';
7
7
  import MdEditor from 'react-markdown-editor-lite';
8
8
  import 'react-markdown-editor-lite/lib/index.css';
9
9
  import './index.less';
10
- import MdView from '../MdView';
10
+ import MdView from '../MdView'; // MdEditor.use(Mark);
11
11
 
12
12
  var MdEdit = function MdEdit(props) {
13
13
  var value = props.value,
@@ -16,12 +16,17 @@ var MdEdit = function MdEdit(props) {
16
16
  onChange = props.onChange,
17
17
  onImageUpload = props.onImageUpload,
18
18
  onCustomImageUpload = props.onCustomImageUpload;
19
+ var mdEditor = React.useRef();
19
20
 
20
21
  var onValueChange = function onValueChange(v) {
21
22
  onChange && onChange(v.text);
22
23
  };
23
24
 
25
+ React.useEffect(function () {}, []);
24
26
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(MdEditor, {
27
+ ref: function ref(node) {
28
+ return mdEditor.current = node;
29
+ },
25
30
  value: value,
26
31
  onImageUpload: onImageUpload,
27
32
  onCustomImageUpload: onCustomImageUpload,
@@ -1,3 +1,6 @@
1
- .rc-md-editor.full {
2
- width: 100% !important;
3
- }
1
+ .rc-md-editor.full {
2
+ width: 100% !important;
3
+ }
4
+ .rc-md-editor .rc-md-navigation .button-wrap {
5
+ align-items: center;
6
+ }
@@ -0,0 +1,5 @@
1
+ interface IEditContentProps {
2
+ source: string;
3
+ }
4
+ declare const EditContent: (props: IEditContentProps) => JSX.Element;
5
+ export default EditContent;
@@ -0,0 +1,34 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
+ import MarkdownIt from 'markdown-it';
3
+ import React from 'react';
4
+ import ContentEditable from 'react-contenteditable';
5
+
6
+ var EditContent = function EditContent(props) {
7
+ var source = props.source;
8
+
9
+ var _React$useState = React.useState(),
10
+ _React$useState2 = _slicedToArray(_React$useState, 2),
11
+ html = _React$useState2[0],
12
+ setHtml = _React$useState2[1];
13
+
14
+ React.useEffect(function () {
15
+ var md = new MarkdownIt();
16
+
17
+ var _html = md.render(source);
18
+
19
+ setHtml(_html);
20
+ }, [source]);
21
+ return /*#__PURE__*/React.createElement(ContentEditable, {
22
+ className: "editable",
23
+ tagName: "pre",
24
+ html: html // innerHTML of the editable div
25
+ ,
26
+ disabled: false // use true to disable edition
27
+ ,
28
+ onChange: function onChange() {} // handle innerHTML change
29
+ ,
30
+ onBlur: function onBlur() {}
31
+ });
32
+ };
33
+
34
+ export default EditContent;
@@ -0,0 +1,7 @@
1
+ import { PluginProps } from 'react-markdown-editor-lite';
2
+ declare const Mark: {
3
+ (props: PluginProps): JSX.Element;
4
+ align: string;
5
+ pluginName: string;
6
+ };
7
+ export default Mark;
@@ -0,0 +1,60 @@
1
+ import "antd/es/button/style";
2
+ import _Button from "antd/es/button";
3
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
4
+
5
+ /*
6
+ * @Author: uloveits 719310130@qq.com
7
+ * @Date: 2023-04-12 13:36:01
8
+ * @LastEditors: uloveits 719310130@qq.com
9
+ * @LastEditTime: 2023-04-12 16:19:09
10
+ */
11
+ import React from 'react';
12
+ import { BookOutlined } from '@ant-design/icons';
13
+
14
+ var Mark = function Mark(props) {
15
+ var _React$useState = React.useState([]),
16
+ _React$useState2 = _slicedToArray(_React$useState, 2),
17
+ images = _React$useState2[0],
18
+ setImages = _React$useState2[1];
19
+
20
+ var onChange = function onChange(mdString) {
21
+ getImages(mdString);
22
+ };
23
+
24
+ var getImages = function getImages(mdString) {
25
+ var regex = /\!\[.*\]\((.*?)\)/g;
26
+ var _images = [];
27
+ var match;
28
+
29
+ while ((match = regex.exec(mdString)) !== null) {
30
+ _images.push(match[1]);
31
+ }
32
+
33
+ setImages([].concat(_images));
34
+ };
35
+
36
+ React.useEffect(function () {
37
+ var mdString = props.editor.getMdValue();
38
+ getImages(mdString);
39
+ props.editor.on('change', onChange);
40
+ }, []);
41
+
42
+ var handleClick = function handleClick() {// 调用API,往编辑器中插入一个数字
43
+ // props.editor.insertText(num.toString());
44
+ // // 更新一下自身的state
45
+ // setNum(num + 1);
46
+ };
47
+
48
+ return /*#__PURE__*/React.createElement(_Button, {
49
+ size: "small",
50
+ disabled: images.length === 0,
51
+ type: "link",
52
+ icon: /*#__PURE__*/React.createElement(BookOutlined, null),
53
+ onClick: handleClick
54
+ });
55
+ };
56
+
57
+ export default Mark; // 如果需要的话,可以在这里定义默认选项
58
+
59
+ Mark.align = 'left';
60
+ Mark.pluginName = 'mark';
@@ -17,7 +17,7 @@ import _Input from "antd/es/input";
17
17
  /*
18
18
  * @Author: wangxian
19
19
  * @Date: 2021-09-18 14:15:04
20
- * @LastEditTime: 2023-03-08 15:50:12
20
+ * @LastEditTime: 2023-04-04 09:20:39
21
21
  */
22
22
  import React from 'react';
23
23
  import { UploadOutlined } from '@ant-design/icons';
@@ -76,6 +76,8 @@ function Index(props) {
76
76
 
77
77
  case 'textarea':
78
78
  return /*#__PURE__*/React.createElement(TextArea, {
79
+ showCount: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.showCount,
80
+ maxLength: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.maxLength,
79
81
  rows: (extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.textareaRows) || 4,
80
82
  disabled: (_extraInfo$disabled2 = extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.disabled) !== null && _extraInfo$disabled2 !== void 0 ? _extraInfo$disabled2 : disabled,
81
83
  placeholder: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.placeholder
@@ -114,6 +116,8 @@ function Index(props) {
114
116
  value: v
115
117
  }, v);
116
118
  }))) : undefined,
119
+ showCount: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.showCount,
120
+ maxLength: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.maxLength,
117
121
  disabled: (_extraInfo$disabled6 = extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.disabled) !== null && _extraInfo$disabled6 !== void 0 ? _extraInfo$disabled6 : disabled,
118
122
  placeholder: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.placeholder,
119
123
  allowClear: true,
@@ -3,19 +3,58 @@ interface ICreate {
3
3
  create(data: any): ILayoutSetting & IReturnMethod;
4
4
  }
5
5
  interface ILayoutSetting {
6
+ /**
7
+ * 表单整体布局
8
+ * @param this
9
+ * @param _value 最多限制4行
10
+ */
6
11
  grid<T>(this: T, _value: 1 | 2 | 3 | 4): Omit<T, 'grid'> & IReturnMethod;
12
+ /**
13
+ * 标签展示模式
14
+ * @param this
15
+ * @param _value horizontal:同行 vertical:单独一行
16
+ */
17
+ layout<T>(this: T, _value: 'horizontal' | 'vertical'): Omit<T, 'layout'> & IReturnMethod;
18
+ /**
19
+ * 标签宽度
20
+ * @param this
21
+ * @param _value
22
+ */
7
23
  labelSpan<T>(this: T, _value: number): Omit<T, 'labelSpan'> & IReturnMethod;
8
24
  }
9
25
  interface IComps {
10
26
  object(data: FG.Node[] | any, _id: string): ICommonSetting & IReturnMethod;
11
- input(_id: string): ICommonSetting;
12
- textarea(_id: string): ICommonSetting;
27
+ input(_id: string): ICommonSetting & ITextAreaSetting;
28
+ textarea(_id: string): ICommonSetting & ITextAreaSetting;
13
29
  date(_id: string): ICommonSetting;
14
30
  number(_id: string): ICommonSetting;
15
31
  switch(_id: string): ICommonSetting;
16
- select(_id: string): ICommonSetting;
32
+ select(_id: string): ICommonSetting & ISelectSetting;
17
33
  mutiSelect(_id: string): ICommonSetting;
18
34
  }
35
+ interface ITextAreaSetting {
36
+ /**
37
+ * 显示计数器
38
+ * @param this
39
+ */
40
+ showCount<T>(this: T): Omit<T, 'showCount'> & IReturnMethod;
41
+ /**
42
+ * 最大字数限制
43
+ * @param this
44
+ * @param _value
45
+ */
46
+ maxLength<T>(this: T, _value: number): Omit<T, 'maxLength'> & IReturnMethod;
47
+ }
48
+ interface ISelectSetting {
49
+ /**
50
+ * 枚举值
51
+ * @param this
52
+ */
53
+ enum<T>(this: T, _value: {
54
+ key: number | string;
55
+ value: string;
56
+ }[]): Omit<T, 'enum'> & IReturnMethod;
57
+ }
19
58
  interface ICommonSetting {
20
59
  label<T>(this: T, _label: string): Omit<T, 'label'> & IReturnMethod;
21
60
  require<T>(this: T): Omit<T, 'require'> & IReturnMethod;
@@ -74,13 +113,13 @@ export declare class FormRobot implements IFormRobot {
74
113
  * @param _id 属性名
75
114
  * @returns
76
115
  */
77
- input(_id: string): ICommonSetting;
116
+ input(_id: string): ICommonSetting & ITextAreaSetting;
78
117
  /**
79
118
  * 文本框
80
119
  * @param _id
81
120
  * @returns
82
121
  */
83
- textarea(_id: string): ICommonSetting;
122
+ textarea(_id: string): ICommonSetting & ITextAreaSetting;
84
123
  /**
85
124
  * 日期选择
86
125
  * @param _id
@@ -104,7 +143,7 @@ export declare class FormRobot implements IFormRobot {
104
143
  * @param _id
105
144
  * @returns
106
145
  */
107
- select(_id: string): ICommonSetting;
146
+ select(_id: string): ICommonSetting & ISelectSetting;
108
147
  /**
109
148
  * 下拉多选
110
149
  * @param _id
@@ -122,7 +161,31 @@ export declare class FormRobot implements IFormRobot {
122
161
  disabled<T>(this: T): Omit<T, 'disabled'> & IReturnMethod;
123
162
  br<T>(this: T): Omit<T, 'br'> & IReturnMethod;
124
163
  hidden<T>(this: T): Omit<T, 'hidden'> & IReturnMethod;
164
+ enum<T>(this: T, _value: {
165
+ key: number | string;
166
+ value: string;
167
+ }[]): Omit<T, 'enum'> & IReturnMethod;
168
+ /**
169
+ * 整体布局
170
+ * @param this
171
+ * @param _vaule
172
+ * @returns
173
+ */
125
174
  grid<T>(this: T, _vaule: 1 | 2 | 3 | 4): Omit<T, 'grid'> & IReturnMethod;
175
+ /**
176
+ * 标签展示模式
177
+ * @param this
178
+ * @param _vaule
179
+ * @returns
180
+ */
181
+ layout<T>(this: T, _vaule: 'horizontal' | 'vertical'): Omit<T, 'layout'> & IReturnMethod;
182
+ /**
183
+ * 标签宽度
184
+ * @param this
185
+ * @param _vaule
186
+ * @returns
187
+ */
188
+ labelSpan<T>(this: T, _vaule: number): Omit<T, 'labelSpan'> & IReturnMethod;
126
189
  valueOf(): any;
127
190
  toString(): string;
128
191
  }
@@ -162,7 +162,7 @@ export var FormRobot = /*#__PURE__*/function () {
162
162
  return new FormRobot(_data);
163
163
  } //*********************************表单基本类型__END************************************//
164
164
  //*********************************提供的扩展规则完善表单__START************************************//
165
- // 标签显示文本
165
+ // common
166
166
 
167
167
  }, {
168
168
  key: "label",
@@ -261,10 +261,28 @@ export var FormRobot = /*#__PURE__*/function () {
261
261
 
262
262
  var _data = renderSetting(_init, 'hidden', true);
263
263
 
264
+ return new FormRobot(_data);
265
+ } // textarea
266
+ // select
267
+
268
+ }, {
269
+ key: "enum",
270
+ value: function _enum(_value) {
271
+ var _init = this._hasInitData ? this._data : {};
272
+
273
+ var _data = renderSetting(_init, 'enum', _value);
274
+
264
275
  return new FormRobot(_data);
265
276
  } //*********************************提供的扩展规则完善表单__END************************************//
266
277
  //*********************************表单布局的扩展规则__START************************************//
267
278
 
279
+ /**
280
+ * 整体布局
281
+ * @param this
282
+ * @param _vaule
283
+ * @returns
284
+ */
285
+
268
286
  }, {
269
287
  key: "grid",
270
288
  value: function grid(_vaule) {
@@ -280,6 +298,52 @@ export var FormRobot = /*#__PURE__*/function () {
280
298
  })
281
299
  };
282
300
  return new FormRobot(_data);
301
+ }
302
+ /**
303
+ * 标签展示模式
304
+ * @param this
305
+ * @param _vaule
306
+ * @returns
307
+ */
308
+
309
+ }, {
310
+ key: "layout",
311
+ value: function layout(_vaule) {
312
+ var _init = this._hasInitData ? this._data : {
313
+ nodes: [],
314
+ setting: {}
315
+ };
316
+
317
+ var _data = {
318
+ nodes: _toConsumableArray(_init.nodes),
319
+ setting: _objectSpread(_objectSpread({}, _init.setting), {}, {
320
+ layout: _vaule
321
+ })
322
+ };
323
+ return new FormRobot(_data);
324
+ }
325
+ /**
326
+ * 标签宽度
327
+ * @param this
328
+ * @param _vaule
329
+ * @returns
330
+ */
331
+
332
+ }, {
333
+ key: "labelSpan",
334
+ value: function labelSpan(_vaule) {
335
+ var _init = this._hasInitData ? this._data : {
336
+ nodes: [],
337
+ setting: {}
338
+ };
339
+
340
+ var _data = {
341
+ nodes: _toConsumableArray(_init.nodes),
342
+ setting: _objectSpread(_objectSpread({}, _init.setting), {}, {
343
+ labelSpan: _vaule
344
+ })
345
+ };
346
+ return new FormRobot(_data);
283
347
  } //*********************************表单布局的扩展规则__END************************************//
284
348
  //*********************************拿到最终的数据方法__START************************************//
285
349
 
@@ -11,4 +11,4 @@ export declare const renderLayoutFormProps: (_arr: FG.Node[], _id: string, _type
11
11
  type: string;
12
12
  param: FG.NodeParam;
13
13
  };
14
- export declare const renderSetting: (_init: FG.Node, _type: string, _value: string | number | boolean) => FG.Node;
14
+ export declare const renderSetting: (_init: FG.Node, _type: string, _value: string | number | boolean | any) => FG.Node;
@@ -4,7 +4,7 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
4
4
  /*
5
5
  * @Author: wangxian
6
6
  * @Date: 2023-03-21 15:44:45
7
- * @LastEditTime: 2023-03-22 09:20:34
7
+ * @LastEditTime: 2023-04-04 17:21:07
8
8
  */
9
9
  import { deepClone } from '../../utils';
10
10
  import { basicComps, layoutComps } from './../../comps/FormGenerator/settings/index';
package/es/index.d.ts CHANGED
@@ -21,3 +21,4 @@ export { default as useObservable } from './framework/rxjs-hooks/useObservable';
21
21
  export { default as useSyncScroll, useSyncScrollByRefs } from './framework/hooks/use-sync-scroll';
22
22
  export { registerMetadataAPI } from './framework/metadata/MetadataService';
23
23
  export { globalSettingStream } from './config';
24
+ export { handleMd2Doc } from './utils';
package/es/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * @Author:wangxian
3
3
  * @Date: 2021-09-18 14:15:04
4
- * @LastEditTime: 2023-02-04 13:52:49
4
+ * @LastEditTime: 2023-04-12 10:44:59
5
5
  */
6
6
  import './theme.less';
7
7
  export { default as MetadataEdit } from './comps/MetadataEdit';
@@ -25,4 +25,5 @@ export { default as useMemoSubject } from './framework/rxjs-hooks/useMemoSubject
25
25
  export { default as useObservable } from './framework/rxjs-hooks/useObservable';
26
26
  export { default as useSyncScroll, useSyncScrollByRefs } from './framework/hooks/use-sync-scroll';
27
27
  export { registerMetadataAPI } from './framework/metadata/MetadataService';
28
- export { globalSettingStream } from './config';
28
+ export { globalSettingStream } from './config';
29
+ export { handleMd2Doc } from './utils';
package/es/utils.d.ts CHANGED
@@ -24,3 +24,9 @@ export declare function arrayInsert(array: any[], index: number, item: any): any
24
24
  * @returns {string|string|string}
25
25
  */
26
26
  export declare function getConstantValue(array: any[], key: string | number, strKey?: string, strValue?: string): string;
27
+ /**
28
+ * markdown转doc
29
+ * @param mdText string
30
+ * @param fileName string
31
+ */
32
+ export declare function handleMd2Doc(mdText: string, fileName: string): Promise<void>;
package/es/utils.js CHANGED
@@ -1,3 +1,5 @@
1
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
2
+ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
1
3
  import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
2
4
  import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
3
5
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
@@ -5,8 +7,11 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
5
7
  /*
6
8
  * @Author: wangxian
7
9
  * @Date: 2021-09-18 14:15:04
8
- * @LastEditTime: 2023-03-24 09:49:51
10
+ * @LastEditTime: 2023-04-13 09:51:21
9
11
  */
12
+ import saveAs from 'file-saver';
13
+ import { asBlob } from 'html-docx-js-typescript';
14
+ import MarkdownIt from 'markdown-it';
10
15
  import { useCallback, useEffect, useRef } from 'react';
11
16
  /** 防抖 */
12
17
 
@@ -177,4 +182,45 @@ export function getConstantValue(array, key, strKey, strValue) {
177
182
  }
178
183
 
179
184
  return result;
185
+ }
186
+ /**
187
+ * markdown转doc
188
+ * @param mdText string
189
+ * @param fileName string
190
+ */
191
+
192
+ export function handleMd2Doc(_x, _x2) {
193
+ return _handleMd2Doc.apply(this, arguments);
194
+ }
195
+
196
+ function _handleMd2Doc() {
197
+ _handleMd2Doc = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(mdText, fileName) {
198
+ var md, html, opt, blob;
199
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
200
+ while (1) {
201
+ switch (_context.prev = _context.next) {
202
+ case 0:
203
+ md = new MarkdownIt();
204
+ html = md.render(mdText);
205
+ opt = {
206
+ margin: {
207
+ top: 100
208
+ },
209
+ orientation: 'landscape'
210
+ };
211
+ _context.next = 5;
212
+ return asBlob(html, opt);
213
+
214
+ case 5:
215
+ blob = _context.sent;
216
+ saveAs(blob, "".concat(fileName, ".doc"));
217
+
218
+ case 7:
219
+ case "end":
220
+ return _context.stop();
221
+ }
222
+ }
223
+ }, _callee);
224
+ }));
225
+ return _handleMd2Doc.apply(this, arguments);
180
226
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "public": true,
3
3
  "name": "ronds-metadata",
4
- "version": "1.2.29",
4
+ "version": "1.2.31",
5
5
  "scripts": {
6
6
  "start": "dumi dev",
7
7
  "docs:build": "dumi build",
@@ -37,6 +37,8 @@
37
37
  "@babel/helper-create-regexp-features-plugin": "^7.12.13",
38
38
  "@babel/runtime": "^7.11.2",
39
39
  "@popperjs/core": "^2.4.4",
40
+ "@types/file-saver": "^2.0.5",
41
+ "@types/markdown-it": "^12.2.3",
40
42
  "@types/markdown-navbar": "^1.4.0",
41
43
  "ahooks": "^3.4.0",
42
44
  "axios": "^0.21.4",
@@ -46,12 +48,16 @@
46
48
  "codemirror": "^5.63.0",
47
49
  "codepage": "^1.15.0",
48
50
  "css-element-queries": "^1.2.3",
51
+ "file-saver": "^2.0.5",
49
52
  "github-markdown-css": "^5.1.0",
53
+ "html-docx-js-typescript": "^0.1.5",
50
54
  "immer": "^9.0.14",
51
55
  "lodash": "^4.17.21",
56
+ "markdown-it": "^13.0.1",
52
57
  "markdown-navbar": "^1.4.3",
53
58
  "qs": "^6.10.1",
54
59
  "react": "^17.0.2",
60
+ "react-contenteditable": "^3.3.7",
55
61
  "react-dnd": "^11.1.3",
56
62
  "react-dnd-html5-backend": "^11.1.3",
57
63
  "react-jexcel": "^1.0.2",