@titaui/pc 1.10.40 → 1.10.44-beta.1
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/okr-detail/components/okr-tree/tree-node/e-node/e-project.js +5 -1
- package/lib/components/okr-detail/components/okr-tree/tree-node/e-node/index.css +19 -1
- package/lib/components/superset-charts/utils/axios.js +2 -2
- 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 -250
- 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 -144
- package/lib/components/rich-editor/ui/editor/index.js +0 -143
- package/lib/components/rich-editor/ui/normal-toolbar/index.css +0 -29
- 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,188 +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.HeadingSchema = exports.HeadingPlugin = void 0;
|
|
9
|
-
|
|
10
|
-
var _controller = _interopRequireDefault(require("../../../models/controller"));
|
|
11
|
-
|
|
12
|
-
var _plugin = _interopRequireDefault(require("../../../models/plugin"));
|
|
13
|
-
|
|
14
|
-
var _schema = require("../../../models/schema");
|
|
15
|
-
|
|
16
|
-
var _util = require("../../util");
|
|
17
|
-
|
|
18
|
-
var _commonds = require("./commonds");
|
|
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 = 'heading';
|
|
43
|
-
|
|
44
|
-
var HeadingSchema = /*#__PURE__*/function (_BlockSchema) {
|
|
45
|
-
_inherits(HeadingSchema, _BlockSchema);
|
|
46
|
-
|
|
47
|
-
var _super = _createSuper(HeadingSchema);
|
|
48
|
-
|
|
49
|
-
function HeadingSchema() {
|
|
50
|
-
var _this;
|
|
51
|
-
|
|
52
|
-
_classCallCheck(this, HeadingSchema);
|
|
53
|
-
|
|
54
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
55
|
-
args[_key] = arguments[_key];
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
return _possibleConstructorReturn(_this, (_this = _super.call.apply(_super, [this].concat(args)), _this.name = PLUGIN_NAME, _this.attrs = {
|
|
59
|
-
level: {
|
|
60
|
-
"default": 1
|
|
61
|
-
},
|
|
62
|
-
textAlign: {
|
|
63
|
-
"default": 'left'
|
|
64
|
-
}
|
|
65
|
-
}, _this.parseDOM = [{
|
|
66
|
-
tag: 'h1',
|
|
67
|
-
attrs: {
|
|
68
|
-
level: 1
|
|
69
|
-
}
|
|
70
|
-
}, {
|
|
71
|
-
tag: 'h2',
|
|
72
|
-
attrs: {
|
|
73
|
-
level: 2
|
|
74
|
-
}
|
|
75
|
-
}, {
|
|
76
|
-
tag: 'h3',
|
|
77
|
-
attrs: {
|
|
78
|
-
level: 3
|
|
79
|
-
}
|
|
80
|
-
}, {
|
|
81
|
-
tag: 'h4',
|
|
82
|
-
attrs: {
|
|
83
|
-
level: 4
|
|
84
|
-
}
|
|
85
|
-
}, {
|
|
86
|
-
tag: 'h5',
|
|
87
|
-
attrs: {
|
|
88
|
-
level: 5
|
|
89
|
-
}
|
|
90
|
-
}, {
|
|
91
|
-
tag: 'h6',
|
|
92
|
-
attrs: {
|
|
93
|
-
level: 6
|
|
94
|
-
}
|
|
95
|
-
}], _assertThisInitialized(_this)));
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
_createClass(HeadingSchema, [{
|
|
99
|
-
key: "toDOM",
|
|
100
|
-
value: function toDOM(node) {
|
|
101
|
-
return ["h".concat(node.attrs.level), {
|
|
102
|
-
style: "text-align:".concat(node.attrs["textAlign"])
|
|
103
|
-
}, 0];
|
|
104
|
-
}
|
|
105
|
-
}]);
|
|
106
|
-
|
|
107
|
-
return HeadingSchema;
|
|
108
|
-
}(_schema.BlockSchema);
|
|
109
|
-
|
|
110
|
-
exports.HeadingSchema = HeadingSchema;
|
|
111
|
-
|
|
112
|
-
var HeadingController = /*#__PURE__*/function (_BaseController) {
|
|
113
|
-
_inherits(HeadingController, _BaseController);
|
|
114
|
-
|
|
115
|
-
var _super2 = _createSuper(HeadingController);
|
|
116
|
-
|
|
117
|
-
function HeadingController() {
|
|
118
|
-
var _this2;
|
|
119
|
-
|
|
120
|
-
_classCallCheck(this, HeadingController);
|
|
121
|
-
|
|
122
|
-
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
123
|
-
args[_key2] = arguments[_key2];
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
return _possibleConstructorReturn(_this2, (_this2 = _super2.call.apply(_super2, [this].concat(args)), _this2.toolbar = [{
|
|
127
|
-
title: '一级标题',
|
|
128
|
-
icon: 'tu-icon-text-H1',
|
|
129
|
-
handler: function handler(editor) {
|
|
130
|
-
(0, _commonds.setHeadLine)(editor, 1);
|
|
131
|
-
editor.view.focus();
|
|
132
|
-
},
|
|
133
|
-
active: function active(state) {
|
|
134
|
-
return (0, _util.isBlockActive)(state, PLUGIN_NAME, {
|
|
135
|
-
level: 1
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
}, {
|
|
139
|
-
title: '二级标题',
|
|
140
|
-
icon: 'tu-icon-text-H2',
|
|
141
|
-
handler: function handler(editor) {
|
|
142
|
-
(0, _commonds.setHeadLine)(editor, 2);
|
|
143
|
-
editor.view.focus();
|
|
144
|
-
},
|
|
145
|
-
active: function active(state) {
|
|
146
|
-
return (0, _util.isBlockActive)(state, PLUGIN_NAME, {
|
|
147
|
-
level: 2
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
}, {
|
|
151
|
-
title: '三级标题',
|
|
152
|
-
icon: 'tu-icon-text-H3',
|
|
153
|
-
handler: function handler(editor) {
|
|
154
|
-
(0, _commonds.setHeadLine)(editor, 3);
|
|
155
|
-
editor.view.focus();
|
|
156
|
-
},
|
|
157
|
-
active: function active(state) {
|
|
158
|
-
return (0, _util.isBlockActive)(state, PLUGIN_NAME, {
|
|
159
|
-
level: 3
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
}], _assertThisInitialized(_this2)));
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
return _createClass(HeadingController);
|
|
166
|
-
}(_controller["default"]);
|
|
167
|
-
|
|
168
|
-
var HeadingPlugin = /*#__PURE__*/function (_BasePlugin) {
|
|
169
|
-
_inherits(HeadingPlugin, _BasePlugin);
|
|
170
|
-
|
|
171
|
-
var _super3 = _createSuper(HeadingPlugin);
|
|
172
|
-
|
|
173
|
-
function HeadingPlugin() {
|
|
174
|
-
var _this3;
|
|
175
|
-
|
|
176
|
-
_classCallCheck(this, HeadingPlugin);
|
|
177
|
-
|
|
178
|
-
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
179
|
-
args[_key3] = arguments[_key3];
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
return _possibleConstructorReturn(_this3, (_this3 = _super3.call.apply(_super3, [this].concat(args)), _this3.name = PLUGIN_NAME, _this3.schema = HeadingSchema, _this3.controller = HeadingController, _assertThisInitialized(_this3)));
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
return _createClass(HeadingPlugin);
|
|
186
|
-
}(_plugin["default"]);
|
|
187
|
-
|
|
188
|
-
exports.HeadingPlugin = HeadingPlugin;
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
var _blockQuote = require("./block-quote");
|
|
8
|
-
|
|
9
|
-
Object.keys(_blockQuote).forEach(function (key) {
|
|
10
|
-
if (key === "default" || key === "__esModule") return;
|
|
11
|
-
if (key in exports && exports[key] === _blockQuote[key]) return;
|
|
12
|
-
Object.defineProperty(exports, key, {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function get() {
|
|
15
|
-
return _blockQuote[key];
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
var _heading = require("./heading");
|
|
21
|
-
|
|
22
|
-
Object.keys(_heading).forEach(function (key) {
|
|
23
|
-
if (key === "default" || key === "__esModule") return;
|
|
24
|
-
if (key in exports && exports[key] === _heading[key]) return;
|
|
25
|
-
Object.defineProperty(exports, key, {
|
|
26
|
-
enumerable: true,
|
|
27
|
-
get: function get() {
|
|
28
|
-
return _heading[key];
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
var _paragraph = require("./paragraph");
|
|
34
|
-
|
|
35
|
-
Object.keys(_paragraph).forEach(function (key) {
|
|
36
|
-
if (key === "default" || key === "__esModule") return;
|
|
37
|
-
if (key in exports && exports[key] === _paragraph[key]) return;
|
|
38
|
-
Object.defineProperty(exports, key, {
|
|
39
|
-
enumerable: true,
|
|
40
|
-
get: function get() {
|
|
41
|
-
return _paragraph[key];
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
var _lists = require("./lists");
|
|
47
|
-
|
|
48
|
-
Object.keys(_lists).forEach(function (key) {
|
|
49
|
-
if (key === "default" || key === "__esModule") return;
|
|
50
|
-
if (key in exports && exports[key] === _lists[key]) return;
|
|
51
|
-
Object.defineProperty(exports, key, {
|
|
52
|
-
enumerable: true,
|
|
53
|
-
get: function get() {
|
|
54
|
-
return _lists[key];
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
});
|
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.convertListType = convertListType;
|
|
7
|
-
|
|
8
|
-
var _prosemirrorState = require("prosemirror-state");
|
|
9
|
-
|
|
10
|
-
var _prosemirrorModel = require("prosemirror-model");
|
|
11
|
-
|
|
12
|
-
var _prosemirrorTransform = require("prosemirror-transform");
|
|
13
|
-
|
|
14
|
-
var _prosemirrorUtils = require("prosemirror-utils");
|
|
15
|
-
|
|
16
|
-
var _node = require("../utils/node");
|
|
17
|
-
|
|
18
|
-
var _find = require("../utils/find");
|
|
19
|
-
|
|
20
|
-
// import { isEmptyParagraph } from '../../../utils';
|
|
21
|
-
function isEmptyParagraph(node) {
|
|
22
|
-
return !!node && node.type.name === 'paragraph' && !node.childCount;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function convertListType(_ref) {
|
|
26
|
-
var tr = _ref.tr,
|
|
27
|
-
nextListNodeType = _ref.nextListNodeType;
|
|
28
|
-
var doc = tr.doc,
|
|
29
|
-
_tr$selection = tr.selection,
|
|
30
|
-
$from = _tr$selection.$from,
|
|
31
|
-
$to = _tr$selection.$to;
|
|
32
|
-
var listRange = $from.blockRange($to, _node.isListNode);
|
|
33
|
-
|
|
34
|
-
if (listRange) {
|
|
35
|
-
return convertSelectedList({
|
|
36
|
-
tr: tr,
|
|
37
|
-
nextListNodeType: nextListNodeType
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
var nodeRangeAroundList = $from.blockRange($to);
|
|
42
|
-
|
|
43
|
-
if (!nodeRangeAroundList) {
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
var parentNode = nodeRangeAroundList.parent;
|
|
48
|
-
var startIndex = nodeRangeAroundList.startIndex,
|
|
49
|
-
endIndex = nodeRangeAroundList.endIndex,
|
|
50
|
-
depth = nodeRangeAroundList.depth; // Checking for invalid nodes to prevent conversion
|
|
51
|
-
// eg. a panel cannot be wrapped in a list so return
|
|
52
|
-
// It will skip this check if the selection begins within a list
|
|
53
|
-
// This is to match the behaviour of the toolbar buttons being disabled
|
|
54
|
-
|
|
55
|
-
if (!(0, _find.findFirstParentListNode)($from)) {
|
|
56
|
-
for (var i = startIndex; i < endIndex; i++) {
|
|
57
|
-
var position = nodeRangeAroundList.$from.posAtIndex(i, depth);
|
|
58
|
-
var resolvedPosition = doc.resolve(position);
|
|
59
|
-
var currentChild = parentNode.child(i);
|
|
60
|
-
var currentNodeRange = resolvedPosition.blockRange(tr.doc.resolve(position + currentChild.nodeSize));
|
|
61
|
-
|
|
62
|
-
if (currentNodeRange && !(0, _node.isListNode)(currentChild) && !(0, _prosemirrorTransform.findWrapping)(currentNodeRange, nextListNodeType)) {
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
} // Checking for any non list nodes and wrapping them in a list
|
|
67
|
-
// so they can be converted
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
tr.doc.nodesBetween(nodeRangeAroundList.start, nodeRangeAroundList.end, function (node, pos) {
|
|
71
|
-
// Skip over any nodes that are part of a list
|
|
72
|
-
if ((0, _find.findFirstParentListNode)(tr.doc.resolve(tr.mapping.map(pos)))) {
|
|
73
|
-
return false;
|
|
74
|
-
} // The following applies to suitable nodes that are not within a list
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
var currentNodeNotWrappedInList = node;
|
|
78
|
-
var isNotAnEmptyParagraphAndIsParagraphOrLeafNode = !isEmptyParagraph(currentNodeNotWrappedInList) && (!node.type.isBlock || node.type.name === 'paragraph');
|
|
79
|
-
|
|
80
|
-
if (isNotAnEmptyParagraphAndIsParagraphOrLeafNode) {
|
|
81
|
-
var remainingNodeRange = new _prosemirrorModel.NodeRange(tr.doc.resolve(tr.mapping.map(pos)), tr.doc.resolve(tr.mapping.map(pos) + currentNodeNotWrappedInList.nodeSize), nodeRangeAroundList.depth);
|
|
82
|
-
convertAroundList({
|
|
83
|
-
tr: tr,
|
|
84
|
-
nextListNodeType: nextListNodeType,
|
|
85
|
-
nodeRange: remainingNodeRange
|
|
86
|
-
});
|
|
87
|
-
return false;
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
convertSelectedList({
|
|
91
|
-
tr: tr,
|
|
92
|
-
nextListNodeType: nextListNodeType
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
if (tr.docChanged) {
|
|
96
|
-
(0, _node.joinSiblingLists)({
|
|
97
|
-
tr: tr,
|
|
98
|
-
forceListType: nextListNodeType
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
var convertSelectedList = function convertSelectedList(_ref2) {
|
|
104
|
-
var tr = _ref2.tr,
|
|
105
|
-
nextListNodeType = _ref2.nextListNodeType;
|
|
106
|
-
var selection = tr.selection,
|
|
107
|
-
_tr$selection2 = tr.selection,
|
|
108
|
-
from = _tr$selection2.from,
|
|
109
|
-
to = _tr$selection2.to; // get the positions of all the leaf nodes within the selection
|
|
110
|
-
|
|
111
|
-
var nodePositions = [];
|
|
112
|
-
|
|
113
|
-
if (selection instanceof _prosemirrorState.TextSelection && selection.$cursor) {
|
|
114
|
-
nodePositions.push(from);
|
|
115
|
-
} else {
|
|
116
|
-
// nodesBetween doesn't return leaf nodes that are outside of from and to
|
|
117
|
-
tr.doc.nodesBetween(from, to, function (node, pos) {
|
|
118
|
-
if (!node.isLeaf) {
|
|
119
|
-
return true;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
nodePositions.push(pos);
|
|
123
|
-
});
|
|
124
|
-
} // use those positions to get the closest parent list nodes
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
nodePositions.reduce(function (acc, pos) {
|
|
128
|
-
var closestParentListNode = (0, _prosemirrorUtils.findParentNodeClosestToPos)(tr.doc.resolve(pos), _node.isListNode);
|
|
129
|
-
|
|
130
|
-
if (!closestParentListNode) {
|
|
131
|
-
return acc;
|
|
132
|
-
} // don't add duplicates if the parent has already been added into the array
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
var existingParent = acc.find(function (node) {
|
|
136
|
-
return node.pos === closestParentListNode.pos && node.start === closestParentListNode.start && node.depth === closestParentListNode.depth;
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
if (!existingParent) {
|
|
140
|
-
acc.push(closestParentListNode);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
return acc;
|
|
144
|
-
}, []).forEach(function (item) {
|
|
145
|
-
tr.setNodeMarkup(item.pos, nextListNodeType);
|
|
146
|
-
});
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
var convertAroundList = function convertAroundList(_ref3) {
|
|
150
|
-
var tr = _ref3.tr,
|
|
151
|
-
nextListNodeType = _ref3.nextListNodeType,
|
|
152
|
-
nodeRange = _ref3.nodeRange;
|
|
153
|
-
|
|
154
|
-
for (var i = nodeRange.endIndex - 1; i >= nodeRange.startIndex; i--) {
|
|
155
|
-
// @ts-ignore posAtIndex is a public API but has no type yet
|
|
156
|
-
var position = nodeRange.$from.posAtIndex(i, nodeRange.depth);
|
|
157
|
-
var resolvedPos = tr.doc.resolve(position + 1);
|
|
158
|
-
var range = resolvedPos.blockRange(resolvedPos);
|
|
159
|
-
|
|
160
|
-
if (!range) {
|
|
161
|
-
return;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
var wrappings = (0, _prosemirrorTransform.findWrapping)(range, nextListNodeType);
|
|
165
|
-
|
|
166
|
-
if (!range || !wrappings) {
|
|
167
|
-
return;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
tr.wrap(range, wrappings);
|
|
171
|
-
}
|
|
172
|
-
};
|
package/lib/components/rich-editor/plugins/block/lists/actions/indent-list-items-selected.js
DELETED
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.indentListItemsSelected = void 0;
|
|
7
|
-
|
|
8
|
-
var _prosemirrorState = require("prosemirror-state");
|
|
9
|
-
|
|
10
|
-
var _prosemirrorModel = require("prosemirror-model");
|
|
11
|
-
|
|
12
|
-
var _node = require("../utils/node");
|
|
13
|
-
|
|
14
|
-
var _find = require("../utils/find");
|
|
15
|
-
|
|
16
|
-
var _selection = require("../utils/selection");
|
|
17
|
-
|
|
18
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
19
|
-
|
|
20
|
-
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."); }
|
|
21
|
-
|
|
22
|
-
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); }
|
|
23
|
-
|
|
24
|
-
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; }
|
|
25
|
-
|
|
26
|
-
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; }
|
|
27
|
-
|
|
28
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
29
|
-
|
|
30
|
-
// import { GapCursorSelection } from '../../selection/gap-cursor-selection';
|
|
31
|
-
var indentListItemsSelected = function indentListItemsSelected(tr) {
|
|
32
|
-
var originalSelection = tr.selection;
|
|
33
|
-
var normalizedSelection = (0, _selection.normalizeListItemsSelection)({
|
|
34
|
-
selection: originalSelection,
|
|
35
|
-
doc: tr.doc
|
|
36
|
-
});
|
|
37
|
-
var $from = normalizedSelection.$from,
|
|
38
|
-
$to = normalizedSelection.$to;
|
|
39
|
-
var range = calculateRange({
|
|
40
|
-
selection: normalizedSelection
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
if (!range) {
|
|
44
|
-
return false;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
var listItemsSelected = {
|
|
48
|
-
from: (0, _find.findFirstParentListItemNode)($from),
|
|
49
|
-
to: (0, _find.findFirstParentListItemNode)($to)
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
if (listItemsSelected.from === null || listItemsSelected.to === null) {
|
|
53
|
-
return null;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
var resolvedPos = tr.doc.resolve(listItemsSelected.from.pos);
|
|
57
|
-
var listItemIndex = resolvedPos.index(); // @ts-ignore
|
|
58
|
-
|
|
59
|
-
var positionListItemPosition = resolvedPos.posAtIndex(listItemIndex - 1);
|
|
60
|
-
var previousListItem = tr.doc.nodeAt(positionListItemPosition);
|
|
61
|
-
|
|
62
|
-
if (!previousListItem || !(0, _node.isListItemNode)(previousListItem)) {
|
|
63
|
-
return null;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
if ((0, _node.isListItemNode)(previousListItem) && listItemIndex === 0) {
|
|
67
|
-
return null;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
var listItemSelectedCommonParent = range.parent;
|
|
71
|
-
var previousNestedList = (0, _node.isListNode)(previousListItem.lastChild) ? previousListItem.lastChild : null;
|
|
72
|
-
var listNodeType = previousNestedList ? previousNestedList.type : listItemSelectedCommonParent.type;
|
|
73
|
-
var nestedList = listItemsSelected.to.node.lastChild;
|
|
74
|
-
var nestedItemsOffset = nestedList && (0, _node.isListNode)(nestedList) ? nestedList.nodeSize : 0;
|
|
75
|
-
var from = listItemsSelected.from.pos;
|
|
76
|
-
var to = listItemsSelected.to.pos + listItemsSelected.to.node.nodeSize - nestedItemsOffset;
|
|
77
|
-
|
|
78
|
-
var _createIndentedListIt = createIndentedListItemsSlice({
|
|
79
|
-
tr: tr,
|
|
80
|
-
listNodeType: listNodeType,
|
|
81
|
-
range: range,
|
|
82
|
-
from: from,
|
|
83
|
-
to: to
|
|
84
|
-
}),
|
|
85
|
-
_createIndentedListIt2 = _slicedToArray(_createIndentedListIt, 2),
|
|
86
|
-
sliceSelected = _createIndentedListIt2[0],
|
|
87
|
-
nestedListItemsLeftover = _createIndentedListIt2[1];
|
|
88
|
-
|
|
89
|
-
var hasPreviousNestedList = Boolean(previousNestedList);
|
|
90
|
-
var start = from - 1;
|
|
91
|
-
tr.replaceRange(hasPreviousNestedList ? start - 1 : start, range.end, sliceSelected);
|
|
92
|
-
var leftoverContentPosition = tr.mapping.map(to) - 2;
|
|
93
|
-
|
|
94
|
-
if (nestedListItemsLeftover.openStart === 0) {
|
|
95
|
-
tr.insert(leftoverContentPosition, nestedListItemsLeftover.content);
|
|
96
|
-
} else {
|
|
97
|
-
tr.replace(leftoverContentPosition - nestedListItemsLeftover.openStart, leftoverContentPosition - nestedListItemsLeftover.openStart, nestedListItemsLeftover);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
var nextSelection = calculateNewSelection({
|
|
101
|
-
originalSelection: originalSelection,
|
|
102
|
-
normalizedSelection: normalizedSelection,
|
|
103
|
-
tr: tr,
|
|
104
|
-
hasPreviousNestedList: hasPreviousNestedList
|
|
105
|
-
});
|
|
106
|
-
tr.setSelection(nextSelection);
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
exports.indentListItemsSelected = indentListItemsSelected;
|
|
110
|
-
|
|
111
|
-
var calculateRange = function calculateRange(_ref) {
|
|
112
|
-
var selection = _ref.selection;
|
|
113
|
-
var $from = selection.$from,
|
|
114
|
-
$to = selection.$to;
|
|
115
|
-
var range = $from.blockRange($to, _node.isListNode);
|
|
116
|
-
|
|
117
|
-
if (!range) {
|
|
118
|
-
return null;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
return range;
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
var calculateNewSelection = function calculateNewSelection(_ref2) {
|
|
125
|
-
var tr = _ref2.tr,
|
|
126
|
-
normalizedSelection = _ref2.normalizedSelection,
|
|
127
|
-
originalSelection = _ref2.originalSelection,
|
|
128
|
-
hasPreviousNestedList = _ref2.hasPreviousNestedList;
|
|
129
|
-
var offset = hasPreviousNestedList ? 2 : 0;
|
|
130
|
-
var $from = normalizedSelection.$from,
|
|
131
|
-
$to = normalizedSelection.$to; // if (normalizedSelection instanceof GapCursorSelection) {
|
|
132
|
-
// const nextSelectionFrom = tr.doc.resolve($from.pos - offset);
|
|
133
|
-
// return new GapCursorSelection(nextSelectionFrom, normalizedSelection.side);
|
|
134
|
-
// }
|
|
135
|
-
|
|
136
|
-
if (originalSelection instanceof _prosemirrorState.NodeSelection) {
|
|
137
|
-
return _prosemirrorState.NodeSelection.create(tr.doc, $from.pos - offset);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
var _Selection$near = _prosemirrorState.Selection.near(tr.doc.resolve($from.pos - offset)),
|
|
141
|
-
nextSelectionFrom = _Selection$near.$from;
|
|
142
|
-
|
|
143
|
-
var _Selection$near2 = _prosemirrorState.Selection.near(tr.doc.resolve($to.pos - offset), -1),
|
|
144
|
-
nextSelectionTo = _Selection$near2.$to;
|
|
145
|
-
|
|
146
|
-
return new _prosemirrorState.TextSelection(nextSelectionFrom, nextSelectionTo);
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
var createIndentedListItemsSlice = function createIndentedListItemsSlice(_ref3) {
|
|
150
|
-
var tr = _ref3.tr,
|
|
151
|
-
from = _ref3.from,
|
|
152
|
-
to = _ref3.to,
|
|
153
|
-
listNodeType = _ref3.listNodeType,
|
|
154
|
-
range = _ref3.range;
|
|
155
|
-
var listItemsSlice = tr.doc.slice(from, to - 2);
|
|
156
|
-
|
|
157
|
-
var listFragment = _prosemirrorModel.Fragment.from(listNodeType.create(null, listItemsSlice.content));
|
|
158
|
-
|
|
159
|
-
var nonSelectedListItemsSlice = tr.doc.slice(to, range.end - 2);
|
|
160
|
-
var openStart = tr.doc.slice(from - 1, range.end).openStart;
|
|
161
|
-
var slice = new _prosemirrorModel.Slice(listFragment, openStart, 0);
|
|
162
|
-
return [slice, nonSelectedListItemsSlice];
|
|
163
|
-
};
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.indentList = void 0;
|
|
7
|
-
|
|
8
|
-
var _prosemirrorTransform = require("prosemirror-transform");
|
|
9
|
-
|
|
10
|
-
var _prosemirrorModel = require("prosemirror-model");
|
|
11
|
-
|
|
12
|
-
// adapted from https://github.com/ProseMirror/prosemirror-schema-list/blob/master/src/schema-list.js#L206:L231
|
|
13
|
-
var indentList = function indentList(tr) {
|
|
14
|
-
var _tr$selection = tr.selection,
|
|
15
|
-
$from = _tr$selection.$from,
|
|
16
|
-
$to = _tr$selection.$to;
|
|
17
|
-
var listItem = tr.doc.type.schema.nodes.listItem;
|
|
18
|
-
var range = $from.blockRange($to, function (node) {
|
|
19
|
-
return !!node.childCount && !!node.firstChild && node.firstChild.type === listItem;
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
if (!range) {
|
|
23
|
-
return false;
|
|
24
|
-
} // get the index of the selected list item in the list it is part of
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
var startIndex = range.startIndex;
|
|
28
|
-
|
|
29
|
-
if (startIndex === 0) {
|
|
30
|
-
return false;
|
|
31
|
-
} // get the parent list of the list item(s) in the selected range
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
var parent = range.parent; // get the list immediately before the selection start
|
|
35
|
-
|
|
36
|
-
var previousListItem = parent.child(startIndex - 1);
|
|
37
|
-
|
|
38
|
-
if (previousListItem.type !== listItem) {
|
|
39
|
-
return false;
|
|
40
|
-
} // if that list was nested, join the selected list items into the same
|
|
41
|
-
// nested list; if not, create a new child list of the same type and
|
|
42
|
-
// nest it under the current level
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
var isPreviousListNested = previousListItem.lastChild && ['bulletList', 'orderedList'].includes(previousListItem.lastChild.type.name);
|
|
46
|
-
|
|
47
|
-
var inner = _prosemirrorModel.Fragment.from(isPreviousListNested ? listItem.create() : undefined);
|
|
48
|
-
|
|
49
|
-
var nextListNodeType = isPreviousListNested ? previousListItem.lastChild.type : parent.type;
|
|
50
|
-
|
|
51
|
-
var nextListNodeContent = _prosemirrorModel.Fragment.from(nextListNodeType.create(null, inner));
|
|
52
|
-
|
|
53
|
-
var slice = new _prosemirrorModel.Slice(_prosemirrorModel.Fragment.from(listItem.create(null, nextListNodeContent)), isPreviousListNested ? 3 : 1, 0);
|
|
54
|
-
var before = range.start;
|
|
55
|
-
var after = range.end;
|
|
56
|
-
tr.step(new _prosemirrorTransform.ReplaceAroundStep(before - (isPreviousListNested ? 3 : 1), after, before, after, slice, 1, true));
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
exports.indentList = indentList;
|