@atlaskit/editor-plugin-rule 1.9.8 → 1.9.10
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 +12 -0
- package/dist/cjs/pm-plugins/input-rule.js +21 -4
- package/dist/cjs/pm-plugins/keymap.js +7 -1
- package/dist/cjs/rulePlugin.js +6 -0
- package/dist/es2019/index.js +3 -0
- package/dist/es2019/pm-plugins/input-rule.js +21 -4
- package/dist/es2019/pm-plugins/keymap.js +7 -1
- package/dist/es2019/rulePlugin.js +5 -1
- package/dist/esm/index.js +3 -0
- package/dist/esm/pm-plugins/input-rule.js +21 -4
- package/dist/esm/pm-plugins/keymap.js +7 -1
- package/dist/esm/rulePlugin.js +4 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -12,7 +12,10 @@ var _utils = require("@atlaskit/editor-common/utils");
|
|
|
12
12
|
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
13
13
|
var _utils2 = require("@atlaskit/editor-prosemirror/utils");
|
|
14
14
|
var _prosemirrorInputRules = require("@atlaskit/prosemirror-input-rules");
|
|
15
|
-
var createHorizontalRule = exports.createHorizontalRule = function createHorizontalRule(state, start, end, inputMethod, editorAnalyticsAPI
|
|
15
|
+
var createHorizontalRule = exports.createHorizontalRule = function createHorizontalRule(state, start, end, inputMethod, editorAnalyticsAPI
|
|
16
|
+
// Ignored via go/ees005
|
|
17
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
18
|
+
) {
|
|
16
19
|
if (!state.selection.empty) {
|
|
17
20
|
return null;
|
|
18
21
|
}
|
|
@@ -39,7 +42,10 @@ var createHorizontalRule = exports.createHorizontalRule = function createHorizon
|
|
|
39
42
|
})(tr);
|
|
40
43
|
return tr;
|
|
41
44
|
};
|
|
42
|
-
var createHorizontalRuleAutoformat = function createHorizontalRuleAutoformat(state, start, end, editorAnalyticsAPI
|
|
45
|
+
var createHorizontalRuleAutoformat = function createHorizontalRuleAutoformat(state, start, end, editorAnalyticsAPI
|
|
46
|
+
// Ignored via go/ees005
|
|
47
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
48
|
+
) {
|
|
43
49
|
var listItem = state.schema.nodes.listItem;
|
|
44
50
|
if ((0, _utils2.hasParentNodeOfType)(listItem)(state.selection)) {
|
|
45
51
|
return null;
|
|
@@ -50,13 +56,24 @@ function inputRulePlugin(schema, editorAnalyticsAPI) {
|
|
|
50
56
|
var rules = [];
|
|
51
57
|
if (schema.nodes.rule) {
|
|
52
58
|
// '---' and '***' for hr
|
|
53
|
-
rules.push(
|
|
59
|
+
rules.push(
|
|
60
|
+
// Ignored via go/ees005
|
|
61
|
+
// eslint-disable-next-line require-unicode-regexp, @typescript-eslint/max-params
|
|
62
|
+
(0, _utils.createRule)(/^(\-\-\-|\*\*\*)$/, function (state, _match, start, end) {
|
|
54
63
|
return createHorizontalRuleAutoformat(state, start, end, editorAnalyticsAPI);
|
|
55
64
|
}));
|
|
56
65
|
|
|
57
66
|
// '---' and '***' after shift+enter for hr
|
|
58
|
-
rules.push((0, _utils.createRule)(
|
|
67
|
+
rules.push((0, _utils.createRule)(
|
|
68
|
+
// Ignored via go/ees005
|
|
69
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
70
|
+
new RegExp("".concat(_prosemirrorInputRules.leafNodeReplacementCharacter, "(\\-\\-\\-|\\*\\*\\*)")),
|
|
71
|
+
// Ignored via go/ees005
|
|
72
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
73
|
+
function (state, _match, start, end) {
|
|
59
74
|
var hardBreak = state.schema.nodes.hardBreak;
|
|
75
|
+
// Ignored via go/ees005
|
|
76
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
60
77
|
if (state.doc.resolve(start).nodeAfter.type !== hardBreak) {
|
|
61
78
|
return null;
|
|
62
79
|
}
|
|
@@ -11,7 +11,13 @@ var _keymap = require("@atlaskit/editor-prosemirror/keymap");
|
|
|
11
11
|
var _commands = require("./commands");
|
|
12
12
|
function keymapPlugin(editorAnalyticsAPI) {
|
|
13
13
|
var list = {};
|
|
14
|
-
(0, _keymaps.bindKeymapWithCommand)(
|
|
14
|
+
(0, _keymaps.bindKeymapWithCommand)(
|
|
15
|
+
// Ignored via go/ees005
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
17
|
+
_keymaps.insertRule.common, (0, _commands.insertHorizontalRule)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.SHORTCUT), list);
|
|
18
|
+
|
|
19
|
+
// Ignored via go/ees005
|
|
20
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
15
21
|
(0, _keymaps.bindKeymapWithCommand)(_keymaps.escape.common, function () {
|
|
16
22
|
return true;
|
|
17
23
|
}, list);
|
package/dist/cjs/rulePlugin.js
CHANGED
|
@@ -13,6 +13,12 @@ var _quickInsert = require("@atlaskit/editor-common/quick-insert");
|
|
|
13
13
|
var _commands = require("./pm-plugins/commands");
|
|
14
14
|
var _inputRule = _interopRequireDefault(require("./pm-plugins/input-rule"));
|
|
15
15
|
var _keymap = _interopRequireDefault(require("./pm-plugins/keymap"));
|
|
16
|
+
// Ignored via go/ees005
|
|
17
|
+
// eslint-disable-next-line import/no-named-as-default
|
|
18
|
+
|
|
19
|
+
// Ignored via go/ees005
|
|
20
|
+
// eslint-disable-next-line import/no-named-as-default
|
|
21
|
+
|
|
16
22
|
var rulePlugin = exports.rulePlugin = function rulePlugin(_ref) {
|
|
17
23
|
var _api$analytics;
|
|
18
24
|
var api = _ref.api;
|
package/dist/es2019/index.js
CHANGED
|
@@ -5,7 +5,10 @@ import { createRule } from '@atlaskit/editor-common/utils';
|
|
|
5
5
|
import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
|
|
6
6
|
import { hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
7
7
|
import { createPlugin, leafNodeReplacementCharacter } from '@atlaskit/prosemirror-input-rules';
|
|
8
|
-
export const createHorizontalRule = (state, start, end, inputMethod, editorAnalyticsAPI
|
|
8
|
+
export const createHorizontalRule = (state, start, end, inputMethod, editorAnalyticsAPI
|
|
9
|
+
// Ignored via go/ees005
|
|
10
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
11
|
+
) => {
|
|
9
12
|
if (!state.selection.empty) {
|
|
10
13
|
return null;
|
|
11
14
|
}
|
|
@@ -34,7 +37,10 @@ export const createHorizontalRule = (state, start, end, inputMethod, editorAnaly
|
|
|
34
37
|
})(tr);
|
|
35
38
|
return tr;
|
|
36
39
|
};
|
|
37
|
-
const createHorizontalRuleAutoformat = (state, start, end, editorAnalyticsAPI
|
|
40
|
+
const createHorizontalRuleAutoformat = (state, start, end, editorAnalyticsAPI
|
|
41
|
+
// Ignored via go/ees005
|
|
42
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
43
|
+
) => {
|
|
38
44
|
const {
|
|
39
45
|
listItem
|
|
40
46
|
} = state.schema.nodes;
|
|
@@ -47,13 +53,24 @@ export function inputRulePlugin(schema, editorAnalyticsAPI) {
|
|
|
47
53
|
const rules = [];
|
|
48
54
|
if (schema.nodes.rule) {
|
|
49
55
|
// '---' and '***' for hr
|
|
50
|
-
rules.push(
|
|
56
|
+
rules.push(
|
|
57
|
+
// Ignored via go/ees005
|
|
58
|
+
// eslint-disable-next-line require-unicode-regexp, @typescript-eslint/max-params
|
|
59
|
+
createRule(/^(\-\-\-|\*\*\*)$/, (state, _match, start, end) => createHorizontalRuleAutoformat(state, start, end, editorAnalyticsAPI)));
|
|
51
60
|
|
|
52
61
|
// '---' and '***' after shift+enter for hr
|
|
53
|
-
rules.push(createRule(
|
|
62
|
+
rules.push(createRule(
|
|
63
|
+
// Ignored via go/ees005
|
|
64
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
65
|
+
new RegExp(`${leafNodeReplacementCharacter}(\\-\\-\\-|\\*\\*\\*)`),
|
|
66
|
+
// Ignored via go/ees005
|
|
67
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
68
|
+
(state, _match, start, end) => {
|
|
54
69
|
const {
|
|
55
70
|
hardBreak
|
|
56
71
|
} = state.schema.nodes;
|
|
72
|
+
// Ignored via go/ees005
|
|
73
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
57
74
|
if (state.doc.resolve(start).nodeAfter.type !== hardBreak) {
|
|
58
75
|
return null;
|
|
59
76
|
}
|
|
@@ -4,7 +4,13 @@ import { keymap } from '@atlaskit/editor-prosemirror/keymap';
|
|
|
4
4
|
import { insertHorizontalRule } from './commands';
|
|
5
5
|
export function keymapPlugin(editorAnalyticsAPI) {
|
|
6
6
|
const list = {};
|
|
7
|
-
bindKeymapWithCommand(
|
|
7
|
+
bindKeymapWithCommand(
|
|
8
|
+
// Ignored via go/ees005
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
10
|
+
insertRule.common, insertHorizontalRule(editorAnalyticsAPI)(INPUT_METHOD.SHORTCUT), list);
|
|
11
|
+
|
|
12
|
+
// Ignored via go/ees005
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
8
14
|
bindKeymapWithCommand(escape.common, () => true, list);
|
|
9
15
|
return keymap(list);
|
|
10
16
|
}
|
|
@@ -4,7 +4,11 @@ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } f
|
|
|
4
4
|
import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
|
|
5
5
|
import { IconDivider } from '@atlaskit/editor-common/quick-insert';
|
|
6
6
|
import { insertHorizontalRule } from './pm-plugins/commands';
|
|
7
|
+
// Ignored via go/ees005
|
|
8
|
+
// eslint-disable-next-line import/no-named-as-default
|
|
7
9
|
import inputRulePlugin from './pm-plugins/input-rule';
|
|
10
|
+
// Ignored via go/ees005
|
|
11
|
+
// eslint-disable-next-line import/no-named-as-default
|
|
8
12
|
import keymapPlugin from './pm-plugins/keymap';
|
|
9
13
|
export const rulePlugin = ({
|
|
10
14
|
api
|
|
@@ -51,7 +55,7 @@ export const rulePlugin = ({
|
|
|
51
55
|
icon: () => /*#__PURE__*/React.createElement(IconDivider, null),
|
|
52
56
|
action(insert, state) {
|
|
53
57
|
var _api$analytics4;
|
|
54
|
-
|
|
58
|
+
const tr = insert(state.schema.nodes.rule.createChecked());
|
|
55
59
|
api === null || api === void 0 ? void 0 : (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions.attachAnalyticsEvent({
|
|
56
60
|
action: ACTION.INSERTED,
|
|
57
61
|
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
package/dist/esm/index.js
CHANGED
|
@@ -5,7 +5,10 @@ import { createRule } from '@atlaskit/editor-common/utils';
|
|
|
5
5
|
import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
|
|
6
6
|
import { hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
7
7
|
import { createPlugin, leafNodeReplacementCharacter } from '@atlaskit/prosemirror-input-rules';
|
|
8
|
-
export var createHorizontalRule = function createHorizontalRule(state, start, end, inputMethod, editorAnalyticsAPI
|
|
8
|
+
export var createHorizontalRule = function createHorizontalRule(state, start, end, inputMethod, editorAnalyticsAPI
|
|
9
|
+
// Ignored via go/ees005
|
|
10
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
11
|
+
) {
|
|
9
12
|
if (!state.selection.empty) {
|
|
10
13
|
return null;
|
|
11
14
|
}
|
|
@@ -32,7 +35,10 @@ export var createHorizontalRule = function createHorizontalRule(state, start, en
|
|
|
32
35
|
})(tr);
|
|
33
36
|
return tr;
|
|
34
37
|
};
|
|
35
|
-
var createHorizontalRuleAutoformat = function createHorizontalRuleAutoformat(state, start, end, editorAnalyticsAPI
|
|
38
|
+
var createHorizontalRuleAutoformat = function createHorizontalRuleAutoformat(state, start, end, editorAnalyticsAPI
|
|
39
|
+
// Ignored via go/ees005
|
|
40
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
41
|
+
) {
|
|
36
42
|
var listItem = state.schema.nodes.listItem;
|
|
37
43
|
if (hasParentNodeOfType(listItem)(state.selection)) {
|
|
38
44
|
return null;
|
|
@@ -43,13 +49,24 @@ export function inputRulePlugin(schema, editorAnalyticsAPI) {
|
|
|
43
49
|
var rules = [];
|
|
44
50
|
if (schema.nodes.rule) {
|
|
45
51
|
// '---' and '***' for hr
|
|
46
|
-
rules.push(
|
|
52
|
+
rules.push(
|
|
53
|
+
// Ignored via go/ees005
|
|
54
|
+
// eslint-disable-next-line require-unicode-regexp, @typescript-eslint/max-params
|
|
55
|
+
createRule(/^(\-\-\-|\*\*\*)$/, function (state, _match, start, end) {
|
|
47
56
|
return createHorizontalRuleAutoformat(state, start, end, editorAnalyticsAPI);
|
|
48
57
|
}));
|
|
49
58
|
|
|
50
59
|
// '---' and '***' after shift+enter for hr
|
|
51
|
-
rules.push(createRule(
|
|
60
|
+
rules.push(createRule(
|
|
61
|
+
// Ignored via go/ees005
|
|
62
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
63
|
+
new RegExp("".concat(leafNodeReplacementCharacter, "(\\-\\-\\-|\\*\\*\\*)")),
|
|
64
|
+
// Ignored via go/ees005
|
|
65
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
66
|
+
function (state, _match, start, end) {
|
|
52
67
|
var hardBreak = state.schema.nodes.hardBreak;
|
|
68
|
+
// Ignored via go/ees005
|
|
69
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
53
70
|
if (state.doc.resolve(start).nodeAfter.type !== hardBreak) {
|
|
54
71
|
return null;
|
|
55
72
|
}
|
|
@@ -4,7 +4,13 @@ import { keymap } from '@atlaskit/editor-prosemirror/keymap';
|
|
|
4
4
|
import { insertHorizontalRule } from './commands';
|
|
5
5
|
export function keymapPlugin(editorAnalyticsAPI) {
|
|
6
6
|
var list = {};
|
|
7
|
-
bindKeymapWithCommand(
|
|
7
|
+
bindKeymapWithCommand(
|
|
8
|
+
// Ignored via go/ees005
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
10
|
+
insertRule.common, insertHorizontalRule(editorAnalyticsAPI)(INPUT_METHOD.SHORTCUT), list);
|
|
11
|
+
|
|
12
|
+
// Ignored via go/ees005
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
8
14
|
bindKeymapWithCommand(escape.common, function () {
|
|
9
15
|
return true;
|
|
10
16
|
}, list);
|
package/dist/esm/rulePlugin.js
CHANGED
|
@@ -4,7 +4,11 @@ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } f
|
|
|
4
4
|
import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
|
|
5
5
|
import { IconDivider } from '@atlaskit/editor-common/quick-insert';
|
|
6
6
|
import { insertHorizontalRule } from './pm-plugins/commands';
|
|
7
|
+
// Ignored via go/ees005
|
|
8
|
+
// eslint-disable-next-line import/no-named-as-default
|
|
7
9
|
import inputRulePlugin from './pm-plugins/input-rule';
|
|
10
|
+
// Ignored via go/ees005
|
|
11
|
+
// eslint-disable-next-line import/no-named-as-default
|
|
8
12
|
import keymapPlugin from './pm-plugins/keymap';
|
|
9
13
|
export var rulePlugin = function rulePlugin(_ref) {
|
|
10
14
|
var _api$analytics;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-rule",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.10",
|
|
4
4
|
"description": "Rule plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@atlaskit/adf-schema": "^46.1.0",
|
|
35
|
-
"@atlaskit/editor-common": "^
|
|
35
|
+
"@atlaskit/editor-common": "^98.0.0",
|
|
36
36
|
"@atlaskit/editor-plugin-analytics": "^1.10.0",
|
|
37
37
|
"@atlaskit/editor-prosemirror": "6.2.1",
|
|
38
38
|
"@atlaskit/prosemirror-input-rules": "^3.2.0",
|