@atlaskit/editor-plugin-rule 0.1.0
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 +1 -0
- package/LICENSE.md +13 -0
- package/README.md +30 -0
- package/dist/cjs/commands.js +22 -0
- package/dist/cjs/index.js +12 -0
- package/dist/cjs/plugin.js +79 -0
- package/dist/cjs/pm-plugins/input-rule.js +76 -0
- package/dist/cjs/pm-plugins/keymap.js +21 -0
- package/dist/es2019/commands.js +11 -0
- package/dist/es2019/index.js +1 -0
- package/dist/es2019/plugin.js +70 -0
- package/dist/es2019/pm-plugins/input-rule.js +73 -0
- package/dist/es2019/pm-plugins/keymap.js +11 -0
- package/dist/esm/commands.js +15 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/plugin.js +71 -0
- package/dist/esm/pm-plugins/input-rule.js +67 -0
- package/dist/esm/pm-plugins/keymap.js +13 -0
- package/dist/types/commands.d.ts +3 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/plugin.d.ts +12 -0
- package/dist/types/pm-plugins/input-rule.d.ts +9 -0
- package/dist/types/pm-plugins/keymap.d.ts +5 -0
- package/dist/types-ts4.5/commands.d.ts +3 -0
- package/dist/types-ts4.5/index.d.ts +2 -0
- package/dist/types-ts4.5/plugin.d.ts +15 -0
- package/dist/types-ts4.5/pm-plugins/input-rule.d.ts +9 -0
- package/dist/types-ts4.5/pm-plugins/keymap.d.ts +5 -0
- package/package.json +87 -0
- package/report.api.md +70 -0
- package/tmp/api-report-tmp.d.ts +33 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# @atlaskit/editor-plugin-rule
|
package/LICENSE.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Copyright 2023 Atlassian Pty Ltd
|
|
2
|
+
|
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License.
|
|
5
|
+
You may obtain a copy of the License at
|
|
6
|
+
|
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
|
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
See the License for the specific language governing permissions and
|
|
13
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Editor plugin rule
|
|
2
|
+
|
|
3
|
+
Rule plugin for @atlaskit/editor-core
|
|
4
|
+
|
|
5
|
+
**Note:** This component is designed for internal Atlassian development.
|
|
6
|
+
External contributors will be able to use this component but will not be able to submit issues.
|
|
7
|
+
|
|
8
|
+
## Install
|
|
9
|
+
---
|
|
10
|
+
- **Install** - *yarn add @atlaskit/editor-plugin-rule*
|
|
11
|
+
- **npm** - [@atlaskit/editor-plugin-rule](https://www.npmjs.com/package/@atlaskit/editor-plugin-rule)
|
|
12
|
+
- **Source** - [Bitbucket](https://bitbucket.org/atlassian/atlassian-frontend/src/master/packages/editor/editor-plugin-rule)
|
|
13
|
+
- **Bundle** - [unpkg.com](https://unpkg.com/@atlaskit/editor-plugin-rule/dist/)
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
---
|
|
17
|
+
**Internal use only**
|
|
18
|
+
|
|
19
|
+
@atlaskit/editor-plugin-rule is intended for internal use by the @atlaskit/editor-core and as a plugin dependency of the Editor within your product.
|
|
20
|
+
|
|
21
|
+
Direct use of this component is not supported.
|
|
22
|
+
|
|
23
|
+
Please see [Atlaskit - Editor plugin rule](https://atlaskit.atlassian.com/packages/editor/editor-plugin-rule) for documentation and examples for this package.
|
|
24
|
+
|
|
25
|
+
## Support
|
|
26
|
+
---
|
|
27
|
+
For internal Atlassian, visit the slack channel [#help-editor](https://atlassian.slack.com/archives/CFG3PSQ9E) for support or visit [go/editor-help](https://go/editor-help) to submit a bug.
|
|
28
|
+
## License
|
|
29
|
+
---
|
|
30
|
+
Please see [Atlassian Frontend - License](https://developer.atlassian.com/cloud/framework/atlassian-frontend/#license) for more licensing information.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.insertHorizontalRule = void 0;
|
|
7
|
+
var _inputRule = require("./pm-plugins/input-rule");
|
|
8
|
+
var insertHorizontalRule = function insertHorizontalRule(featureFlags, editorAnalyticsAPI) {
|
|
9
|
+
return function (inputMethod) {
|
|
10
|
+
return function (state, dispatch) {
|
|
11
|
+
var tr = (0, _inputRule.createHorizontalRule)(state, featureFlags, state.selection.from, state.selection.to, inputMethod, editorAnalyticsAPI);
|
|
12
|
+
if (tr) {
|
|
13
|
+
if (dispatch) {
|
|
14
|
+
dispatch(tr);
|
|
15
|
+
}
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
return false;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
exports.insertHorizontalRule = insertHorizontalRule;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.rulePlugin = void 0;
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _adfSchema = require("@atlaskit/adf-schema");
|
|
10
|
+
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
11
|
+
var _messages = require("@atlaskit/editor-common/messages");
|
|
12
|
+
var _quickInsert = require("@atlaskit/editor-common/quick-insert");
|
|
13
|
+
var _commands = require("./commands");
|
|
14
|
+
var _inputRule = _interopRequireDefault(require("./pm-plugins/input-rule"));
|
|
15
|
+
var _keymap = _interopRequireDefault(require("./pm-plugins/keymap"));
|
|
16
|
+
var rulePlugin = function rulePlugin(_ref) {
|
|
17
|
+
var _api$featureFlags, _api$analytics;
|
|
18
|
+
var api = _ref.api;
|
|
19
|
+
var featureFlags = (api === null || api === void 0 ? void 0 : (_api$featureFlags = api.featureFlags) === null || _api$featureFlags === void 0 ? void 0 : _api$featureFlags.sharedState.currentState()) || {};
|
|
20
|
+
return {
|
|
21
|
+
name: 'rule',
|
|
22
|
+
nodes: function nodes() {
|
|
23
|
+
return [{
|
|
24
|
+
name: 'rule',
|
|
25
|
+
node: _adfSchema.rule
|
|
26
|
+
}];
|
|
27
|
+
},
|
|
28
|
+
actions: {
|
|
29
|
+
insertHorizontalRule: (0, _commands.insertHorizontalRule)(featureFlags, api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions)
|
|
30
|
+
},
|
|
31
|
+
pmPlugins: function pmPlugins() {
|
|
32
|
+
return [{
|
|
33
|
+
name: 'ruleInputRule',
|
|
34
|
+
plugin: function plugin(_ref2) {
|
|
35
|
+
var _api$analytics2;
|
|
36
|
+
var schema = _ref2.schema;
|
|
37
|
+
return (0, _inputRule.default)(schema, featureFlags, api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions);
|
|
38
|
+
}
|
|
39
|
+
}, {
|
|
40
|
+
name: 'ruleKeymap',
|
|
41
|
+
plugin: function plugin() {
|
|
42
|
+
var _api$analytics3;
|
|
43
|
+
return (0, _keymap.default)(featureFlags, api === null || api === void 0 ? void 0 : (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions);
|
|
44
|
+
}
|
|
45
|
+
}];
|
|
46
|
+
},
|
|
47
|
+
pluginsOptions: {
|
|
48
|
+
quickInsert: function quickInsert(_ref3) {
|
|
49
|
+
var formatMessage = _ref3.formatMessage;
|
|
50
|
+
return [{
|
|
51
|
+
id: 'rule',
|
|
52
|
+
title: formatMessage(_messages.toolbarInsertBlockMessages.horizontalRule),
|
|
53
|
+
description: formatMessage(_messages.toolbarInsertBlockMessages.horizontalRuleDescription),
|
|
54
|
+
keywords: ['horizontal', 'rule', 'line', 'hr'],
|
|
55
|
+
priority: 1200,
|
|
56
|
+
keyshortcut: '---',
|
|
57
|
+
icon: function icon() {
|
|
58
|
+
return /*#__PURE__*/_react.default.createElement(_quickInsert.IconDivider, null);
|
|
59
|
+
},
|
|
60
|
+
action: function action(insert, state) {
|
|
61
|
+
var _api$analytics4;
|
|
62
|
+
var tr = insert(state.schema.nodes.rule.createChecked());
|
|
63
|
+
api === null || api === void 0 ? void 0 : (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions.attachAnalyticsEvent({
|
|
64
|
+
action: _analytics.ACTION.INSERTED,
|
|
65
|
+
actionSubject: _analytics.ACTION_SUBJECT.DOCUMENT,
|
|
66
|
+
actionSubjectId: _analytics.ACTION_SUBJECT_ID.DIVIDER,
|
|
67
|
+
attributes: {
|
|
68
|
+
inputMethod: _analytics.INPUT_METHOD.QUICK_INSERT
|
|
69
|
+
},
|
|
70
|
+
eventType: _analytics.EVENT_TYPE.TRACK
|
|
71
|
+
})(tr);
|
|
72
|
+
return tr;
|
|
73
|
+
}
|
|
74
|
+
}];
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
exports.rulePlugin = rulePlugin;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.createHorizontalRule = void 0;
|
|
7
|
+
exports.inputRulePlugin = inputRulePlugin;
|
|
8
|
+
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
9
|
+
var _insert = require("@atlaskit/editor-common/insert");
|
|
10
|
+
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
11
|
+
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
12
|
+
var _prosemirrorInputRules = require("@atlaskit/prosemirror-input-rules");
|
|
13
|
+
var createHorizontalRule = function createHorizontalRule(state, featureFlags, start, end, inputMethod, editorAnalyticsAPI) {
|
|
14
|
+
if (!state.selection.empty) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
var tr = null;
|
|
18
|
+
var rule = state.schema.nodes.rule;
|
|
19
|
+
var newInsertionBehaviour = featureFlags.newInsertionBehaviour;
|
|
20
|
+
if (newInsertionBehaviour) {
|
|
21
|
+
/**
|
|
22
|
+
* This is a workaround to get rid of the typeahead text when using quick insert
|
|
23
|
+
* Once we insert *nothing*, we get a new transaction, so we can use the new selection
|
|
24
|
+
* without considering the extra text after the `/` command.
|
|
25
|
+
**/
|
|
26
|
+
tr = state.tr.replaceWith(start, end, _model.Fragment.empty);
|
|
27
|
+
tr = (0, _insert.safeInsert)(rule.createChecked(), tr.selection.from)(tr);
|
|
28
|
+
}
|
|
29
|
+
if (!tr) {
|
|
30
|
+
tr = state.tr.replaceRange(start, end, new _model.Slice(_model.Fragment.from(state.schema.nodes.rule.createChecked()), 0, 0));
|
|
31
|
+
}
|
|
32
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
|
|
33
|
+
action: _analytics.ACTION.INSERTED,
|
|
34
|
+
actionSubject: _analytics.ACTION_SUBJECT.DOCUMENT,
|
|
35
|
+
actionSubjectId: _analytics.ACTION_SUBJECT_ID.DIVIDER,
|
|
36
|
+
attributes: {
|
|
37
|
+
inputMethod: inputMethod
|
|
38
|
+
},
|
|
39
|
+
eventType: _analytics.EVENT_TYPE.TRACK
|
|
40
|
+
})(tr);
|
|
41
|
+
return tr;
|
|
42
|
+
};
|
|
43
|
+
exports.createHorizontalRule = createHorizontalRule;
|
|
44
|
+
var createHorizontalRuleAutoformat = function createHorizontalRuleAutoformat(state, featureFlags, start, end, editorAnalyticsAPI) {
|
|
45
|
+
var listItem = state.schema.nodes.listItem;
|
|
46
|
+
if ((0, _utils.hasParentNodeOfType)(listItem)(state.selection)) {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
return createHorizontalRule(state, featureFlags, start, end, _analytics.INPUT_METHOD.FORMATTING, editorAnalyticsAPI);
|
|
50
|
+
};
|
|
51
|
+
function inputRulePlugin(schema, featureFlags, editorAnalyticsAPI) {
|
|
52
|
+
var rules = [];
|
|
53
|
+
if (schema.nodes.rule) {
|
|
54
|
+
// '---' and '***' for hr
|
|
55
|
+
rules.push((0, _prosemirrorInputRules.createRule)(/^(\-\-\-|\*\*\*)$/, function (state, _match, start, end) {
|
|
56
|
+
return createHorizontalRuleAutoformat(state, featureFlags, start, end, editorAnalyticsAPI);
|
|
57
|
+
}));
|
|
58
|
+
|
|
59
|
+
// '---' and '***' after shift+enter for hr
|
|
60
|
+
rules.push((0, _prosemirrorInputRules.createRule)(new RegExp("".concat(_prosemirrorInputRules.leafNodeReplacementCharacter, "(\\-\\-\\-|\\*\\*\\*)")), function (state, _match, start, end) {
|
|
61
|
+
var hardBreak = state.schema.nodes.hardBreak;
|
|
62
|
+
if (state.doc.resolve(start).nodeAfter.type !== hardBreak) {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
return createHorizontalRuleAutoformat(state, featureFlags, start, end, editorAnalyticsAPI);
|
|
66
|
+
}));
|
|
67
|
+
}
|
|
68
|
+
if (rules.length !== 0) {
|
|
69
|
+
return (0, _prosemirrorInputRules.createPlugin)('rule', rules, {
|
|
70
|
+
isBlockNodeRule: true
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
var _default = inputRulePlugin;
|
|
76
|
+
exports.default = _default;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
exports.keymapPlugin = keymapPlugin;
|
|
8
|
+
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
9
|
+
var _keymaps = require("@atlaskit/editor-common/keymaps");
|
|
10
|
+
var _keymap = require("@atlaskit/editor-prosemirror/keymap");
|
|
11
|
+
var _commands = require("../commands");
|
|
12
|
+
function keymapPlugin(featureFlags, editorAnalyticsAPI) {
|
|
13
|
+
var list = {};
|
|
14
|
+
(0, _keymaps.bindKeymapWithCommand)(_keymaps.insertRule.common, (0, _commands.insertHorizontalRule)(featureFlags, editorAnalyticsAPI)(_analytics.INPUT_METHOD.SHORTCUT), list);
|
|
15
|
+
(0, _keymaps.bindKeymapWithCommand)(_keymaps.escape.common, function () {
|
|
16
|
+
return true;
|
|
17
|
+
}, list);
|
|
18
|
+
return (0, _keymap.keymap)(list);
|
|
19
|
+
}
|
|
20
|
+
var _default = keymapPlugin;
|
|
21
|
+
exports.default = _default;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createHorizontalRule } from './pm-plugins/input-rule';
|
|
2
|
+
export const insertHorizontalRule = (featureFlags, editorAnalyticsAPI) => inputMethod => (state, dispatch) => {
|
|
3
|
+
const tr = createHorizontalRule(state, featureFlags, state.selection.from, state.selection.to, inputMethod, editorAnalyticsAPI);
|
|
4
|
+
if (tr) {
|
|
5
|
+
if (dispatch) {
|
|
6
|
+
dispatch(tr);
|
|
7
|
+
}
|
|
8
|
+
return true;
|
|
9
|
+
}
|
|
10
|
+
return false;
|
|
11
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { rulePlugin } from './plugin';
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { rule } from '@atlaskit/adf-schema';
|
|
3
|
+
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
4
|
+
import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
|
|
5
|
+
import { IconDivider } from '@atlaskit/editor-common/quick-insert';
|
|
6
|
+
import { insertHorizontalRule } from './commands';
|
|
7
|
+
import inputRulePlugin from './pm-plugins/input-rule';
|
|
8
|
+
import keymapPlugin from './pm-plugins/keymap';
|
|
9
|
+
export const rulePlugin = ({
|
|
10
|
+
api
|
|
11
|
+
}) => {
|
|
12
|
+
var _api$featureFlags, _api$analytics;
|
|
13
|
+
const featureFlags = (api === null || api === void 0 ? void 0 : (_api$featureFlags = api.featureFlags) === null || _api$featureFlags === void 0 ? void 0 : _api$featureFlags.sharedState.currentState()) || {};
|
|
14
|
+
return {
|
|
15
|
+
name: 'rule',
|
|
16
|
+
nodes() {
|
|
17
|
+
return [{
|
|
18
|
+
name: 'rule',
|
|
19
|
+
node: rule
|
|
20
|
+
}];
|
|
21
|
+
},
|
|
22
|
+
actions: {
|
|
23
|
+
insertHorizontalRule: insertHorizontalRule(featureFlags, api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions)
|
|
24
|
+
},
|
|
25
|
+
pmPlugins() {
|
|
26
|
+
return [{
|
|
27
|
+
name: 'ruleInputRule',
|
|
28
|
+
plugin: ({
|
|
29
|
+
schema
|
|
30
|
+
}) => {
|
|
31
|
+
var _api$analytics2;
|
|
32
|
+
return inputRulePlugin(schema, featureFlags, api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions);
|
|
33
|
+
}
|
|
34
|
+
}, {
|
|
35
|
+
name: 'ruleKeymap',
|
|
36
|
+
plugin: () => {
|
|
37
|
+
var _api$analytics3;
|
|
38
|
+
return keymapPlugin(featureFlags, api === null || api === void 0 ? void 0 : (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions);
|
|
39
|
+
}
|
|
40
|
+
}];
|
|
41
|
+
},
|
|
42
|
+
pluginsOptions: {
|
|
43
|
+
quickInsert: ({
|
|
44
|
+
formatMessage
|
|
45
|
+
}) => [{
|
|
46
|
+
id: 'rule',
|
|
47
|
+
title: formatMessage(messages.horizontalRule),
|
|
48
|
+
description: formatMessage(messages.horizontalRuleDescription),
|
|
49
|
+
keywords: ['horizontal', 'rule', 'line', 'hr'],
|
|
50
|
+
priority: 1200,
|
|
51
|
+
keyshortcut: '---',
|
|
52
|
+
icon: () => /*#__PURE__*/React.createElement(IconDivider, null),
|
|
53
|
+
action(insert, state) {
|
|
54
|
+
var _api$analytics4;
|
|
55
|
+
let tr = insert(state.schema.nodes.rule.createChecked());
|
|
56
|
+
api === null || api === void 0 ? void 0 : (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions.attachAnalyticsEvent({
|
|
57
|
+
action: ACTION.INSERTED,
|
|
58
|
+
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
59
|
+
actionSubjectId: ACTION_SUBJECT_ID.DIVIDER,
|
|
60
|
+
attributes: {
|
|
61
|
+
inputMethod: INPUT_METHOD.QUICK_INSERT
|
|
62
|
+
},
|
|
63
|
+
eventType: EVENT_TYPE.TRACK
|
|
64
|
+
})(tr);
|
|
65
|
+
return tr;
|
|
66
|
+
}
|
|
67
|
+
}]
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import { safeInsert } from '@atlaskit/editor-common/insert';
|
|
3
|
+
import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
|
|
4
|
+
import { hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
5
|
+
import { createPlugin, createRule, leafNodeReplacementCharacter } from '@atlaskit/prosemirror-input-rules';
|
|
6
|
+
export const createHorizontalRule = (state, featureFlags, start, end, inputMethod, editorAnalyticsAPI) => {
|
|
7
|
+
if (!state.selection.empty) {
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
let tr = null;
|
|
11
|
+
const {
|
|
12
|
+
rule
|
|
13
|
+
} = state.schema.nodes;
|
|
14
|
+
const {
|
|
15
|
+
newInsertionBehaviour
|
|
16
|
+
} = featureFlags;
|
|
17
|
+
if (newInsertionBehaviour) {
|
|
18
|
+
/**
|
|
19
|
+
* This is a workaround to get rid of the typeahead text when using quick insert
|
|
20
|
+
* Once we insert *nothing*, we get a new transaction, so we can use the new selection
|
|
21
|
+
* without considering the extra text after the `/` command.
|
|
22
|
+
**/
|
|
23
|
+
tr = state.tr.replaceWith(start, end, Fragment.empty);
|
|
24
|
+
tr = safeInsert(rule.createChecked(), tr.selection.from)(tr);
|
|
25
|
+
}
|
|
26
|
+
if (!tr) {
|
|
27
|
+
tr = state.tr.replaceRange(start, end, new Slice(Fragment.from(state.schema.nodes.rule.createChecked()), 0, 0));
|
|
28
|
+
}
|
|
29
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
|
|
30
|
+
action: ACTION.INSERTED,
|
|
31
|
+
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
32
|
+
actionSubjectId: ACTION_SUBJECT_ID.DIVIDER,
|
|
33
|
+
attributes: {
|
|
34
|
+
inputMethod
|
|
35
|
+
},
|
|
36
|
+
eventType: EVENT_TYPE.TRACK
|
|
37
|
+
})(tr);
|
|
38
|
+
return tr;
|
|
39
|
+
};
|
|
40
|
+
const createHorizontalRuleAutoformat = (state, featureFlags, start, end, editorAnalyticsAPI) => {
|
|
41
|
+
const {
|
|
42
|
+
listItem
|
|
43
|
+
} = state.schema.nodes;
|
|
44
|
+
if (hasParentNodeOfType(listItem)(state.selection)) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
return createHorizontalRule(state, featureFlags, start, end, INPUT_METHOD.FORMATTING, editorAnalyticsAPI);
|
|
48
|
+
};
|
|
49
|
+
export function inputRulePlugin(schema, featureFlags, editorAnalyticsAPI) {
|
|
50
|
+
const rules = [];
|
|
51
|
+
if (schema.nodes.rule) {
|
|
52
|
+
// '---' and '***' for hr
|
|
53
|
+
rules.push(createRule(/^(\-\-\-|\*\*\*)$/, (state, _match, start, end) => createHorizontalRuleAutoformat(state, featureFlags, start, end, editorAnalyticsAPI)));
|
|
54
|
+
|
|
55
|
+
// '---' and '***' after shift+enter for hr
|
|
56
|
+
rules.push(createRule(new RegExp(`${leafNodeReplacementCharacter}(\\-\\-\\-|\\*\\*\\*)`), (state, _match, start, end) => {
|
|
57
|
+
const {
|
|
58
|
+
hardBreak
|
|
59
|
+
} = state.schema.nodes;
|
|
60
|
+
if (state.doc.resolve(start).nodeAfter.type !== hardBreak) {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
return createHorizontalRuleAutoformat(state, featureFlags, start, end, editorAnalyticsAPI);
|
|
64
|
+
}));
|
|
65
|
+
}
|
|
66
|
+
if (rules.length !== 0) {
|
|
67
|
+
return createPlugin('rule', rules, {
|
|
68
|
+
isBlockNodeRule: true
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
export default inputRulePlugin;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import { bindKeymapWithCommand, escape, insertRule } from '@atlaskit/editor-common/keymaps';
|
|
3
|
+
import { keymap } from '@atlaskit/editor-prosemirror/keymap';
|
|
4
|
+
import { insertHorizontalRule } from '../commands';
|
|
5
|
+
export function keymapPlugin(featureFlags, editorAnalyticsAPI) {
|
|
6
|
+
const list = {};
|
|
7
|
+
bindKeymapWithCommand(insertRule.common, insertHorizontalRule(featureFlags, editorAnalyticsAPI)(INPUT_METHOD.SHORTCUT), list);
|
|
8
|
+
bindKeymapWithCommand(escape.common, () => true, list);
|
|
9
|
+
return keymap(list);
|
|
10
|
+
}
|
|
11
|
+
export default keymapPlugin;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { createHorizontalRule } from './pm-plugins/input-rule';
|
|
2
|
+
export var insertHorizontalRule = function insertHorizontalRule(featureFlags, editorAnalyticsAPI) {
|
|
3
|
+
return function (inputMethod) {
|
|
4
|
+
return function (state, dispatch) {
|
|
5
|
+
var tr = createHorizontalRule(state, featureFlags, state.selection.from, state.selection.to, inputMethod, editorAnalyticsAPI);
|
|
6
|
+
if (tr) {
|
|
7
|
+
if (dispatch) {
|
|
8
|
+
dispatch(tr);
|
|
9
|
+
}
|
|
10
|
+
return true;
|
|
11
|
+
}
|
|
12
|
+
return false;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { rulePlugin } from './plugin';
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { rule } from '@atlaskit/adf-schema';
|
|
3
|
+
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
4
|
+
import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
|
|
5
|
+
import { IconDivider } from '@atlaskit/editor-common/quick-insert';
|
|
6
|
+
import { insertHorizontalRule } from './commands';
|
|
7
|
+
import inputRulePlugin from './pm-plugins/input-rule';
|
|
8
|
+
import keymapPlugin from './pm-plugins/keymap';
|
|
9
|
+
export var rulePlugin = function rulePlugin(_ref) {
|
|
10
|
+
var _api$featureFlags, _api$analytics;
|
|
11
|
+
var api = _ref.api;
|
|
12
|
+
var featureFlags = (api === null || api === void 0 ? void 0 : (_api$featureFlags = api.featureFlags) === null || _api$featureFlags === void 0 ? void 0 : _api$featureFlags.sharedState.currentState()) || {};
|
|
13
|
+
return {
|
|
14
|
+
name: 'rule',
|
|
15
|
+
nodes: function nodes() {
|
|
16
|
+
return [{
|
|
17
|
+
name: 'rule',
|
|
18
|
+
node: rule
|
|
19
|
+
}];
|
|
20
|
+
},
|
|
21
|
+
actions: {
|
|
22
|
+
insertHorizontalRule: insertHorizontalRule(featureFlags, api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions)
|
|
23
|
+
},
|
|
24
|
+
pmPlugins: function pmPlugins() {
|
|
25
|
+
return [{
|
|
26
|
+
name: 'ruleInputRule',
|
|
27
|
+
plugin: function plugin(_ref2) {
|
|
28
|
+
var _api$analytics2;
|
|
29
|
+
var schema = _ref2.schema;
|
|
30
|
+
return inputRulePlugin(schema, featureFlags, api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions);
|
|
31
|
+
}
|
|
32
|
+
}, {
|
|
33
|
+
name: 'ruleKeymap',
|
|
34
|
+
plugin: function plugin() {
|
|
35
|
+
var _api$analytics3;
|
|
36
|
+
return keymapPlugin(featureFlags, api === null || api === void 0 ? void 0 : (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions);
|
|
37
|
+
}
|
|
38
|
+
}];
|
|
39
|
+
},
|
|
40
|
+
pluginsOptions: {
|
|
41
|
+
quickInsert: function quickInsert(_ref3) {
|
|
42
|
+
var formatMessage = _ref3.formatMessage;
|
|
43
|
+
return [{
|
|
44
|
+
id: 'rule',
|
|
45
|
+
title: formatMessage(messages.horizontalRule),
|
|
46
|
+
description: formatMessage(messages.horizontalRuleDescription),
|
|
47
|
+
keywords: ['horizontal', 'rule', 'line', 'hr'],
|
|
48
|
+
priority: 1200,
|
|
49
|
+
keyshortcut: '---',
|
|
50
|
+
icon: function icon() {
|
|
51
|
+
return /*#__PURE__*/React.createElement(IconDivider, null);
|
|
52
|
+
},
|
|
53
|
+
action: function action(insert, state) {
|
|
54
|
+
var _api$analytics4;
|
|
55
|
+
var tr = insert(state.schema.nodes.rule.createChecked());
|
|
56
|
+
api === null || api === void 0 ? void 0 : (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions.attachAnalyticsEvent({
|
|
57
|
+
action: ACTION.INSERTED,
|
|
58
|
+
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
59
|
+
actionSubjectId: ACTION_SUBJECT_ID.DIVIDER,
|
|
60
|
+
attributes: {
|
|
61
|
+
inputMethod: INPUT_METHOD.QUICK_INSERT
|
|
62
|
+
},
|
|
63
|
+
eventType: EVENT_TYPE.TRACK
|
|
64
|
+
})(tr);
|
|
65
|
+
return tr;
|
|
66
|
+
}
|
|
67
|
+
}];
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import { safeInsert } from '@atlaskit/editor-common/insert';
|
|
3
|
+
import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
|
|
4
|
+
import { hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
5
|
+
import { createPlugin, createRule, leafNodeReplacementCharacter } from '@atlaskit/prosemirror-input-rules';
|
|
6
|
+
export var createHorizontalRule = function createHorizontalRule(state, featureFlags, start, end, inputMethod, editorAnalyticsAPI) {
|
|
7
|
+
if (!state.selection.empty) {
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
var tr = null;
|
|
11
|
+
var rule = state.schema.nodes.rule;
|
|
12
|
+
var newInsertionBehaviour = featureFlags.newInsertionBehaviour;
|
|
13
|
+
if (newInsertionBehaviour) {
|
|
14
|
+
/**
|
|
15
|
+
* This is a workaround to get rid of the typeahead text when using quick insert
|
|
16
|
+
* Once we insert *nothing*, we get a new transaction, so we can use the new selection
|
|
17
|
+
* without considering the extra text after the `/` command.
|
|
18
|
+
**/
|
|
19
|
+
tr = state.tr.replaceWith(start, end, Fragment.empty);
|
|
20
|
+
tr = safeInsert(rule.createChecked(), tr.selection.from)(tr);
|
|
21
|
+
}
|
|
22
|
+
if (!tr) {
|
|
23
|
+
tr = state.tr.replaceRange(start, end, new Slice(Fragment.from(state.schema.nodes.rule.createChecked()), 0, 0));
|
|
24
|
+
}
|
|
25
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
|
|
26
|
+
action: ACTION.INSERTED,
|
|
27
|
+
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
28
|
+
actionSubjectId: ACTION_SUBJECT_ID.DIVIDER,
|
|
29
|
+
attributes: {
|
|
30
|
+
inputMethod: inputMethod
|
|
31
|
+
},
|
|
32
|
+
eventType: EVENT_TYPE.TRACK
|
|
33
|
+
})(tr);
|
|
34
|
+
return tr;
|
|
35
|
+
};
|
|
36
|
+
var createHorizontalRuleAutoformat = function createHorizontalRuleAutoformat(state, featureFlags, start, end, editorAnalyticsAPI) {
|
|
37
|
+
var listItem = state.schema.nodes.listItem;
|
|
38
|
+
if (hasParentNodeOfType(listItem)(state.selection)) {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
return createHorizontalRule(state, featureFlags, start, end, INPUT_METHOD.FORMATTING, editorAnalyticsAPI);
|
|
42
|
+
};
|
|
43
|
+
export function inputRulePlugin(schema, featureFlags, editorAnalyticsAPI) {
|
|
44
|
+
var rules = [];
|
|
45
|
+
if (schema.nodes.rule) {
|
|
46
|
+
// '---' and '***' for hr
|
|
47
|
+
rules.push(createRule(/^(\-\-\-|\*\*\*)$/, function (state, _match, start, end) {
|
|
48
|
+
return createHorizontalRuleAutoformat(state, featureFlags, start, end, editorAnalyticsAPI);
|
|
49
|
+
}));
|
|
50
|
+
|
|
51
|
+
// '---' and '***' after shift+enter for hr
|
|
52
|
+
rules.push(createRule(new RegExp("".concat(leafNodeReplacementCharacter, "(\\-\\-\\-|\\*\\*\\*)")), function (state, _match, start, end) {
|
|
53
|
+
var hardBreak = state.schema.nodes.hardBreak;
|
|
54
|
+
if (state.doc.resolve(start).nodeAfter.type !== hardBreak) {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
return createHorizontalRuleAutoformat(state, featureFlags, start, end, editorAnalyticsAPI);
|
|
58
|
+
}));
|
|
59
|
+
}
|
|
60
|
+
if (rules.length !== 0) {
|
|
61
|
+
return createPlugin('rule', rules, {
|
|
62
|
+
isBlockNodeRule: true
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
export default inputRulePlugin;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import { bindKeymapWithCommand, escape, insertRule } from '@atlaskit/editor-common/keymaps';
|
|
3
|
+
import { keymap } from '@atlaskit/editor-prosemirror/keymap';
|
|
4
|
+
import { insertHorizontalRule } from '../commands';
|
|
5
|
+
export function keymapPlugin(featureFlags, editorAnalyticsAPI) {
|
|
6
|
+
var list = {};
|
|
7
|
+
bindKeymapWithCommand(insertRule.common, insertHorizontalRule(featureFlags, editorAnalyticsAPI)(INPUT_METHOD.SHORTCUT), list);
|
|
8
|
+
bindKeymapWithCommand(escape.common, function () {
|
|
9
|
+
return true;
|
|
10
|
+
}, list);
|
|
11
|
+
return keymap(list);
|
|
12
|
+
}
|
|
13
|
+
export default keymapPlugin;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { EditorAnalyticsAPI, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import type { Command, FeatureFlags } from '@atlaskit/editor-common/types';
|
|
3
|
+
export declare const insertHorizontalRule: (featureFlags: FeatureFlags, editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (inputMethod: INPUT_METHOD.QUICK_INSERT | INPUT_METHOD.TOOLBAR | INPUT_METHOD.INSERT_MENU | INPUT_METHOD.FORMATTING | INPUT_METHOD.SHORTCUT) => Command;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
|
|
2
|
+
import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
3
|
+
import type { FeatureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
|
|
4
|
+
import { insertHorizontalRule } from './commands';
|
|
5
|
+
export type RulePlugin = NextEditorPlugin<'rule', {
|
|
6
|
+
pluginConfiguration: undefined;
|
|
7
|
+
dependencies: [FeatureFlagsPlugin, OptionalPlugin<AnalyticsPlugin>];
|
|
8
|
+
actions: {
|
|
9
|
+
insertHorizontalRule: ReturnType<typeof insertHorizontalRule>;
|
|
10
|
+
};
|
|
11
|
+
}>;
|
|
12
|
+
export declare const rulePlugin: RulePlugin;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
3
|
+
import type { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
4
|
+
import type { FeatureFlags } from '@atlaskit/editor-common/types';
|
|
5
|
+
import type { Schema } from '@atlaskit/editor-prosemirror/model';
|
|
6
|
+
import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
7
|
+
export declare const createHorizontalRule: (state: EditorState, featureFlags: FeatureFlags, start: number, end: number, inputMethod: INPUT_METHOD.QUICK_INSERT | INPUT_METHOD.TOOLBAR | INPUT_METHOD.INSERT_MENU | INPUT_METHOD.FORMATTING | INPUT_METHOD.SHORTCUT, editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => Transaction | null;
|
|
8
|
+
export declare function inputRulePlugin(schema: Schema, featureFlags: FeatureFlags, editorAnalyticsAPI: EditorAnalyticsAPI | undefined): SafePlugin | undefined;
|
|
9
|
+
export default inputRulePlugin;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import type { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
3
|
+
import type { FeatureFlags } from '@atlaskit/editor-common/types';
|
|
4
|
+
export declare function keymapPlugin(featureFlags: FeatureFlags, editorAnalyticsAPI: EditorAnalyticsAPI | undefined): SafePlugin;
|
|
5
|
+
export default keymapPlugin;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { EditorAnalyticsAPI, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import type { Command, FeatureFlags } from '@atlaskit/editor-common/types';
|
|
3
|
+
export declare const insertHorizontalRule: (featureFlags: FeatureFlags, editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (inputMethod: INPUT_METHOD.QUICK_INSERT | INPUT_METHOD.TOOLBAR | INPUT_METHOD.INSERT_MENU | INPUT_METHOD.FORMATTING | INPUT_METHOD.SHORTCUT) => Command;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
|
|
2
|
+
import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
3
|
+
import type { FeatureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
|
|
4
|
+
import { insertHorizontalRule } from './commands';
|
|
5
|
+
export type RulePlugin = NextEditorPlugin<'rule', {
|
|
6
|
+
pluginConfiguration: undefined;
|
|
7
|
+
dependencies: [
|
|
8
|
+
FeatureFlagsPlugin,
|
|
9
|
+
OptionalPlugin<AnalyticsPlugin>
|
|
10
|
+
];
|
|
11
|
+
actions: {
|
|
12
|
+
insertHorizontalRule: ReturnType<typeof insertHorizontalRule>;
|
|
13
|
+
};
|
|
14
|
+
}>;
|
|
15
|
+
export declare const rulePlugin: RulePlugin;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
3
|
+
import type { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
4
|
+
import type { FeatureFlags } from '@atlaskit/editor-common/types';
|
|
5
|
+
import type { Schema } from '@atlaskit/editor-prosemirror/model';
|
|
6
|
+
import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
7
|
+
export declare const createHorizontalRule: (state: EditorState, featureFlags: FeatureFlags, start: number, end: number, inputMethod: INPUT_METHOD.QUICK_INSERT | INPUT_METHOD.TOOLBAR | INPUT_METHOD.INSERT_MENU | INPUT_METHOD.FORMATTING | INPUT_METHOD.SHORTCUT, editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => Transaction | null;
|
|
8
|
+
export declare function inputRulePlugin(schema: Schema, featureFlags: FeatureFlags, editorAnalyticsAPI: EditorAnalyticsAPI | undefined): SafePlugin | undefined;
|
|
9
|
+
export default inputRulePlugin;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import type { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
3
|
+
import type { FeatureFlags } from '@atlaskit/editor-common/types';
|
|
4
|
+
export declare function keymapPlugin(featureFlags: FeatureFlags, editorAnalyticsAPI: EditorAnalyticsAPI | undefined): SafePlugin;
|
|
5
|
+
export default keymapPlugin;
|
package/package.json
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@atlaskit/editor-plugin-rule",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Rule plugin for @atlaskit/editor-core",
|
|
5
|
+
"author": "Atlassian Pty Ltd",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"publishConfig": {
|
|
8
|
+
"registry": "https://registry.npmjs.org/"
|
|
9
|
+
},
|
|
10
|
+
"atlassian": {
|
|
11
|
+
"team": "Editor: AI",
|
|
12
|
+
"singleton": true,
|
|
13
|
+
"releaseModel": "continuous"
|
|
14
|
+
},
|
|
15
|
+
"repository": "https://bitbucket.org/atlassian/atlassian-frontend",
|
|
16
|
+
"main": "dist/cjs/index.js",
|
|
17
|
+
"module": "dist/esm/index.js",
|
|
18
|
+
"module:es2019": "dist/es2019/index.js",
|
|
19
|
+
"types": "dist/types/index.d.ts",
|
|
20
|
+
"typesVersions": {
|
|
21
|
+
">=4.5 <4.9": {
|
|
22
|
+
"*": [
|
|
23
|
+
"dist/types-ts4.5/*",
|
|
24
|
+
"dist/types-ts4.5/index.d.ts"
|
|
25
|
+
]
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"sideEffects": false,
|
|
29
|
+
"atlaskit:src": "src/index.ts",
|
|
30
|
+
"af:exports": {
|
|
31
|
+
".": "./src/index.ts"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"@atlaskit/adf-schema": "28.1.2",
|
|
35
|
+
"@atlaskit/editor-common": "^74.56.0",
|
|
36
|
+
"@atlaskit/editor-plugin-analytics": "^0.2.0",
|
|
37
|
+
"@atlaskit/editor-plugin-feature-flags": "^1.0.0",
|
|
38
|
+
"@atlaskit/editor-prosemirror": "1.1.0",
|
|
39
|
+
"@atlaskit/prosemirror-input-rules": "^2.4.0",
|
|
40
|
+
"@babel/runtime": "^7.0.0"
|
|
41
|
+
},
|
|
42
|
+
"peerDependencies": {
|
|
43
|
+
"react": "^16.8.0"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@atlassian/atlassian-frontend-prettier-config-1.0.0": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.0",
|
|
47
|
+
"@testing-library/react": "^12.1.5",
|
|
48
|
+
"react-dom": "^16.8.0",
|
|
49
|
+
"typescript": "~4.9.5"
|
|
50
|
+
},
|
|
51
|
+
"techstack": {
|
|
52
|
+
"@atlassian/frontend": {
|
|
53
|
+
"import-structure": [
|
|
54
|
+
"atlassian-conventions"
|
|
55
|
+
],
|
|
56
|
+
"circular-dependencies": [
|
|
57
|
+
"file-and-folder-level"
|
|
58
|
+
]
|
|
59
|
+
},
|
|
60
|
+
"@repo/internal": {
|
|
61
|
+
"dom-events": "use-bind-event-listener",
|
|
62
|
+
"analytics": [
|
|
63
|
+
"analytics-next"
|
|
64
|
+
],
|
|
65
|
+
"design-tokens": [
|
|
66
|
+
"color"
|
|
67
|
+
],
|
|
68
|
+
"theming": [
|
|
69
|
+
"react-context"
|
|
70
|
+
],
|
|
71
|
+
"ui-components": [
|
|
72
|
+
"lite-mode"
|
|
73
|
+
],
|
|
74
|
+
"deprecation": [
|
|
75
|
+
"no-deprecated-imports"
|
|
76
|
+
],
|
|
77
|
+
"styling": [
|
|
78
|
+
"static",
|
|
79
|
+
"emotion"
|
|
80
|
+
],
|
|
81
|
+
"imports": [
|
|
82
|
+
"import-no-extraneous-disable-for-examples-and-docs"
|
|
83
|
+
]
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
"prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.0"
|
|
87
|
+
}
|
package/report.api.md
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
<!-- API Report Version: 2.3 -->
|
|
2
|
+
|
|
3
|
+
## API Report File for "@atlaskit/editor-plugin-rule"
|
|
4
|
+
|
|
5
|
+
> Do not edit this file. This report is auto-generated using [API Extractor](https://api-extractor.com/).
|
|
6
|
+
> [Learn more about API reports](https://hello.atlassian.net/wiki/spaces/UR/pages/1825484529/Package+API+Reports)
|
|
7
|
+
|
|
8
|
+
### Table of contents
|
|
9
|
+
|
|
10
|
+
- [Main Entry Types](#main-entry-types)
|
|
11
|
+
- [Peer Dependencies](#peer-dependencies)
|
|
12
|
+
|
|
13
|
+
### Main Entry Types
|
|
14
|
+
|
|
15
|
+
<!--SECTION START: Main Entry Types-->
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
19
|
+
import type { Command } from '@atlaskit/editor-common/types';
|
|
20
|
+
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
21
|
+
import type { FeatureFlags } from '@atlaskit/editor-common/types';
|
|
22
|
+
import type { FeatureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
|
|
23
|
+
import type { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
24
|
+
import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
|
|
25
|
+
import type { OptionalPlugin } from '@atlaskit/editor-common/types';
|
|
26
|
+
|
|
27
|
+
// @public (undocumented)
|
|
28
|
+
const insertHorizontalRule: (
|
|
29
|
+
featureFlags: FeatureFlags,
|
|
30
|
+
editorAnalyticsAPI: EditorAnalyticsAPI | undefined,
|
|
31
|
+
) => (
|
|
32
|
+
inputMethod:
|
|
33
|
+
| INPUT_METHOD.FORMATTING
|
|
34
|
+
| INPUT_METHOD.INSERT_MENU
|
|
35
|
+
| INPUT_METHOD.QUICK_INSERT
|
|
36
|
+
| INPUT_METHOD.SHORTCUT
|
|
37
|
+
| INPUT_METHOD.TOOLBAR,
|
|
38
|
+
) => Command;
|
|
39
|
+
|
|
40
|
+
// @public (undocumented)
|
|
41
|
+
export type RulePlugin = NextEditorPlugin<
|
|
42
|
+
'rule',
|
|
43
|
+
{
|
|
44
|
+
pluginConfiguration: undefined;
|
|
45
|
+
dependencies: [FeatureFlagsPlugin, OptionalPlugin<AnalyticsPlugin>];
|
|
46
|
+
actions: {
|
|
47
|
+
insertHorizontalRule: ReturnType<typeof insertHorizontalRule>;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
>;
|
|
51
|
+
|
|
52
|
+
// @public (undocumented)
|
|
53
|
+
export const rulePlugin: RulePlugin;
|
|
54
|
+
|
|
55
|
+
// (No @packageDocumentation comment for this package)
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
<!--SECTION END: Main Entry Types-->
|
|
59
|
+
|
|
60
|
+
### Peer Dependencies
|
|
61
|
+
|
|
62
|
+
<!--SECTION START: Peer Dependencies-->
|
|
63
|
+
|
|
64
|
+
```json
|
|
65
|
+
{
|
|
66
|
+
"react": "^16.8.0"
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
<!--SECTION END: Peer Dependencies-->
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
## API Report File for "@atlaskit/editor-plugin-rule"
|
|
2
|
+
|
|
3
|
+
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
|
|
7
|
+
import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
8
|
+
import type { Command } from '@atlaskit/editor-common/types';
|
|
9
|
+
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
10
|
+
import type { FeatureFlags } from '@atlaskit/editor-common/types';
|
|
11
|
+
import type { FeatureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
|
|
12
|
+
import type { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
13
|
+
import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
|
|
14
|
+
import type { OptionalPlugin } from '@atlaskit/editor-common/types';
|
|
15
|
+
|
|
16
|
+
// @public (undocumented)
|
|
17
|
+
const insertHorizontalRule: (featureFlags: FeatureFlags, editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (inputMethod: INPUT_METHOD.FORMATTING | INPUT_METHOD.INSERT_MENU | INPUT_METHOD.QUICK_INSERT | INPUT_METHOD.SHORTCUT | INPUT_METHOD.TOOLBAR) => Command;
|
|
18
|
+
|
|
19
|
+
// @public (undocumented)
|
|
20
|
+
export type RulePlugin = NextEditorPlugin<'rule', {
|
|
21
|
+
pluginConfiguration: undefined;
|
|
22
|
+
dependencies: [FeatureFlagsPlugin, OptionalPlugin<AnalyticsPlugin>];
|
|
23
|
+
actions: {
|
|
24
|
+
insertHorizontalRule: ReturnType<typeof insertHorizontalRule>;
|
|
25
|
+
};
|
|
26
|
+
}>;
|
|
27
|
+
|
|
28
|
+
// @public (undocumented)
|
|
29
|
+
export const rulePlugin: RulePlugin;
|
|
30
|
+
|
|
31
|
+
// (No @packageDocumentation comment for this package)
|
|
32
|
+
|
|
33
|
+
```
|