fan-standard-comp 3.1.10 → 3.2.0
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/Readme.md +35 -0
- package/dist/fan-standard-comp.umd.js +15 -15
- package/es/ButtonGroup/ButtonList.js +0 -3
- package/es/ButtonGroup/ButtonMenu.js +0 -3
- package/es/ButtonGroup/PopConfirmTitle.js +5 -15
- package/es/ButtonGroup/index.js +212 -216
- package/es/ButtonGroup/style/index.less +1 -1
- package/es/DragContent/DragBar.js +2 -6
- package/es/DragContent/index.js +44 -75
- package/es/FormComp/ChunkUploader/api.js +6 -10
- package/es/FormComp/ChunkUploader/index.js +105 -171
- package/es/FormComp/ChunkUploader/lib.js +4 -17
- package/es/FormComp/ChunkUploader/upload-queue.class.js +10 -45
- package/es/FormComp/ChunkUploader/worker.js +0 -3
- package/es/FormComp/EditButton/index.js +24 -49
- package/es/FormComp/FieldComponent/ReUpload.js +18 -38
- package/es/FormComp/FieldComponent/RefactorTreeSelect.js +36 -74
- package/es/FormComp/FieldComponent/TitleNode.js +1 -3
- package/es/FormComp/FieldComponent/index.js +38 -74
- package/es/FormComp/FieldComponent/setReadonlyValues.js +34 -63
- package/es/FormComp/RenderItemGroup/index.js +46 -74
- package/es/FormComp/Uploader/index.js +36 -77
- package/es/FormComp/Uploader/util.js +0 -6
- package/es/FormComp/VarTemplate/index.js +58 -96
- package/es/NavLeafScroll/index.js +172 -154
- package/es/NavLeafScroll/style/index.less +33 -1
- package/es/RefactorTree/index.js +36 -53
- package/es/RefactorTree/indexTreeNode.js +35 -68
- package/es/RefactorTree/util.js +9 -43
- package/es/SpecIcon/fonts/iconfont.js +7 -12
- package/es/SpecIcon/index.js +16 -25
- package/es/SplitterLayout/Pane.js +2 -5
- package/es/SplitterLayout/index.js +20 -70
- package/es/StandardContent/SplitterLayout/Pane.js +6 -10
- package/es/StandardContent/SplitterLayout/index.js +12 -63
- package/es/StandardContent/SubfieldContent.js +12 -14
- package/es/StandardContent/WrapperContent.js +8 -10
- package/es/StandardDragModal/ChangeStandardModal.d.ts +44 -0
- package/es/StandardDragModal/ChangeStandardModal.js +493 -0
- package/es/StandardDragModal/DraggableModal.d.ts +7 -0
- package/es/StandardDragModal/DraggableModal.js +31 -0
- package/es/StandardDragModal/DraggableModalContext.d.ts +9 -0
- package/es/StandardDragModal/DraggableModalContext.js +5 -0
- package/es/StandardDragModal/DraggableModalInner.d.ts +16 -0
- package/es/StandardDragModal/DraggableModalInner.js +114 -0
- package/es/StandardDragModal/DraggableModalProvider.d.ts +4 -0
- package/es/StandardDragModal/DraggableModalProvider.js +40 -0
- package/es/StandardDragModal/Modal.d.ts +11 -0
- package/es/StandardDragModal/Modal.js +24 -0
- package/es/StandardDragModal/ResizeHandle.d.ts +2 -0
- package/es/StandardDragModal/ResizeHandle.js +8 -0
- package/es/StandardDragModal/clamp.d.ts +1 -0
- package/es/StandardDragModal/clamp.js +3 -0
- package/es/StandardDragModal/draggableModalReducer.d.ts +66 -0
- package/es/StandardDragModal/draggableModalReducer.js +157 -0
- package/es/StandardDragModal/getWindowSize.d.ts +4 -0
- package/es/StandardDragModal/getWindowSize.js +6 -0
- package/es/StandardDragModal/index.d.ts +3 -11
- package/es/StandardDragModal/index.js +3 -30
- package/es/StandardDragModal/index.less +65 -0
- package/es/StandardDragModal/useDrag.d.ts +5 -0
- package/es/StandardDragModal/useDrag.js +66 -0
- package/es/StandardDragModal/usePrevious.d.ts +1 -0
- package/es/StandardDragModal/usePrevious.js +8 -0
- package/es/StandardDragModal/useResize.d.ts +7 -0
- package/es/StandardDragModal/useResize.js +74 -0
- package/es/StandardFilter/index.js +30 -70
- package/es/StandardForm/ActionList.js +5 -7
- package/es/StandardForm/StepForm.js +50 -71
- package/es/StandardForm/TabForm.js +58 -70
- package/es/StandardForm/index.js +37 -56
- package/es/StandardModal/UpdateFormRef.js +1 -4
- package/es/StandardModal/index.d.ts +0 -1
- package/es/StandardModal/index.js +113 -157
- package/es/StandardPanel/index.js +19 -35
- package/es/StandardTable/index.js +18 -29
- package/es/components/IconNode/index.js +0 -4
- package/es/index.d.ts +1 -0
- package/es/index.js +15 -14
- package/es/utils/ValueFormat.js +0 -9
- package/es/utils/dictSelectUtil.js +153 -0
- package/es/utils/filterPermission.js +16 -34
- package/es/utils/getParentNodes.js +24 -47
- package/es/utils/index.js +2 -1
- package/lib/ButtonGroup/ButtonList.js +1 -13
- package/lib/ButtonGroup/ButtonMenu.js +1 -8
- package/lib/ButtonGroup/PopConfirmTitle.js +3 -16
- package/lib/ButtonGroup/index.js +215 -239
- package/lib/ButtonGroup/style/index.less +1 -1
- package/lib/DragContent/DragBar.js +2 -10
- package/lib/DragContent/index.js +47 -85
- package/lib/FormComp/ChunkUploader/api.js +6 -15
- package/lib/FormComp/ChunkUploader/index.js +107 -185
- package/lib/FormComp/ChunkUploader/lib.js +8 -27
- package/lib/FormComp/ChunkUploader/upload-queue.class.js +10 -46
- package/lib/FormComp/ChunkUploader/worker.js +1 -5
- package/lib/FormComp/EditButton/index.js +26 -60
- package/lib/FormComp/FieldComponent/ReUpload.js +21 -50
- package/lib/FormComp/FieldComponent/RefactorTreeSelect.js +38 -89
- package/lib/FormComp/FieldComponent/TitleNode.js +1 -5
- package/lib/FormComp/FieldComponent/index.js +38 -110
- package/lib/FormComp/FieldComponent/setReadonlyValues.js +37 -79
- package/lib/FormComp/RenderItemGroup/index.js +46 -87
- package/lib/FormComp/Uploader/index.js +38 -95
- package/lib/FormComp/Uploader/util.js +1 -9
- package/lib/FormComp/VarTemplate/index.js +62 -106
- package/lib/FormComp/index.js +0 -2
- package/lib/NavLeafScroll/index.js +174 -165
- package/lib/NavLeafScroll/style/index.less +33 -1
- package/lib/RefactorTree/index.js +36 -67
- package/lib/RefactorTree/indexTreeNode.js +37 -83
- package/lib/RefactorTree/util.js +11 -45
- package/lib/SpecIcon/fonts/iconfont.js +7 -12
- package/lib/SpecIcon/index.js +16 -30
- package/lib/SplitterLayout/Pane.js +0 -7
- package/lib/SplitterLayout/index.js +18 -72
- package/lib/StandardContent/SplitterLayout/Pane.js +6 -14
- package/lib/StandardContent/SplitterLayout/index.js +12 -68
- package/lib/StandardContent/SubfieldContent.js +12 -21
- package/lib/StandardContent/WrapperContent.js +8 -16
- package/lib/StandardDragModal/ChangeStandardModal.d.ts +44 -0
- package/lib/StandardDragModal/ChangeStandardModal.js +502 -0
- package/lib/StandardDragModal/DraggableModal.d.ts +7 -0
- package/lib/StandardDragModal/DraggableModal.js +40 -0
- package/lib/StandardDragModal/DraggableModalContext.d.ts +9 -0
- package/lib/StandardDragModal/DraggableModalContext.js +15 -0
- package/lib/StandardDragModal/DraggableModalInner.d.ts +16 -0
- package/lib/StandardDragModal/DraggableModalInner.js +124 -0
- package/lib/StandardDragModal/DraggableModalProvider.d.ts +4 -0
- package/lib/StandardDragModal/DraggableModalProvider.js +48 -0
- package/lib/StandardDragModal/Modal.d.ts +11 -0
- package/lib/StandardDragModal/Modal.js +32 -0
- package/lib/StandardDragModal/ResizeHandle.d.ts +2 -0
- package/lib/StandardDragModal/ResizeHandle.js +18 -0
- package/lib/StandardDragModal/clamp.d.ts +1 -0
- package/lib/StandardDragModal/clamp.js +10 -0
- package/lib/StandardDragModal/draggableModalReducer.d.ts +66 -0
- package/lib/StandardDragModal/draggableModalReducer.js +167 -0
- package/lib/StandardDragModal/getWindowSize.d.ts +4 -0
- package/lib/StandardDragModal/getWindowSize.js +13 -0
- package/lib/StandardDragModal/index.d.ts +3 -11
- package/lib/StandardDragModal/index.js +33 -38
- package/lib/StandardDragModal/index.less +65 -0
- package/lib/StandardDragModal/useDrag.d.ts +5 -0
- package/lib/StandardDragModal/useDrag.js +73 -0
- package/lib/StandardDragModal/usePrevious.d.ts +1 -0
- package/lib/StandardDragModal/usePrevious.js +15 -0
- package/lib/StandardDragModal/useResize.d.ts +7 -0
- package/lib/StandardDragModal/useResize.js +81 -0
- package/lib/StandardFilter/index.js +28 -78
- package/lib/StandardForm/ActionList.js +5 -12
- package/lib/StandardForm/StepForm.js +52 -90
- package/lib/StandardForm/TabForm.js +61 -88
- package/lib/StandardForm/index.js +40 -75
- package/lib/StandardModal/UpdateFormRef.js +4 -12
- package/lib/StandardModal/index.d.ts +0 -1
- package/lib/StandardModal/index.js +115 -182
- package/lib/StandardPanel/index.js +22 -48
- package/lib/StandardTable/index.js +18 -38
- package/lib/components/IconNode/index.js +0 -7
- package/lib/components/index.js +0 -2
- package/lib/data/index.js +4 -7
- package/lib/index.d.ts +1 -0
- package/lib/index.js +50 -68
- package/lib/utils/ValueFormat.js +0 -10
- package/lib/utils/dictSelectUtil.js +161 -0
- package/lib/utils/filterPermission.js +15 -39
- package/lib/utils/getParentNodes.js +25 -52
- package/lib/utils/index.js +24 -9
- package/package.json +5 -4
|
@@ -1,62 +1,40 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(
|
|
4
|
-
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = void 0;
|
|
9
|
-
|
|
10
8
|
require("antd/es/tag/style");
|
|
11
|
-
|
|
12
9
|
var _tag = _interopRequireDefault(require("antd/es/tag"));
|
|
13
|
-
|
|
14
10
|
require("antd/es/input/style");
|
|
15
|
-
|
|
16
11
|
var _input = _interopRequireDefault(require("antd/es/input"));
|
|
17
|
-
|
|
18
12
|
var _react = _interopRequireWildcard(require("react"));
|
|
19
|
-
|
|
20
|
-
function
|
|
21
|
-
|
|
22
|
-
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
23
|
-
|
|
13
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
14
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
24
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
25
|
-
|
|
26
|
-
function
|
|
27
|
-
|
|
28
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
29
|
-
|
|
16
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
17
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
30
18
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
31
|
-
|
|
32
|
-
function
|
|
33
|
-
|
|
34
|
-
function
|
|
35
|
-
|
|
36
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
37
|
-
|
|
38
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
39
|
-
|
|
19
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
20
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
21
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
22
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
40
23
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
41
|
-
|
|
42
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
43
|
-
|
|
24
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
44
25
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
45
|
-
|
|
46
|
-
function
|
|
47
|
-
|
|
48
|
-
function
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
26
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
27
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
28
|
+
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; }
|
|
29
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
30
|
+
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); } /**
|
|
31
|
+
* Created by S.C. on 2019/11/16.
|
|
32
|
+
*/
|
|
52
33
|
var TextArea = _input.default.TextArea;
|
|
53
34
|
var isIE = !!document.all;
|
|
54
|
-
|
|
55
35
|
var VarTemplate = /*#__PURE__*/function (_Component) {
|
|
56
36
|
_inherits(VarTemplate, _Component);
|
|
57
|
-
|
|
58
37
|
var _super = _createSuper(VarTemplate);
|
|
59
|
-
|
|
60
38
|
_createClass(VarTemplate, null, [{
|
|
61
39
|
key: "getDerivedStateFromProps",
|
|
62
40
|
value: function getDerivedStateFromProps(nextProps) {
|
|
@@ -65,48 +43,37 @@ var VarTemplate = /*#__PURE__*/function (_Component) {
|
|
|
65
43
|
if ('value' in nextProps) {
|
|
66
44
|
return _objectSpread({}, nextProps.value || {});
|
|
67
45
|
}
|
|
68
|
-
|
|
69
46
|
return null;
|
|
70
47
|
}
|
|
71
48
|
}]);
|
|
72
|
-
|
|
73
49
|
function VarTemplate(props) {
|
|
74
50
|
var _this;
|
|
75
|
-
|
|
76
51
|
_classCallCheck(this, VarTemplate);
|
|
77
|
-
|
|
78
52
|
_this = _super.call(this, props);
|
|
79
|
-
|
|
80
53
|
_defineProperty(_assertThisInitialized(_this), "handleBlur", function (e) {
|
|
81
54
|
_this.getCurrentCursor();
|
|
82
55
|
});
|
|
83
|
-
|
|
84
|
-
|
|
56
|
+
_defineProperty(_assertThisInitialized(_this), "handleFocus", function (e) {
|
|
57
|
+
// console.log('获取焦点')
|
|
85
58
|
// this.$emit('focus', event)
|
|
86
59
|
});
|
|
87
|
-
|
|
88
60
|
_defineProperty(_assertThisInitialized(_this), "handleInputChange", function (e) {
|
|
89
61
|
var onChange = _this.props.onChange;
|
|
90
|
-
|
|
91
62
|
_this.getCurrentCursor();
|
|
92
|
-
|
|
93
63
|
_this.setState({
|
|
94
64
|
currentContent: e.target.value,
|
|
95
65
|
startNum: e.target.value.length,
|
|
96
66
|
endNum: e.target.value.length,
|
|
97
67
|
wordCount: e.target.value.length
|
|
98
68
|
});
|
|
99
|
-
|
|
100
69
|
if (onChange) onChange(e.target.value);
|
|
101
70
|
});
|
|
102
|
-
|
|
103
71
|
_defineProperty(_assertThisInitialized(_this), "setTagWords", function (key) {
|
|
104
72
|
var onChange = _this.props.onChange;
|
|
105
73
|
var _this$state = _this.state,
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
74
|
+
currentContent = _this$state.currentContent,
|
|
75
|
+
startNum = _this$state.startNum,
|
|
76
|
+
endNum = _this$state.endNum;
|
|
110
77
|
_this.setState({
|
|
111
78
|
currentContent: _this.insertContent(currentContent, key, startNum, endNum),
|
|
112
79
|
startNum: startNum + key.length,
|
|
@@ -115,65 +82,51 @@ var VarTemplate = /*#__PURE__*/function (_Component) {
|
|
|
115
82
|
// 光标起始位置累加
|
|
116
83
|
wordCount: _this.insertContent(currentContent, key, startNum, endNum).length
|
|
117
84
|
});
|
|
118
|
-
|
|
119
85
|
if (onChange) onChange(_this.insertContent(currentContent, key, startNum, endNum));
|
|
120
86
|
setTimeout(function () {
|
|
121
87
|
_this.moveToCursor(); // 重新定位光标
|
|
122
|
-
|
|
123
88
|
});
|
|
124
89
|
});
|
|
125
|
-
|
|
126
90
|
_defineProperty(_assertThisInitialized(_this), "insertContent", function (str, insertStr, start, end) {
|
|
127
91
|
if (start !== end) {
|
|
128
92
|
var _prevStr = str.substring(0, start);
|
|
129
|
-
|
|
130
93
|
var _nextStr = str.substring(end, str.length);
|
|
131
|
-
|
|
132
94
|
return _prevStr + insertStr + _nextStr;
|
|
133
95
|
}
|
|
134
|
-
|
|
135
96
|
var prevStr = str.substring(0, start);
|
|
136
97
|
var nextStr = str.substring(start, str.length);
|
|
137
98
|
return prevStr + insertStr + nextStr;
|
|
138
99
|
});
|
|
139
|
-
|
|
140
100
|
_defineProperty(_assertThisInitialized(_this), "getCurrentCursor", function () {
|
|
141
101
|
var start = 0;
|
|
142
102
|
var end = 0;
|
|
143
|
-
|
|
144
103
|
var oTextarea = _this.content.querySelector('textarea'); // 获取textarea标签
|
|
145
|
-
|
|
146
|
-
|
|
147
104
|
if (isIE) {
|
|
148
105
|
// selection 当前激活选中区,即高亮文本块,和/或文当中用户可执行某些操作的其它元素。
|
|
149
106
|
// createRange 从当前文本选中区中创建 TextRange 对象,
|
|
150
107
|
// 或从控件选中区中创建 controlRange 集合。
|
|
151
|
-
var sTextRange = document.selection.createRange();
|
|
152
|
-
|
|
108
|
+
var sTextRange = document.selection.createRange();
|
|
109
|
+
// 判断选中的是不是textarea对象
|
|
153
110
|
if (sTextRange.parentElement() === oTextarea) {
|
|
154
111
|
// 创建一个TextRange对象
|
|
155
|
-
var oTextRange = document.body.createTextRange();
|
|
156
|
-
|
|
157
|
-
oTextRange.moveToElementText(oTextarea);
|
|
158
|
-
|
|
112
|
+
var oTextRange = document.body.createTextRange();
|
|
113
|
+
// 移动文本范围以便范围的开始和结束位置能够完全包含给定元素的文本。
|
|
114
|
+
oTextRange.moveToElementText(oTextarea);
|
|
115
|
+
// 这里我们比较oTextRange和sTextRange的开头,的到选中区域的开头位置
|
|
159
116
|
for (start = 0; oTextRange.compareEndPoints('StartToStart', sTextRange) < 0; start++) {
|
|
160
117
|
oTextRange.moveStart('character', 1);
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
|
|
118
|
+
}
|
|
119
|
+
// 需要计算一下\n的数目(按字符移动的方式不计\n,所以这里加上)
|
|
164
120
|
for (var i = 0; i <= start; i++) {
|
|
165
121
|
if (oTextarea.value.charAt(i) === '\n') {
|
|
166
122
|
start++;
|
|
167
123
|
}
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
|
|
124
|
+
}
|
|
125
|
+
// 再计算一次结束的位置
|
|
171
126
|
oTextRange.moveToElementText(oTextarea);
|
|
172
|
-
|
|
173
127
|
for (end = 0; oTextRange.compareEndPoints('StartToEnd', sTextRange) < 0; end++) {
|
|
174
128
|
oTextRange.moveStart('character', 1);
|
|
175
129
|
}
|
|
176
|
-
|
|
177
130
|
for (var j = 0; j <= end; j++) {
|
|
178
131
|
if (oTextarea.value.charAt(j) === '\n') {
|
|
179
132
|
end++;
|
|
@@ -184,27 +137,21 @@ var VarTemplate = /*#__PURE__*/function (_Component) {
|
|
|
184
137
|
start = oTextarea.selectionStart;
|
|
185
138
|
end = oTextarea.selectionEnd;
|
|
186
139
|
}
|
|
187
|
-
|
|
188
140
|
_this.setState({
|
|
189
141
|
startNum: start,
|
|
190
142
|
endNum: end
|
|
191
143
|
});
|
|
192
144
|
});
|
|
193
|
-
|
|
194
145
|
_defineProperty(_assertThisInitialized(_this), "moveToCursor", function () {
|
|
195
146
|
var _this$state2 = _this.state,
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
147
|
+
startNum = _this$state2.startNum,
|
|
148
|
+
endNum = _this$state2.endNum;
|
|
199
149
|
var oTextarea = _this.content.querySelector('textarea');
|
|
200
|
-
|
|
201
150
|
var start = startNum;
|
|
202
151
|
var end = endNum;
|
|
203
|
-
|
|
204
152
|
if (isNaN(start) || isNaN(end)) {
|
|
205
153
|
alert('位置输入错误');
|
|
206
154
|
}
|
|
207
|
-
|
|
208
155
|
if (isIE) {
|
|
209
156
|
var oTextRange = oTextarea.createTextRange();
|
|
210
157
|
var LStart = startNum;
|
|
@@ -212,26 +159,21 @@ var VarTemplate = /*#__PURE__*/function (_Component) {
|
|
|
212
159
|
var _start = 0;
|
|
213
160
|
var _end = 0;
|
|
214
161
|
var value = oTextarea.value;
|
|
215
|
-
|
|
216
162
|
for (var i = 0; i < value.length && i < LStart; i++) {
|
|
217
163
|
var c = value.charAt(i);
|
|
218
|
-
|
|
219
164
|
if (c !== '\n') {
|
|
220
165
|
_start++;
|
|
221
166
|
}
|
|
222
167
|
}
|
|
223
|
-
|
|
224
168
|
for (var j = value.length - 1; j >= LEnd && j >= 0; j--) {
|
|
225
169
|
var _c = value.charAt(j);
|
|
226
|
-
|
|
227
170
|
if (_c !== '\n') {
|
|
228
171
|
_end++;
|
|
229
172
|
}
|
|
230
173
|
}
|
|
231
|
-
|
|
232
174
|
oTextRange.moveStart('character', _start);
|
|
233
|
-
oTextRange.moveEnd('character', -_end);
|
|
234
|
-
|
|
175
|
+
oTextRange.moveEnd('character', -_end);
|
|
176
|
+
// oTextRange.collapse(true);
|
|
235
177
|
oTextRange.select();
|
|
236
178
|
oTextarea.focus();
|
|
237
179
|
} else {
|
|
@@ -240,9 +182,7 @@ var VarTemplate = /*#__PURE__*/function (_Component) {
|
|
|
240
182
|
oTextarea.selectionEnd = endNum;
|
|
241
183
|
}
|
|
242
184
|
});
|
|
243
|
-
|
|
244
185
|
var _value = props.value || '';
|
|
245
|
-
|
|
246
186
|
_this.state = {
|
|
247
187
|
currentContent: _value,
|
|
248
188
|
startNum: _value.length,
|
|
@@ -250,25 +190,43 @@ var VarTemplate = /*#__PURE__*/function (_Component) {
|
|
|
250
190
|
endNum: _value.length,
|
|
251
191
|
// 光标结束位置(当选中文本时)
|
|
252
192
|
wordCount: _value.length // 输入框内的字符数总和(包含占位符所需要的长度)
|
|
253
|
-
|
|
254
193
|
};
|
|
194
|
+
|
|
255
195
|
_this.content = /*#__PURE__*/_react.default.createRef();
|
|
256
196
|
return _this;
|
|
257
197
|
}
|
|
258
198
|
|
|
199
|
+
/**
|
|
200
|
+
* 指定位置插入标签占位符字符串,当光标有选中一段字符时,会将直接将其替换
|
|
201
|
+
* @param {str} 需要做插入的字符串
|
|
202
|
+
* @param {insertStr} 需要插入的字符串
|
|
203
|
+
* @param {start} 指定开始位置
|
|
204
|
+
* @param {end} 指定结束位置
|
|
205
|
+
* */
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* 获取当前(上一次)光标的位置
|
|
209
|
+
* @参考 http://blog.csdn.net/chadcao/article/details/6575927
|
|
210
|
+
* @TODO IE、火狐浏览器下未验证
|
|
211
|
+
*/
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* 跳转到上一次光标的位置
|
|
215
|
+
* @参考 http://blog.csdn.net/chadcao/article/details/6575927
|
|
216
|
+
* @TODO IE、火狐浏览器下未验证
|
|
217
|
+
*/
|
|
259
218
|
_createClass(VarTemplate, [{
|
|
260
219
|
key: "render",
|
|
261
220
|
value: function render() {
|
|
262
221
|
var _this2 = this;
|
|
263
|
-
|
|
264
222
|
var _this$props = this.props,
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
223
|
+
size = _this$props.size,
|
|
224
|
+
style = _this$props.style,
|
|
225
|
+
tags = _this$props.tags,
|
|
226
|
+
disabled = _this$props.disabled;
|
|
269
227
|
var _this$state3 = this.state,
|
|
270
|
-
|
|
271
|
-
|
|
228
|
+
currentContent = _this$state3.currentContent,
|
|
229
|
+
wordCount = _this$state3.wordCount;
|
|
272
230
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
273
231
|
className: "vart-wrap",
|
|
274
232
|
style: style,
|
|
@@ -300,9 +258,7 @@ var VarTemplate = /*#__PURE__*/function (_Component) {
|
|
|
300
258
|
})));
|
|
301
259
|
}
|
|
302
260
|
}]);
|
|
303
|
-
|
|
304
261
|
return VarTemplate;
|
|
305
262
|
}(_react.Component);
|
|
306
|
-
|
|
307
263
|
var _default = VarTemplate;
|
|
308
264
|
exports.default = _default;
|
package/lib/FormComp/index.js
CHANGED