@atlaskit/editor-core 190.1.11 → 190.1.12
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/CHANGELOG.md +7 -0
- package/afm-cc/tsconfig.json +3 -0
- package/dist/cjs/plugins/index.js +0 -7
- package/dist/cjs/presets/universal.js +2 -1
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/es2019/plugins/index.js +0 -1
- package/dist/es2019/presets/universal.js +2 -1
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/esm/plugins/index.js +0 -1
- package/dist/esm/presets/universal.js +2 -1
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/types/plugins/index.d.ts +0 -1
- package/dist/types-ts4.5/plugins/index.d.ts +0 -1
- package/package.json +2 -1
- package/dist/cjs/plugins/custom-autoformat/doc.js +0 -91
- package/dist/cjs/plugins/custom-autoformat/index.js +0 -131
- package/dist/cjs/plugins/custom-autoformat/input-rules.js +0 -35
- package/dist/cjs/plugins/custom-autoformat/reducers.js +0 -56
- package/dist/cjs/plugins/custom-autoformat/types.js +0 -5
- package/dist/cjs/plugins/custom-autoformat/utils.js +0 -14
- package/dist/es2019/plugins/custom-autoformat/doc.js +0 -71
- package/dist/es2019/plugins/custom-autoformat/index.js +0 -101
- package/dist/es2019/plugins/custom-autoformat/input-rules.js +0 -31
- package/dist/es2019/plugins/custom-autoformat/reducers.js +0 -40
- package/dist/es2019/plugins/custom-autoformat/types.js +0 -1
- package/dist/es2019/plugins/custom-autoformat/utils.js +0 -6
- package/dist/esm/plugins/custom-autoformat/doc.js +0 -84
- package/dist/esm/plugins/custom-autoformat/index.js +0 -124
- package/dist/esm/plugins/custom-autoformat/input-rules.js +0 -29
- package/dist/esm/plugins/custom-autoformat/reducers.js +0 -49
- package/dist/esm/plugins/custom-autoformat/types.js +0 -1
- package/dist/esm/plugins/custom-autoformat/utils.js +0 -8
- package/dist/types/plugins/custom-autoformat/doc.d.ts +0 -6
- package/dist/types/plugins/custom-autoformat/index.d.ts +0 -6
- package/dist/types/plugins/custom-autoformat/input-rules.d.ts +0 -9
- package/dist/types/plugins/custom-autoformat/reducers.d.ts +0 -4
- package/dist/types/plugins/custom-autoformat/types.d.ts +0 -31
- package/dist/types/plugins/custom-autoformat/utils.d.ts +0 -6
- package/dist/types-ts4.5/plugins/custom-autoformat/doc.d.ts +0 -6
- package/dist/types-ts4.5/plugins/custom-autoformat/index.d.ts +0 -6
- package/dist/types-ts4.5/plugins/custom-autoformat/input-rules.d.ts +0 -9
- package/dist/types-ts4.5/plugins/custom-autoformat/reducers.d.ts +0 -4
- package/dist/types-ts4.5/plugins/custom-autoformat/types.d.ts +0 -31
- package/dist/types-ts4.5/plugins/custom-autoformat/utils.d.ts +0 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# @atlaskit/editor-core
|
|
2
2
|
|
|
3
|
+
## 190.1.12
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#62650](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/62650) [`225557f65dcd`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/225557f65dcd) - Extract custom autoformat plugin from editor-core as @atlaskit/editor-plugin-custom-autoformat
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
|
|
3
10
|
## 190.1.11
|
|
4
11
|
|
|
5
12
|
### Patch Changes
|
package/afm-cc/tsconfig.json
CHANGED
|
@@ -34,12 +34,6 @@ Object.defineProperty(exports, "collabEditPlugin", {
|
|
|
34
34
|
return _collabEdit.default;
|
|
35
35
|
}
|
|
36
36
|
});
|
|
37
|
-
Object.defineProperty(exports, "customAutoformatPlugin", {
|
|
38
|
-
enumerable: true,
|
|
39
|
-
get: function get() {
|
|
40
|
-
return _customAutoformat.default;
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
37
|
Object.defineProperty(exports, "extensionPlugin", {
|
|
44
38
|
enumerable: true,
|
|
45
39
|
get: function get() {
|
|
@@ -82,7 +76,6 @@ var _jiraIssue = _interopRequireDefault(require("./jira-issue"));
|
|
|
82
76
|
var _paste = _interopRequireDefault(require("./paste"));
|
|
83
77
|
var _breakout = _interopRequireDefault(require("./breakout"));
|
|
84
78
|
var _annotation = _interopRequireDefault(require("./annotation"));
|
|
85
|
-
var _customAutoformat = _interopRequireDefault(require("./custom-autoformat"));
|
|
86
79
|
var _feedbackDialog = _interopRequireDefault(require("./feedback-dialog"));
|
|
87
80
|
var _findReplace = _interopRequireDefault(require("./find-replace"));
|
|
88
81
|
var _undoRedo = _interopRequireDefault(require("./undo-redo"));
|
|
@@ -42,6 +42,7 @@ var _editorPluginTable = require("@atlaskit/editor-plugin-table");
|
|
|
42
42
|
var _editorPluginTasksAndDecisions = require("@atlaskit/editor-plugin-tasks-and-decisions");
|
|
43
43
|
var _editorPluginTextColor = require("@atlaskit/editor-plugin-text-color");
|
|
44
44
|
var _editorPluginToolbarListsIndentation = require("@atlaskit/editor-plugin-toolbar-lists-indentation");
|
|
45
|
+
var _editorPluginCustomAutoformat = require("@atlaskit/editor-plugin-custom-autoformat");
|
|
45
46
|
var _editorPluginAlignment = require("@atlaskit/editor-plugin-alignment");
|
|
46
47
|
var _editorPluginDataConsumer = require("@atlaskit/editor-plugin-data-consumer");
|
|
47
48
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
@@ -322,7 +323,7 @@ function createUniversalPreset(appearance, props, featureFlags, prevAppearance,
|
|
|
322
323
|
})]);
|
|
323
324
|
}
|
|
324
325
|
return builder;
|
|
325
|
-
}).maybeAdd(
|
|
326
|
+
}).maybeAdd(_editorPluginCustomAutoformat.customAutoformatPlugin, function (plugin, builder) {
|
|
326
327
|
if (props.autoformattingProvider) {
|
|
327
328
|
return builder.add(plugin);
|
|
328
329
|
}
|
|
@@ -4,7 +4,6 @@ export { default as jiraIssuePlugin } from './jira-issue';
|
|
|
4
4
|
export { default as pastePlugin } from './paste';
|
|
5
5
|
export { default as breakoutPlugin } from './breakout';
|
|
6
6
|
export { default as annotationPlugin } from './annotation';
|
|
7
|
-
export { default as customAutoformatPlugin } from './custom-autoformat';
|
|
8
7
|
export { default as feedbackDialogPlugin } from './feedback-dialog';
|
|
9
8
|
export { default as findReplacePlugin } from './find-replace';
|
|
10
9
|
export { default as undoRedoPlugin } from './undo-redo';
|
|
@@ -32,10 +32,11 @@ import { tablesPlugin } from '@atlaskit/editor-plugin-table';
|
|
|
32
32
|
import { tasksAndDecisionsPlugin } from '@atlaskit/editor-plugin-tasks-and-decisions';
|
|
33
33
|
import { textColorPlugin } from '@atlaskit/editor-plugin-text-color';
|
|
34
34
|
import { toolbarListsIndentationPlugin } from '@atlaskit/editor-plugin-toolbar-lists-indentation';
|
|
35
|
+
import { customAutoformatPlugin } from '@atlaskit/editor-plugin-custom-autoformat';
|
|
35
36
|
import { alignmentPlugin } from '@atlaskit/editor-plugin-alignment';
|
|
36
37
|
import { dataConsumerPlugin } from '@atlaskit/editor-plugin-data-consumer';
|
|
37
38
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
38
|
-
import { annotationPlugin, avatarGroupPlugin, beforePrimaryToolbarPlugin, breakoutPlugin, collabEditPlugin,
|
|
39
|
+
import { annotationPlugin, avatarGroupPlugin, beforePrimaryToolbarPlugin, breakoutPlugin, collabEditPlugin, extensionPlugin, feedbackDialogPlugin, findReplacePlugin, jiraIssuePlugin } from '../plugins';
|
|
39
40
|
import { shouldForceTracking } from '@atlaskit/editor-common/utils';
|
|
40
41
|
import { isFullPage as fullPageCheck } from '../utils/is-full-page';
|
|
41
42
|
import { createDefaultPreset } from './default';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export const name = "@atlaskit/editor-core";
|
|
2
|
-
export const version = "190.1.
|
|
2
|
+
export const version = "190.1.12";
|
|
@@ -4,7 +4,6 @@ export { default as jiraIssuePlugin } from './jira-issue';
|
|
|
4
4
|
export { default as pastePlugin } from './paste';
|
|
5
5
|
export { default as breakoutPlugin } from './breakout';
|
|
6
6
|
export { default as annotationPlugin } from './annotation';
|
|
7
|
-
export { default as customAutoformatPlugin } from './custom-autoformat';
|
|
8
7
|
export { default as feedbackDialogPlugin } from './feedback-dialog';
|
|
9
8
|
export { default as findReplacePlugin } from './find-replace';
|
|
10
9
|
export { default as undoRedoPlugin } from './undo-redo';
|
|
@@ -36,10 +36,11 @@ import { tablesPlugin } from '@atlaskit/editor-plugin-table';
|
|
|
36
36
|
import { tasksAndDecisionsPlugin } from '@atlaskit/editor-plugin-tasks-and-decisions';
|
|
37
37
|
import { textColorPlugin } from '@atlaskit/editor-plugin-text-color';
|
|
38
38
|
import { toolbarListsIndentationPlugin } from '@atlaskit/editor-plugin-toolbar-lists-indentation';
|
|
39
|
+
import { customAutoformatPlugin } from '@atlaskit/editor-plugin-custom-autoformat';
|
|
39
40
|
import { alignmentPlugin } from '@atlaskit/editor-plugin-alignment';
|
|
40
41
|
import { dataConsumerPlugin } from '@atlaskit/editor-plugin-data-consumer';
|
|
41
42
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
42
|
-
import { annotationPlugin, avatarGroupPlugin, beforePrimaryToolbarPlugin, breakoutPlugin, collabEditPlugin,
|
|
43
|
+
import { annotationPlugin, avatarGroupPlugin, beforePrimaryToolbarPlugin, breakoutPlugin, collabEditPlugin, extensionPlugin, feedbackDialogPlugin, findReplacePlugin, jiraIssuePlugin } from '../plugins';
|
|
43
44
|
import { shouldForceTracking } from '@atlaskit/editor-common/utils';
|
|
44
45
|
import { isFullPage as fullPageCheck } from '../utils/is-full-page';
|
|
45
46
|
import { createDefaultPreset } from './default';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export var name = "@atlaskit/editor-core";
|
|
2
|
-
export var version = "190.1.
|
|
2
|
+
export var version = "190.1.12";
|
|
@@ -4,7 +4,6 @@ export { default as jiraIssuePlugin } from './jira-issue';
|
|
|
4
4
|
export { default as pastePlugin } from './paste';
|
|
5
5
|
export { default as breakoutPlugin } from './breakout';
|
|
6
6
|
export { default as annotationPlugin } from './annotation';
|
|
7
|
-
export { default as customAutoformatPlugin } from './custom-autoformat';
|
|
8
7
|
export { default as feedbackDialogPlugin } from './feedback-dialog';
|
|
9
8
|
export { default as findReplacePlugin } from './find-replace';
|
|
10
9
|
export { default as undoRedoPlugin } from './undo-redo';
|
|
@@ -4,7 +4,6 @@ export { default as jiraIssuePlugin } from './jira-issue';
|
|
|
4
4
|
export { default as pastePlugin } from './paste';
|
|
5
5
|
export { default as breakoutPlugin } from './breakout';
|
|
6
6
|
export { default as annotationPlugin } from './annotation';
|
|
7
|
-
export { default as customAutoformatPlugin } from './custom-autoformat';
|
|
8
7
|
export { default as feedbackDialogPlugin } from './feedback-dialog';
|
|
9
8
|
export { default as findReplacePlugin } from './find-replace';
|
|
10
9
|
export { default as undoRedoPlugin } from './undo-redo';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-core",
|
|
3
|
-
"version": "190.1.
|
|
3
|
+
"version": "190.1.12",
|
|
4
4
|
"description": "A package contains Atlassian editor core functionality",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -70,6 +70,7 @@
|
|
|
70
70
|
"@atlaskit/editor-plugin-content-insertion": "^0.1.4",
|
|
71
71
|
"@atlaskit/editor-plugin-context-panel": "^0.2.0",
|
|
72
72
|
"@atlaskit/editor-plugin-copy-button": "^1.0.0",
|
|
73
|
+
"@atlaskit/editor-plugin-custom-autoformat": "^0.1.0",
|
|
73
74
|
"@atlaskit/editor-plugin-data-consumer": "^0.1.0",
|
|
74
75
|
"@atlaskit/editor-plugin-date": "^0.2.0",
|
|
75
76
|
"@atlaskit/editor-plugin-decorations": "^0.2.0",
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.completeReplacements = exports.buildHandler = void 0;
|
|
8
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
|
-
var _history = require("@atlaskit/editor-prosemirror/history");
|
|
11
|
-
var _utils = require("@atlaskit/editor-common/utils");
|
|
12
|
-
var _utils2 = require("./utils");
|
|
13
|
-
var buildHandler = exports.buildHandler = function buildHandler(_regex, handler) {
|
|
14
|
-
return /*#__PURE__*/function () {
|
|
15
|
-
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(view, match, start, end) {
|
|
16
|
-
var replacementPromise, replacementData, replacementNode;
|
|
17
|
-
return _regenerator.default.wrap(function _callee$(_context) {
|
|
18
|
-
while (1) switch (_context.prev = _context.next) {
|
|
19
|
-
case 0:
|
|
20
|
-
replacementPromise = handler(match.slice(1, match.length - 1)); // queue the position and match pair so that we can remap across transactions
|
|
21
|
-
// while we wait for the replacmentPromise to resolve
|
|
22
|
-
view.dispatch((0, _utils2.autoformatAction)(view.state.tr, {
|
|
23
|
-
action: 'matched',
|
|
24
|
-
match: match,
|
|
25
|
-
start: start,
|
|
26
|
-
end: end
|
|
27
|
-
}));
|
|
28
|
-
|
|
29
|
-
// ask the provider to give us an ADF node to replace the text with
|
|
30
|
-
_context.next = 4;
|
|
31
|
-
return replacementPromise;
|
|
32
|
-
case 4:
|
|
33
|
-
replacementData = _context.sent;
|
|
34
|
-
replacementNode = (0, _utils.processRawValue)(view.state.schema, replacementData);
|
|
35
|
-
view.dispatch((0, _utils2.autoformatAction)(view.state.tr, {
|
|
36
|
-
action: 'resolved',
|
|
37
|
-
matchString: match[0],
|
|
38
|
-
replacement: replacementNode
|
|
39
|
-
}));
|
|
40
|
-
return _context.abrupt("return", replacementData);
|
|
41
|
-
case 8:
|
|
42
|
-
case "end":
|
|
43
|
-
return _context.stop();
|
|
44
|
-
}
|
|
45
|
-
}, _callee);
|
|
46
|
-
}));
|
|
47
|
-
return function (_x, _x2, _x3, _x4) {
|
|
48
|
-
return _ref.apply(this, arguments);
|
|
49
|
-
};
|
|
50
|
-
}();
|
|
51
|
-
};
|
|
52
|
-
var completeReplacements = exports.completeReplacements = function completeReplacements(view, state) {
|
|
53
|
-
var inlineCard = view.state.schema.nodes.inlineCard;
|
|
54
|
-
state.matches.forEach(function (completedMatch) {
|
|
55
|
-
var matchingRequests = state.resolving.filter(function (candidate) {
|
|
56
|
-
return candidate.match[0] === completedMatch.matchString;
|
|
57
|
-
});
|
|
58
|
-
var tr = view.state.tr;
|
|
59
|
-
matchingRequests.forEach(function (request) {
|
|
60
|
-
var match = request.match,
|
|
61
|
-
start = request.start,
|
|
62
|
-
end = request.end;
|
|
63
|
-
var replacement = completedMatch.replacement;
|
|
64
|
-
var prefix = match[1];
|
|
65
|
-
var suffix = match[match.length - 1];
|
|
66
|
-
var matchEndPos = end + suffix.length;
|
|
67
|
-
|
|
68
|
-
// only permit inlineCard as replacement target for now
|
|
69
|
-
if (!replacement || replacement.type !== inlineCard && !replacement.isText) {
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// get the current document text, adding # or | if we cross node boundaries
|
|
74
|
-
var docText = view.state.doc.textBetween(start, matchEndPos, '#', '|');
|
|
75
|
-
|
|
76
|
-
// only replace if text still remains the same as when typed at the start
|
|
77
|
-
if (docText === match[0]) {
|
|
78
|
-
tr = tr.replaceWith(tr.mapping.map(start + prefix.length), tr.mapping.map(end, -1), replacement);
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
// clear this match from plugin state now that we've processed it
|
|
83
|
-
tr = (0, _utils2.autoformatAction)(tr, {
|
|
84
|
-
action: 'finish',
|
|
85
|
-
matchString: completedMatch.matchString
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
// and dispatch the replacement, closing history for cmd+z to allow undo separately
|
|
89
|
-
view.dispatch((0, _history.closeHistory)(tr));
|
|
90
|
-
});
|
|
91
|
-
};
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = exports.createPMPlugin = void 0;
|
|
8
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
12
|
-
var _keymap = require("@atlaskit/editor-prosemirror/keymap");
|
|
13
|
-
var _reducers = _interopRequireDefault(require("./reducers"));
|
|
14
|
-
var _inputRules = require("./input-rules");
|
|
15
|
-
var _doc = require("./doc");
|
|
16
|
-
var _utils = require("./utils");
|
|
17
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
18
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
19
|
-
var createPMPlugin = exports.createPMPlugin = function createPMPlugin(_ref) {
|
|
20
|
-
var providerFactory = _ref.providerFactory;
|
|
21
|
-
var rules = [];
|
|
22
|
-
return new _safePlugin.SafePlugin({
|
|
23
|
-
state: {
|
|
24
|
-
init: function init() {
|
|
25
|
-
return {
|
|
26
|
-
resolving: [],
|
|
27
|
-
matches: []
|
|
28
|
-
};
|
|
29
|
-
},
|
|
30
|
-
apply: function apply(tr, prevPluginState) {
|
|
31
|
-
if (!prevPluginState) {
|
|
32
|
-
return prevPluginState;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// remap positions
|
|
36
|
-
var remappedPluginState = _objectSpread(_objectSpread({}, prevPluginState), {}, {
|
|
37
|
-
resolving: prevPluginState.resolving.map(function (candidate) {
|
|
38
|
-
return _objectSpread(_objectSpread({}, candidate), {}, {
|
|
39
|
-
start: tr.mapping.map(candidate.start),
|
|
40
|
-
end: tr.mapping.map(candidate.end, -1)
|
|
41
|
-
});
|
|
42
|
-
})
|
|
43
|
-
});
|
|
44
|
-
var meta = tr.getMeta(_utils.pluginKey);
|
|
45
|
-
if (!meta) {
|
|
46
|
-
return remappedPluginState;
|
|
47
|
-
}
|
|
48
|
-
return (0, _reducers.default)(remappedPluginState, meta);
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
|
-
props: {
|
|
52
|
-
handleTextInput: function handleTextInput(view, from, to, text) {
|
|
53
|
-
(0, _inputRules.triggerInputRule)(view, rules, from, to, text);
|
|
54
|
-
return false;
|
|
55
|
-
},
|
|
56
|
-
handleKeyDown: (0, _keymap.keydownHandler)({
|
|
57
|
-
Enter: function Enter(_state, _dispatch, view) {
|
|
58
|
-
if (view) {
|
|
59
|
-
(0, _inputRules.triggerInputRule)(view, rules, view.state.selection.from, view.state.selection.to, '');
|
|
60
|
-
}
|
|
61
|
-
return false;
|
|
62
|
-
}
|
|
63
|
-
})
|
|
64
|
-
},
|
|
65
|
-
view: function view() {
|
|
66
|
-
var handleProvider = function handleProvider(name, provider) {
|
|
67
|
-
if (name !== 'autoformattingProvider' || !provider) {
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
provider.then( /*#__PURE__*/function () {
|
|
71
|
-
var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(autoformattingProvider) {
|
|
72
|
-
var ruleset;
|
|
73
|
-
return _regenerator.default.wrap(function _callee$(_context) {
|
|
74
|
-
while (1) switch (_context.prev = _context.next) {
|
|
75
|
-
case 0:
|
|
76
|
-
_context.next = 2;
|
|
77
|
-
return autoformattingProvider.getRules();
|
|
78
|
-
case 2:
|
|
79
|
-
ruleset = _context.sent;
|
|
80
|
-
Object.keys(ruleset).forEach(function (rule) {
|
|
81
|
-
var inputRule = {
|
|
82
|
-
matchTyping: new RegExp('(\\s+|^)' + rule + '(\\s|,|\\.)$'),
|
|
83
|
-
matchEnter: new RegExp('(\\s+|^)' + rule + '()$'),
|
|
84
|
-
handler: (0, _doc.buildHandler)(rule, ruleset[rule])
|
|
85
|
-
};
|
|
86
|
-
rules.push(inputRule);
|
|
87
|
-
});
|
|
88
|
-
case 4:
|
|
89
|
-
case "end":
|
|
90
|
-
return _context.stop();
|
|
91
|
-
}
|
|
92
|
-
}, _callee);
|
|
93
|
-
}));
|
|
94
|
-
return function (_x) {
|
|
95
|
-
return _ref2.apply(this, arguments);
|
|
96
|
-
};
|
|
97
|
-
}());
|
|
98
|
-
};
|
|
99
|
-
providerFactory.subscribe('autoformattingProvider', handleProvider);
|
|
100
|
-
return {
|
|
101
|
-
update: function update(view) {
|
|
102
|
-
var currentState = (0, _utils.getPluginState)(view.state);
|
|
103
|
-
if (!currentState) {
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
// make replacements in document for finished autoformats
|
|
108
|
-
if (currentState.matches) {
|
|
109
|
-
(0, _doc.completeReplacements)(view, currentState);
|
|
110
|
-
}
|
|
111
|
-
},
|
|
112
|
-
destroy: function destroy() {
|
|
113
|
-
providerFactory.unsubscribe('autoformattingProvider', handleProvider);
|
|
114
|
-
}
|
|
115
|
-
};
|
|
116
|
-
},
|
|
117
|
-
key: _utils.pluginKey
|
|
118
|
-
});
|
|
119
|
-
};
|
|
120
|
-
var customAutoformatPlugin = function customAutoformatPlugin() {
|
|
121
|
-
return {
|
|
122
|
-
name: 'customAutoformat',
|
|
123
|
-
pmPlugins: function pmPlugins() {
|
|
124
|
-
return [{
|
|
125
|
-
name: 'customAutoformat',
|
|
126
|
-
plugin: createPMPlugin
|
|
127
|
-
}];
|
|
128
|
-
}
|
|
129
|
-
};
|
|
130
|
-
};
|
|
131
|
-
var _default = exports.default = customAutoformatPlugin;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.triggerInputRule = void 0;
|
|
7
|
-
var MAX_MATCH = 500;
|
|
8
|
-
|
|
9
|
-
// this is a modified version of
|
|
10
|
-
// https://github.com/ProseMirror/prosemirror-inputrules/blob/master/src/inputrules.js#L53
|
|
11
|
-
var triggerInputRule = exports.triggerInputRule = function triggerInputRule(view, rules, from, to, text) {
|
|
12
|
-
var state = view.state;
|
|
13
|
-
var $from = state.doc.resolve(from);
|
|
14
|
-
if ($from.parent.type.spec.code) {
|
|
15
|
-
return false;
|
|
16
|
-
}
|
|
17
|
-
var textBefore = $from.parent.textBetween(Math.max(0, $from.parentOffset - MAX_MATCH), $from.parentOffset, undefined, "\uFFFC") + text;
|
|
18
|
-
|
|
19
|
-
// loop through rules trying to find one that matches
|
|
20
|
-
for (var i = 0; i < rules.length; i++) {
|
|
21
|
-
var _match = void 0;
|
|
22
|
-
if (text.length) {
|
|
23
|
-
_match = rules[i].matchTyping.exec(textBefore);
|
|
24
|
-
} else {
|
|
25
|
-
_match = rules[i].matchEnter.exec(textBefore);
|
|
26
|
-
}
|
|
27
|
-
if (_match) {
|
|
28
|
-
// kick off the handler
|
|
29
|
-
var pos = from - (_match[0].length - text.length);
|
|
30
|
-
rules[i].handler(view, _match, pos, to);
|
|
31
|
-
return true;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
return false;
|
|
35
|
-
};
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
11
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
12
|
-
// queues a match at a given position in the document
|
|
13
|
-
var matched = function matched(state, action) {
|
|
14
|
-
return _objectSpread(_objectSpread({}, state), {}, {
|
|
15
|
-
resolving: [].concat((0, _toConsumableArray2.default)(state.resolving), [{
|
|
16
|
-
start: action.start,
|
|
17
|
-
end: action.end,
|
|
18
|
-
match: action.match
|
|
19
|
-
}])
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
// store the replacement for a match
|
|
24
|
-
var resolved = function resolved(state, action) {
|
|
25
|
-
return _objectSpread(_objectSpread({}, state), {}, {
|
|
26
|
-
matches: [].concat((0, _toConsumableArray2.default)(state.matches), [{
|
|
27
|
-
replacement: action.replacement,
|
|
28
|
-
matchString: action.matchString
|
|
29
|
-
}])
|
|
30
|
-
});
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
// indicates a replacement in the document has been completed, and removes the match from both resolving and matches
|
|
34
|
-
var finish = function finish(state, action) {
|
|
35
|
-
return _objectSpread(_objectSpread({}, state), {}, {
|
|
36
|
-
resolving: state.resolving.filter(function (resolving) {
|
|
37
|
-
return resolving.match[0] !== action.matchString;
|
|
38
|
-
}),
|
|
39
|
-
matches: state.matches.filter(function (matching) {
|
|
40
|
-
return matching.matchString !== action.matchString;
|
|
41
|
-
})
|
|
42
|
-
});
|
|
43
|
-
};
|
|
44
|
-
var reduce = function reduce(state, action) {
|
|
45
|
-
switch (action.action) {
|
|
46
|
-
case 'matched':
|
|
47
|
-
return matched(state, action);
|
|
48
|
-
case 'resolved':
|
|
49
|
-
return resolved(state, action);
|
|
50
|
-
case 'finish':
|
|
51
|
-
return finish(state, action);
|
|
52
|
-
default:
|
|
53
|
-
return state;
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
var _default = exports.default = reduce;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.pluginKey = exports.getPluginState = exports.autoformatAction = void 0;
|
|
7
|
-
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
8
|
-
var pluginKey = exports.pluginKey = new _state.PluginKey('customAutoformatPlugin');
|
|
9
|
-
var getPluginState = exports.getPluginState = function getPluginState(editorState) {
|
|
10
|
-
return pluginKey.getState(editorState);
|
|
11
|
-
};
|
|
12
|
-
var autoformatAction = exports.autoformatAction = function autoformatAction(tr, action) {
|
|
13
|
-
return tr.setMeta(pluginKey, action);
|
|
14
|
-
};
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { closeHistory } from '@atlaskit/editor-prosemirror/history';
|
|
2
|
-
import { processRawValue } from '@atlaskit/editor-common/utils';
|
|
3
|
-
import { autoformatAction } from './utils';
|
|
4
|
-
export const buildHandler = (_regex, handler) => {
|
|
5
|
-
return async (view, match, start, end) => {
|
|
6
|
-
const replacementPromise = handler(match.slice(1, match.length - 1));
|
|
7
|
-
|
|
8
|
-
// queue the position and match pair so that we can remap across transactions
|
|
9
|
-
// while we wait for the replacmentPromise to resolve
|
|
10
|
-
view.dispatch(autoformatAction(view.state.tr, {
|
|
11
|
-
action: 'matched',
|
|
12
|
-
match: match,
|
|
13
|
-
start,
|
|
14
|
-
end
|
|
15
|
-
}));
|
|
16
|
-
|
|
17
|
-
// ask the provider to give us an ADF node to replace the text with
|
|
18
|
-
const replacementData = await replacementPromise;
|
|
19
|
-
const replacementNode = processRawValue(view.state.schema, replacementData);
|
|
20
|
-
view.dispatch(autoformatAction(view.state.tr, {
|
|
21
|
-
action: 'resolved',
|
|
22
|
-
matchString: match[0],
|
|
23
|
-
replacement: replacementNode
|
|
24
|
-
}));
|
|
25
|
-
return replacementData;
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
export const completeReplacements = (view, state) => {
|
|
29
|
-
const {
|
|
30
|
-
inlineCard
|
|
31
|
-
} = view.state.schema.nodes;
|
|
32
|
-
state.matches.forEach(completedMatch => {
|
|
33
|
-
const matchingRequests = state.resolving.filter(candidate => candidate.match[0] === completedMatch.matchString);
|
|
34
|
-
let tr = view.state.tr;
|
|
35
|
-
matchingRequests.forEach(request => {
|
|
36
|
-
const {
|
|
37
|
-
match,
|
|
38
|
-
start,
|
|
39
|
-
end
|
|
40
|
-
} = request;
|
|
41
|
-
const {
|
|
42
|
-
replacement
|
|
43
|
-
} = completedMatch;
|
|
44
|
-
const prefix = match[1];
|
|
45
|
-
const suffix = match[match.length - 1];
|
|
46
|
-
const matchEndPos = end + suffix.length;
|
|
47
|
-
|
|
48
|
-
// only permit inlineCard as replacement target for now
|
|
49
|
-
if (!replacement || replacement.type !== inlineCard && !replacement.isText) {
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// get the current document text, adding # or | if we cross node boundaries
|
|
54
|
-
const docText = view.state.doc.textBetween(start, matchEndPos, '#', '|');
|
|
55
|
-
|
|
56
|
-
// only replace if text still remains the same as when typed at the start
|
|
57
|
-
if (docText === match[0]) {
|
|
58
|
-
tr = tr.replaceWith(tr.mapping.map(start + prefix.length), tr.mapping.map(end, -1), replacement);
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
// clear this match from plugin state now that we've processed it
|
|
63
|
-
tr = autoformatAction(tr, {
|
|
64
|
-
action: 'finish',
|
|
65
|
-
matchString: completedMatch.matchString
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
// and dispatch the replacement, closing history for cmd+z to allow undo separately
|
|
69
|
-
view.dispatch(closeHistory(tr));
|
|
70
|
-
});
|
|
71
|
-
};
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
-
import { keydownHandler } from '@atlaskit/editor-prosemirror/keymap';
|
|
3
|
-
import reducers from './reducers';
|
|
4
|
-
import { triggerInputRule } from './input-rules';
|
|
5
|
-
import { completeReplacements, buildHandler } from './doc';
|
|
6
|
-
import { getPluginState, pluginKey } from './utils';
|
|
7
|
-
export const createPMPlugin = ({
|
|
8
|
-
providerFactory
|
|
9
|
-
}) => {
|
|
10
|
-
const rules = [];
|
|
11
|
-
return new SafePlugin({
|
|
12
|
-
state: {
|
|
13
|
-
init() {
|
|
14
|
-
return {
|
|
15
|
-
resolving: [],
|
|
16
|
-
matches: []
|
|
17
|
-
};
|
|
18
|
-
},
|
|
19
|
-
apply(tr, prevPluginState) {
|
|
20
|
-
if (!prevPluginState) {
|
|
21
|
-
return prevPluginState;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
// remap positions
|
|
25
|
-
const remappedPluginState = {
|
|
26
|
-
...prevPluginState,
|
|
27
|
-
resolving: prevPluginState.resolving.map(candidate => ({
|
|
28
|
-
...candidate,
|
|
29
|
-
start: tr.mapping.map(candidate.start),
|
|
30
|
-
end: tr.mapping.map(candidate.end, -1)
|
|
31
|
-
}))
|
|
32
|
-
};
|
|
33
|
-
const meta = tr.getMeta(pluginKey);
|
|
34
|
-
if (!meta) {
|
|
35
|
-
return remappedPluginState;
|
|
36
|
-
}
|
|
37
|
-
return reducers(remappedPluginState, meta);
|
|
38
|
-
}
|
|
39
|
-
},
|
|
40
|
-
props: {
|
|
41
|
-
handleTextInput(view, from, to, text) {
|
|
42
|
-
triggerInputRule(view, rules, from, to, text);
|
|
43
|
-
return false;
|
|
44
|
-
},
|
|
45
|
-
handleKeyDown: keydownHandler({
|
|
46
|
-
Enter: (_state, _dispatch, view) => {
|
|
47
|
-
if (view) {
|
|
48
|
-
triggerInputRule(view, rules, view.state.selection.from, view.state.selection.to, '');
|
|
49
|
-
}
|
|
50
|
-
return false;
|
|
51
|
-
}
|
|
52
|
-
})
|
|
53
|
-
},
|
|
54
|
-
view() {
|
|
55
|
-
const handleProvider = (name, provider) => {
|
|
56
|
-
if (name !== 'autoformattingProvider' || !provider) {
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
provider.then(async autoformattingProvider => {
|
|
60
|
-
const ruleset = await autoformattingProvider.getRules();
|
|
61
|
-
Object.keys(ruleset).forEach(rule => {
|
|
62
|
-
const inputRule = {
|
|
63
|
-
matchTyping: new RegExp('(\\s+|^)' + rule + '(\\s|,|\\.)$'),
|
|
64
|
-
matchEnter: new RegExp('(\\s+|^)' + rule + '()$'),
|
|
65
|
-
handler: buildHandler(rule, ruleset[rule])
|
|
66
|
-
};
|
|
67
|
-
rules.push(inputRule);
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
};
|
|
71
|
-
providerFactory.subscribe('autoformattingProvider', handleProvider);
|
|
72
|
-
return {
|
|
73
|
-
update(view) {
|
|
74
|
-
const currentState = getPluginState(view.state);
|
|
75
|
-
if (!currentState) {
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// make replacements in document for finished autoformats
|
|
80
|
-
if (currentState.matches) {
|
|
81
|
-
completeReplacements(view, currentState);
|
|
82
|
-
}
|
|
83
|
-
},
|
|
84
|
-
destroy() {
|
|
85
|
-
providerFactory.unsubscribe('autoformattingProvider', handleProvider);
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
},
|
|
89
|
-
key: pluginKey
|
|
90
|
-
});
|
|
91
|
-
};
|
|
92
|
-
const customAutoformatPlugin = () => ({
|
|
93
|
-
name: 'customAutoformat',
|
|
94
|
-
pmPlugins() {
|
|
95
|
-
return [{
|
|
96
|
-
name: 'customAutoformat',
|
|
97
|
-
plugin: createPMPlugin
|
|
98
|
-
}];
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
|
-
export default customAutoformatPlugin;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
const MAX_MATCH = 500;
|
|
2
|
-
|
|
3
|
-
// this is a modified version of
|
|
4
|
-
// https://github.com/ProseMirror/prosemirror-inputrules/blob/master/src/inputrules.js#L53
|
|
5
|
-
export const triggerInputRule = (view, rules, from, to, text) => {
|
|
6
|
-
const {
|
|
7
|
-
state
|
|
8
|
-
} = view;
|
|
9
|
-
const $from = state.doc.resolve(from);
|
|
10
|
-
if ($from.parent.type.spec.code) {
|
|
11
|
-
return false;
|
|
12
|
-
}
|
|
13
|
-
let textBefore = $from.parent.textBetween(Math.max(0, $from.parentOffset - MAX_MATCH), $from.parentOffset, undefined, '\ufffc') + text;
|
|
14
|
-
|
|
15
|
-
// loop through rules trying to find one that matches
|
|
16
|
-
for (let i = 0; i < rules.length; i++) {
|
|
17
|
-
let match;
|
|
18
|
-
if (text.length) {
|
|
19
|
-
match = rules[i].matchTyping.exec(textBefore);
|
|
20
|
-
} else {
|
|
21
|
-
match = rules[i].matchEnter.exec(textBefore);
|
|
22
|
-
}
|
|
23
|
-
if (match) {
|
|
24
|
-
// kick off the handler
|
|
25
|
-
const pos = from - (match[0].length - text.length);
|
|
26
|
-
rules[i].handler(view, match, pos, to);
|
|
27
|
-
return true;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
return false;
|
|
31
|
-
};
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
// queues a match at a given position in the document
|
|
2
|
-
const matched = (state, action) => ({
|
|
3
|
-
...state,
|
|
4
|
-
resolving: [...state.resolving, {
|
|
5
|
-
start: action.start,
|
|
6
|
-
end: action.end,
|
|
7
|
-
match: action.match
|
|
8
|
-
}]
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
// store the replacement for a match
|
|
12
|
-
const resolved = (state, action) => ({
|
|
13
|
-
...state,
|
|
14
|
-
matches: [...state.matches, {
|
|
15
|
-
replacement: action.replacement,
|
|
16
|
-
matchString: action.matchString
|
|
17
|
-
}]
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
// indicates a replacement in the document has been completed, and removes the match from both resolving and matches
|
|
21
|
-
const finish = (state, action) => {
|
|
22
|
-
return {
|
|
23
|
-
...state,
|
|
24
|
-
resolving: state.resolving.filter(resolving => resolving.match[0] !== action.matchString),
|
|
25
|
-
matches: state.matches.filter(matching => matching.matchString !== action.matchString)
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
const reduce = (state, action) => {
|
|
29
|
-
switch (action.action) {
|
|
30
|
-
case 'matched':
|
|
31
|
-
return matched(state, action);
|
|
32
|
-
case 'resolved':
|
|
33
|
-
return resolved(state, action);
|
|
34
|
-
case 'finish':
|
|
35
|
-
return finish(state, action);
|
|
36
|
-
default:
|
|
37
|
-
return state;
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
export default reduce;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
-
export const pluginKey = new PluginKey('customAutoformatPlugin');
|
|
3
|
-
export const getPluginState = editorState => pluginKey.getState(editorState);
|
|
4
|
-
export const autoformatAction = (tr, action) => {
|
|
5
|
-
return tr.setMeta(pluginKey, action);
|
|
6
|
-
};
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
-
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
3
|
-
import { closeHistory } from '@atlaskit/editor-prosemirror/history';
|
|
4
|
-
import { processRawValue } from '@atlaskit/editor-common/utils';
|
|
5
|
-
import { autoformatAction } from './utils';
|
|
6
|
-
export var buildHandler = function buildHandler(_regex, handler) {
|
|
7
|
-
return /*#__PURE__*/function () {
|
|
8
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(view, match, start, end) {
|
|
9
|
-
var replacementPromise, replacementData, replacementNode;
|
|
10
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
11
|
-
while (1) switch (_context.prev = _context.next) {
|
|
12
|
-
case 0:
|
|
13
|
-
replacementPromise = handler(match.slice(1, match.length - 1)); // queue the position and match pair so that we can remap across transactions
|
|
14
|
-
// while we wait for the replacmentPromise to resolve
|
|
15
|
-
view.dispatch(autoformatAction(view.state.tr, {
|
|
16
|
-
action: 'matched',
|
|
17
|
-
match: match,
|
|
18
|
-
start: start,
|
|
19
|
-
end: end
|
|
20
|
-
}));
|
|
21
|
-
|
|
22
|
-
// ask the provider to give us an ADF node to replace the text with
|
|
23
|
-
_context.next = 4;
|
|
24
|
-
return replacementPromise;
|
|
25
|
-
case 4:
|
|
26
|
-
replacementData = _context.sent;
|
|
27
|
-
replacementNode = processRawValue(view.state.schema, replacementData);
|
|
28
|
-
view.dispatch(autoformatAction(view.state.tr, {
|
|
29
|
-
action: 'resolved',
|
|
30
|
-
matchString: match[0],
|
|
31
|
-
replacement: replacementNode
|
|
32
|
-
}));
|
|
33
|
-
return _context.abrupt("return", replacementData);
|
|
34
|
-
case 8:
|
|
35
|
-
case "end":
|
|
36
|
-
return _context.stop();
|
|
37
|
-
}
|
|
38
|
-
}, _callee);
|
|
39
|
-
}));
|
|
40
|
-
return function (_x, _x2, _x3, _x4) {
|
|
41
|
-
return _ref.apply(this, arguments);
|
|
42
|
-
};
|
|
43
|
-
}();
|
|
44
|
-
};
|
|
45
|
-
export var completeReplacements = function completeReplacements(view, state) {
|
|
46
|
-
var inlineCard = view.state.schema.nodes.inlineCard;
|
|
47
|
-
state.matches.forEach(function (completedMatch) {
|
|
48
|
-
var matchingRequests = state.resolving.filter(function (candidate) {
|
|
49
|
-
return candidate.match[0] === completedMatch.matchString;
|
|
50
|
-
});
|
|
51
|
-
var tr = view.state.tr;
|
|
52
|
-
matchingRequests.forEach(function (request) {
|
|
53
|
-
var match = request.match,
|
|
54
|
-
start = request.start,
|
|
55
|
-
end = request.end;
|
|
56
|
-
var replacement = completedMatch.replacement;
|
|
57
|
-
var prefix = match[1];
|
|
58
|
-
var suffix = match[match.length - 1];
|
|
59
|
-
var matchEndPos = end + suffix.length;
|
|
60
|
-
|
|
61
|
-
// only permit inlineCard as replacement target for now
|
|
62
|
-
if (!replacement || replacement.type !== inlineCard && !replacement.isText) {
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// get the current document text, adding # or | if we cross node boundaries
|
|
67
|
-
var docText = view.state.doc.textBetween(start, matchEndPos, '#', '|');
|
|
68
|
-
|
|
69
|
-
// only replace if text still remains the same as when typed at the start
|
|
70
|
-
if (docText === match[0]) {
|
|
71
|
-
tr = tr.replaceWith(tr.mapping.map(start + prefix.length), tr.mapping.map(end, -1), replacement);
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
// clear this match from plugin state now that we've processed it
|
|
76
|
-
tr = autoformatAction(tr, {
|
|
77
|
-
action: 'finish',
|
|
78
|
-
matchString: completedMatch.matchString
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
// and dispatch the replacement, closing history for cmd+z to allow undo separately
|
|
82
|
-
view.dispatch(closeHistory(tr));
|
|
83
|
-
});
|
|
84
|
-
};
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
-
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
4
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
5
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
6
|
-
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
7
|
-
import { keydownHandler } from '@atlaskit/editor-prosemirror/keymap';
|
|
8
|
-
import reducers from './reducers';
|
|
9
|
-
import { triggerInputRule } from './input-rules';
|
|
10
|
-
import { completeReplacements, buildHandler } from './doc';
|
|
11
|
-
import { getPluginState, pluginKey } from './utils';
|
|
12
|
-
export var createPMPlugin = function createPMPlugin(_ref) {
|
|
13
|
-
var providerFactory = _ref.providerFactory;
|
|
14
|
-
var rules = [];
|
|
15
|
-
return new SafePlugin({
|
|
16
|
-
state: {
|
|
17
|
-
init: function init() {
|
|
18
|
-
return {
|
|
19
|
-
resolving: [],
|
|
20
|
-
matches: []
|
|
21
|
-
};
|
|
22
|
-
},
|
|
23
|
-
apply: function apply(tr, prevPluginState) {
|
|
24
|
-
if (!prevPluginState) {
|
|
25
|
-
return prevPluginState;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// remap positions
|
|
29
|
-
var remappedPluginState = _objectSpread(_objectSpread({}, prevPluginState), {}, {
|
|
30
|
-
resolving: prevPluginState.resolving.map(function (candidate) {
|
|
31
|
-
return _objectSpread(_objectSpread({}, candidate), {}, {
|
|
32
|
-
start: tr.mapping.map(candidate.start),
|
|
33
|
-
end: tr.mapping.map(candidate.end, -1)
|
|
34
|
-
});
|
|
35
|
-
})
|
|
36
|
-
});
|
|
37
|
-
var meta = tr.getMeta(pluginKey);
|
|
38
|
-
if (!meta) {
|
|
39
|
-
return remappedPluginState;
|
|
40
|
-
}
|
|
41
|
-
return reducers(remappedPluginState, meta);
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
|
-
props: {
|
|
45
|
-
handleTextInput: function handleTextInput(view, from, to, text) {
|
|
46
|
-
triggerInputRule(view, rules, from, to, text);
|
|
47
|
-
return false;
|
|
48
|
-
},
|
|
49
|
-
handleKeyDown: keydownHandler({
|
|
50
|
-
Enter: function Enter(_state, _dispatch, view) {
|
|
51
|
-
if (view) {
|
|
52
|
-
triggerInputRule(view, rules, view.state.selection.from, view.state.selection.to, '');
|
|
53
|
-
}
|
|
54
|
-
return false;
|
|
55
|
-
}
|
|
56
|
-
})
|
|
57
|
-
},
|
|
58
|
-
view: function view() {
|
|
59
|
-
var handleProvider = function handleProvider(name, provider) {
|
|
60
|
-
if (name !== 'autoformattingProvider' || !provider) {
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
provider.then( /*#__PURE__*/function () {
|
|
64
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(autoformattingProvider) {
|
|
65
|
-
var ruleset;
|
|
66
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
67
|
-
while (1) switch (_context.prev = _context.next) {
|
|
68
|
-
case 0:
|
|
69
|
-
_context.next = 2;
|
|
70
|
-
return autoformattingProvider.getRules();
|
|
71
|
-
case 2:
|
|
72
|
-
ruleset = _context.sent;
|
|
73
|
-
Object.keys(ruleset).forEach(function (rule) {
|
|
74
|
-
var inputRule = {
|
|
75
|
-
matchTyping: new RegExp('(\\s+|^)' + rule + '(\\s|,|\\.)$'),
|
|
76
|
-
matchEnter: new RegExp('(\\s+|^)' + rule + '()$'),
|
|
77
|
-
handler: buildHandler(rule, ruleset[rule])
|
|
78
|
-
};
|
|
79
|
-
rules.push(inputRule);
|
|
80
|
-
});
|
|
81
|
-
case 4:
|
|
82
|
-
case "end":
|
|
83
|
-
return _context.stop();
|
|
84
|
-
}
|
|
85
|
-
}, _callee);
|
|
86
|
-
}));
|
|
87
|
-
return function (_x) {
|
|
88
|
-
return _ref2.apply(this, arguments);
|
|
89
|
-
};
|
|
90
|
-
}());
|
|
91
|
-
};
|
|
92
|
-
providerFactory.subscribe('autoformattingProvider', handleProvider);
|
|
93
|
-
return {
|
|
94
|
-
update: function update(view) {
|
|
95
|
-
var currentState = getPluginState(view.state);
|
|
96
|
-
if (!currentState) {
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
// make replacements in document for finished autoformats
|
|
101
|
-
if (currentState.matches) {
|
|
102
|
-
completeReplacements(view, currentState);
|
|
103
|
-
}
|
|
104
|
-
},
|
|
105
|
-
destroy: function destroy() {
|
|
106
|
-
providerFactory.unsubscribe('autoformattingProvider', handleProvider);
|
|
107
|
-
}
|
|
108
|
-
};
|
|
109
|
-
},
|
|
110
|
-
key: pluginKey
|
|
111
|
-
});
|
|
112
|
-
};
|
|
113
|
-
var customAutoformatPlugin = function customAutoformatPlugin() {
|
|
114
|
-
return {
|
|
115
|
-
name: 'customAutoformat',
|
|
116
|
-
pmPlugins: function pmPlugins() {
|
|
117
|
-
return [{
|
|
118
|
-
name: 'customAutoformat',
|
|
119
|
-
plugin: createPMPlugin
|
|
120
|
-
}];
|
|
121
|
-
}
|
|
122
|
-
};
|
|
123
|
-
};
|
|
124
|
-
export default customAutoformatPlugin;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
var MAX_MATCH = 500;
|
|
2
|
-
|
|
3
|
-
// this is a modified version of
|
|
4
|
-
// https://github.com/ProseMirror/prosemirror-inputrules/blob/master/src/inputrules.js#L53
|
|
5
|
-
export var triggerInputRule = function triggerInputRule(view, rules, from, to, text) {
|
|
6
|
-
var state = view.state;
|
|
7
|
-
var $from = state.doc.resolve(from);
|
|
8
|
-
if ($from.parent.type.spec.code) {
|
|
9
|
-
return false;
|
|
10
|
-
}
|
|
11
|
-
var textBefore = $from.parent.textBetween(Math.max(0, $from.parentOffset - MAX_MATCH), $from.parentOffset, undefined, "\uFFFC") + text;
|
|
12
|
-
|
|
13
|
-
// loop through rules trying to find one that matches
|
|
14
|
-
for (var i = 0; i < rules.length; i++) {
|
|
15
|
-
var _match = void 0;
|
|
16
|
-
if (text.length) {
|
|
17
|
-
_match = rules[i].matchTyping.exec(textBefore);
|
|
18
|
-
} else {
|
|
19
|
-
_match = rules[i].matchEnter.exec(textBefore);
|
|
20
|
-
}
|
|
21
|
-
if (_match) {
|
|
22
|
-
// kick off the handler
|
|
23
|
-
var pos = from - (_match[0].length - text.length);
|
|
24
|
-
rules[i].handler(view, _match, pos, to);
|
|
25
|
-
return true;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
return false;
|
|
29
|
-
};
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5
|
-
// queues a match at a given position in the document
|
|
6
|
-
var matched = function matched(state, action) {
|
|
7
|
-
return _objectSpread(_objectSpread({}, state), {}, {
|
|
8
|
-
resolving: [].concat(_toConsumableArray(state.resolving), [{
|
|
9
|
-
start: action.start,
|
|
10
|
-
end: action.end,
|
|
11
|
-
match: action.match
|
|
12
|
-
}])
|
|
13
|
-
});
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
// store the replacement for a match
|
|
17
|
-
var resolved = function resolved(state, action) {
|
|
18
|
-
return _objectSpread(_objectSpread({}, state), {}, {
|
|
19
|
-
matches: [].concat(_toConsumableArray(state.matches), [{
|
|
20
|
-
replacement: action.replacement,
|
|
21
|
-
matchString: action.matchString
|
|
22
|
-
}])
|
|
23
|
-
});
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
// indicates a replacement in the document has been completed, and removes the match from both resolving and matches
|
|
27
|
-
var finish = function finish(state, action) {
|
|
28
|
-
return _objectSpread(_objectSpread({}, state), {}, {
|
|
29
|
-
resolving: state.resolving.filter(function (resolving) {
|
|
30
|
-
return resolving.match[0] !== action.matchString;
|
|
31
|
-
}),
|
|
32
|
-
matches: state.matches.filter(function (matching) {
|
|
33
|
-
return matching.matchString !== action.matchString;
|
|
34
|
-
})
|
|
35
|
-
});
|
|
36
|
-
};
|
|
37
|
-
var reduce = function reduce(state, action) {
|
|
38
|
-
switch (action.action) {
|
|
39
|
-
case 'matched':
|
|
40
|
-
return matched(state, action);
|
|
41
|
-
case 'resolved':
|
|
42
|
-
return resolved(state, action);
|
|
43
|
-
case 'finish':
|
|
44
|
-
return finish(state, action);
|
|
45
|
-
default:
|
|
46
|
-
return state;
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
export default reduce;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
-
export var pluginKey = new PluginKey('customAutoformatPlugin');
|
|
3
|
-
export var getPluginState = function getPluginState(editorState) {
|
|
4
|
-
return pluginKey.getState(editorState);
|
|
5
|
-
};
|
|
6
|
-
export var autoformatAction = function autoformatAction(tr, action) {
|
|
7
|
-
return tr.setMeta(pluginKey, action);
|
|
8
|
-
};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
2
|
-
import type { CustomAutoformatState } from './types';
|
|
3
|
-
import type { InputRuleHander } from './input-rules';
|
|
4
|
-
import type { AutoformatHandler } from '@atlaskit/editor-common/provider-factory';
|
|
5
|
-
export declare const buildHandler: (_regex: string, handler: AutoformatHandler) => InputRuleHander;
|
|
6
|
-
export declare const completeReplacements: (view: EditorView, state: CustomAutoformatState) => void;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
-
import type { NextEditorPlugin, PMPluginFactoryParams } from '../../types';
|
|
3
|
-
import type { CustomAutoformatState } from './types';
|
|
4
|
-
export declare const createPMPlugin: ({ providerFactory }: PMPluginFactoryParams) => SafePlugin<CustomAutoformatState>;
|
|
5
|
-
declare const customAutoformatPlugin: NextEditorPlugin<'customAutoformat'>;
|
|
6
|
-
export default customAutoformatPlugin;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
2
|
-
import type { AutoformatReplacement } from '@atlaskit/editor-common/provider-factory';
|
|
3
|
-
export type InputRuleHander = (view: EditorView, match: string[], start: number, end: number) => Promise<AutoformatReplacement>;
|
|
4
|
-
export type InputRule = {
|
|
5
|
-
matchTyping: RegExp;
|
|
6
|
-
matchEnter: RegExp;
|
|
7
|
-
handler: InputRuleHander;
|
|
8
|
-
};
|
|
9
|
-
export declare const triggerInputRule: (view: EditorView, rules: Array<InputRule>, from: number, to: number, text: string) => boolean;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import type { Node as ProsemirrorNode } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
-
export type { AutoformatHandler, AutoformatReplacement, AutoformattingProvider, AutoformatRuleset as Ruleset, } from '@atlaskit/editor-common/provider-factory';
|
|
3
|
-
export type AutoformatCandidate = {
|
|
4
|
-
start: number;
|
|
5
|
-
end: number;
|
|
6
|
-
match: string[];
|
|
7
|
-
};
|
|
8
|
-
export type AutoformatMatch = {
|
|
9
|
-
matchString: string;
|
|
10
|
-
replacement?: ProsemirrorNode;
|
|
11
|
-
};
|
|
12
|
-
export type CustomAutoformatState = {
|
|
13
|
-
resolving: Array<AutoformatCandidate>;
|
|
14
|
-
matches: Array<AutoformatMatch>;
|
|
15
|
-
};
|
|
16
|
-
export type CustomAutoformatMatched = {
|
|
17
|
-
action: 'matched';
|
|
18
|
-
start: number;
|
|
19
|
-
end: number;
|
|
20
|
-
match: string[];
|
|
21
|
-
};
|
|
22
|
-
export type CustomAutoformatResolved = {
|
|
23
|
-
action: 'resolved';
|
|
24
|
-
matchString: string;
|
|
25
|
-
replacement?: ProsemirrorNode;
|
|
26
|
-
};
|
|
27
|
-
export type CustomAutoformatFinish = {
|
|
28
|
-
action: 'finish';
|
|
29
|
-
matchString: string;
|
|
30
|
-
};
|
|
31
|
-
export type CustomAutoformatAction = CustomAutoformatMatched | CustomAutoformatResolved | CustomAutoformatFinish;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
-
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
-
import type { CustomAutoformatState, CustomAutoformatAction } from './types';
|
|
4
|
-
export declare const pluginKey: PluginKey<any>;
|
|
5
|
-
export declare const getPluginState: (editorState: EditorState) => CustomAutoformatState | undefined;
|
|
6
|
-
export declare const autoformatAction: (tr: Transaction, action: CustomAutoformatAction) => Transaction;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
2
|
-
import type { CustomAutoformatState } from './types';
|
|
3
|
-
import type { InputRuleHander } from './input-rules';
|
|
4
|
-
import type { AutoformatHandler } from '@atlaskit/editor-common/provider-factory';
|
|
5
|
-
export declare const buildHandler: (_regex: string, handler: AutoformatHandler) => InputRuleHander;
|
|
6
|
-
export declare const completeReplacements: (view: EditorView, state: CustomAutoformatState) => void;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
-
import type { NextEditorPlugin, PMPluginFactoryParams } from '../../types';
|
|
3
|
-
import type { CustomAutoformatState } from './types';
|
|
4
|
-
export declare const createPMPlugin: ({ providerFactory }: PMPluginFactoryParams) => SafePlugin<CustomAutoformatState>;
|
|
5
|
-
declare const customAutoformatPlugin: NextEditorPlugin<'customAutoformat'>;
|
|
6
|
-
export default customAutoformatPlugin;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
2
|
-
import type { AutoformatReplacement } from '@atlaskit/editor-common/provider-factory';
|
|
3
|
-
export type InputRuleHander = (view: EditorView, match: string[], start: number, end: number) => Promise<AutoformatReplacement>;
|
|
4
|
-
export type InputRule = {
|
|
5
|
-
matchTyping: RegExp;
|
|
6
|
-
matchEnter: RegExp;
|
|
7
|
-
handler: InputRuleHander;
|
|
8
|
-
};
|
|
9
|
-
export declare const triggerInputRule: (view: EditorView, rules: Array<InputRule>, from: number, to: number, text: string) => boolean;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import type { Node as ProsemirrorNode } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
-
export type { AutoformatHandler, AutoformatReplacement, AutoformattingProvider, AutoformatRuleset as Ruleset, } from '@atlaskit/editor-common/provider-factory';
|
|
3
|
-
export type AutoformatCandidate = {
|
|
4
|
-
start: number;
|
|
5
|
-
end: number;
|
|
6
|
-
match: string[];
|
|
7
|
-
};
|
|
8
|
-
export type AutoformatMatch = {
|
|
9
|
-
matchString: string;
|
|
10
|
-
replacement?: ProsemirrorNode;
|
|
11
|
-
};
|
|
12
|
-
export type CustomAutoformatState = {
|
|
13
|
-
resolving: Array<AutoformatCandidate>;
|
|
14
|
-
matches: Array<AutoformatMatch>;
|
|
15
|
-
};
|
|
16
|
-
export type CustomAutoformatMatched = {
|
|
17
|
-
action: 'matched';
|
|
18
|
-
start: number;
|
|
19
|
-
end: number;
|
|
20
|
-
match: string[];
|
|
21
|
-
};
|
|
22
|
-
export type CustomAutoformatResolved = {
|
|
23
|
-
action: 'resolved';
|
|
24
|
-
matchString: string;
|
|
25
|
-
replacement?: ProsemirrorNode;
|
|
26
|
-
};
|
|
27
|
-
export type CustomAutoformatFinish = {
|
|
28
|
-
action: 'finish';
|
|
29
|
-
matchString: string;
|
|
30
|
-
};
|
|
31
|
-
export type CustomAutoformatAction = CustomAutoformatMatched | CustomAutoformatResolved | CustomAutoformatFinish;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
-
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
-
import type { CustomAutoformatState, CustomAutoformatAction } from './types';
|
|
4
|
-
export declare const pluginKey: PluginKey<any>;
|
|
5
|
-
export declare const getPluginState: (editorState: EditorState) => CustomAutoformatState | undefined;
|
|
6
|
-
export declare const autoformatAction: (tr: Transaction, action: CustomAutoformatAction) => Transaction;
|