@titaui/pc 1.10.44 → 1.10.45
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/basic/schema.js +47 -0
- package/lib/components/rich-editor/consts/events.js +12 -0
- package/lib/components/rich-editor/enums.js +42 -0
- package/lib/components/rich-editor/index.js +58 -0
- package/lib/components/rich-editor/keymap.js +119 -0
- package/lib/components/rich-editor/keymaps/index.js +241 -0
- package/lib/components/rich-editor/models/controller.js +18 -0
- package/lib/components/rich-editor/models/editor.js +47 -0
- package/lib/components/rich-editor/models/plugin.js +20 -0
- package/lib/components/rich-editor/models/schema.js +121 -0
- package/lib/components/rich-editor/plugins/block/block-quote/commond.js +27 -0
- package/lib/components/rich-editor/plugins/block/block-quote/index.js +126 -0
- package/lib/components/rich-editor/plugins/block/heading/commonds.js +31 -0
- package/lib/components/rich-editor/plugins/block/heading/index.js +188 -0
- package/lib/components/rich-editor/plugins/block/index.js +57 -0
- package/lib/components/rich-editor/plugins/block/lists/actions/conversions.js +172 -0
- package/lib/components/rich-editor/plugins/block/lists/actions/indent-list-items-selected.js +163 -0
- package/lib/components/rich-editor/plugins/block/lists/actions/indent-list.js +59 -0
- package/lib/components/rich-editor/plugins/block/lists/actions/join-list-items-forward.js +74 -0
- package/lib/components/rich-editor/plugins/block/lists/actions/join-list-items-scenarios/index.js +45 -0
- package/lib/components/rich-editor/plugins/block/lists/actions/join-list-items-scenarios/join-list-item-with-paragraph.js +104 -0
- package/lib/components/rich-editor/plugins/block/lists/actions/join-list-items-scenarios/join-list-item-with-parent-nested-list.js +92 -0
- package/lib/components/rich-editor/plugins/block/lists/actions/join-list-items-scenarios/join-nested-list-with-parent-list-item.js +89 -0
- package/lib/components/rich-editor/plugins/block/lists/actions/join-list-items-scenarios/join-paragraph-with-list.js +48 -0
- package/lib/components/rich-editor/plugins/block/lists/actions/join-list-items-scenarios/join-sibling-list-items.js +61 -0
- package/lib/components/rich-editor/plugins/block/lists/actions/merge-lists.js +34 -0
- package/lib/components/rich-editor/plugins/block/lists/actions/outdent-list-items-selected.js +289 -0
- package/lib/components/rich-editor/plugins/block/lists/actions/wrap-and-join-lists.js +180 -0
- package/lib/components/rich-editor/plugins/block/lists/baseCommand.js +328 -0
- package/lib/components/rich-editor/plugins/block/lists/commond/indent-list.js +60 -0
- package/lib/components/rich-editor/plugins/block/lists/commond/index.js +396 -0
- package/lib/components/rich-editor/plugins/block/lists/commond/join-list-item-forward.js +45 -0
- package/lib/components/rich-editor/plugins/block/lists/commond/listBackspace.js +302 -0
- package/lib/components/rich-editor/plugins/block/lists/commond/outdent-list.js +43 -0
- package/lib/components/rich-editor/plugins/block/lists/index.js +222 -0
- package/lib/components/rich-editor/plugins/block/lists/messages.js +38 -0
- package/lib/components/rich-editor/plugins/block/lists/pm-plugins/input-rule.js +152 -0
- package/lib/components/rich-editor/plugins/block/lists/pm-plugins/keymap.js +33 -0
- package/lib/components/rich-editor/plugins/block/lists/pm-plugins/main.js +94 -0
- package/lib/components/rich-editor/plugins/block/lists/styles.js +15 -0
- package/lib/components/rich-editor/plugins/block/lists/transforms.js +347 -0
- package/lib/components/rich-editor/plugins/block/lists/utils/analytics.js +48 -0
- package/lib/components/rich-editor/plugins/block/lists/utils/find.js +126 -0
- package/lib/components/rich-editor/plugins/block/lists/utils/indentation.js +87 -0
- package/lib/components/rich-editor/plugins/block/lists/utils/node.js +144 -0
- package/lib/components/rich-editor/plugins/block/lists/utils/replace-content.js +31 -0
- package/lib/components/rich-editor/plugins/block/lists/utils/selection.js +201 -0
- package/lib/components/rich-editor/plugins/block/lists/utils.js +52 -0
- package/lib/components/rich-editor/plugins/block/paragraph/index.js +91 -0
- package/lib/components/rich-editor/plugins/core/index.js +90 -0
- package/lib/components/rich-editor/plugins/core/pm-plugins/focus-handler.js +67 -0
- package/lib/components/rich-editor/plugins/core/pm-plugins/keymap.js +29 -0
- package/lib/components/rich-editor/plugins/core/pm-plugins/reactNodeView.js +80 -0
- package/lib/components/rich-editor/plugins/extension/alignment/commond.js +24 -0
- package/lib/components/rich-editor/plugins/extension/alignment/index.js +111 -0
- package/lib/components/rich-editor/plugins/extension/alignment/utils.js +19 -0
- package/lib/components/rich-editor/plugins/extension/index.js +18 -0
- package/lib/components/rich-editor/plugins/index.js +44 -0
- package/lib/components/rich-editor/plugins/inline/color/commond.js +128 -0
- package/lib/components/rich-editor/plugins/inline/color/consts.js +43 -0
- package/lib/components/rich-editor/plugins/inline/color/index.css +61 -0
- package/lib/components/rich-editor/plugins/inline/color/index.js +209 -0
- package/lib/components/rich-editor/plugins/inline/color/selector.js +250 -0
- package/lib/components/rich-editor/plugins/inline/delete-line/index.js +147 -0
- package/lib/components/rich-editor/plugins/inline/em/index.js +93 -0
- package/lib/components/rich-editor/plugins/inline/index.js +83 -0
- package/lib/components/rich-editor/plugins/inline/link/commands.js +256 -0
- package/lib/components/rich-editor/plugins/inline/link/index.js +149 -0
- package/lib/components/rich-editor/plugins/inline/link/pm-plugins/fake-cursor-for-toolbar.js +77 -0
- package/lib/components/rich-editor/plugins/inline/link/pm-plugins/main.js +293 -0
- package/lib/components/rich-editor/plugins/inline/link/ui/index.css +79 -0
- package/lib/components/rich-editor/plugins/inline/link/ui/linkEditor.js +148 -0
- package/lib/components/rich-editor/plugins/inline/link/ui/linkToolbar.js +88 -0
- package/lib/components/rich-editor/plugins/inline/link/ui/toolbarBtn.js +117 -0
- package/lib/components/rich-editor/plugins/inline/link/utils.js +33 -0
- package/lib/components/rich-editor/plugins/inline/strong/index.js +137 -0
- package/lib/components/rich-editor/plugins/inline/under-line/index.js +145 -0
- package/lib/components/rich-editor/plugins/util.js +281 -0
- package/lib/components/rich-editor/react/reactNodeView.js +383 -0
- package/lib/components/rich-editor/react/uiProvider.js +185 -0
- package/lib/components/rich-editor/schemas/basic.js +309 -0
- package/lib/components/rich-editor/schemas/index.js +19 -0
- package/lib/components/rich-editor/schemas/list.js +342 -0
- package/lib/components/rich-editor/types/commond.js +5 -0
- package/lib/components/rich-editor/types/index.js +18 -0
- package/lib/components/rich-editor/ui/Popup/index.js +247 -0
- package/lib/components/rich-editor/ui/Popup/utils.js +399 -0
- package/lib/components/rich-editor/ui/editor/index.css +144 -0
- package/lib/components/rich-editor/ui/editor/index.js +143 -0
- package/lib/components/rich-editor/ui/normal-toolbar/index.css +29 -0
- package/lib/components/rich-editor/ui/normal-toolbar/index.js +109 -0
- package/lib/components/rich-editor/utils/browser.js +35 -0
- package/lib/components/rich-editor/utils/commands.js +266 -0
- package/lib/components/rich-editor/utils/document.js +160 -0
- package/lib/components/rich-editor/utils/event.js +79 -0
- package/lib/components/rich-editor/utils/helpers.js +16 -0
- package/lib/components/rich-editor/utils/mark.js +168 -0
- package/lib/components/rich-editor/utils/slice.js +85 -0
- package/lib/components/rich-editor/utils/toolbar.js +228 -0
- package/lib/components/upload/index.js +4 -2
- package/lib/components/upload/util.js +2 -0
- package/lib/index.js +8 -0
- package/package.json +20 -2
- package/yarn-error.log +22184 -0
|
@@ -0,0 +1,147 @@
|
|
|
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.DeleteLineSchema = exports.DeleteLinePlugin = exports.DeleteLineController = void 0;
|
|
9
|
+
|
|
10
|
+
var _plugin = _interopRequireDefault(require("../../../models/plugin"));
|
|
11
|
+
|
|
12
|
+
var _schema = require("../../../models/schema");
|
|
13
|
+
|
|
14
|
+
var _controller = _interopRequireDefault(require("../../../models/controller"));
|
|
15
|
+
|
|
16
|
+
var _prosemirrorCommands = require("prosemirror-commands");
|
|
17
|
+
|
|
18
|
+
var _mark = require("../../../utils/mark");
|
|
19
|
+
|
|
20
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
21
|
+
|
|
22
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
23
|
+
|
|
24
|
+
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, descriptor.key, descriptor); } }
|
|
25
|
+
|
|
26
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
27
|
+
|
|
28
|
+
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); }
|
|
29
|
+
|
|
30
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
31
|
+
|
|
32
|
+
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); }; }
|
|
33
|
+
|
|
34
|
+
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); }
|
|
35
|
+
|
|
36
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
37
|
+
|
|
38
|
+
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; } }
|
|
39
|
+
|
|
40
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
41
|
+
|
|
42
|
+
var PLUGIN_NAME = 'deleteLine';
|
|
43
|
+
|
|
44
|
+
var getAttrs = function getAttrs(value) {
|
|
45
|
+
if (/line-through/i.test(value)) {
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return false;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
var DeleteLineSchema = /*#__PURE__*/function (_InlineSchema) {
|
|
53
|
+
_inherits(DeleteLineSchema, _InlineSchema);
|
|
54
|
+
|
|
55
|
+
var _super = _createSuper(DeleteLineSchema);
|
|
56
|
+
|
|
57
|
+
function DeleteLineSchema() {
|
|
58
|
+
var _this;
|
|
59
|
+
|
|
60
|
+
_classCallCheck(this, DeleteLineSchema);
|
|
61
|
+
|
|
62
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
63
|
+
args[_key] = arguments[_key];
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return _possibleConstructorReturn(_this, (_this = _super.call.apply(_super, [this].concat(args)), _this.name = PLUGIN_NAME, _this.parseDOM = [{
|
|
67
|
+
tag: 's',
|
|
68
|
+
priority: 25
|
|
69
|
+
}, {
|
|
70
|
+
tag: 'strike',
|
|
71
|
+
priority: 25
|
|
72
|
+
}, {
|
|
73
|
+
tag: 'del',
|
|
74
|
+
priority: 25
|
|
75
|
+
}, {
|
|
76
|
+
style: 'text-decoration-line',
|
|
77
|
+
getAttrs: getAttrs
|
|
78
|
+
}], _assertThisInitialized(_this)));
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
_createClass(DeleteLineSchema, [{
|
|
82
|
+
key: "toDOM",
|
|
83
|
+
value: function toDOM() {
|
|
84
|
+
return ["s", {
|
|
85
|
+
style: 'text-decoration:line-through;'
|
|
86
|
+
}, 0];
|
|
87
|
+
}
|
|
88
|
+
}]);
|
|
89
|
+
|
|
90
|
+
return DeleteLineSchema;
|
|
91
|
+
}(_schema.InlineSchema);
|
|
92
|
+
|
|
93
|
+
exports.DeleteLineSchema = DeleteLineSchema;
|
|
94
|
+
|
|
95
|
+
var DeleteLineController = /*#__PURE__*/function (_BaseController) {
|
|
96
|
+
_inherits(DeleteLineController, _BaseController);
|
|
97
|
+
|
|
98
|
+
var _super2 = _createSuper(DeleteLineController);
|
|
99
|
+
|
|
100
|
+
function DeleteLineController() {
|
|
101
|
+
var _this2;
|
|
102
|
+
|
|
103
|
+
_classCallCheck(this, DeleteLineController);
|
|
104
|
+
|
|
105
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
106
|
+
args[_key2] = arguments[_key2];
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return _possibleConstructorReturn(_this2, (_this2 = _super2.call.apply(_super2, [this].concat(args)), _this2.toolbar = {
|
|
110
|
+
title: '删除线',
|
|
111
|
+
icon: 'tu-icon-text-delline',
|
|
112
|
+
handler: function handler(editor) {
|
|
113
|
+
(0, _prosemirrorCommands.toggleMark)(editor.state.schema.marks[PLUGIN_NAME])(editor.state, editor.view.dispatch);
|
|
114
|
+
editor.view.focus();
|
|
115
|
+
},
|
|
116
|
+
active: function active(state) {
|
|
117
|
+
return (0, _mark.selectionContainsMark)(state, PLUGIN_NAME);
|
|
118
|
+
}
|
|
119
|
+
}, _assertThisInitialized(_this2)));
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return _createClass(DeleteLineController);
|
|
123
|
+
}(_controller["default"]);
|
|
124
|
+
|
|
125
|
+
exports.DeleteLineController = DeleteLineController;
|
|
126
|
+
|
|
127
|
+
var DeleteLinePlugin = /*#__PURE__*/function (_BasePlugin) {
|
|
128
|
+
_inherits(DeleteLinePlugin, _BasePlugin);
|
|
129
|
+
|
|
130
|
+
var _super3 = _createSuper(DeleteLinePlugin);
|
|
131
|
+
|
|
132
|
+
function DeleteLinePlugin() {
|
|
133
|
+
var _this3;
|
|
134
|
+
|
|
135
|
+
_classCallCheck(this, DeleteLinePlugin);
|
|
136
|
+
|
|
137
|
+
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
138
|
+
args[_key3] = arguments[_key3];
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return _possibleConstructorReturn(_this3, (_this3 = _super3.call.apply(_super3, [this].concat(args)), _this3.name = PLUGIN_NAME, _this3.schema = DeleteLineSchema, _this3.controller = DeleteLineController, _assertThisInitialized(_this3)));
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
return _createClass(DeleteLinePlugin);
|
|
145
|
+
}(_plugin["default"]);
|
|
146
|
+
|
|
147
|
+
exports.DeleteLinePlugin = DeleteLinePlugin;
|
|
@@ -0,0 +1,93 @@
|
|
|
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.EmSchema = exports.EmPlugin = void 0;
|
|
9
|
+
|
|
10
|
+
var _plugin = _interopRequireDefault(require("../../../models/plugin"));
|
|
11
|
+
|
|
12
|
+
var _schema = require("../../../models/schema");
|
|
13
|
+
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
15
|
+
|
|
16
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
17
|
+
|
|
18
|
+
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, descriptor.key, descriptor); } }
|
|
19
|
+
|
|
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
|
+
|
|
22
|
+
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); }
|
|
23
|
+
|
|
24
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
25
|
+
|
|
26
|
+
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); }; }
|
|
27
|
+
|
|
28
|
+
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); }
|
|
29
|
+
|
|
30
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
31
|
+
|
|
32
|
+
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; } }
|
|
33
|
+
|
|
34
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
35
|
+
|
|
36
|
+
var PLUGIN_NAME = 'em';
|
|
37
|
+
|
|
38
|
+
var EmSchema = /*#__PURE__*/function (_InlineSchema) {
|
|
39
|
+
_inherits(EmSchema, _InlineSchema);
|
|
40
|
+
|
|
41
|
+
var _super = _createSuper(EmSchema);
|
|
42
|
+
|
|
43
|
+
function EmSchema() {
|
|
44
|
+
var _this;
|
|
45
|
+
|
|
46
|
+
_classCallCheck(this, EmSchema);
|
|
47
|
+
|
|
48
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
49
|
+
args[_key] = arguments[_key];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return _possibleConstructorReturn(_this, (_this = _super.call.apply(_super, [this].concat(args)), _this.name = PLUGIN_NAME, _this.parseDOM = [{
|
|
53
|
+
tag: "i"
|
|
54
|
+
}, {
|
|
55
|
+
tag: "em"
|
|
56
|
+
}, {
|
|
57
|
+
style: "font-style=italic"
|
|
58
|
+
}], _assertThisInitialized(_this)));
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
_createClass(EmSchema, [{
|
|
62
|
+
key: "toDOM",
|
|
63
|
+
value: function toDOM() {
|
|
64
|
+
return ["em", 0];
|
|
65
|
+
}
|
|
66
|
+
}]);
|
|
67
|
+
|
|
68
|
+
return EmSchema;
|
|
69
|
+
}(_schema.InlineSchema);
|
|
70
|
+
|
|
71
|
+
exports.EmSchema = EmSchema;
|
|
72
|
+
|
|
73
|
+
var EmPlugin = /*#__PURE__*/function (_BasePlugin) {
|
|
74
|
+
_inherits(EmPlugin, _BasePlugin);
|
|
75
|
+
|
|
76
|
+
var _super2 = _createSuper(EmPlugin);
|
|
77
|
+
|
|
78
|
+
function EmPlugin() {
|
|
79
|
+
var _this2;
|
|
80
|
+
|
|
81
|
+
_classCallCheck(this, EmPlugin);
|
|
82
|
+
|
|
83
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
84
|
+
args[_key2] = arguments[_key2];
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return _possibleConstructorReturn(_this2, (_this2 = _super2.call.apply(_super2, [this].concat(args)), _this2.name = PLUGIN_NAME, _this2.schema = EmSchema, _assertThisInitialized(_this2)));
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return _createClass(EmPlugin);
|
|
91
|
+
}(_plugin["default"]);
|
|
92
|
+
|
|
93
|
+
exports.EmPlugin = EmPlugin;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
var _deleteLine = require("./delete-line");
|
|
8
|
+
|
|
9
|
+
Object.keys(_deleteLine).forEach(function (key) {
|
|
10
|
+
if (key === "default" || key === "__esModule") return;
|
|
11
|
+
if (key in exports && exports[key] === _deleteLine[key]) return;
|
|
12
|
+
Object.defineProperty(exports, key, {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function get() {
|
|
15
|
+
return _deleteLine[key];
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
var _em = require("./em");
|
|
21
|
+
|
|
22
|
+
Object.keys(_em).forEach(function (key) {
|
|
23
|
+
if (key === "default" || key === "__esModule") return;
|
|
24
|
+
if (key in exports && exports[key] === _em[key]) return;
|
|
25
|
+
Object.defineProperty(exports, key, {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: function get() {
|
|
28
|
+
return _em[key];
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
var _strong = require("./strong");
|
|
34
|
+
|
|
35
|
+
Object.keys(_strong).forEach(function (key) {
|
|
36
|
+
if (key === "default" || key === "__esModule") return;
|
|
37
|
+
if (key in exports && exports[key] === _strong[key]) return;
|
|
38
|
+
Object.defineProperty(exports, key, {
|
|
39
|
+
enumerable: true,
|
|
40
|
+
get: function get() {
|
|
41
|
+
return _strong[key];
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
var _underLine = require("./under-line");
|
|
47
|
+
|
|
48
|
+
Object.keys(_underLine).forEach(function (key) {
|
|
49
|
+
if (key === "default" || key === "__esModule") return;
|
|
50
|
+
if (key in exports && exports[key] === _underLine[key]) return;
|
|
51
|
+
Object.defineProperty(exports, key, {
|
|
52
|
+
enumerable: true,
|
|
53
|
+
get: function get() {
|
|
54
|
+
return _underLine[key];
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
var _color = require("./color");
|
|
60
|
+
|
|
61
|
+
Object.keys(_color).forEach(function (key) {
|
|
62
|
+
if (key === "default" || key === "__esModule") return;
|
|
63
|
+
if (key in exports && exports[key] === _color[key]) return;
|
|
64
|
+
Object.defineProperty(exports, key, {
|
|
65
|
+
enumerable: true,
|
|
66
|
+
get: function get() {
|
|
67
|
+
return _color[key];
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
var _link = require("./link");
|
|
73
|
+
|
|
74
|
+
Object.keys(_link).forEach(function (key) {
|
|
75
|
+
if (key === "default" || key === "__esModule") return;
|
|
76
|
+
if (key in exports && exports[key] === _link[key]) return;
|
|
77
|
+
Object.defineProperty(exports, key, {
|
|
78
|
+
enumerable: true,
|
|
79
|
+
get: function get() {
|
|
80
|
+
return _link[key];
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
});
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.editInsertedLink = editInsertedLink;
|
|
7
|
+
exports.hideLinkToolbar = hideLinkToolbar;
|
|
8
|
+
exports.insertLink = insertLink;
|
|
9
|
+
exports.isLinkAtPos = isLinkAtPos;
|
|
10
|
+
exports.isTextAtPos = isTextAtPos;
|
|
11
|
+
exports.removeLink = removeLink;
|
|
12
|
+
exports.setLinkHref = setLinkHref;
|
|
13
|
+
exports.setLinkText = setLinkText;
|
|
14
|
+
exports.updateLink = updateLink;
|
|
15
|
+
|
|
16
|
+
var _utils = require("./utils");
|
|
17
|
+
|
|
18
|
+
var _main = require("./pm-plugins/main");
|
|
19
|
+
|
|
20
|
+
var _prosemirrorState = require("prosemirror-state");
|
|
21
|
+
|
|
22
|
+
var _commands = require("../../../utils/commands");
|
|
23
|
+
|
|
24
|
+
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; }
|
|
25
|
+
|
|
26
|
+
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; }
|
|
27
|
+
|
|
28
|
+
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; }
|
|
29
|
+
|
|
30
|
+
// import {
|
|
31
|
+
// addAnalytics,
|
|
32
|
+
// ACTION,
|
|
33
|
+
// ACTION_SUBJECT,
|
|
34
|
+
// INPUT_METHOD,
|
|
35
|
+
// EVENT_TYPE,
|
|
36
|
+
// ACTION_SUBJECT_ID,
|
|
37
|
+
// withAnalytics,
|
|
38
|
+
// } from '../analytics';
|
|
39
|
+
// import { queueCardsFromChangedTr } from '../card/pm-plugins/doc';
|
|
40
|
+
// import { LinkInputType } from './ui/HyperlinkAddToolbar/HyperlinkAddToolbar';
|
|
41
|
+
// import { getLinkCreationAnalyticsEvent } from './analytics';
|
|
42
|
+
function isTextAtPos(pos) {
|
|
43
|
+
return function (state) {
|
|
44
|
+
var node = state.doc.nodeAt(pos);
|
|
45
|
+
return !!node && node.isText;
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function isLinkAtPos(pos) {
|
|
50
|
+
return function (state) {
|
|
51
|
+
var node = state.doc.nodeAt(pos);
|
|
52
|
+
return !!node && state.schema.marks.link.isInSet(node.marks);
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function setLinkHref(href, pos, to, isTabPressed) {
|
|
57
|
+
return (0, _commands.filter)(isTextAtPos(pos), function (state, dispatch) {
|
|
58
|
+
var $pos = state.doc.resolve(pos);
|
|
59
|
+
var node = state.doc.nodeAt(pos);
|
|
60
|
+
var linkMark = state.schema.marks.link;
|
|
61
|
+
var mark = linkMark.isInSet(node.marks);
|
|
62
|
+
var url = (0, _utils.normalizeUrl)(href);
|
|
63
|
+
|
|
64
|
+
if (mark && mark.attrs.href === url) {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
var rightBound = to && pos !== to ? to : pos - $pos.textOffset + node.nodeSize;
|
|
69
|
+
var tr = state.tr.removeMark(pos, rightBound, linkMark);
|
|
70
|
+
|
|
71
|
+
if (href.trim()) {
|
|
72
|
+
tr.addMark(pos, rightBound, linkMark.create(_objectSpread(_objectSpread({}, mark && mark.attrs || {}), {}, {
|
|
73
|
+
href: url
|
|
74
|
+
})));
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (!isTabPressed) {
|
|
78
|
+
tr.setMeta(_main.stateKey, {
|
|
79
|
+
type: _main.LinkAction.HIDE_TOOLBAR
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (dispatch) {
|
|
84
|
+
dispatch(tr);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return true;
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function updateLink(href, text, pos, to) {
|
|
92
|
+
return function (state, dispatch) {
|
|
93
|
+
var $pos = state.doc.resolve(pos);
|
|
94
|
+
var node = state.doc.nodeAt(pos);
|
|
95
|
+
|
|
96
|
+
if (!node) {
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
var url = (0, _utils.normalizeUrl)(href);
|
|
101
|
+
|
|
102
|
+
if (!url) {
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
var mark = state.schema.marks.link.isInSet(node.marks);
|
|
107
|
+
var linkMark = state.schema.marks.link;
|
|
108
|
+
var rightBound = to && pos !== to ? to : pos - $pos.textOffset + node.nodeSize;
|
|
109
|
+
var tr = state.tr;
|
|
110
|
+
tr.insertText(text, pos, rightBound); // Casting to LinkAttributes to prevent wrong attributes been passed (Example ED-7951)
|
|
111
|
+
|
|
112
|
+
var linkAttrs = _objectSpread(_objectSpread({}, mark && mark.attrs || {}), {}, {
|
|
113
|
+
href: url
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
tr.addMark(pos, pos + text.length, linkMark.create(linkAttrs));
|
|
117
|
+
tr.setMeta(_main.stateKey, {
|
|
118
|
+
type: _main.LinkAction.HIDE_TOOLBAR
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
if (dispatch) {
|
|
122
|
+
dispatch(tr);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
return true;
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function setLinkText(text, pos, to) {
|
|
130
|
+
return (0, _commands.filter)(isLinkAtPos(pos), function (state, dispatch) {
|
|
131
|
+
var $pos = state.doc.resolve(pos);
|
|
132
|
+
var node = state.doc.nodeAt(pos);
|
|
133
|
+
var mark = state.schema.marks.link.isInSet(node.marks);
|
|
134
|
+
|
|
135
|
+
if (node && text.length > 0 && text !== node.text) {
|
|
136
|
+
var rightBound = to && pos !== to ? to : pos - $pos.textOffset + node.nodeSize;
|
|
137
|
+
var tr = state.tr;
|
|
138
|
+
tr.insertText(text, pos, rightBound);
|
|
139
|
+
tr.addMark(pos, pos + text.length, mark);
|
|
140
|
+
tr.setMeta(_main.stateKey, {
|
|
141
|
+
type: _main.LinkAction.HIDE_TOOLBAR
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
if (dispatch) {
|
|
145
|
+
dispatch(tr);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
return true;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
return false;
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function insertLink(from, to, href, text // source?: INPUT_METHOD.MANUAL | INPUT_METHOD.TYPEAHEAD,
|
|
156
|
+
) {
|
|
157
|
+
return (0, _commands.filter)((0, _main.canLinkBeCreatedInRange)(from, to), function (state, dispatch) {
|
|
158
|
+
var link = state.schema.marks.link;
|
|
159
|
+
|
|
160
|
+
if (href.trim()) {
|
|
161
|
+
var tr = state.tr;
|
|
162
|
+
var normalizedUrl = (0, _utils.normalizeUrl)(href);
|
|
163
|
+
|
|
164
|
+
if (from === to) {
|
|
165
|
+
var textContent = text || href;
|
|
166
|
+
tr.insertText(textContent, from, to);
|
|
167
|
+
tr.addMark(from, from + textContent.length, link.create({
|
|
168
|
+
href: normalizedUrl
|
|
169
|
+
}));
|
|
170
|
+
} else {
|
|
171
|
+
var _textContent = text || href;
|
|
172
|
+
|
|
173
|
+
tr.insertText(_textContent, from, to);
|
|
174
|
+
tr.addMark(from, from + _textContent.length, link.create({
|
|
175
|
+
href: normalizedUrl
|
|
176
|
+
}));
|
|
177
|
+
tr.setSelection(_prosemirrorState.Selection.near(tr.doc.resolve(from + _textContent.length)));
|
|
178
|
+
} // queueCardsFromChangedTr(state, tr, source!, false);
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
tr.setMeta(_main.stateKey, {
|
|
182
|
+
type: _main.LinkAction.HIDE_TOOLBAR
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
if (dispatch) {
|
|
186
|
+
dispatch(tr);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
return true;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
return false;
|
|
193
|
+
});
|
|
194
|
+
} // export const insertLinkWithAnalytics = (
|
|
195
|
+
// inputMethod: LinkInputType,
|
|
196
|
+
// from: number,
|
|
197
|
+
// to: number,
|
|
198
|
+
// href: string,
|
|
199
|
+
// text?: string,
|
|
200
|
+
// ) =>
|
|
201
|
+
// withAnalytics(getLinkCreationAnalyticsEvent(inputMethod, href))(
|
|
202
|
+
// insertLink(from, to, href, text, inputMethod),
|
|
203
|
+
// );
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
function removeLink(pos) {
|
|
207
|
+
return setLinkHref('', pos);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
function editInsertedLink() {
|
|
211
|
+
return function (state, dispatch) {
|
|
212
|
+
if (dispatch) {
|
|
213
|
+
dispatch(state.tr.setMeta(_main.stateKey, {
|
|
214
|
+
type: _main.LinkAction.EDIT_INSERTED_TOOLBAR
|
|
215
|
+
}));
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
return true;
|
|
219
|
+
};
|
|
220
|
+
} // export function showLinkToolbar(
|
|
221
|
+
// inputMethod:
|
|
222
|
+
// | INPUT_METHOD.TOOLBAR
|
|
223
|
+
// | INPUT_METHOD.QUICK_INSERT
|
|
224
|
+
// | INPUT_METHOD.SHORTCUT
|
|
225
|
+
// | INPUT_METHOD.INSERT_MENU = INPUT_METHOD.TOOLBAR,
|
|
226
|
+
// ): Command {
|
|
227
|
+
// return function(state, dispatch) {
|
|
228
|
+
// if (dispatch) {
|
|
229
|
+
// let tr = state.tr.setMeta(stateKey, {
|
|
230
|
+
// type: LinkAction.SHOW_INSERT_TOOLBAR,
|
|
231
|
+
// });
|
|
232
|
+
// tr = addAnalytics(state, tr, {
|
|
233
|
+
// action: ACTION.INVOKED,
|
|
234
|
+
// actionSubject: ACTION_SUBJECT.TYPEAHEAD,
|
|
235
|
+
// actionSubjectId: ACTION_SUBJECT_ID.TYPEAHEAD_LINK,
|
|
236
|
+
// attributes: { inputMethod },
|
|
237
|
+
// eventType: EVENT_TYPE.UI,
|
|
238
|
+
// });
|
|
239
|
+
// dispatch(tr);
|
|
240
|
+
// }
|
|
241
|
+
// return true;
|
|
242
|
+
// };
|
|
243
|
+
// }
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
function hideLinkToolbar() {
|
|
247
|
+
return function (state, dispatch) {
|
|
248
|
+
if (dispatch) {
|
|
249
|
+
dispatch(state.tr.setMeta(_main.stateKey, {
|
|
250
|
+
type: _main.LinkAction.HIDE_TOOLBAR
|
|
251
|
+
}));
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
return true;
|
|
255
|
+
};
|
|
256
|
+
}
|