@titaui/pc 1.10.39 → 1.10.40
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/lib/components/rich-editor/plugins/inline/color/selector.js +6 -8
- package/lib/components/rich-editor/ui/editor/index.css +3 -0
- package/lib/components/rich-editor/ui/editor/index.js +21 -8
- package/lib/components/rich-editor/ui/normal-toolbar/index.css +1 -0
- package/lib/components/rich-editor/utils/mark.js +1 -1
- package/package.json +1 -1
|
@@ -91,7 +91,8 @@ function ColorSelector(_ref) {
|
|
|
91
91
|
style: {
|
|
92
92
|
backgroundColor: color
|
|
93
93
|
},
|
|
94
|
-
onClick: function onClick() {
|
|
94
|
+
onClick: function onClick(e) {
|
|
95
|
+
e.stopPropagation();
|
|
95
96
|
onClickItem(editor.state.schema.marks[_index2.BACKGROUND_COLOR_SCHEMA_NAME], color);
|
|
96
97
|
}
|
|
97
98
|
}));
|
|
@@ -106,7 +107,10 @@ function ColorSelector(_ref) {
|
|
|
106
107
|
return colors;
|
|
107
108
|
}, [background]);
|
|
108
109
|
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
109
|
-
className: preCls
|
|
110
|
+
className: preCls,
|
|
111
|
+
onClick: function onClick(e) {
|
|
112
|
+
return e.stopPropagation();
|
|
113
|
+
}
|
|
110
114
|
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
111
115
|
className: preCls + '__title'
|
|
112
116
|
}, "\u6587\u5B57\u989C\u8272"), /*#__PURE__*/_react["default"].createElement("div", {
|
|
@@ -216,12 +220,6 @@ function ColorSelectorPop(_ref2) {
|
|
|
216
220
|
}, [activeColor, activeBackground]);
|
|
217
221
|
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
218
222
|
className: preCls + '__icon',
|
|
219
|
-
onMouseOver: function onMouseOver(e) {
|
|
220
|
-
return e.stopPropagation();
|
|
221
|
-
},
|
|
222
|
-
onMouseEnter: function onMouseEnter(e) {
|
|
223
|
-
return e.stopPropagation();
|
|
224
|
-
},
|
|
225
223
|
style: {
|
|
226
224
|
backgroundColor: activeBackground || _consts.BackgroundColor["default"],
|
|
227
225
|
color: activeColor || _consts.FontColor["default"]
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
font-weight: 500;
|
|
20
20
|
color: #141c28;
|
|
21
21
|
line-height: 38px;
|
|
22
|
+
padding: 36px 0 20px;
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
.tita-rich-editor h2 {
|
|
@@ -26,6 +27,7 @@
|
|
|
26
27
|
font-weight: 500;
|
|
27
28
|
color: #141c28;
|
|
28
29
|
line-height: 32px;
|
|
30
|
+
padding: 20px 0 8px;
|
|
29
31
|
}
|
|
30
32
|
|
|
31
33
|
.tita-rich-editor h3 {
|
|
@@ -33,6 +35,7 @@
|
|
|
33
35
|
font-weight: 500;
|
|
34
36
|
color: #3f4755;
|
|
35
37
|
line-height: 30px;
|
|
38
|
+
padding: 18px 0 8px;
|
|
36
39
|
}
|
|
37
40
|
|
|
38
41
|
.tita-rich-editor p {
|
|
@@ -70,13 +70,16 @@ function RichEditor(_ref, ref) {
|
|
|
70
70
|
plugins: nativePlugins
|
|
71
71
|
};
|
|
72
72
|
|
|
73
|
-
var state = _prosemirrorState.EditorState.create(stateConf);
|
|
73
|
+
var state = _prosemirrorState.EditorState.create(stateConf); // debugger
|
|
74
|
+
|
|
74
75
|
|
|
75
76
|
if (defaultState) {
|
|
76
77
|
try {
|
|
77
78
|
var jsonState = typeof defaultState == 'string' ? JSON.parse(defaultState) : defaultState;
|
|
78
|
-
state = _prosemirrorState.EditorState.fromJSON(
|
|
79
|
-
} catch (e) {
|
|
79
|
+
state = _prosemirrorState.EditorState.fromJSON(stateConf, jsonState);
|
|
80
|
+
} catch (e) {
|
|
81
|
+
console.log(e);
|
|
82
|
+
}
|
|
80
83
|
}
|
|
81
84
|
|
|
82
85
|
var pmEditor = new _prosemirrorView.EditorView(container.current, {
|
|
@@ -103,6 +106,20 @@ function RichEditor(_ref, ref) {
|
|
|
103
106
|
return dataRef.current.editor.destroy();
|
|
104
107
|
};
|
|
105
108
|
}, []);
|
|
109
|
+
var handleClick = (0, _react.useCallback)(function (e) {
|
|
110
|
+
var _dataRef$current$edit, _dataRef$current$edit2;
|
|
111
|
+
|
|
112
|
+
if (e.target != e.currentTarget) return;
|
|
113
|
+
var view = (_dataRef$current$edit = dataRef.current.editor) === null || _dataRef$current$edit === void 0 ? void 0 : _dataRef$current$edit.view;
|
|
114
|
+
if (!view) return;
|
|
115
|
+
var tr = view.state.tr;
|
|
116
|
+
|
|
117
|
+
var selection = _prosemirrorState.TextSelection.atEnd(view.state.doc);
|
|
118
|
+
|
|
119
|
+
view.dispatch(tr.setSelection(selection));
|
|
120
|
+
view.focus();
|
|
121
|
+
(_dataRef$current$edit2 = dataRef.current.editor) === null || _dataRef$current$edit2 === void 0 ? void 0 : _dataRef$current$edit2.view.focus();
|
|
122
|
+
}, []);
|
|
106
123
|
(0, _react.useImperativeHandle)(ref, function () {
|
|
107
124
|
return {
|
|
108
125
|
getState: function getState() {
|
|
@@ -117,11 +134,7 @@ function RichEditor(_ref, ref) {
|
|
|
117
134
|
backgroundColor: "#FFF"
|
|
118
135
|
},
|
|
119
136
|
spellCheck: false,
|
|
120
|
-
onClick:
|
|
121
|
-
var _dataRef$current$edit;
|
|
122
|
-
|
|
123
|
-
return (_dataRef$current$edit = dataRef.current.editor) === null || _dataRef$current$edit === void 0 ? void 0 : _dataRef$current$edit.view.focus();
|
|
124
|
-
}
|
|
137
|
+
onClick: handleClick
|
|
125
138
|
});
|
|
126
139
|
}
|
|
127
140
|
|
|
@@ -156,7 +156,7 @@ var selectionContainsMark = function selectionContainsMark(state, markName) {
|
|
|
156
156
|
marks = state.storedMarks || $from.marks();
|
|
157
157
|
} else {
|
|
158
158
|
state.doc.nodesBetween(from, to, function (node) {
|
|
159
|
-
marks.concat(node.marks);
|
|
159
|
+
marks = marks.concat(node.marks);
|
|
160
160
|
});
|
|
161
161
|
}
|
|
162
162
|
|