x-star-editor 0.6.4 → 0.6.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.
- package/dist/components/Fade.d.ts +2 -2
- package/dist/components/Fade.js +23 -10
- package/dist/components/Toolbar.js +18 -21
- package/dist/icons/Clear.d.ts +4 -0
- package/dist/icons/Clear.js +20 -0
- package/dist/icons/Eraser.d.ts +4 -0
- package/dist/icons/Eraser.js +15 -0
- package/dist/icons/Pencil.d.ts +4 -0
- package/dist/icons/Pencil.js +15 -0
- package/dist/icons/Screenshot.d.ts +4 -0
- package/dist/icons/Screenshot.js +18 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/locales/en_US.d.ts +18 -7
- package/dist/locales/en_US.js +19 -8
- package/dist/locales/index.d.ts +76 -32
- package/dist/locales/zh_CN.d.ts +19 -8
- package/dist/locales/zh_CN.js +20 -9
- package/dist/styles/index.css +42 -26
- package/dist/utils/markdown.d.ts +8 -0
- package/dist/utils/markdown.js +1 -1
- package/dist/utils/rehype/rehype-math.js +1 -3
- package/dist/utils/slide.d.ts +26 -0
- package/dist/utils/slide.js +24 -0
- package/dist/utils/viewer.d.ts +10 -0
- package/dist/utils/viewer.js +73 -0
- package/dist/x-star-editor/index.d.ts +1 -1
- package/dist/x-star-editor/index.js +4 -9
- package/dist/x-star-md-editor/index.d.ts +1 -1
- package/dist/x-star-md-viewer/index.js +5 -64
- package/dist/x-star-slide-viewer/index.d.ts +9 -0
- package/dist/x-star-slide-viewer/index.js +318 -281
- package/package.json +1 -3
- package/dist/utils/slide/index.d.ts +0 -0
- package/dist/utils/slide/index.js +0 -32
- /package/dist/styles/cursor/{editor-eraser.png → eraser.png} +0 -0
package/dist/styles/index.css
CHANGED
|
@@ -1840,7 +1840,6 @@ body {
|
|
|
1840
1840
|
.x-star-editor-slide-viewer {
|
|
1841
1841
|
position: relative;
|
|
1842
1842
|
color: rgba(0, 0, 0, 0.88);
|
|
1843
|
-
position: relative;
|
|
1844
1843
|
overflow: hidden;
|
|
1845
1844
|
aspect-ratio: 16/9;
|
|
1846
1845
|
}
|
|
@@ -1896,11 +1895,16 @@ body {
|
|
|
1896
1895
|
.x-star-editor-slide-viewer .x-star-editor-slide > :last-child {
|
|
1897
1896
|
margin-bottom: 0; /* 防止垂直居中时出现视觉上不居中的现象 */
|
|
1898
1897
|
}
|
|
1898
|
+
.x-star-editor-slide-viewer .x-star-editor-pad {
|
|
1899
|
+
position: absolute;
|
|
1900
|
+
top: 0;
|
|
1901
|
+
left: 0;
|
|
1902
|
+
}
|
|
1899
1903
|
.x-star-editor-slide-viewer .x-star-editor-custom-cursor-pencil {
|
|
1900
1904
|
cursor: url("./cursor/pencil.png"), auto;
|
|
1901
1905
|
}
|
|
1902
1906
|
.x-star-editor-slide-viewer .x-star-editor-custom-cursor-eraser {
|
|
1903
|
-
cursor: url("./cursor/
|
|
1907
|
+
cursor: url("./cursor/eraser.png"), auto;
|
|
1904
1908
|
}
|
|
1905
1909
|
.x-star-editor-slide-viewer .x-star-editor-btn-container {
|
|
1906
1910
|
position: absolute;
|
|
@@ -1909,7 +1913,7 @@ body {
|
|
|
1909
1913
|
height: 32px;
|
|
1910
1914
|
display: flex;
|
|
1911
1915
|
flex-direction: row-reverse;
|
|
1912
|
-
z-index:
|
|
1916
|
+
z-index: 1;
|
|
1913
1917
|
}
|
|
1914
1918
|
.x-star-editor-slide-viewer .x-star-editor-btn-container .x-star-editor-common-btn {
|
|
1915
1919
|
position: relative;
|
|
@@ -1925,13 +1929,14 @@ body {
|
|
|
1925
1929
|
cursor: pointer;
|
|
1926
1930
|
}
|
|
1927
1931
|
.x-star-editor-slide-viewer .x-star-editor-btn-container .x-star-editor-common-btn:hover {
|
|
1928
|
-
color:
|
|
1932
|
+
color: rgb(132, 174, 241);
|
|
1929
1933
|
background-color: #f0f0f0;
|
|
1930
1934
|
}
|
|
1931
1935
|
.x-star-editor-slide-viewer .x-star-editor-btn-container .x-star-editor-popover {
|
|
1932
1936
|
position: absolute;
|
|
1933
1937
|
width: 150px;
|
|
1934
1938
|
height: 0;
|
|
1939
|
+
margin: 5px;
|
|
1935
1940
|
display: flex;
|
|
1936
1941
|
flex-direction: column;
|
|
1937
1942
|
align-items: center;
|
|
@@ -1940,40 +1945,51 @@ body {
|
|
|
1940
1945
|
border-radius: 6px;
|
|
1941
1946
|
box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.1);
|
|
1942
1947
|
overflow: hidden;
|
|
1943
|
-
z-index:
|
|
1948
|
+
z-index: 1;
|
|
1944
1949
|
transition: all 0.3s cubic-bezier(0.51, 0.3, 0.06, 0.98);
|
|
1950
|
+
user-select: none;
|
|
1945
1951
|
}
|
|
1946
1952
|
.x-star-editor-slide-viewer .x-star-editor-btn-container .x-star-editor-popover > * {
|
|
1947
1953
|
margin: 8px 0;
|
|
1948
1954
|
}
|
|
1955
|
+
.x-star-editor-slide-viewer .x-star-editor-btn-container .x-star-editor-popover-label {
|
|
1956
|
+
margin-right: 15px;
|
|
1957
|
+
font-size: 12px;
|
|
1958
|
+
}
|
|
1959
|
+
.x-star-editor-slide-viewer .x-star-editor-btn-container .x-star-editor-tooltip {
|
|
1960
|
+
position: absolute;
|
|
1961
|
+
height: 0;
|
|
1962
|
+
margin-top: 36px;
|
|
1963
|
+
margin-left: 10px;
|
|
1964
|
+
padding: 10px;
|
|
1965
|
+
display: flex;
|
|
1966
|
+
flex-direction: column;
|
|
1967
|
+
align-items: center;
|
|
1968
|
+
justify-content: center;
|
|
1969
|
+
line-height: 30px;
|
|
1970
|
+
white-space: nowrap;
|
|
1971
|
+
font-size: 12px;
|
|
1972
|
+
background-color: #fff;
|
|
1973
|
+
border-radius: 6px;
|
|
1974
|
+
box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.1);
|
|
1975
|
+
z-index: 1;
|
|
1976
|
+
transform: scale(0);
|
|
1977
|
+
transition: all 0.25s cubic-bezier(0.51, 0.3, 0.06, 0.98);
|
|
1978
|
+
user-select: none;
|
|
1979
|
+
}
|
|
1980
|
+
.x-star-editor-slide-viewer .x-star-editor-btn-container .x-star-editor-common-btn:hover + .x-star-editor-tooltip {
|
|
1981
|
+
height: 30px;
|
|
1982
|
+
transform: scale(1);
|
|
1983
|
+
}
|
|
1949
1984
|
.x-star-editor-slide-viewer .x-star-editor-btn-container .x-star-editor-common-btn:hover + .x-star-editor-popover,
|
|
1950
1985
|
.x-star-editor-slide-viewer .x-star-editor-btn-container .x-star-editor-popover:hover {
|
|
1951
1986
|
height: 100px;
|
|
1952
1987
|
}
|
|
1953
|
-
.x-star-editor-slide-viewer .x-star-editor-btn-container .x-star-editor-
|
|
1988
|
+
.x-star-editor-slide-viewer .x-star-editor-btn-container .x-star-editor-pencil-popover {
|
|
1954
1989
|
top: 33px;
|
|
1955
1990
|
left: 120px;
|
|
1956
1991
|
}
|
|
1957
|
-
.x-star-editor-slide-viewer .x-star-editor-btn-container .x-star-editor-
|
|
1992
|
+
.x-star-editor-slide-viewer .x-star-editor-btn-container .x-star-editor-eraser-popover {
|
|
1958
1993
|
top: 33px;
|
|
1959
1994
|
left: 75px;
|
|
1960
1995
|
}
|
|
1961
|
-
.x-star-editor-slide-viewer .x-star-editor-pad {
|
|
1962
|
-
position: absolute;
|
|
1963
|
-
top: 0;
|
|
1964
|
-
left: 0;
|
|
1965
|
-
width: 960px;
|
|
1966
|
-
height: 540px;
|
|
1967
|
-
}
|
|
1968
|
-
.x-star-editor-slide-viewer .x-star-editor-ring {
|
|
1969
|
-
position: absolute;
|
|
1970
|
-
top: 50%;
|
|
1971
|
-
left: 50%;
|
|
1972
|
-
width: 100px;
|
|
1973
|
-
height: 100px;
|
|
1974
|
-
border: 2px solid black;
|
|
1975
|
-
border-radius: 50%;
|
|
1976
|
-
opacity: 0.5; /* 圆环内部透明 */
|
|
1977
|
-
transform: translate(-50%, -50%);
|
|
1978
|
-
pointer-events: none; /* 防止圆环遮挡鼠标事件 */
|
|
1979
|
-
}
|
package/dist/utils/markdown.d.ts
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
import type { Root as HastRoot } from 'hast';
|
|
2
|
+
import type { Root as MdastRoot } from 'mdast';
|
|
2
3
|
import type { Options as ToStringOptions } from 'mdast-util-to-string';
|
|
3
4
|
import { defaultSchema } from 'rehype-sanitize';
|
|
4
5
|
import type { ViewerOptions } from '../x-star-md-viewer';
|
|
6
|
+
/**
|
|
7
|
+
* 带缓存的解析函数
|
|
8
|
+
*
|
|
9
|
+
* @param sourceCode Markdown 文本
|
|
10
|
+
* @returns Mdast 树
|
|
11
|
+
*/
|
|
12
|
+
export declare const cachedParse: (sourceCode: string) => MdastRoot;
|
|
5
13
|
/**
|
|
6
14
|
* 将 Markdown 文本映射到 DOM 树,第一层为 `<div>` 块元素,第二层为 `<div>` 行元素,之后均为 `<span>` 元素
|
|
7
15
|
*
|
package/dist/utils/markdown.js
CHANGED
|
@@ -41,7 +41,7 @@ var toMdastProcessor = unified().use(remarkParse).use(remarkGfm).use(remarkMath)
|
|
|
41
41
|
* @param sourceCode Markdown 文本
|
|
42
42
|
* @returns Mdast 树
|
|
43
43
|
*/
|
|
44
|
-
var cachedParse = function () {
|
|
44
|
+
export var cachedParse = function () {
|
|
45
45
|
var cache = {};
|
|
46
46
|
return function (sourceCode) {
|
|
47
47
|
var _cache$sourceCode;
|
|
@@ -139,9 +139,7 @@ var rehypeMath = function rehypeMath() {
|
|
|
139
139
|
}, function (node, index, parent) {
|
|
140
140
|
var _node$properties3;
|
|
141
141
|
if (typeof ((_node$properties3 = node.properties) === null || _node$properties3 === void 0 ? void 0 : _node$properties3.value) === 'string') {
|
|
142
|
-
rawPositions = node.properties.value.split(' ').map(
|
|
143
|
-
return parseInt(offset);
|
|
144
|
-
});
|
|
142
|
+
rawPositions = node.properties.value.split(' ').map(Number);
|
|
145
143
|
}
|
|
146
144
|
if (index !== null && parent) {
|
|
147
145
|
parent.children.splice(index);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { PointGroup } from 'signature_pad';
|
|
2
|
+
export interface PadValue {
|
|
3
|
+
data: PointGroup[];
|
|
4
|
+
scale: number;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* 计算缩放后点的坐标值
|
|
8
|
+
*
|
|
9
|
+
* @param padValue 画板数据
|
|
10
|
+
* @param parentWidth 父元素宽度
|
|
11
|
+
* @returns 新坐标值
|
|
12
|
+
*/
|
|
13
|
+
export declare const getScaledData: ({ data, scale }: PadValue, parentWidth: number) => {
|
|
14
|
+
minWidth: number;
|
|
15
|
+
maxWidth: number;
|
|
16
|
+
points: {
|
|
17
|
+
x: number;
|
|
18
|
+
y: number;
|
|
19
|
+
pressure: number;
|
|
20
|
+
time: number;
|
|
21
|
+
}[];
|
|
22
|
+
dotSize: number;
|
|
23
|
+
penColor: string;
|
|
24
|
+
velocityFilterWeight: number;
|
|
25
|
+
compositeOperation: GlobalCompositeOperation;
|
|
26
|
+
}[];
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
/**
|
|
3
|
+
* 计算缩放后点的坐标值
|
|
4
|
+
*
|
|
5
|
+
* @param padValue 画板数据
|
|
6
|
+
* @param parentWidth 父元素宽度
|
|
7
|
+
* @returns 新坐标值
|
|
8
|
+
*/
|
|
9
|
+
export var getScaledData = function getScaledData(_ref, parentWidth) {
|
|
10
|
+
var data = _ref.data,
|
|
11
|
+
scale = _ref.scale;
|
|
12
|
+
return data.map(function (group) {
|
|
13
|
+
return _objectSpread(_objectSpread({}, group), {}, {
|
|
14
|
+
minWidth: group.minWidth / scale * (parentWidth / 1280),
|
|
15
|
+
maxWidth: group.maxWidth / scale * (parentWidth / 1280),
|
|
16
|
+
points: group.points.map(function (point) {
|
|
17
|
+
return _objectSpread(_objectSpread({}, point), {}, {
|
|
18
|
+
x: point.x / scale * (parentWidth / 1280),
|
|
19
|
+
y: point.y / scale * (parentWidth / 1280)
|
|
20
|
+
});
|
|
21
|
+
})
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { ViewerOptions } from '../x-star-md-viewer';
|
|
3
|
+
/**
|
|
4
|
+
* 将 Markdown 文本映射到 React 虚拟 DOM 树
|
|
5
|
+
*
|
|
6
|
+
* @param sourceCode Markdown 文本
|
|
7
|
+
* @param options 配置项
|
|
8
|
+
* @returns React 虚拟 DOM 树
|
|
9
|
+
*/
|
|
10
|
+
export declare const useViewerRender: (sourceCode: string, options: ViewerOptions) => import("react").JSX.Element | undefined;
|