x-star-editor 0.0.3 → 0.0.5

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.
@@ -11,12 +11,11 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
11
11
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
12
12
  function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
13
13
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
14
- import classNames from 'classnames/bind';
14
+ import classNames from 'classnames';
15
15
  import React, { useEffect, useImperativeHandle, useRef, useState } from 'react';
16
16
  import XStarMdEditor, { useMdEditorRef } from "../XStarMdEditor";
17
17
  import XStarMdViewer, { useMdViewerRef } from "../XStarMdViewer";
18
- import styles from "./index.module.css";
19
- var cx = classNames.bind(styles);
18
+ import { prefix } from "../utils/global";
20
19
  var XStarEditor = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
21
20
  var height = _ref.height,
22
21
  initialValue = _ref.initialValue,
@@ -137,15 +136,13 @@ var XStarEditor = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
137
136
  };
138
137
  }, []);
139
138
  return /*#__PURE__*/React.createElement("div", {
140
- className: cx('container')
139
+ className: classNames("".concat(prefix, "editor"))
141
140
  }, /*#__PURE__*/React.createElement(XStarMdEditor, _extends({
142
141
  ref: editorRef
143
142
  }, editorProps, {
144
- className: cx('editor', editorProps === null || editorProps === void 0 ? void 0 : editorProps.className),
145
143
  style: _objectSpread({
146
144
  height: height
147
145
  }, editorProps === null || editorProps === void 0 ? void 0 : editorProps.style),
148
- toolbarClassName: cx('toolbar', editorProps === null || editorProps === void 0 ? void 0 : editorProps.toolbarClassName),
149
146
  initialValue: initialValue,
150
147
  onChange: function onChange(value) {
151
148
  setValue(value);
@@ -154,7 +151,6 @@ var XStarEditor = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
154
151
  })), /*#__PURE__*/React.createElement(XStarMdViewer, _extends({
155
152
  ref: viewerRef
156
153
  }, viewerProps, {
157
- className: cx('viewer', viewerProps === null || viewerProps === void 0 ? void 0 : viewerProps.className),
158
154
  style: _objectSpread({
159
155
  height: height
160
156
  }, viewerProps === null || viewerProps === void 0 ? void 0 : viewerProps.style),
@@ -0,0 +1,24 @@
1
+ @import '../styles/global.less';
2
+
3
+ .@{prefix}editor {
4
+ display: flex;
5
+ flex-wrap: wrap;
6
+
7
+ .@{prefix}toolbar {
8
+ width: 100%;
9
+ }
10
+
11
+ .@{prefix}md-editor {
12
+ flex: 1;
13
+ border-top: none;
14
+ border-bottom-right-radius: 0;
15
+ }
16
+
17
+ .@{prefix}md-viewer {
18
+ flex: 1;
19
+ border-top: none;
20
+ border-left: none;
21
+ border-radius: 0;
22
+ border-bottom-right-radius: 0.2em;
23
+ }
24
+ }
@@ -1,10 +1,18 @@
1
1
  import React from 'react';
2
2
  import type { ToolbarItem } from '../components/Toolbar';
3
- import '../styles/markdown.css';
4
3
  import type { Executor, KeyboardEventHandler } from '../utils/handler';
5
4
  interface EditorOptions {
5
+ /**
6
+ * 工具栏项映射
7
+ */
6
8
  toolbarItemMap: Partial<Record<string, ToolbarItem>>;
9
+ /**
10
+ * 工具栏项
11
+ */
7
12
  toolbarItems: (string | ToolbarItem)[][];
13
+ /**
14
+ * 键盘事件处理函数
15
+ */
8
16
  keyboardEventHandlers: KeyboardEventHandler[];
9
17
  }
10
18
  export interface XStarMdEditorPlugin {
@@ -1,12 +1,10 @@
1
- import classNames from 'classnames/bind';
1
+ import classNames from 'classnames';
2
2
  import React, { useEffect, useImperativeHandle, useRef } from 'react';
3
3
  import Toolbar, { getDefaultToolbarItemMap, getDefaultToolbarItems } from "../components/Toolbar";
4
- import "../styles/markdown.css";
5
4
  import { createSelection, getRange, useContainer } from "../utils/container";
5
+ import { prefix } from "../utils/global";
6
6
  import { composeHandlers, getDefaultKeyboardEventHandlers } from "../utils/handler";
7
7
  import { useHistory } from "../utils/history";
8
- import styles from "./index.module.css";
9
- var cx = classNames.bind(styles);
10
8
  var XStarMdEditor = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
11
9
  var className = _ref.className,
12
10
  style = _ref.style,
@@ -238,14 +236,14 @@ var XStarMdEditor = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
238
236
  }
239
237
  };
240
238
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Toolbar, {
241
- className: cx(toolbarClassName),
239
+ className: classNames(toolbarClassName),
242
240
  style: toolbarStyle,
243
241
  itemMap: toolbarItemMap,
244
242
  items: toolbarItems,
245
243
  exec: exec
246
244
  }), /*#__PURE__*/React.createElement("div", {
247
245
  ref: container.ref,
248
- className: cx('container', className),
246
+ className: classNames("".concat(prefix, "md-editor"), className),
249
247
  style: style,
250
248
  contentEditable: true,
251
249
  onBeforeInput: formEventHandler,
@@ -1,4 +1,6 @@
1
- .container {
1
+ @import '../styles/global.less';
2
+
3
+ .@{prefix}md-editor {
2
4
  position: relative;
3
5
  line-height: 1.6em;
4
6
  white-space: break-spaces;
@@ -9,4 +11,8 @@
9
11
  border-bottom-left-radius: 0.2em;
10
12
  outline: none;
11
13
  overflow: auto;
14
+
15
+ ::selection {
16
+ background: #c1def1;
17
+ }
12
18
  }
@@ -1,6 +1,4 @@
1
1
  import React from 'react';
2
- import '../styles/katex.css';
3
- import '../styles/prism.css';
4
2
  import type { ViewerOptions } from '../utils/markdown';
5
3
  export interface XStarMdViewerPlugin {
6
4
  (ctx: ViewerOptions): void;
@@ -1,11 +1,8 @@
1
- import classNames from 'classnames/bind';
1
+ import classNames from 'classnames';
2
2
  import React, { useImperativeHandle, useRef } from 'react';
3
- import "../styles/katex.css";
4
- import "../styles/prism.css";
3
+ import { prefix } from "../utils/global";
5
4
  import { composeHandlers } from "../utils/handler";
6
- import { viewerRender } from "../utils/markdown";
7
- import styles from "./index.module.css";
8
- var cx = classNames.bind(styles);
5
+ import { getDefaultSchema, viewerRender } from "../utils/markdown";
9
6
  var XStarMdViewer = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
10
7
  var className = _ref.className,
11
8
  style = _ref.style,
@@ -22,9 +19,10 @@ var XStarMdViewer = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
22
19
  }, []);
23
20
  return /*#__PURE__*/React.createElement("div", {
24
21
  ref: container,
25
- className: cx('x-star-md-viewer', 'container', className),
22
+ className: classNames("".concat(prefix, "md-viewer"), className),
26
23
  style: style
27
24
  }, viewerRender(value, composeHandlers(plugins)({
25
+ customSchema: getDefaultSchema(),
28
26
  customHTMLElements: {},
29
27
  customBlocks: {}
30
28
  })));
@@ -1,4 +1,6 @@
1
- .container {
1
+ @import '../styles/global.less';
2
+
3
+ .@{prefix}md-viewer {
2
4
  position: relative;
3
5
  padding: 0 1em;
4
6
  color: #000000d9;
@@ -6,4 +8,8 @@
6
8
  border: 1px solid #d0d0d0;
7
9
  border-radius: 0.2em;
8
10
  overflow: auto;
11
+
12
+ ::selection {
13
+ background: #c1def1;
14
+ }
9
15
  }
@@ -1,13 +1,16 @@
1
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
3
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
4
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
1
5
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
6
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
7
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
4
8
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
5
9
  function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
6
10
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
- import classNames from 'classnames/bind';
11
+ import classNames from 'classnames';
8
12
  import React, { useState } from 'react';
9
- import styles from "./FileInput.module.css";
10
- var cx = classNames.bind(styles);
13
+ import { prefix } from "../utils/global";
11
14
  var FileInput = function FileInput(_ref) {
12
15
  var _file$name;
13
16
  var onCancel = _ref.onCancel,
@@ -29,59 +32,55 @@ var FileInput = function FileInput(_ref) {
29
32
  description = _useState8[0],
30
33
  setDescription = _useState8[1];
31
34
  return /*#__PURE__*/React.createElement("div", {
32
- className: cx('container')
35
+ className: classNames("".concat(prefix, "file-input"))
33
36
  }, /*#__PURE__*/React.createElement("div", {
34
- className: cx('tabs')
37
+ className: classNames("".concat(prefix, "tabs"))
35
38
  }, /*#__PURE__*/React.createElement("div", {
36
- className: cx('tab', {
37
- active: type === 'file'
38
- }),
39
+ className: classNames("".concat(prefix, "tab"), _defineProperty({}, "".concat(prefix, "active"), type === 'file')),
39
40
  onClick: function onClick() {
40
41
  return setType('file');
41
42
  }
42
43
  }, "\u6587\u4EF6"), /*#__PURE__*/React.createElement("div", {
43
- className: cx('tab', {
44
- active: type === 'url'
45
- }),
44
+ className: classNames("".concat(prefix, "tab"), _defineProperty({}, "".concat(prefix, "active"), type === 'url')),
46
45
  onClick: function onClick() {
47
46
  return setType('url');
48
47
  }
49
48
  }, "\u7F51\u5740")), type === 'file' ? /*#__PURE__*/React.createElement("label", {
50
- className: cx('field')
49
+ className: classNames("".concat(prefix, "field"))
51
50
  }, "\u6587\u4EF6", /*#__PURE__*/React.createElement("div", {
52
- className: cx('file-container')
51
+ className: classNames("".concat(prefix, "file-container"))
53
52
  }, /*#__PURE__*/React.createElement("input", {
54
- className: cx('hidden'),
53
+ className: classNames("".concat(prefix, "hidden")),
55
54
  type: "file",
56
55
  onChange: function onChange(e) {
57
56
  var _e$target$files;
58
57
  return setFile((_e$target$files = e.target.files) === null || _e$target$files === void 0 ? void 0 : _e$target$files[0]);
59
58
  }
60
59
  }), /*#__PURE__*/React.createElement("input", {
61
- className: cx('input'),
60
+ className: classNames("".concat(prefix, "input")),
62
61
  readOnly: true,
63
62
  value: (_file$name = file === null || file === void 0 ? void 0 : file.name) !== null && _file$name !== void 0 ? _file$name : ''
64
63
  }), /*#__PURE__*/React.createElement("button", {
65
- className: cx('button'),
64
+ className: classNames("".concat(prefix, "button")),
66
65
  type: "button"
67
66
  }, "\u9009\u62E9\u6587\u4EF6"))) : /*#__PURE__*/React.createElement("label", {
68
- className: cx('field')
67
+ className: classNames("".concat(prefix, "field"))
69
68
  }, "\u7F51\u5740", /*#__PURE__*/React.createElement("input", {
70
- className: cx('input'),
69
+ className: classNames("".concat(prefix, "input")),
71
70
  onChange: function onChange(e) {
72
71
  return setUrl(e.target.value);
73
72
  }
74
73
  })), /*#__PURE__*/React.createElement("label", {
75
- className: cx('field')
74
+ className: classNames("".concat(prefix, "field"))
76
75
  }, "\u63CF\u8FF0", /*#__PURE__*/React.createElement("input", {
77
- className: cx('input'),
76
+ className: classNames("".concat(prefix, "input")),
78
77
  onChange: function onChange(e) {
79
78
  return setDescription(e.target.value);
80
79
  }
81
80
  })), /*#__PURE__*/React.createElement("div", {
82
- className: cx('buttons')
81
+ className: classNames("".concat(prefix, "buttons"))
83
82
  }, /*#__PURE__*/React.createElement("button", {
84
- className: cx('button', 'primary'),
83
+ className: classNames("".concat(prefix, "button"), "".concat(prefix, "primary")),
85
84
  type: "button",
86
85
  onClick: function onClick() {
87
86
  if (type === 'file' && file) {
@@ -99,7 +98,7 @@ var FileInput = function FileInput(_ref) {
99
98
  }
100
99
  }
101
100
  }, "\u786E\u5B9A"), /*#__PURE__*/React.createElement("button", {
102
- className: cx('button'),
101
+ className: classNames("".concat(prefix, "button")),
103
102
  type: "button",
104
103
  onClick: onCancel
105
104
  }, "\u53D6\u6D88")));
@@ -0,0 +1,83 @@
1
+ @import '../styles/global.less';
2
+
3
+ .@{prefix}file-input {
4
+ margin: 0.5em 1em 1em;
5
+
6
+ .@{prefix}tabs {
7
+ display: flex;
8
+
9
+ .@{prefix}tab {
10
+ padding: 0.4em 1em;
11
+ border-bottom: 1px solid #f5771280;
12
+ cursor: pointer;
13
+ user-select: none;
14
+
15
+ &.@{prefix}active {
16
+ color: #f57712;
17
+ border-bottom: 2px solid #f57712;
18
+ }
19
+ }
20
+ }
21
+
22
+ .@{prefix}buttons {
23
+ display: flex;
24
+ flex-direction: row-reverse;
25
+ gap: 0.4em;
26
+ }
27
+
28
+ .@{prefix}button {
29
+ padding: 0.4em 1em;
30
+ background-color: #f0f0f0;
31
+ border: 1px solid #d0d0d0;
32
+ border-radius: 0.2em;
33
+ cursor: pointer;
34
+ user-select: none;
35
+
36
+ &.@{prefix}primary {
37
+ color: #fff;
38
+ background-color: #f57712;
39
+ border: none;
40
+ }
41
+ }
42
+
43
+ .@{prefix}field {
44
+ margin: 0.8em;
45
+ display: flex;
46
+ flex-direction: column;
47
+ gap: 0.2em;
48
+ font-size: 0.9em;
49
+
50
+ .@{prefix}input {
51
+ width: 20em;
52
+ padding: 0.4em;
53
+ border: 1px solid #d0d0d0;
54
+ border-radius: 0.2em;
55
+ outline: none;
56
+
57
+ &:focus {
58
+ border: 1px solid #f57712;
59
+ }
60
+ }
61
+
62
+ .@{prefix}file-container {
63
+ position: relative;
64
+ display: flex;
65
+ align-items: center;
66
+ justify-content: space-between;
67
+
68
+ .@{prefix}hidden {
69
+ position: absolute;
70
+ inset: 0;
71
+ opacity: 0;
72
+ }
73
+
74
+ .@{prefix}input {
75
+ width: 14em;
76
+ }
77
+
78
+ .@{prefix}button {
79
+ padding: 0.3em 0.4em;
80
+ }
81
+ }
82
+ }
83
+ }
@@ -1,15 +1,18 @@
1
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
3
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
4
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
1
5
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
6
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
7
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
4
8
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
5
9
  function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
6
10
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
- import classNames from 'classnames/bind';
11
+ import classNames from 'classnames';
8
12
  import React, { useEffect, useRef, useState } from 'react';
13
+ import { prefix } from "../utils/global";
9
14
  import { toggleHandler } from "../utils/handler";
10
15
  import FileInput from "./FileInput";
11
- import styles from "./Toolbar.module.css";
12
- var cx = classNames.bind(styles);
13
16
  var Button = function Button(_ref) {
14
17
  var toolbarRef = _ref.toolbarRef,
15
18
  children = _ref.children,
@@ -55,11 +58,9 @@ var Button = function Button(_ref) {
55
58
  }
56
59
  }, [popoverMount]);
57
60
  return /*#__PURE__*/React.createElement("div", {
58
- className: cx('button-container')
61
+ className: classNames("".concat(prefix, "button-container"))
59
62
  }, /*#__PURE__*/React.createElement("div", {
60
- className: cx('button', {
61
- active: tooltipOpen || popoverMount
62
- }),
63
+ className: classNames("".concat(prefix, "button"), _defineProperty({}, "".concat(prefix, "active"), tooltipOpen || popoverMount)),
63
64
  onClick: function onClick() {
64
65
  setPopoverOpen(true);
65
66
  _onClick === null || _onClick === void 0 ? void 0 : _onClick();
@@ -74,10 +75,10 @@ var Button = function Button(_ref) {
74
75
  return setTooltipOpen(false);
75
76
  }
76
77
  }, children, tooltipMount && /*#__PURE__*/React.createElement("div", {
77
- className: cx('tooltip')
78
+ className: classNames("".concat(prefix, "tooltip"))
78
79
  }, tooltip)), popoverMount && /*#__PURE__*/React.createElement("div", {
79
80
  ref: popoverRef,
80
- className: cx('popover')
81
+ className: classNames("".concat(prefix, "popover"))
81
82
  }, popover));
82
83
  };
83
84
  export var getDefaultToolbarItemMap = function getDefaultToolbarItemMap(onInsertFile) {
@@ -88,7 +89,7 @@ export var getDefaultToolbarItemMap = function getDefaultToolbarItemMap(onInsert
88
89
  popoverRender: function popoverRender(exec, close) {
89
90
  var optionRender = function optionRender(depth, fontSize) {
90
91
  return /*#__PURE__*/React.createElement("div", {
91
- className: cx('option'),
92
+ className: classNames("".concat(prefix, "option")),
92
93
  style: {
93
94
  fontSize: fontSize
94
95
  },
@@ -124,7 +125,7 @@ export var getDefaultToolbarItemMap = function getDefaultToolbarItemMap(onInsert
124
125
  },
125
126
  code: {
126
127
  children: /*#__PURE__*/React.createElement("div", {
127
- className: cx('icon', 'code-library')
128
+ className: classNames("".concat(prefix, "icon"), "".concat(prefix, "code-library"))
128
129
  }),
129
130
  tooltip: '代码块',
130
131
  onClick: function onClick(exec) {
@@ -135,7 +136,7 @@ export var getDefaultToolbarItemMap = function getDefaultToolbarItemMap(onInsert
135
136
  },
136
137
  emphasis: {
137
138
  children: /*#__PURE__*/React.createElement("div", {
138
- className: cx('icon', 'italic')
139
+ className: classNames("".concat(prefix, "icon"), "".concat(prefix, "italic"))
139
140
  }),
140
141
  tooltip: '斜体',
141
142
  onClick: function onClick(exec) {
@@ -146,7 +147,7 @@ export var getDefaultToolbarItemMap = function getDefaultToolbarItemMap(onInsert
146
147
  },
147
148
  strong: {
148
149
  children: /*#__PURE__*/React.createElement("div", {
149
- className: cx('icon', 'bold')
150
+ className: classNames("".concat(prefix, "icon"), "".concat(prefix, "bold"))
150
151
  }),
151
152
  tooltip: '粗体',
152
153
  onClick: function onClick(exec) {
@@ -157,7 +158,7 @@ export var getDefaultToolbarItemMap = function getDefaultToolbarItemMap(onInsert
157
158
  },
158
159
  inlineCode: {
159
160
  children: /*#__PURE__*/React.createElement("div", {
160
- className: cx('icon', 'code')
161
+ className: classNames("".concat(prefix, "icon"), "".concat(prefix, "code"))
161
162
  }),
162
163
  tooltip: '行内代码',
163
164
  onClick: function onClick(exec) {
@@ -168,7 +169,7 @@ export var getDefaultToolbarItemMap = function getDefaultToolbarItemMap(onInsert
168
169
  },
169
170
  link: {
170
171
  children: /*#__PURE__*/React.createElement("div", {
171
- className: cx('icon', 'link')
172
+ className: classNames("".concat(prefix, "icon"), "".concat(prefix, "link"))
172
173
  }),
173
174
  tooltip: '链接',
174
175
  popoverRender: function popoverRender(exec, close) {
@@ -194,7 +195,7 @@ export var getDefaultToolbarItemMap = function getDefaultToolbarItemMap(onInsert
194
195
  },
195
196
  image: {
196
197
  children: /*#__PURE__*/React.createElement("div", {
197
- className: cx('icon', 'image')
198
+ className: classNames("".concat(prefix, "icon"), "".concat(prefix, "image"))
198
199
  }),
199
200
  tooltip: '图片',
200
201
  popoverRender: function popoverRender(exec, close) {
@@ -220,7 +221,7 @@ export var getDefaultToolbarItemMap = function getDefaultToolbarItemMap(onInsert
220
221
  },
221
222
  delete: {
222
223
  children: /*#__PURE__*/React.createElement("div", {
223
- className: cx('icon', 'strikethrough')
224
+ className: classNames("".concat(prefix, "icon"), "".concat(prefix, "strikethrough"))
224
225
  }),
225
226
  tooltip: '删除线',
226
227
  onClick: function onClick(exec) {
@@ -261,13 +262,13 @@ var Toolbar = function Toolbar(_ref2) {
261
262
  var toolbarRef = useRef(null);
262
263
  return /*#__PURE__*/React.createElement("div", {
263
264
  ref: toolbarRef,
264
- className: cx('toolbar', className),
265
+ className: classNames("".concat(prefix, "toolbar"), className),
265
266
  style: style
266
267
  }, items.map(function (group, index) {
267
268
  return /*#__PURE__*/React.createElement(React.Fragment, {
268
269
  key: index
269
270
  }, !!index && /*#__PURE__*/React.createElement("div", {
270
- className: cx('divider')
271
+ className: classNames("".concat(prefix, "divider"))
271
272
  }), group.map(function (item, index) {
272
273
  var toolbarItem = typeof item === 'string' ? itemMap[item] : item;
273
274
  if (!toolbarItem) {
@@ -0,0 +1,118 @@
1
+ @import '../styles/global.less';
2
+
3
+ .@{prefix}toolbar {
4
+ padding: 0.2em;
5
+ display: flex;
6
+ flex-wrap: wrap;
7
+ gap: 0.2em;
8
+ font-size: 1.1em;
9
+ background-color: #f5771210;
10
+ border: 1px solid #f5771220;
11
+ border-top-left-radius: 0.2em;
12
+ border-top-right-radius: 0.2em;
13
+
14
+ .@{prefix}button-container {
15
+ position: relative;
16
+
17
+ > .@{prefix}button {
18
+ width: 2em;
19
+ height: 2em;
20
+ display: flex;
21
+ align-items: center;
22
+ justify-content: center;
23
+ font-family: Consolas;
24
+ border: 1px solid transparent;
25
+ cursor: pointer;
26
+ user-select: none;
27
+
28
+ &.@{prefix}active {
29
+ background-color: #f8f8f8;
30
+ border: 1px solid #f5771280;
31
+ border-radius: 0.2em;
32
+ }
33
+
34
+ .@{prefix}icon {
35
+ width: 45%;
36
+ height: 45%;
37
+ background-size: contain;
38
+
39
+ &.@{prefix}code-library {
40
+ background-image: url('icons/code-library.svg');
41
+ }
42
+
43
+ &.@{prefix}italic {
44
+ background-image: url('icons/italic.svg');
45
+ }
46
+
47
+ &.@{prefix}bold {
48
+ background-image: url('icons/bold.svg');
49
+ }
50
+
51
+ &.@{prefix}code {
52
+ background-image: url('icons/code.svg');
53
+ }
54
+
55
+ &.@{prefix}link {
56
+ background-image: url('icons/link.svg');
57
+ }
58
+
59
+ &.@{prefix}image {
60
+ background-image: url('icons/image.svg');
61
+ }
62
+
63
+ &.@{prefix}strikethrough {
64
+ background-image: url('icons/strikethrough.svg');
65
+ }
66
+ }
67
+
68
+ .@{prefix}tooltip {
69
+ position: absolute;
70
+ top: 3em;
71
+ width: max-content;
72
+ padding: 0.4em;
73
+ font-size: 0.8em;
74
+ color: #f8f8f8;
75
+ background-color: #022679;
76
+ border-radius: 0.2em;
77
+ z-index: 2;
78
+
79
+ &::before {
80
+ content: '';
81
+ position: absolute;
82
+ top: -0.3em;
83
+ left: 50%;
84
+ border-top: 0.6em solid #022679;
85
+ border-right: 0.6em solid transparent;
86
+ transform-origin: 0 0;
87
+ transform: rotate(45deg);
88
+ }
89
+ }
90
+ }
91
+
92
+ .@{prefix}popover {
93
+ position: absolute;
94
+ width: max-content;
95
+ background-color: #f8f8f8;
96
+ border: 1px solid #f5771280;
97
+ border-radius: 0.2em;
98
+ box-shadow: 0 2px 4px #00000020;
99
+ opacity: 0;
100
+ z-index: 1;
101
+
102
+ .@{prefix}option {
103
+ padding: 4px 8px;
104
+ cursor: pointer;
105
+ user-select: none;
106
+
107
+ &:hover {
108
+ background-color: #f0f0f0;
109
+ }
110
+ }
111
+ }
112
+ }
113
+
114
+ .@{prefix}divider {
115
+ margin: 0.4em;
116
+ border: 1px solid #f5771280;
117
+ }
118
+ }
@@ -0,0 +1,8 @@
1
+ @import './components/FileInput.less';
2
+ @import './components/Toolbar.less';
3
+ @import './styles/katex.css';
4
+ @import './styles/markdown.less';
5
+ @import './styles/prism.less';
6
+ @import './XStarEditor/index.less';
7
+ @import './XStarMdEditor/index.less';
8
+ @import './XStarMdViewer/index.less';
@@ -0,0 +1 @@
1
+ @prefix: x-star-;