@titaui/pc 1.10.39 → 1.10.43
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/dynamic/dynamic-item/dynamic-chart/index.js +18 -3
- package/lib/components/upload/index.js +2 -4
- package/lib/index.js +0 -8
- package/package.json +2 -20
- package/lib/components/rich-editor/basic/schema.js +0 -47
- package/lib/components/rich-editor/consts/events.js +0 -12
- package/lib/components/rich-editor/enums.js +0 -42
- package/lib/components/rich-editor/index.js +0 -58
- package/lib/components/rich-editor/keymap.js +0 -119
- package/lib/components/rich-editor/keymaps/index.js +0 -241
- package/lib/components/rich-editor/models/controller.js +0 -18
- package/lib/components/rich-editor/models/editor.js +0 -47
- package/lib/components/rich-editor/models/plugin.js +0 -20
- package/lib/components/rich-editor/models/schema.js +0 -121
- package/lib/components/rich-editor/plugins/block/block-quote/commond.js +0 -27
- package/lib/components/rich-editor/plugins/block/block-quote/index.js +0 -126
- package/lib/components/rich-editor/plugins/block/heading/commonds.js +0 -31
- package/lib/components/rich-editor/plugins/block/heading/index.js +0 -188
- package/lib/components/rich-editor/plugins/block/index.js +0 -57
- package/lib/components/rich-editor/plugins/block/lists/actions/conversions.js +0 -172
- package/lib/components/rich-editor/plugins/block/lists/actions/indent-list-items-selected.js +0 -163
- package/lib/components/rich-editor/plugins/block/lists/actions/indent-list.js +0 -59
- package/lib/components/rich-editor/plugins/block/lists/actions/join-list-items-forward.js +0 -74
- package/lib/components/rich-editor/plugins/block/lists/actions/join-list-items-scenarios/index.js +0 -45
- package/lib/components/rich-editor/plugins/block/lists/actions/join-list-items-scenarios/join-list-item-with-paragraph.js +0 -104
- package/lib/components/rich-editor/plugins/block/lists/actions/join-list-items-scenarios/join-list-item-with-parent-nested-list.js +0 -92
- package/lib/components/rich-editor/plugins/block/lists/actions/join-list-items-scenarios/join-nested-list-with-parent-list-item.js +0 -89
- package/lib/components/rich-editor/plugins/block/lists/actions/join-list-items-scenarios/join-paragraph-with-list.js +0 -48
- package/lib/components/rich-editor/plugins/block/lists/actions/join-list-items-scenarios/join-sibling-list-items.js +0 -61
- package/lib/components/rich-editor/plugins/block/lists/actions/merge-lists.js +0 -34
- package/lib/components/rich-editor/plugins/block/lists/actions/outdent-list-items-selected.js +0 -289
- package/lib/components/rich-editor/plugins/block/lists/actions/wrap-and-join-lists.js +0 -180
- package/lib/components/rich-editor/plugins/block/lists/baseCommand.js +0 -328
- package/lib/components/rich-editor/plugins/block/lists/commond/indent-list.js +0 -60
- package/lib/components/rich-editor/plugins/block/lists/commond/index.js +0 -398
- package/lib/components/rich-editor/plugins/block/lists/commond/join-list-item-forward.js +0 -45
- package/lib/components/rich-editor/plugins/block/lists/commond/listBackspace.js +0 -302
- package/lib/components/rich-editor/plugins/block/lists/commond/outdent-list.js +0 -43
- package/lib/components/rich-editor/plugins/block/lists/index.js +0 -222
- package/lib/components/rich-editor/plugins/block/lists/messages.js +0 -38
- package/lib/components/rich-editor/plugins/block/lists/pm-plugins/input-rule.js +0 -152
- package/lib/components/rich-editor/plugins/block/lists/pm-plugins/keymap.js +0 -33
- package/lib/components/rich-editor/plugins/block/lists/pm-plugins/main.js +0 -94
- package/lib/components/rich-editor/plugins/block/lists/styles.js +0 -15
- package/lib/components/rich-editor/plugins/block/lists/transforms.js +0 -347
- package/lib/components/rich-editor/plugins/block/lists/utils/analytics.js +0 -48
- package/lib/components/rich-editor/plugins/block/lists/utils/find.js +0 -126
- package/lib/components/rich-editor/plugins/block/lists/utils/indentation.js +0 -87
- package/lib/components/rich-editor/plugins/block/lists/utils/node.js +0 -144
- package/lib/components/rich-editor/plugins/block/lists/utils/replace-content.js +0 -31
- package/lib/components/rich-editor/plugins/block/lists/utils/selection.js +0 -201
- package/lib/components/rich-editor/plugins/block/lists/utils.js +0 -52
- package/lib/components/rich-editor/plugins/block/paragraph/index.js +0 -91
- package/lib/components/rich-editor/plugins/core/index.js +0 -90
- package/lib/components/rich-editor/plugins/core/pm-plugins/focus-handler.js +0 -67
- package/lib/components/rich-editor/plugins/core/pm-plugins/keymap.js +0 -29
- package/lib/components/rich-editor/plugins/core/pm-plugins/reactNodeView.js +0 -80
- package/lib/components/rich-editor/plugins/extension/alignment/commond.js +0 -24
- package/lib/components/rich-editor/plugins/extension/alignment/index.js +0 -111
- package/lib/components/rich-editor/plugins/extension/alignment/utils.js +0 -19
- package/lib/components/rich-editor/plugins/extension/index.js +0 -18
- package/lib/components/rich-editor/plugins/index.js +0 -44
- package/lib/components/rich-editor/plugins/inline/color/commond.js +0 -128
- package/lib/components/rich-editor/plugins/inline/color/consts.js +0 -43
- package/lib/components/rich-editor/plugins/inline/color/index.css +0 -61
- package/lib/components/rich-editor/plugins/inline/color/index.js +0 -209
- package/lib/components/rich-editor/plugins/inline/color/selector.js +0 -252
- package/lib/components/rich-editor/plugins/inline/delete-line/index.js +0 -147
- package/lib/components/rich-editor/plugins/inline/em/index.js +0 -93
- package/lib/components/rich-editor/plugins/inline/index.js +0 -83
- package/lib/components/rich-editor/plugins/inline/link/commands.js +0 -256
- package/lib/components/rich-editor/plugins/inline/link/index.js +0 -149
- package/lib/components/rich-editor/plugins/inline/link/pm-plugins/fake-cursor-for-toolbar.js +0 -77
- package/lib/components/rich-editor/plugins/inline/link/pm-plugins/main.js +0 -293
- package/lib/components/rich-editor/plugins/inline/link/ui/index.css +0 -79
- package/lib/components/rich-editor/plugins/inline/link/ui/linkEditor.js +0 -148
- package/lib/components/rich-editor/plugins/inline/link/ui/linkToolbar.js +0 -88
- package/lib/components/rich-editor/plugins/inline/link/ui/toolbarBtn.js +0 -117
- package/lib/components/rich-editor/plugins/inline/link/utils.js +0 -33
- package/lib/components/rich-editor/plugins/inline/strong/index.js +0 -137
- package/lib/components/rich-editor/plugins/inline/under-line/index.js +0 -145
- package/lib/components/rich-editor/plugins/util.js +0 -281
- package/lib/components/rich-editor/react/reactNodeView.js +0 -383
- package/lib/components/rich-editor/react/uiProvider.js +0 -185
- package/lib/components/rich-editor/schemas/basic.js +0 -309
- package/lib/components/rich-editor/schemas/index.js +0 -19
- package/lib/components/rich-editor/schemas/list.js +0 -342
- package/lib/components/rich-editor/types/commond.js +0 -5
- package/lib/components/rich-editor/types/index.js +0 -18
- package/lib/components/rich-editor/ui/Popup/index.js +0 -247
- package/lib/components/rich-editor/ui/Popup/utils.js +0 -399
- package/lib/components/rich-editor/ui/editor/index.css +0 -141
- package/lib/components/rich-editor/ui/editor/index.js +0 -130
- package/lib/components/rich-editor/ui/normal-toolbar/index.css +0 -28
- package/lib/components/rich-editor/ui/normal-toolbar/index.js +0 -109
- package/lib/components/rich-editor/utils/browser.js +0 -35
- package/lib/components/rich-editor/utils/commands.js +0 -266
- package/lib/components/rich-editor/utils/document.js +0 -160
- package/lib/components/rich-editor/utils/event.js +0 -79
- package/lib/components/rich-editor/utils/helpers.js +0 -16
- package/lib/components/rich-editor/utils/mark.js +0 -168
- package/lib/components/rich-editor/utils/slice.js +0 -85
- package/lib/components/rich-editor/utils/toolbar.js +0 -228
- package/yarn-error.log +0 -22184
|
@@ -1,293 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.stateKey = exports.plugin = exports["default"] = exports.canLinkBeCreatedInRange = exports.LinkAction = exports.InsertStatus = void 0;
|
|
7
|
-
|
|
8
|
-
var _prosemirrorState = require("prosemirror-state");
|
|
9
|
-
|
|
10
|
-
var _helpers = require("../../../../utils/helpers");
|
|
11
|
-
|
|
12
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
13
|
-
|
|
14
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
15
|
-
|
|
16
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
17
|
-
|
|
18
|
-
var LinkAction;
|
|
19
|
-
exports.LinkAction = LinkAction;
|
|
20
|
-
|
|
21
|
-
(function (LinkAction) {
|
|
22
|
-
LinkAction["SHOW_INSERT_TOOLBAR"] = "SHOW_INSERT_TOOLBAR";
|
|
23
|
-
LinkAction["HIDE_TOOLBAR"] = "HIDE_TOOLBAR";
|
|
24
|
-
LinkAction["SELECTION_CHANGE"] = "SELECTION_CHANGE";
|
|
25
|
-
LinkAction["INSERT_LINK_TOOLBAR"] = "INSERT";
|
|
26
|
-
LinkAction["EDIT_INSERTED_TOOLBAR"] = "EDIT_INSERTED_TOOLBAR";
|
|
27
|
-
})(LinkAction || (exports.LinkAction = LinkAction = {}));
|
|
28
|
-
|
|
29
|
-
var InsertStatus;
|
|
30
|
-
exports.InsertStatus = InsertStatus;
|
|
31
|
-
|
|
32
|
-
(function (InsertStatus) {
|
|
33
|
-
InsertStatus["EDIT_LINK_TOOLBAR"] = "EDIT";
|
|
34
|
-
InsertStatus["INSERT_LINK_TOOLBAR"] = "INSERT";
|
|
35
|
-
InsertStatus["EDIT_INSERTED_TOOLBAR"] = "EDIT_INSERTED";
|
|
36
|
-
})(InsertStatus || (exports.InsertStatus = InsertStatus = {}));
|
|
37
|
-
|
|
38
|
-
var canLinkBeCreatedInRange = function canLinkBeCreatedInRange(from, to) {
|
|
39
|
-
return function (state) {
|
|
40
|
-
if (!state.doc.rangeHasMark(from, to, state.schema.marks.link)) {
|
|
41
|
-
var $from = state.doc.resolve(from);
|
|
42
|
-
var $to = state.doc.resolve(to);
|
|
43
|
-
var link = state.schema.marks.link;
|
|
44
|
-
|
|
45
|
-
if ($from.parent === $to.parent && $from.parent.isTextblock) {
|
|
46
|
-
if ($from.parent.type.allowsMarkType(link)) {
|
|
47
|
-
var allowed = true;
|
|
48
|
-
state.doc.nodesBetween(from, to, function (node) {
|
|
49
|
-
allowed = allowed && !node.marks.some(function (m) {
|
|
50
|
-
return m.type.excludes(link);
|
|
51
|
-
});
|
|
52
|
-
return allowed;
|
|
53
|
-
});
|
|
54
|
-
return allowed;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
return false;
|
|
60
|
-
};
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
exports.canLinkBeCreatedInRange = canLinkBeCreatedInRange;
|
|
64
|
-
|
|
65
|
-
var isSelectionInsideLink = function isSelectionInsideLink(state) {
|
|
66
|
-
return !!state.doc.type.schema.marks.link.isInSet(state.selection.$from.marks());
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
var isSelectionAroundLink = function isSelectionAroundLink(state) {
|
|
70
|
-
var _state$selection = state.selection,
|
|
71
|
-
$from = _state$selection.$from,
|
|
72
|
-
$to = _state$selection.$to;
|
|
73
|
-
var node = $from.nodeAfter;
|
|
74
|
-
return !!node && $from.textOffset === 0 && $to.pos - $from.pos === node.nodeSize && !!state.doc.type.schema.marks.link.isInSet(node.marks);
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
var mapTransactionToState = function mapTransactionToState(state, tr) {
|
|
78
|
-
if (!state) {
|
|
79
|
-
return undefined;
|
|
80
|
-
} else if (state.type === InsertStatus.EDIT_LINK_TOOLBAR || state.type === InsertStatus.EDIT_INSERTED_TOOLBAR) {
|
|
81
|
-
var _tr$mapping$mapResult = tr.mapping.mapResult(state.pos, 1),
|
|
82
|
-
pos = _tr$mapping$mapResult.pos,
|
|
83
|
-
deleted = _tr$mapping$mapResult.deleted;
|
|
84
|
-
|
|
85
|
-
var node = tr.doc.nodeAt(pos); // If the position was not deleted & it is still a link
|
|
86
|
-
|
|
87
|
-
if (!deleted && !!node.type.schema.marks.link.isInSet(node.marks)) {
|
|
88
|
-
if (node === state.node && pos === state.pos) {
|
|
89
|
-
return state;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
return _objectSpread(_objectSpread({}, state), {}, {
|
|
93
|
-
pos: pos,
|
|
94
|
-
node: node
|
|
95
|
-
});
|
|
96
|
-
} // If the position has been deleted, then require a navigation to show the toolbar again
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
return;
|
|
100
|
-
} else if (state.type === InsertStatus.INSERT_LINK_TOOLBAR) {
|
|
101
|
-
return _objectSpread(_objectSpread({}, state), {}, {
|
|
102
|
-
from: tr.mapping.map(state.from),
|
|
103
|
-
to: tr.mapping.map(state.to)
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
return;
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
var toState = function toState(state, action, editorState) {
|
|
111
|
-
// Show insert or edit toolbar
|
|
112
|
-
if (!state) {
|
|
113
|
-
switch (action) {
|
|
114
|
-
case LinkAction.SHOW_INSERT_TOOLBAR:
|
|
115
|
-
{
|
|
116
|
-
var _editorState$selectio = editorState.selection,
|
|
117
|
-
from = _editorState$selectio.from,
|
|
118
|
-
to = _editorState$selectio.to;
|
|
119
|
-
|
|
120
|
-
if (canLinkBeCreatedInRange(from, to)(editorState)) {
|
|
121
|
-
return {
|
|
122
|
-
type: InsertStatus.INSERT_LINK_TOOLBAR,
|
|
123
|
-
from: from,
|
|
124
|
-
to: to
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
return undefined;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
case LinkAction.SELECTION_CHANGE:
|
|
132
|
-
// If the user has moved their cursor, see if they're in a link
|
|
133
|
-
var link = getActiveLinkMark(editorState);
|
|
134
|
-
|
|
135
|
-
if (link) {
|
|
136
|
-
return _objectSpread(_objectSpread({}, link), {}, {
|
|
137
|
-
type: InsertStatus.EDIT_LINK_TOOLBAR
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
return undefined;
|
|
142
|
-
|
|
143
|
-
default:
|
|
144
|
-
return undefined;
|
|
145
|
-
}
|
|
146
|
-
} // Update toolbar state if selection changes, or if toolbar is hidden
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
if (state.type === InsertStatus.EDIT_LINK_TOOLBAR) {
|
|
150
|
-
switch (action) {
|
|
151
|
-
case LinkAction.EDIT_INSERTED_TOOLBAR:
|
|
152
|
-
{
|
|
153
|
-
var _link2 = getActiveLinkMark(editorState);
|
|
154
|
-
|
|
155
|
-
if (_link2) {
|
|
156
|
-
if (_link2.pos === state.pos && _link2.node === state.node) {
|
|
157
|
-
return _objectSpread(_objectSpread({}, state), {}, {
|
|
158
|
-
type: InsertStatus.EDIT_INSERTED_TOOLBAR
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
return _objectSpread(_objectSpread({}, _link2), {}, {
|
|
163
|
-
type: InsertStatus.EDIT_INSERTED_TOOLBAR
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
return undefined;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
case LinkAction.SELECTION_CHANGE:
|
|
171
|
-
var _link = getActiveLinkMark(editorState);
|
|
172
|
-
|
|
173
|
-
if (_link) {
|
|
174
|
-
if (_link.pos === state.pos && _link.node === state.node) {
|
|
175
|
-
// Make sure we return the same object, if it's the same link
|
|
176
|
-
return state;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
return _objectSpread(_objectSpread({}, _link), {}, {
|
|
180
|
-
type: InsertStatus.EDIT_LINK_TOOLBAR
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
return undefined;
|
|
185
|
-
|
|
186
|
-
case LinkAction.HIDE_TOOLBAR:
|
|
187
|
-
return undefined;
|
|
188
|
-
|
|
189
|
-
default:
|
|
190
|
-
return state;
|
|
191
|
-
}
|
|
192
|
-
} // Remove toolbar if user changes selection or toolbar is hidden
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
if (state.type === InsertStatus.INSERT_LINK_TOOLBAR) {
|
|
196
|
-
switch (action) {
|
|
197
|
-
case LinkAction.SELECTION_CHANGE:
|
|
198
|
-
case LinkAction.HIDE_TOOLBAR:
|
|
199
|
-
return undefined;
|
|
200
|
-
|
|
201
|
-
default:
|
|
202
|
-
return state;
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
return;
|
|
207
|
-
};
|
|
208
|
-
|
|
209
|
-
var getActiveLinkMark = function getActiveLinkMark(state) {
|
|
210
|
-
var $from = state.selection.$from;
|
|
211
|
-
|
|
212
|
-
if (isSelectionInsideLink(state) || isSelectionAroundLink(state)) {
|
|
213
|
-
var pos = $from.pos - $from.textOffset;
|
|
214
|
-
var node = state.doc.nodeAt(pos);
|
|
215
|
-
return node && node.isText ? {
|
|
216
|
-
node: node,
|
|
217
|
-
pos: pos
|
|
218
|
-
} : undefined;
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
return undefined;
|
|
222
|
-
};
|
|
223
|
-
|
|
224
|
-
var getActiveText = function getActiveText(selection) {
|
|
225
|
-
var currentSlice = selection.content();
|
|
226
|
-
|
|
227
|
-
if (currentSlice.size === 0) {
|
|
228
|
-
return;
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
if (currentSlice.content.childCount === 1 && currentSlice.content.firstChild && selection instanceof _prosemirrorState.TextSelection) {
|
|
232
|
-
return currentSlice.content.firstChild.textContent;
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
return;
|
|
236
|
-
};
|
|
237
|
-
|
|
238
|
-
var stateKey = new _prosemirrorState.PluginKey('hyperlinkPlugin');
|
|
239
|
-
exports.stateKey = stateKey;
|
|
240
|
-
|
|
241
|
-
var plugin = function plugin(dispatch) {
|
|
242
|
-
return new _prosemirrorState.Plugin({
|
|
243
|
-
state: {
|
|
244
|
-
init: function init(_, state) {
|
|
245
|
-
var canInsertLink = canLinkBeCreatedInRange(state.selection.from, state.selection.to)(state);
|
|
246
|
-
return {
|
|
247
|
-
activeText: getActiveText(state.selection),
|
|
248
|
-
canInsertLink: canInsertLink,
|
|
249
|
-
activeLinkMark: toState(undefined, LinkAction.SELECTION_CHANGE, state)
|
|
250
|
-
};
|
|
251
|
-
},
|
|
252
|
-
apply: function apply(tr, pluginState, _oldState, newState) {
|
|
253
|
-
var state = pluginState;
|
|
254
|
-
var action = tr.getMeta(stateKey) && tr.getMeta(stateKey).type;
|
|
255
|
-
|
|
256
|
-
if (tr.docChanged) {
|
|
257
|
-
state = {
|
|
258
|
-
activeText: state.activeText,
|
|
259
|
-
canInsertLink: canLinkBeCreatedInRange(newState.selection.from, newState.selection.to)(newState),
|
|
260
|
-
activeLinkMark: mapTransactionToState(state.activeLinkMark, tr)
|
|
261
|
-
};
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
if (action) {
|
|
265
|
-
state = {
|
|
266
|
-
activeText: state.activeText,
|
|
267
|
-
canInsertLink: state.canInsertLink,
|
|
268
|
-
activeLinkMark: toState(state.activeLinkMark, action, newState)
|
|
269
|
-
};
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
if (tr.selectionSet) {
|
|
273
|
-
state = {
|
|
274
|
-
activeText: getActiveText(newState.selection),
|
|
275
|
-
canInsertLink: canLinkBeCreatedInRange(newState.selection.from, newState.selection.to)(newState),
|
|
276
|
-
activeLinkMark: toState(state.activeLinkMark, LinkAction.SELECTION_CHANGE, newState)
|
|
277
|
-
};
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
if (!(0, _helpers.shallowEqual)(state, pluginState)) {
|
|
281
|
-
dispatch(stateKey, state);
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
return state;
|
|
285
|
-
}
|
|
286
|
-
},
|
|
287
|
-
key: stateKey
|
|
288
|
-
});
|
|
289
|
-
};
|
|
290
|
-
|
|
291
|
-
exports.plugin = plugin;
|
|
292
|
-
var _default = plugin;
|
|
293
|
-
exports["default"] = _default;
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
.ProseMirror .ProseMirror-fake-text-cursor {
|
|
2
|
-
display: inline;
|
|
3
|
-
pointer-events: none;
|
|
4
|
-
position: relative;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
.ProseMirror .ProseMirror-fake-text-selection {
|
|
8
|
-
display: inline;
|
|
9
|
-
pointer-events: none;
|
|
10
|
-
position: relative;
|
|
11
|
-
background-color: #b3d4ff;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
.tita-rich-editor-link {
|
|
15
|
-
box-sizing: border-box;
|
|
16
|
-
width: 348px;
|
|
17
|
-
padding: 24px 32px 20px;
|
|
18
|
-
background: #ffffff;
|
|
19
|
-
box-shadow: 0px 8px 24px 0px rgba(127, 145, 180, 0.2);
|
|
20
|
-
border-radius: 24px;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
.tita-rich-editor-link__btn-wrapper {
|
|
24
|
-
display: flex;
|
|
25
|
-
margin-top: 16px;
|
|
26
|
-
justify-content: flex-end;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
.tita-rich-editor-link__input:first-child {
|
|
30
|
-
margin-bottom: 16px;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
.tita-rich-editor-link__input .form-field-input__label-text {
|
|
34
|
-
color: #89919f;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
.tita-rich-editor-link__common-tool-bar-btn {
|
|
38
|
-
width: 100%;
|
|
39
|
-
height: 100%;
|
|
40
|
-
display: flex;
|
|
41
|
-
align-items: center;
|
|
42
|
-
justify-content: center;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
.tita-rich-editor-toolbar {
|
|
46
|
-
box-sizing: border-box;
|
|
47
|
-
padding: 0 12px;
|
|
48
|
-
display: flex;
|
|
49
|
-
align-items: center;
|
|
50
|
-
width: 344px;
|
|
51
|
-
height: 44px;
|
|
52
|
-
background: #ffffff;
|
|
53
|
-
box-shadow: 0px 4px 12px 0px rgba(127, 145, 180, 0.2);
|
|
54
|
-
border-radius: 8px;
|
|
55
|
-
border: 1px solid #f0f2f5;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
.tita-rich-editor-toolbar__text {
|
|
59
|
-
flex: 1;
|
|
60
|
-
width: 0;
|
|
61
|
-
overflow: hidden;
|
|
62
|
-
text-overflow: ellipsis;
|
|
63
|
-
white-space: nowrap;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
.tita-rich-editor-toolbar__btn {
|
|
67
|
-
width: 24px;
|
|
68
|
-
height: 24px;
|
|
69
|
-
font-size: 18px;
|
|
70
|
-
display: flex;
|
|
71
|
-
align-items: center;
|
|
72
|
-
justify-content: center;
|
|
73
|
-
margin-left: 8px;
|
|
74
|
-
cursor: pointer;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
.tita-rich-editor-toolbar__btn:hover {
|
|
78
|
-
background-color: #f0f4fa;
|
|
79
|
-
}
|
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports["default"] = void 0;
|
|
9
|
-
|
|
10
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
-
|
|
12
|
-
var _prosemirrorUtils = require("prosemirror-utils");
|
|
13
|
-
|
|
14
|
-
var _Popup = _interopRequireDefault(require("../../../../ui/Popup"));
|
|
15
|
-
|
|
16
|
-
var _input = _interopRequireDefault(require("../../../../../form/form-fields/input"));
|
|
17
|
-
|
|
18
|
-
var _button = require("../../../../../button");
|
|
19
|
-
|
|
20
|
-
var _commands = require("../commands");
|
|
21
|
-
|
|
22
|
-
require("./index.css");
|
|
23
|
-
|
|
24
|
-
var _main = require("../pm-plugins/main");
|
|
25
|
-
|
|
26
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
27
|
-
|
|
28
|
-
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); }
|
|
29
|
-
|
|
30
|
-
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; }
|
|
31
|
-
|
|
32
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
33
|
-
|
|
34
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
35
|
-
|
|
36
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
37
|
-
|
|
38
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
39
|
-
|
|
40
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
41
|
-
|
|
42
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
43
|
-
|
|
44
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
45
|
-
|
|
46
|
-
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
47
|
-
|
|
48
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
49
|
-
|
|
50
|
-
var preCls = 'tita-rich-editor-link';
|
|
51
|
-
|
|
52
|
-
function LinkEditor(_ref) {
|
|
53
|
-
var editor = _ref.editor,
|
|
54
|
-
text = _ref.text,
|
|
55
|
-
href = _ref.href,
|
|
56
|
-
editType = _ref.editType,
|
|
57
|
-
pos = _ref.pos;
|
|
58
|
-
|
|
59
|
-
var _useState = (0, _react.useState)(),
|
|
60
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
61
|
-
target = _useState2[0],
|
|
62
|
-
setTarget = _useState2[1];
|
|
63
|
-
|
|
64
|
-
var _useState3 = (0, _react.useState)({
|
|
65
|
-
text: text,
|
|
66
|
-
href: href
|
|
67
|
-
}),
|
|
68
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
69
|
-
content = _useState4[0],
|
|
70
|
-
setContent = _useState4[1];
|
|
71
|
-
|
|
72
|
-
(0, _react.useEffect)(function () {
|
|
73
|
-
var view = editor.view;
|
|
74
|
-
setTarget((0, _prosemirrorUtils.findDomRefAtPos)(view.state.selection.from, view.domAtPos.bind(view)));
|
|
75
|
-
}, []);
|
|
76
|
-
(0, _react.useEffect)(function () {
|
|
77
|
-
setContent({
|
|
78
|
-
text: text,
|
|
79
|
-
href: href
|
|
80
|
-
});
|
|
81
|
-
}, [text, href]);
|
|
82
|
-
var handleSubmit = (0, _react.useCallback)(function () {
|
|
83
|
-
var text = content.text,
|
|
84
|
-
href = content.href;
|
|
85
|
-
|
|
86
|
-
if (!href) {
|
|
87
|
-
(0, _commands.hideLinkToolbar)()(editor.state, editor.view.dispatch);
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
var _editor$state$selecti = editor.state.selection,
|
|
92
|
-
from = _editor$state$selecti.from,
|
|
93
|
-
to = _editor$state$selecti.to;
|
|
94
|
-
|
|
95
|
-
if (editType == _main.InsertStatus.INSERT_LINK_TOOLBAR) {
|
|
96
|
-
(0, _commands.insertLink)(from, to, href, text)(editor.state, editor.view.dispatch);
|
|
97
|
-
} else {
|
|
98
|
-
console.log(pos);
|
|
99
|
-
(0, _commands.updateLink)(href, text || href, pos || from)(editor.state, editor.view.dispatch);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
editor.view.focus();
|
|
103
|
-
}, [content.text, content.href, pos]);
|
|
104
|
-
return /*#__PURE__*/_react["default"].createElement(_Popup["default"], {
|
|
105
|
-
mountTo: editor.view.dom.parentNode,
|
|
106
|
-
target: target
|
|
107
|
-
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
108
|
-
className: preCls,
|
|
109
|
-
onMouseDown: function onMouseDown(e) {
|
|
110
|
-
return e.stopPropagation();
|
|
111
|
-
}
|
|
112
|
-
}, /*#__PURE__*/_react["default"].createElement(_input["default"], {
|
|
113
|
-
className: preCls + '__input',
|
|
114
|
-
label: "\u6587\u672C",
|
|
115
|
-
name: "text",
|
|
116
|
-
layout: "row",
|
|
117
|
-
placeholder: "\u8BF7\u8F93\u5165\u6587\u672C",
|
|
118
|
-
onChange: function onChange(text) {
|
|
119
|
-
return setContent(_objectSpread(_objectSpread({}, content), {}, {
|
|
120
|
-
text: text
|
|
121
|
-
}));
|
|
122
|
-
},
|
|
123
|
-
value: content.text
|
|
124
|
-
}), /*#__PURE__*/_react["default"].createElement(_input["default"], {
|
|
125
|
-
className: preCls + '__input',
|
|
126
|
-
label: "\u94FE\u63A5",
|
|
127
|
-
name: "href",
|
|
128
|
-
layout: "row",
|
|
129
|
-
placeholder: "\u6DFB\u52A0\u94FE\u63A5\u5730\u5740",
|
|
130
|
-
onChange: function onChange(href) {
|
|
131
|
-
return setContent(_objectSpread(_objectSpread({}, content), {}, {
|
|
132
|
-
href: href
|
|
133
|
-
}));
|
|
134
|
-
},
|
|
135
|
-
value: content.href
|
|
136
|
-
}), /*#__PURE__*/_react["default"].createElement("div", {
|
|
137
|
-
className: preCls + '__btn-wrapper'
|
|
138
|
-
}, /*#__PURE__*/_react["default"].createElement(_button.RectBtn, {
|
|
139
|
-
type: "primary",
|
|
140
|
-
style: {
|
|
141
|
-
width: 90
|
|
142
|
-
},
|
|
143
|
-
onClick: handleSubmit
|
|
144
|
-
}, "\u5E94\u7528"))));
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
var _default = LinkEditor;
|
|
148
|
-
exports["default"] = _default;
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports["default"] = void 0;
|
|
9
|
-
|
|
10
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
-
|
|
12
|
-
var _prosemirrorUtils = require("prosemirror-utils");
|
|
13
|
-
|
|
14
|
-
var _Popup = _interopRequireDefault(require("../../../../ui/Popup"));
|
|
15
|
-
|
|
16
|
-
var _classnames = _interopRequireDefault(require("classnames"));
|
|
17
|
-
|
|
18
|
-
require("./index.css");
|
|
19
|
-
|
|
20
|
-
var _commands = require("../commands");
|
|
21
|
-
|
|
22
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
23
|
-
|
|
24
|
-
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); }
|
|
25
|
-
|
|
26
|
-
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; }
|
|
27
|
-
|
|
28
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
29
|
-
|
|
30
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
31
|
-
|
|
32
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
33
|
-
|
|
34
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
35
|
-
|
|
36
|
-
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
37
|
-
|
|
38
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
39
|
-
|
|
40
|
-
var preCls = 'tita-rich-editor-toolbar';
|
|
41
|
-
|
|
42
|
-
function LinkToolBar(_ref) {
|
|
43
|
-
var editor = _ref.editor,
|
|
44
|
-
href = _ref.href,
|
|
45
|
-
pos = _ref.pos;
|
|
46
|
-
|
|
47
|
-
var _useState = (0, _react.useState)(),
|
|
48
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
49
|
-
target = _useState2[0],
|
|
50
|
-
setTarget = _useState2[1];
|
|
51
|
-
|
|
52
|
-
(0, _react.useEffect)(function () {
|
|
53
|
-
var view = editor.view;
|
|
54
|
-
setTarget((0, _prosemirrorUtils.findDomRefAtPos)(view.state.selection.from, view.domAtPos.bind(view)));
|
|
55
|
-
}, []);
|
|
56
|
-
var handleEdit = (0, _react.useCallback)(function () {
|
|
57
|
-
(0, _commands.editInsertedLink)()(editor.state, editor.view.dispatch);
|
|
58
|
-
}, []);
|
|
59
|
-
var handleRemoveLink = (0, _react.useCallback)(function () {
|
|
60
|
-
(0, _commands.removeLink)(pos)(editor.state, editor.view.dispatch);
|
|
61
|
-
}, [pos]);
|
|
62
|
-
var handleOpenLink = (0, _react.useCallback)(function () {
|
|
63
|
-
window.open(href);
|
|
64
|
-
}, [href]);
|
|
65
|
-
return /*#__PURE__*/_react["default"].createElement(_Popup["default"], {
|
|
66
|
-
mountTo: editor.view.dom.parentNode,
|
|
67
|
-
target: target
|
|
68
|
-
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
69
|
-
className: preCls,
|
|
70
|
-
onMouseDown: function onMouseDown(e) {
|
|
71
|
-
return e.stopPropagation();
|
|
72
|
-
}
|
|
73
|
-
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
74
|
-
className: preCls + '__text'
|
|
75
|
-
}, href), /*#__PURE__*/_react["default"].createElement("div", {
|
|
76
|
-
className: (0, _classnames["default"])('tu-icon-visit', preCls + '__btn'),
|
|
77
|
-
onClick: handleOpenLink
|
|
78
|
-
}), /*#__PURE__*/_react["default"].createElement("div", {
|
|
79
|
-
className: (0, _classnames["default"])('tu-icon-bianji3', preCls + '__btn'),
|
|
80
|
-
onClick: handleEdit
|
|
81
|
-
}), /*#__PURE__*/_react["default"].createElement("div", {
|
|
82
|
-
className: (0, _classnames["default"])('tu-icon-quxiaoguanlian', preCls + '__btn'),
|
|
83
|
-
onClick: handleRemoveLink
|
|
84
|
-
})));
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
var _default = LinkToolBar;
|
|
88
|
-
exports["default"] = _default;
|