@pinnacle0/web-ui 0.3.44 → 0.3.47
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/core/Form/index.less +0 -15
- package/core/Input/index.d.ts +7 -1
- package/core/Input/index.js +22 -5
- package/core/Input/index.js.map +1 -1
- package/core/NumberInput/index.d.ts +3 -0
- package/core/NumberInput/index.js +2 -2
- package/core/NumberInput/index.js.map +1 -1
- package/core/VirtualTable/index.d.ts +2 -1
- package/core/VirtualTable/index.js +7 -6
- package/core/VirtualTable/index.js.map +1 -1
- package/package.json +2 -4
- package/admin/RichEditor/index.d.ts +0 -34
- package/admin/RichEditor/index.js +0 -104
- package/admin/RichEditor/index.js.map +0 -1
- package/admin/RichEditor/index.less +0 -6
package/core/Form/index.less
CHANGED
|
@@ -79,17 +79,6 @@
|
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
// For braft editor
|
|
83
|
-
.bf-container {
|
|
84
|
-
border: 1px solid #d7d7d7;
|
|
85
|
-
border-radius: 4px;
|
|
86
|
-
width: 780px;
|
|
87
|
-
|
|
88
|
-
.bf-content {
|
|
89
|
-
height: 350px;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
82
|
&.has-error {
|
|
94
83
|
textarea,
|
|
95
84
|
input,
|
|
@@ -99,10 +88,6 @@
|
|
|
99
88
|
.ant-upload {
|
|
100
89
|
border-color: #f5222d !important;
|
|
101
90
|
}
|
|
102
|
-
|
|
103
|
-
.bf-container {
|
|
104
|
-
border-color: #f5222d;
|
|
105
|
-
}
|
|
106
91
|
}
|
|
107
92
|
|
|
108
93
|
&.width-fill {
|
package/core/Input/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import type { ControlledFormValue } from "../../internal/type";
|
|
|
4
4
|
import "antd/lib/input/style";
|
|
5
5
|
import "./index.less";
|
|
6
6
|
declare type ExcludedAntInputKeys = "value" | "onChange" | "addonBefore" | "addonAfter";
|
|
7
|
+
export declare type FocusType = "cursor-at-start" | "cursor-at-last" | "select-all" | "prevent-scroll";
|
|
7
8
|
export interface InputReadonlyProps extends Omit<InputProps, ExcludedAntInputKeys | "readonly" | "disabled" | "allowClear"> {
|
|
8
9
|
value: string;
|
|
9
10
|
}
|
|
@@ -18,6 +19,8 @@ export interface InputNullableProps extends Omit<InputProps, ExcludedAntInputKey
|
|
|
18
19
|
export interface InputNullableTextAreaProps extends Omit<TextAreaProps, ExcludedAntInputKeys>, ControlledFormValue<string | null> {
|
|
19
20
|
}
|
|
20
21
|
export interface Props extends Omit<InputProps, ExcludedAntInputKeys>, ControlledFormValue<string> {
|
|
22
|
+
selectAll?: boolean;
|
|
23
|
+
focus?: FocusType;
|
|
21
24
|
inputRef?: React.RefObject<InputRef>;
|
|
22
25
|
}
|
|
23
26
|
export declare class Input extends React.PureComponent<Props> {
|
|
@@ -31,9 +34,12 @@ export declare class Input extends React.PureComponent<Props> {
|
|
|
31
34
|
static NullableTextArea: ({ value, onChange, ...rest }: InputNullableTextAreaProps) => JSX.Element;
|
|
32
35
|
private static onChange;
|
|
33
36
|
private antInputRef;
|
|
37
|
+
private getRef;
|
|
38
|
+
private createFocusOptions;
|
|
39
|
+
private handleClick;
|
|
34
40
|
componentDidMount(): void;
|
|
35
41
|
blur: () => void | undefined;
|
|
36
|
-
focus: () => void | undefined;
|
|
42
|
+
focus: (focusType?: FocusType) => void | undefined;
|
|
37
43
|
render(): JSX.Element;
|
|
38
44
|
}
|
|
39
45
|
export {};
|
package/core/Input/index.js
CHANGED
|
@@ -44,19 +44,36 @@ var Input = /** @class */ (function (_super) {
|
|
|
44
44
|
function Input() {
|
|
45
45
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
46
46
|
_this.antInputRef = React.createRef();
|
|
47
|
-
_this.
|
|
48
|
-
_this.
|
|
47
|
+
_this.getRef = function () { var _a; return (_a = _this.props.inputRef) !== null && _a !== void 0 ? _a : _this.antInputRef; };
|
|
48
|
+
_this.handleClick = function (event) {
|
|
49
|
+
var _a, _b, _c;
|
|
50
|
+
(_a = _this.getRef().current) === null || _a === void 0 ? void 0 : _a.focus(_this.createFocusOptions());
|
|
51
|
+
(_c = (_b = _this.props).onClick) === null || _c === void 0 ? void 0 : _c.call(_b, event);
|
|
52
|
+
};
|
|
53
|
+
_this.blur = function () { var _a; return (_a = _this.getRef().current) === null || _a === void 0 ? void 0 : _a.blur(); };
|
|
54
|
+
_this.focus = function (focusType) { var _a; return (_a = (_this.props.inputRef || _this.antInputRef).current) === null || _a === void 0 ? void 0 : _a.focus(_this.createFocusOptions(focusType)); };
|
|
49
55
|
return _this;
|
|
50
56
|
}
|
|
57
|
+
Input.prototype.createFocusOptions = function (focus) {
|
|
58
|
+
var type = focus || this.props.focus;
|
|
59
|
+
if (!type)
|
|
60
|
+
return undefined;
|
|
61
|
+
if (type === "prevent-scroll") {
|
|
62
|
+
return { preventScroll: true };
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
return { cursor: type === "cursor-at-start" ? "start" : type === "cursor-at-last" ? "end" : "all" };
|
|
66
|
+
}
|
|
67
|
+
};
|
|
51
68
|
Input.prototype.componentDidMount = function () {
|
|
52
69
|
var _a;
|
|
53
70
|
if (this.props.autoFocus) {
|
|
54
|
-
(_a =
|
|
71
|
+
(_a = this.getRef().current) === null || _a === void 0 ? void 0 : _a.focus(this.createFocusOptions());
|
|
55
72
|
}
|
|
56
73
|
};
|
|
57
74
|
Input.prototype.render = function () {
|
|
58
|
-
var _a = this.props, onChange = _a.onChange, autoFocus = _a.autoFocus, inputRef = _a.inputRef, rest = __rest(_a, ["onChange", "autoFocus", "inputRef"]);
|
|
59
|
-
return React.createElement(AntInput, __assign({}, rest, { onChange: function (e) { return Input.onChange(e, onChange); }
|
|
75
|
+
var _a = this.props, onChange = _a.onChange, autoFocus = _a.autoFocus, inputRef = _a.inputRef, onClick = _a.onClick, rest = __rest(_a, ["onChange", "autoFocus", "inputRef", "onClick"]);
|
|
76
|
+
return React.createElement(AntInput, __assign({}, rest, { ref: inputRef || this.antInputRef, onClick: this.handleClick, onChange: function (e) { return Input.onChange(e, onChange); } }));
|
|
60
77
|
};
|
|
61
78
|
Input.displayName = "Input";
|
|
62
79
|
Input.Group = AntInput.Group;
|
package/core/Input/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/Input/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AAGtC,OAAO,sBAAsB,CAAC;AAC9B,OAAO,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/Input/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AAGtC,OAAO,sBAAsB,CAAC;AAC9B,OAAO,cAAc,CAAC;AA0BtB;IAA2B,yBAA0B;IAArD;QAAA,qEAoDC;QAjCW,iBAAW,GAAG,KAAK,CAAC,SAAS,EAAY,CAAC;QAE1C,YAAM,GAAG,sBAAM,OAAA,MAAA,KAAI,CAAC,KAAK,CAAC,QAAQ,mCAAI,KAAI,CAAC,WAAW,CAAA,EAAA,CAAC;QAYvD,iBAAW,GAA8C,UAAA,KAAK;;YAClE,MAAA,KAAI,CAAC,MAAM,EAAE,CAAC,OAAO,0CAAE,KAAK,CAAC,KAAI,CAAC,kBAAkB,EAAE,CAAC,CAAC;YACxD,MAAA,MAAA,KAAI,CAAC,KAAK,EAAC,OAAO,mDAAG,KAAK,CAAC,CAAC;QAChC,CAAC,CAAC;QAQF,UAAI,GAAG,sBAAM,OAAA,MAAA,KAAI,CAAC,MAAM,EAAE,CAAC,OAAO,0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,cAAA,EAAK,IAAI,cAAzB,qBAA0B,CAAD;QAA0B,OAAA,oBAAC,KAAK,aAAC,KAAK,EAAE,KAAK,IAAI,EAAE,EAAE,QAAQ,EAAE,UAAA,KAAK,IAAI,OAAA,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,EAArC,CAAqC,IAAM,IAAI,EAAI,CAAA;KAAA,CAAC;IAEjK,sBAAgB,GAAG,UAAC,EAAsD;QAArD,IAAA,KAAK,WAAA,EAAE,QAAQ,cAAA,EAAK,IAAI,cAAzB,qBAA0B,CAAD;QAAkC,OAAA,oBAAC,KAAK,CAAC,QAAQ,aAAC,KAAK,EAAE,KAAK,IAAI,EAAE,EAAE,QAAQ,EAAE,UAAA,KAAK,IAAI,OAAA,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,EAArC,CAAqC,IAAM,IAAI,EAAI,CAAA;KAAA,CAAC;IAElL,cAAQ,GAAG,UAAC,CAA4D,EAAE,aAAyC,IAAK,OAAA,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAA7B,CAA6B,CAAC;IAmCzK,YAAC;CAAA,AApDD,CAA2B,KAAK,CAAC,aAAa,GAoD7C;SApDY,KAAK"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
import type { FocusType } from "../Input";
|
|
2
3
|
import { NumberInputPercentage } from "./NumberInputPercentage";
|
|
3
4
|
import type { InputRef as AntInputRef } from "antd/lib";
|
|
4
5
|
import type { ControlledFormValue } from "../../internal/type";
|
|
@@ -43,6 +44,8 @@ export interface Props<AllowNull extends boolean> extends ControlledFormValue<Al
|
|
|
43
44
|
prefix?: React.ReactChild;
|
|
44
45
|
/** Optional Input Ref */
|
|
45
46
|
inputRef?: React.RefObject<InputRef>;
|
|
47
|
+
/** select all the text when focus the input */
|
|
48
|
+
focus?: FocusType;
|
|
46
49
|
}
|
|
47
50
|
interface State {
|
|
48
51
|
editingValue: string;
|
|
@@ -100,11 +100,11 @@ var NumberInput = /** @class */ (function (_super) {
|
|
|
100
100
|
}
|
|
101
101
|
};
|
|
102
102
|
NumberInput.prototype.render = function () {
|
|
103
|
-
var _a = this.typeSafeProps, disabled = _a.disabled, className = _a.className, editable = _a.editable, stepperMode = _a.stepperMode, placeholder = _a.placeholder, inputStyle = _a.inputStyle, suffix = _a.suffix, prefix = _a.prefix, allowClear = _a.allowClear, inputRef = _a.inputRef;
|
|
103
|
+
var _a = this.typeSafeProps, disabled = _a.disabled, className = _a.className, editable = _a.editable, stepperMode = _a.stepperMode, placeholder = _a.placeholder, inputStyle = _a.inputStyle, suffix = _a.suffix, prefix = _a.prefix, allowClear = _a.allowClear, inputRef = _a.inputRef, focus = _a.focus;
|
|
104
104
|
var _b = this.state, editingValue = _b.editingValue, isEditing = _b.isEditing;
|
|
105
105
|
return (React.createElement("div", { className: classNames("g-number-input", "stepper-".concat(stepperMode), { disabled: disabled }, className), onClick: this.stopPropagation },
|
|
106
106
|
React.createElement("button", { type: "button", className: "minus", disabled: disabled || !canMinus(__assign(__assign({}, this.typeSafeProps), { step: this.getStep() })), onClick: this.onMinusClick }, "\uFF0D"),
|
|
107
|
-
React.createElement(Input, { inputRef: inputRef || this.inputRef, style: inputStyle, placeholder: placeholder, disabled: disabled, value: isEditing ? editingValue : getDisplayValue(this.typeSafeProps), readOnly: !editable, onFocus: this.onInputFocus, onBlur: this.onInputBlur, onChange: this.onInputChange, onKeyPress: this.onInputPress, suffix: suffix, prefix: prefix, inputMode: "decimal", className: "count-input", allowClear: allowClear }),
|
|
107
|
+
React.createElement(Input, { inputRef: inputRef || this.inputRef, style: inputStyle, placeholder: placeholder, disabled: disabled, value: isEditing ? editingValue : getDisplayValue(this.typeSafeProps), readOnly: !editable, onFocus: this.onInputFocus, onBlur: this.onInputBlur, onChange: this.onInputChange, onKeyPress: this.onInputPress, suffix: suffix, prefix: prefix, inputMode: "decimal", className: "count-input", allowClear: allowClear, focus: focus }),
|
|
108
108
|
React.createElement("button", { type: "button", className: "add", disabled: disabled || !canAdd(__assign(__assign({}, this.typeSafeProps), { step: this.getStep() })), onClick: this.onAddClick }, "\uFF0B")));
|
|
109
109
|
};
|
|
110
110
|
Object.defineProperty(NumberInput.prototype, "typeSafeProps", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/NumberInput/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,UAAU,EAAC,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/NumberInput/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,UAAU,EAAC,MAAM,uBAAuB,CAAC;AAEjD,OAAO,EAAC,KAAK,EAAC,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAC,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,eAAe,EAAE,mBAAmB,EAAE,QAAQ,EAAC,MAAM,QAAQ,CAAC;AAC/F,OAAO,EAAC,qBAAqB,EAAC,MAAM,yBAAyB,CAAC;AAG9D,OAAO,cAAc,CAAC;AA0DtB;IAA4D,+BAA4C;IAepG,qBAAY,KAAkC;QAA9C,YACI,kBAAM,KAAK,CAAC,SAEf;QALO,cAAQ,GAAG,KAAK,CAAC,SAAS,EAAY,CAAC;QAmB/C,aAAO,GAAG;YACA,IAAA,KAAgB,KAAI,CAAC,aAAa,EAAjC,IAAI,UAAA,EAAE,KAAK,WAAsB,CAAC;YACzC,IAAI,IAAI,KAAK,SAAS,EAAE;gBACpB,OAAO,IAAI,CAAC;aACf;YACD,O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AC,KAAK,EAAC,QAAQ,EAAE,QAAQ,IAAI,CAAC,MAAM,uBAAK,IAAI,CAAC,aAAa,KAAE,IAAI,EAAE,IAAI,CAAC,OAAO,EAAE,IAAE,EAAE,OAAO,EAAE,IAAI,CAAC,UAAU,aAEnI,CACP,CACT,CAAC;IACN,CAAC;IAED,sBAAY,sCAAa;aAAzB;YACI,6FAA6F;YAC7F,OAAO,IAAI,CAAC,KAAoC,CAAC;QACrD,CAAC;;;OAAA;IA/HM,uBAAW,GAAG,aAAa,CAAC;IAE5B,wBAAY,GAAuC;QACtD,KAAK,EAAE,CAAC;QACR,GAAG,EAAE,CAAC,QAAU;QAChB,GAAG,EAAE,QAAU;QACf,QAAQ,EAAE,IAAI;QACd,WAAW,EAAE,MAAM;KACtB,CAAC;IAEK,sBAAU,GAAG,qBAAqB,CAAC;IAsH9C,kBAAC;CAAA,AAjID,CAA4D,KAAK,CAAC,aAAa,GAiI9E;SAjIY,WAAW"}
|
|
@@ -24,7 +24,8 @@ export interface VirtualTableProps<RowType extends object> {
|
|
|
24
24
|
rowKey?: StringKey<RowType> | "index";
|
|
25
25
|
headerHeight?: number;
|
|
26
26
|
rowExpand?: VirtualTableRowExpand<RowType>;
|
|
27
|
+
horizontalScrollBarSize?: number;
|
|
27
28
|
}
|
|
28
|
-
export declare const VirtualTable: (<RowType extends object>({ columns, rowHeight, scrollY, dataSource, className, rowClassName, loading, emptyPlaceholder, rowSelection, onRowClick, scrollX, rowExpand, rowKey, headerHeight, }: VirtualTableProps<RowType>) => JSX.Element) & {
|
|
29
|
+
export declare const VirtualTable: (<RowType extends object>({ columns, rowHeight, scrollY, dataSource, className, rowClassName, loading, emptyPlaceholder, rowSelection, onRowClick, scrollX, rowExpand, rowKey, headerHeight, horizontalScrollBarSize, }: VirtualTableProps<RowType>) => JSX.Element) & {
|
|
29
30
|
displayName: string;
|
|
30
31
|
};
|
|
@@ -33,24 +33,25 @@ import { TableRow } from "./TableRow";
|
|
|
33
33
|
import { TableHeader } from "./TableHeader";
|
|
34
34
|
import "./index.less";
|
|
35
35
|
export var VirtualTable = Object.assign(function (_a) {
|
|
36
|
-
var columns = _a.columns, rowHeight = _a.rowHeight, scrollY = _a.scrollY, dataSource = _a.dataSource, className = _a.className, rowClassName = _a.rowClassName, loading = _a.loading, emptyPlaceholder = _a.emptyPlaceholder, rowSelection = _a.rowSelection, onRowClick = _a.onRowClick, scrollX = _a.scrollX, rowExpand = _a.rowExpand, _b = _a.rowKey, rowKey = _b === void 0 ? "index" : _b, _c = _a.headerHeight, headerHeight = _c === void 0 ? 50 : _c;
|
|
36
|
+
var columns = _a.columns, rowHeight = _a.rowHeight, scrollY = _a.scrollY, dataSource = _a.dataSource, className = _a.className, rowClassName = _a.rowClassName, loading = _a.loading, emptyPlaceholder = _a.emptyPlaceholder, rowSelection = _a.rowSelection, onRowClick = _a.onRowClick, scrollX = _a.scrollX, rowExpand = _a.rowExpand, _b = _a.rowKey, rowKey = _b === void 0 ? "index" : _b, _c = _a.headerHeight, headerHeight = _c === void 0 ? 50 : _c, _d = _a.horizontalScrollBarSize, horizontalScrollBarSize = _d === void 0 ? 20 : _d;
|
|
37
37
|
var size = dataSource.length;
|
|
38
38
|
var scrollContentRef = React.useRef(null);
|
|
39
39
|
var headersRef = React.useRef(null);
|
|
40
40
|
var estimateSize = React.useCallback(function () { return rowHeight; }, [rowHeight]);
|
|
41
41
|
var overscan = rowExpand ? Math.floor(scrollY / rowHeight) : 1;
|
|
42
|
-
var
|
|
42
|
+
var _e = useVirtual({
|
|
43
43
|
size: size,
|
|
44
44
|
parentRef: scrollContentRef,
|
|
45
45
|
estimateSize: estimateSize,
|
|
46
46
|
overscan: overscan,
|
|
47
|
-
}), virtualItems =
|
|
47
|
+
}), virtualItems = _e.virtualItems, totalSize = _e.totalSize;
|
|
48
48
|
var transformedColumns = useTransformColumn({ columns: columns, dataSource: dataSource, rowSelection: rowSelection, rowKey: rowKey, rowExpand: rowExpand });
|
|
49
49
|
var isScrollable = totalSize > scrollY;
|
|
50
|
-
var
|
|
51
|
-
var
|
|
50
|
+
var _f = useLayout({ headersRef: headersRef, scrollContentRef: scrollContentRef, isScrollable: isScrollable, columns: transformedColumns }), scrollBarSize = _f.scrollBarSize, stickyPosition = _f.stickyPosition, columnWidths = _f.columnWidths, isScrollToEdge = _f.isScrollToEdge, isScrollToLeft = _f.isScrollToLeft, isScrollToRight = _f.isScrollToRight;
|
|
51
|
+
var isHorizontalScrollable = scrollContentRef.current ? columnWidths.reduce(function (acc, curr) { return acc + curr; }, 0) - scrollBarSize > scrollContentRef.current.clientWidth : false;
|
|
52
|
+
var tableHeight = scrollY + headerHeight + (isHorizontalScrollable ? horizontalScrollBarSize : 0);
|
|
53
|
+
var tableBodyHeight = scrollY + (isHorizontalScrollable ? horizontalScrollBarSize : 0);
|
|
52
54
|
var emptyElement = emptyPlaceholder || "暂无数据";
|
|
53
|
-
var _e = useLayout({ headersRef: headersRef, scrollContentRef: scrollContentRef, isScrollable: isScrollable, columns: transformedColumns }), scrollBarSize = _e.scrollBarSize, stickyPosition = _e.stickyPosition, columnWidths = _e.columnWidths, isScrollToEdge = _e.isScrollToEdge, isScrollToLeft = _e.isScrollToLeft, isScrollToRight = _e.isScrollToRight;
|
|
54
55
|
var lastShownColumnIndex = React.useMemo(function () { return transformedColumns.length - 1 - __spreadArray([], __read(transformedColumns), false).reverse().findIndex(function (_) { return _.display !== "hidden"; }); }, [transformedColumns]);
|
|
55
56
|
// handle the edge position & shadow of the fixed columns
|
|
56
57
|
var getFixedColumnClassNames = React.useCallback(function (fixed, columnIndex) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/VirtualTable/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,UAAU,EAAC,MAAM,eAAe,CAAC;AACzC,OAAO,EAAC,UAAU,EAAC,MAAM,u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SAAS,EAAC,YAAY,IACtB,UAAU,CAAC,MAAM,KAAK,CAAC;oBACpB,CAAC,CAAC,YAAY;oBACd,CAAC,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC;wBACvB,YAAY,CAAC,GAAG,CAAC,UAAA,WAAW,IAAI,OAAA,CAC5B,oBAAC,QAAQ,IACL,GAAG,EAAE,WAAW,CAAC,KAAK,EACtB,SAAS,EAAE,SAAS,EACpB,UAAU,EAAE,UAAU,EACtB,WAAW,EAAE,WAAW,EACxB,IAAI,EAAE,UAAU,CAAC,WAAW,CAAC,KAAK,CAAC,EACnC,OAAO,EAAE,kBAAkB,EAC3B,YAAY,EAAE,YAAY,EAC1B,aAAa,EAAE,aAAa,EAC5B,cAAc,EAAE,cAAc,EAC9B,oBAAoB,EAAE,oBAAoB,EAC1C,YAAY,EAAE,YAAY,EAC1B,wBAAwB,EAAE,wBAAwB,EAClD,SAAS,EAAE,SAAS,GACtB,CACL,EAhB+B,CAgB/B,CAAC,CACN,CACJ,CACJ,CACJ,CACT,CAAC;AACN,CAAC,EACD,EAAC,WAAW,EAAE,cAAc,EAAC,CAChC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pinnacle0/web-ui",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.47",
|
|
4
4
|
"author": "Pinnacle",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"sideEffects": [
|
|
@@ -25,8 +25,7 @@
|
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@ant-design/icons": "4.7.0",
|
|
28
|
-
"antd": "4.22.
|
|
29
|
-
"braft-editor": "2.3.9",
|
|
28
|
+
"antd": "4.22.2",
|
|
30
29
|
"classnames": "2.3.1",
|
|
31
30
|
"moment": "2.29.4",
|
|
32
31
|
"rc-resize-observer": "1.2.0",
|
|
@@ -44,7 +43,6 @@
|
|
|
44
43
|
"@testing-library/jest-dom": "5.16.4",
|
|
45
44
|
"@testing-library/react": "13.3.0",
|
|
46
45
|
"@testing-library/user-event": "14.3.0",
|
|
47
|
-
"@types/draft-js": "0.11.9",
|
|
48
46
|
"@types/history": "4.7.11",
|
|
49
47
|
"@types/react": "18.0.15",
|
|
50
48
|
"@types/react-dom": "18.0.6",
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import type { EditorState } from "braft-editor";
|
|
3
|
-
import type { ControlledFormValue } from "../../internal/type";
|
|
4
|
-
import type { UploaderProps } from "../../util/UploadUtil/type";
|
|
5
|
-
import "braft-editor/dist/index.css";
|
|
6
|
-
import "./index.less";
|
|
7
|
-
/**
|
|
8
|
-
* onChange/value is of the HTML content.
|
|
9
|
-
* If the HTML content is only empty rows (e.g: pure <p/>), onChange also emit "".
|
|
10
|
-
*
|
|
11
|
-
* CAVEAT:
|
|
12
|
-
* This component is storing the editor state internally (un-controlled).
|
|
13
|
-
* The props.value only represents the initial value.
|
|
14
|
-
* Because createEditorState must only be created only ONCE, in the constructor.
|
|
15
|
-
* Therefore, we cannot create new editor state every time based on current props.value.
|
|
16
|
-
*
|
|
17
|
-
* Ref: https://www.yuque.com/braft-editor/be/lzwpnr#1bbbb204
|
|
18
|
-
*/
|
|
19
|
-
export interface Props<SuccessResponseType, ErrorResponseType> extends ControlledFormValue<string>, UploaderProps<SuccessResponseType, ErrorResponseType> {
|
|
20
|
-
imageURLParser: (response: SuccessResponseType) => string;
|
|
21
|
-
}
|
|
22
|
-
interface State {
|
|
23
|
-
editorState: EditorState;
|
|
24
|
-
}
|
|
25
|
-
export declare class RichEditor<SuccessResponseType, ErrorResponseType> extends React.PureComponent<Props<SuccessResponseType, ErrorResponseType>, State> {
|
|
26
|
-
static displayName: string;
|
|
27
|
-
private readonly editorControls;
|
|
28
|
-
private readonly imageControls;
|
|
29
|
-
private readonly mediaConfig;
|
|
30
|
-
constructor(props: Props<SuccessResponseType, ErrorResponseType>);
|
|
31
|
-
onChange: (editorState: EditorState) => void;
|
|
32
|
-
render(): JSX.Element;
|
|
33
|
-
}
|
|
34
|
-
export {};
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
var __extends = (this && this.__extends) || (function () {
|
|
2
|
-
var extendStatics = function (d, b) {
|
|
3
|
-
extendStatics = Object.setPrototypeOf ||
|
|
4
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
5
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
6
|
-
return extendStatics(d, b);
|
|
7
|
-
};
|
|
8
|
-
return function (d, b) {
|
|
9
|
-
if (typeof b !== "function" && b !== null)
|
|
10
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
11
|
-
extendStatics(d, b);
|
|
12
|
-
function __() { this.constructor = d; }
|
|
13
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
14
|
-
};
|
|
15
|
-
})();
|
|
16
|
-
import React from "react";
|
|
17
|
-
import BraftEditor from "braft-editor";
|
|
18
|
-
import { LocaleUtil } from "../../util/LocaleUtil";
|
|
19
|
-
import "braft-editor/dist/index.css";
|
|
20
|
-
import "./index.less";
|
|
21
|
-
import { UploadUtil } from "../../util/UploadUtil";
|
|
22
|
-
var RichEditor = /** @class */ (function (_super) {
|
|
23
|
-
__extends(RichEditor, _super);
|
|
24
|
-
function RichEditor(props) {
|
|
25
|
-
var _this = _super.call(this, props) || this;
|
|
26
|
-
// API reference: https://www.yuque.com/braft-editor/be/gz44tn
|
|
27
|
-
_this.editorControls = [
|
|
28
|
-
"font-size",
|
|
29
|
-
"text-align",
|
|
30
|
-
"text-color",
|
|
31
|
-
"bold",
|
|
32
|
-
"italic",
|
|
33
|
-
"underline",
|
|
34
|
-
"strike-through",
|
|
35
|
-
"separator",
|
|
36
|
-
"list-ul",
|
|
37
|
-
"list-ol",
|
|
38
|
-
"separator",
|
|
39
|
-
"link",
|
|
40
|
-
"media",
|
|
41
|
-
"separator",
|
|
42
|
-
"remove-styles",
|
|
43
|
-
];
|
|
44
|
-
_this.imageControls = [];
|
|
45
|
-
_this.mediaConfig = {
|
|
46
|
-
pasteImage: false,
|
|
47
|
-
accepts: {
|
|
48
|
-
image: "image/png,image/jpeg,image/gif,image/svg",
|
|
49
|
-
video: false,
|
|
50
|
-
audio: false,
|
|
51
|
-
},
|
|
52
|
-
externals: {
|
|
53
|
-
image: false,
|
|
54
|
-
audio: false,
|
|
55
|
-
video: false,
|
|
56
|
-
embed: false,
|
|
57
|
-
},
|
|
58
|
-
uploadFn: function (params) {
|
|
59
|
-
var _a = _this.props, formField = _a.formField, uploadURL = _a.uploadURL, imageURLParser = _a.imageURLParser, onUploadFailure = _a.onUploadFailure, onUploadSuccess = _a.onUploadSuccess;
|
|
60
|
-
var file = params.file, success = params.success, progress = params.progress;
|
|
61
|
-
UploadUtil.createRequest({
|
|
62
|
-
uploadURL: uploadURL,
|
|
63
|
-
file: file,
|
|
64
|
-
formField: formField,
|
|
65
|
-
onSuccess: function (logEntry, response) {
|
|
66
|
-
var imageURL = imageURLParser(response);
|
|
67
|
-
success({
|
|
68
|
-
url: imageURL,
|
|
69
|
-
meta: {
|
|
70
|
-
id: imageURL,
|
|
71
|
-
title: "",
|
|
72
|
-
alt: "image",
|
|
73
|
-
// Below are for video settings, not available here
|
|
74
|
-
loop: true,
|
|
75
|
-
autoPlay: true,
|
|
76
|
-
controls: true,
|
|
77
|
-
poster: "",
|
|
78
|
-
},
|
|
79
|
-
});
|
|
80
|
-
onUploadSuccess === null || onUploadSuccess === void 0 ? void 0 : onUploadSuccess(logEntry, response);
|
|
81
|
-
},
|
|
82
|
-
onError: onUploadFailure,
|
|
83
|
-
onProgress: progress,
|
|
84
|
-
});
|
|
85
|
-
},
|
|
86
|
-
};
|
|
87
|
-
_this.onChange = function (editorState) {
|
|
88
|
-
_this.setState({ editorState: editorState });
|
|
89
|
-
var onChange = _this.props.onChange;
|
|
90
|
-
var textContent = editorState.toText().trim();
|
|
91
|
-
onChange(textContent === "" ? "" : editorState.toHTML());
|
|
92
|
-
};
|
|
93
|
-
_this.state = { editorState: BraftEditor.createEditorState(_this.props.value) };
|
|
94
|
-
return _this;
|
|
95
|
-
}
|
|
96
|
-
RichEditor.prototype.render = function () {
|
|
97
|
-
var editorState = this.state.editorState;
|
|
98
|
-
return (React.createElement(BraftEditor, { language: LocaleUtil.current(), controls: this.editorControls, media: this.mediaConfig, imageControls: this.imageControls, value: editorState, stripPastedStyles: true, onChange: this.onChange }));
|
|
99
|
-
};
|
|
100
|
-
RichEditor.displayName = "RichEditor";
|
|
101
|
-
return RichEditor;
|
|
102
|
-
}(React.PureComponent));
|
|
103
|
-
export { RichEditor };
|
|
104
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/admin/RichEditor/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,WAAW,MAAM,cAAc,CAAC;AACvC,OAAO,EAAC,UAAU,EAAC,MAAM,uBAAuB,CAAC;AAGjD,OAAO,6BAA6B,CAAC;AACrC,OAAO,cAAc,CAAC;AACtB,OAAO,EAAC,UAAU,EAAC,MAAM,uBAAuB,CAAC;AAsBjD;IAAwE,8BAAyE;IAkE7I,oBAAY,KAAoD;QAAhE,YACI,kBAAM,KAAK,CAAC,SAEf;QAlED,8DAA8D;QAC7C,oBAAc,GAAkB;YAC7C,WAAW;YACX,YAAY;YACZ,YAAY;YACZ,MAAM;YACN,QAAQ;YACR,WAAW;YACX,gBAAgB;YAChB,WAAW;YACX,SAAS;YACT,SAAS;YACT,WAAW;YACX,MAAM;YACN,OAAO;YACP,WAAW;YACX,eAAe;SAClB,CAAC;QACe,mBAAa,GAAuB,EAAE,CAAC;QACvC,iBAAW,GAAc;YACtC,UAAU,EAAE,KAAK;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