x-star-editor 0.0.4 → 0.0.6

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.
Files changed (30) hide show
  1. package/dist/XStarEditor/{index.less → _index.scss} +5 -5
  2. package/dist/XStarEditor/index.d.ts +0 -1
  3. package/dist/XStarEditor/index.js +0 -1
  4. package/dist/XStarMdEditor/{index.less → _index.scss} +2 -2
  5. package/dist/XStarMdEditor/index.d.ts +0 -2
  6. package/dist/XStarMdEditor/index.js +0 -2
  7. package/dist/XStarMdViewer/{index.less → _index.scss} +2 -2
  8. package/dist/XStarMdViewer/index.d.ts +0 -3
  9. package/dist/XStarMdViewer/index.js +0 -3
  10. package/dist/components/FileInput.d.ts +0 -1
  11. package/dist/components/FileInput.js +0 -1
  12. package/dist/components/Toolbar.d.ts +0 -1
  13. package/dist/components/Toolbar.js +0 -1
  14. package/dist/components/{FileInput.less → _FileInput.scss} +14 -14
  15. package/dist/components/{Toolbar.less → _Toolbar.scss} +17 -17
  16. package/dist/styles/_global.scss +1 -0
  17. package/dist/styles/{markdown.less → _markdown.scss} +37 -36
  18. package/dist/styles/{prism.less → _prism.scss} +2 -2
  19. package/dist/styles/index.scss +8 -0
  20. package/package.json +1 -1
  21. package/dist/index.d.ts +0 -9
  22. package/dist/styles/global.less +0 -1
  23. /package/dist/styles/{katex.css → _katex.scss} +0 -0
  24. /package/dist/{components → styles}/icons/bold.svg +0 -0
  25. /package/dist/{components → styles}/icons/code-library.svg +0 -0
  26. /package/dist/{components → styles}/icons/code.svg +0 -0
  27. /package/dist/{components → styles}/icons/image.svg +0 -0
  28. /package/dist/{components → styles}/icons/italic.svg +0 -0
  29. /package/dist/{components → styles}/icons/link.svg +0 -0
  30. /package/dist/{components → styles}/icons/strikethrough.svg +0 -0
@@ -1,20 +1,20 @@
1
- @import '../styles/global.less';
1
+ @import '../styles/global';
2
2
 
3
- .@{prefix}editor {
3
+ .#{$prefix}editor {
4
4
  display: flex;
5
5
  flex-wrap: wrap;
6
6
 
7
- .@{prefix}toolbar {
7
+ .#{$prefix}toolbar {
8
8
  width: 100%;
9
9
  }
10
10
 
11
- .@{prefix}md-editor {
11
+ .#{$prefix}md-editor {
12
12
  flex: 1;
13
13
  border-top: none;
14
14
  border-bottom-right-radius: 0;
15
15
  }
16
16
 
17
- .@{prefix}md-viewer {
17
+ .#{$prefix}md-viewer {
18
18
  flex: 1;
19
19
  border-top: none;
20
20
  border-left: none;
@@ -1,7 +1,6 @@
1
1
  import React from 'react';
2
2
  import type { XStarMdEditorHandle, XStarMdEditorProps } from '../XStarMdEditor';
3
3
  import type { XStarMdViewerHandle, XStarMdViewerProps } from '../XStarMdViewer';
4
- import './index.less';
5
4
  export interface XStarEditorHandle {
6
5
  getEditor: () => XStarMdEditorHandle | null;
7
6
  getViewer: () => XStarMdViewerHandle | null;
@@ -16,7 +16,6 @@ import React, { useEffect, useImperativeHandle, useRef, useState } from 'react';
16
16
  import XStarMdEditor, { useMdEditorRef } from "../XStarMdEditor";
17
17
  import XStarMdViewer, { useMdViewerRef } from "../XStarMdViewer";
18
18
  import { prefix } from "../utils/global";
19
- import "./index.less";
20
19
  var XStarEditor = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
21
20
  var height = _ref.height,
22
21
  initialValue = _ref.initialValue,
@@ -1,6 +1,6 @@
1
- @import '../styles/global.less';
1
+ @import '../styles/global';
2
2
 
3
- .@{prefix}md-editor {
3
+ .#{$prefix}md-editor {
4
4
  position: relative;
5
5
  line-height: 1.6em;
6
6
  white-space: break-spaces;
@@ -1,8 +1,6 @@
1
1
  import React from 'react';
2
2
  import type { ToolbarItem } from '../components/Toolbar';
3
- import '../styles/markdown.less';
4
3
  import type { Executor, KeyboardEventHandler } from '../utils/handler';
5
- import './index.less';
6
4
  interface EditorOptions {
7
5
  /**
8
6
  * 工具栏项映射
@@ -1,12 +1,10 @@
1
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.less";
5
4
  import { createSelection, getRange, useContainer } from "../utils/container";
6
5
  import { prefix } from "../utils/global";
7
6
  import { composeHandlers, getDefaultKeyboardEventHandlers } from "../utils/handler";
8
7
  import { useHistory } from "../utils/history";
9
- import "./index.less";
10
8
  var XStarMdEditor = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
11
9
  var className = _ref.className,
12
10
  style = _ref.style,
@@ -1,6 +1,6 @@
1
- @import '../styles/global.less';
1
+ @import '../styles/global';
2
2
 
3
- .@{prefix}md-viewer {
3
+ .#{$prefix}md-viewer {
4
4
  position: relative;
5
5
  padding: 0 1em;
6
6
  color: #000000d9;
@@ -1,8 +1,5 @@
1
1
  import React from 'react';
2
- import '../styles/katex.css';
3
- import '../styles/prism.less';
4
2
  import type { ViewerOptions } from '../utils/markdown';
5
- import './index.less';
6
3
  export interface XStarMdViewerPlugin {
7
4
  (ctx: ViewerOptions): void;
8
5
  }
@@ -1,11 +1,8 @@
1
1
  import classNames from 'classnames';
2
2
  import React, { useImperativeHandle, useRef } from 'react';
3
- import "../styles/katex.css";
4
- import "../styles/prism.less";
5
3
  import { prefix } from "../utils/global";
6
4
  import { composeHandlers } from "../utils/handler";
7
5
  import { getDefaultSchema, viewerRender } from "../utils/markdown";
8
- import "./index.less";
9
6
  var XStarMdViewer = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
10
7
  var className = _ref.className,
11
8
  style = _ref.style,
@@ -1,5 +1,4 @@
1
1
  import React from 'react';
2
- import './FileInput.less';
3
2
  interface FileInputProps {
4
3
  onCancel: () => void;
5
4
  onOk: (data: ({
@@ -11,7 +11,6 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
11
11
  import classNames from 'classnames';
12
12
  import React, { useState } from 'react';
13
13
  import { prefix } from "../utils/global";
14
- import "./FileInput.less";
15
14
  var FileInput = function FileInput(_ref) {
16
15
  var _file$name;
17
16
  var onCancel = _ref.onCancel,
@@ -1,6 +1,5 @@
1
1
  import React from 'react';
2
2
  import type { Executor } from '../utils/handler';
3
- import './Toolbar.less';
4
3
  export interface ToolbarItem {
5
4
  children: React.ReactNode;
6
5
  tooltip?: React.ReactNode;
@@ -13,7 +13,6 @@ import React, { useEffect, useRef, useState } from 'react';
13
13
  import { prefix } from "../utils/global";
14
14
  import { toggleHandler } from "../utils/handler";
15
15
  import FileInput from "./FileInput";
16
- import "./Toolbar.less";
17
16
  var Button = function Button(_ref) {
18
17
  var toolbarRef = _ref.toolbarRef,
19
18
  children = _ref.children,
@@ -1,31 +1,31 @@
1
- @import '../styles/global.less';
1
+ @import '../styles/global';
2
2
 
3
- .@{prefix}file-input {
3
+ .#{$prefix}file-input {
4
4
  margin: 0.5em 1em 1em;
5
5
 
6
- .@{prefix}tabs {
6
+ .#{$prefix}tabs {
7
7
  display: flex;
8
8
 
9
- .@{prefix}tab {
9
+ .#{$prefix}tab {
10
10
  padding: 0.4em 1em;
11
11
  border-bottom: 1px solid #f5771280;
12
12
  cursor: pointer;
13
13
  user-select: none;
14
14
 
15
- &.@{prefix}active {
15
+ &.#{$prefix}active {
16
16
  color: #f57712;
17
17
  border-bottom: 2px solid #f57712;
18
18
  }
19
19
  }
20
20
  }
21
21
 
22
- .@{prefix}buttons {
22
+ .#{$prefix}buttons {
23
23
  display: flex;
24
24
  flex-direction: row-reverse;
25
25
  gap: 0.4em;
26
26
  }
27
27
 
28
- .@{prefix}button {
28
+ .#{$prefix}button {
29
29
  padding: 0.4em 1em;
30
30
  background-color: #f0f0f0;
31
31
  border: 1px solid #d0d0d0;
@@ -33,21 +33,21 @@
33
33
  cursor: pointer;
34
34
  user-select: none;
35
35
 
36
- &.@{prefix}primary {
36
+ &.#{$prefix}primary {
37
37
  color: #fff;
38
38
  background-color: #f57712;
39
39
  border: none;
40
40
  }
41
41
  }
42
42
 
43
- .@{prefix}field {
43
+ .#{$prefix}field {
44
44
  margin: 0.8em;
45
45
  display: flex;
46
46
  flex-direction: column;
47
47
  gap: 0.2em;
48
48
  font-size: 0.9em;
49
49
 
50
- .@{prefix}input {
50
+ .#{$prefix}input {
51
51
  width: 20em;
52
52
  padding: 0.4em;
53
53
  border: 1px solid #d0d0d0;
@@ -59,23 +59,23 @@
59
59
  }
60
60
  }
61
61
 
62
- .@{prefix}file-container {
62
+ .#{$prefix}file-container {
63
63
  position: relative;
64
64
  display: flex;
65
65
  align-items: center;
66
66
  justify-content: space-between;
67
67
 
68
- .@{prefix}hidden {
68
+ .#{$prefix}hidden {
69
69
  position: absolute;
70
70
  inset: 0;
71
71
  opacity: 0;
72
72
  }
73
73
 
74
- .@{prefix}input {
74
+ .#{$prefix}input {
75
75
  width: 14em;
76
76
  }
77
77
 
78
- .@{prefix}button {
78
+ .#{$prefix}button {
79
79
  padding: 0.3em 0.4em;
80
80
  }
81
81
  }
@@ -1,6 +1,6 @@
1
- @import '../styles/global.less';
1
+ @import '../styles/global';
2
2
 
3
- .@{prefix}toolbar {
3
+ .#{$prefix}toolbar {
4
4
  padding: 0.2em;
5
5
  display: flex;
6
6
  flex-wrap: wrap;
@@ -11,10 +11,10 @@
11
11
  border-top-left-radius: 0.2em;
12
12
  border-top-right-radius: 0.2em;
13
13
 
14
- .@{prefix}button-container {
14
+ .#{$prefix}button-container {
15
15
  position: relative;
16
16
 
17
- > .@{prefix}button {
17
+ > .#{$prefix}button {
18
18
  width: 2em;
19
19
  height: 2em;
20
20
  display: flex;
@@ -25,47 +25,47 @@
25
25
  cursor: pointer;
26
26
  user-select: none;
27
27
 
28
- &.@{prefix}active {
28
+ &.#{$prefix}active {
29
29
  background-color: #f8f8f8;
30
30
  border: 1px solid #f5771280;
31
31
  border-radius: 0.2em;
32
32
  }
33
33
 
34
- .@{prefix}icon {
34
+ .#{$prefix}icon {
35
35
  width: 45%;
36
36
  height: 45%;
37
37
  background-size: contain;
38
38
 
39
- &.@{prefix}code-library {
39
+ &.#{$prefix}code-library {
40
40
  background-image: url('icons/code-library.svg');
41
41
  }
42
42
 
43
- &.@{prefix}italic {
43
+ &.#{$prefix}italic {
44
44
  background-image: url('icons/italic.svg');
45
45
  }
46
46
 
47
- &.@{prefix}bold {
47
+ &.#{$prefix}bold {
48
48
  background-image: url('icons/bold.svg');
49
49
  }
50
50
 
51
- &.@{prefix}code {
51
+ &.#{$prefix}code {
52
52
  background-image: url('icons/code.svg');
53
53
  }
54
54
 
55
- &.@{prefix}link {
55
+ &.#{$prefix}link {
56
56
  background-image: url('icons/link.svg');
57
57
  }
58
58
 
59
- &.@{prefix}image {
59
+ &.#{$prefix}image {
60
60
  background-image: url('icons/image.svg');
61
61
  }
62
62
 
63
- &.@{prefix}strikethrough {
63
+ &.#{$prefix}strikethrough {
64
64
  background-image: url('icons/strikethrough.svg');
65
65
  }
66
66
  }
67
67
 
68
- .@{prefix}tooltip {
68
+ .#{$prefix}tooltip {
69
69
  position: absolute;
70
70
  top: 3em;
71
71
  width: max-content;
@@ -89,7 +89,7 @@
89
89
  }
90
90
  }
91
91
 
92
- .@{prefix}popover {
92
+ .#{$prefix}popover {
93
93
  position: absolute;
94
94
  width: max-content;
95
95
  background-color: #f8f8f8;
@@ -99,7 +99,7 @@
99
99
  opacity: 0;
100
100
  z-index: 1;
101
101
 
102
- .@{prefix}option {
102
+ .#{$prefix}option {
103
103
  padding: 4px 8px;
104
104
  cursor: pointer;
105
105
  user-select: none;
@@ -111,7 +111,7 @@
111
111
  }
112
112
  }
113
113
 
114
- .@{prefix}divider {
114
+ .#{$prefix}divider {
115
115
  margin: 0.4em;
116
116
  border: 1px solid #f5771280;
117
117
  }
@@ -0,0 +1 @@
1
+ $prefix: x-star-;
@@ -1,64 +1,65 @@
1
- @import './global.less';
1
+ @import './global';
2
2
 
3
- @md-prefix: ~'@{prefix}md-editor-';
3
+ $md-prefix: #{$prefix}md-editor-;
4
4
 
5
- .@{md-prefix}block {
5
+ .#{$md-prefix}block {
6
6
  margin: 0.2em;
7
7
  padding: 0.2em;
8
8
  border-radius: 0.2em;
9
9
  }
10
10
 
11
- .@{md-prefix}block:hover {
11
+ .#{$md-prefix}block:hover {
12
12
  background-color: #f8f8f8;
13
13
  }
14
14
 
15
- .@{md-prefix}delimiter,
16
- .@{md-prefix}break {
15
+ .#{$md-prefix}delimiter,
16
+ .#{$md-prefix}break {
17
17
  color: #f5771280;
18
18
  }
19
19
 
20
- .@{md-prefix}heading {
20
+ .#{$md-prefix}heading {
21
+ line-height: 1.6em;
21
22
  font-weight: bold;
22
23
  }
23
24
 
24
- .@{md-prefix}heading1 {
25
+ .#{$md-prefix}heading1 {
25
26
  font-size: 1.6em;
26
27
  }
27
28
 
28
- .@{md-prefix}heading2 {
29
+ .#{$md-prefix}heading2 {
29
30
  font-size: 1.3em;
30
31
  }
31
32
 
32
- .@{md-prefix}heading3 {
33
+ .#{$md-prefix}heading3 {
33
34
  font-size: 1.2em;
34
35
  }
35
36
 
36
- .@{md-prefix}heading4 {
37
+ .#{$md-prefix}heading4 {
37
38
  font-size: 1.1em;
38
39
  }
39
40
 
40
- .@{md-prefix}heading5 {
41
+ .#{$md-prefix}heading5 {
41
42
  font-size: 1em;
42
43
  }
43
44
 
44
- .@{md-prefix}heading6 {
45
+ .#{$md-prefix}heading6 {
45
46
  font-size: 0.9em;
46
47
  }
47
48
 
48
- .@{md-prefix}thematicBreak,
49
- .@{md-prefix}listItem > .@{md-prefix}delimiter,
50
- .@{md-prefix}definition,
51
- .@{md-prefix}link,
52
- .@{md-prefix}image,
53
- .@{md-prefix}linkReference,
54
- .@{md-prefix}imageReference,
55
- .@{md-prefix}footnoteDefinition,
56
- .@{md-prefix}footnoteReference {
49
+ .#{$md-prefix}thematicBreak,
50
+ .#{$md-prefix}listItem > .#{$md-prefix}delimiter,
51
+ .#{$md-prefix}definition,
52
+ .#{$md-prefix}link,
53
+ .#{$md-prefix}image,
54
+ .#{$md-prefix}linkReference,
55
+ .#{$md-prefix}imageReference,
56
+ .#{$md-prefix}footnoteDefinition,
57
+ .#{$md-prefix}footnoteReference {
57
58
  color: #f57712;
58
59
  }
59
60
 
60
- .@{md-prefix}html,
61
- .@{md-prefix}code {
61
+ .#{$md-prefix}html,
62
+ .#{$md-prefix}code {
62
63
  padding: 0 0.2em;
63
64
  tab-size: 4;
64
65
  font-family: Consolas;
@@ -68,21 +69,21 @@
68
69
  border-left: 1px solid #02267920;
69
70
  }
70
71
 
71
- .@{md-prefix}html.@{md-prefix}first,
72
- .@{md-prefix}code.@{md-prefix}first {
72
+ .#{$md-prefix}html.#{$md-prefix}first,
73
+ .#{$md-prefix}code.#{$md-prefix}first {
73
74
  border-top: 1px solid #02267920;
74
75
  border-top-left-radius: 0.2em;
75
76
  border-top-right-radius: 0.2em;
76
77
  }
77
78
 
78
- .@{md-prefix}html.@{md-prefix}last,
79
- .@{md-prefix}code.@{md-prefix}last {
79
+ .#{$md-prefix}html.#{$md-prefix}last,
80
+ .#{$md-prefix}code.#{$md-prefix}last {
80
81
  border-bottom: 1px solid #02267920;
81
82
  border-bottom-right-radius: 0.2em;
82
83
  border-bottom-left-radius: 0.2em;
83
84
  }
84
85
 
85
- .@{md-prefix}inlineCode {
86
+ .#{$md-prefix}inlineCode {
86
87
  margin: 0 0.2em;
87
88
  padding: 0 0.2em;
88
89
  tab-size: 4;
@@ -93,19 +94,19 @@
93
94
  border-radius: 0.2em;
94
95
  }
95
96
 
96
- .@{md-prefix}emphasis {
97
+ .#{$md-prefix}emphasis {
97
98
  font-style: italic;
98
99
  }
99
100
 
100
- .@{md-prefix}strong {
101
+ .#{$md-prefix}strong {
101
102
  font-weight: bold;
102
103
  }
103
104
 
104
- .@{md-prefix}delete > :not(.@{md-prefix}delimiter) {
105
+ .#{$md-prefix}delete > :not(.#{$md-prefix}delimiter) {
105
106
  text-decoration: line-through;
106
107
  }
107
108
 
108
- .@{md-prefix}math {
109
+ .#{$md-prefix}math {
109
110
  padding: 0 0.2em;
110
111
  color: #f57712;
111
112
  background-color: #f5771210;
@@ -113,19 +114,19 @@
113
114
  border-left: 1px solid #f5771220;
114
115
  }
115
116
 
116
- .@{md-prefix}math.@{md-prefix}first {
117
+ .#{$md-prefix}math.#{$md-prefix}first {
117
118
  border-top: 1px solid #f5771220;
118
119
  border-top-left-radius: 0.2em;
119
120
  border-top-right-radius: 0.2em;
120
121
  }
121
122
 
122
- .@{md-prefix}math.@{md-prefix}last {
123
+ .#{$md-prefix}math.#{$md-prefix}last {
123
124
  border-bottom: 1px solid #f5771220;
124
125
  border-bottom-right-radius: 0.2em;
125
126
  border-bottom-left-radius: 0.2em;
126
127
  }
127
128
 
128
- .@{md-prefix}inlineMath {
129
+ .#{$md-prefix}inlineMath {
129
130
  margin: 0 0.2em;
130
131
  padding: 0 0.2em;
131
132
  color: #f57712;
@@ -3,9 +3,9 @@
3
3
  * Inspired by Visual Studio syntax coloring
4
4
  */
5
5
 
6
- @import './global.less';
6
+ @import './global';
7
7
 
8
- .@{prefix}md-viewer.@{prefix}md-viewer {
8
+ .#{$prefix}md-viewer.#{$prefix}md-viewer {
9
9
  code,
10
10
  pre {
11
11
  color: #393a34;
@@ -0,0 +1,8 @@
1
+ @import '../components/FileInput';
2
+ @import '../components/Toolbar';
3
+ @import '../XStarEditor/index';
4
+ @import '../XStarMdEditor/index';
5
+ @import '../XStarMdViewer/index';
6
+ @import './katex';
7
+ @import './markdown';
8
+ @import './prism';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "x-star-editor",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "description": "An editor developed by turingstar",
5
5
  "license": "MIT",
6
6
  "module": "dist/index.js",
package/dist/index.d.ts DELETED
@@ -1,9 +0,0 @@
1
- export { default as XStarEditor, useEditorRef } from './XStarEditor';
2
- export type { XStarEditorHandle, XStarEditorProps } from './XStarEditor';
3
- export { default as XStarMdEditor, useMdEditorRef } from './XStarMdEditor';
4
- export type { XStarMdEditorHandle, XStarMdEditorPlugin, XStarMdEditorProps, } from './XStarMdEditor';
5
- export { default as XStarMdViewer, useMdViewerRef } from './XStarMdViewer';
6
- export type { XStarMdViewerHandle, XStarMdViewerPlugin, XStarMdViewerProps, } from './XStarMdViewer';
7
- export { createSelection, getRange } from './utils/container';
8
- export { deleteHandler, insertHandler, redoHandler, selectHandler, setHandler, toggleHandler, undoHandler, } from './utils/handler';
9
- export type { Handler } from './utils/handler';
@@ -1 +0,0 @@
1
- @prefix: x-star-;
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes