@atlaskit/editor-core 187.37.3 → 187.37.5

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.
Files changed (54) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/cjs/labs/next/presets/universal.js +2 -1
  3. package/dist/cjs/plugins/index.js +0 -7
  4. package/dist/cjs/plugins/media/nodeviews/mediaGroup.js +2 -2
  5. package/dist/cjs/plugins/media/nodeviews/mediaSingle.js +2 -2
  6. package/dist/cjs/plugins/media/utils/analytics.js +25 -2
  7. package/dist/cjs/ui/ContentStyles/index.js +20 -18
  8. package/dist/cjs/version-wrapper.js +1 -1
  9. package/dist/es2019/labs/next/presets/universal.js +2 -1
  10. package/dist/es2019/plugins/index.js +0 -1
  11. package/dist/es2019/plugins/media/nodeviews/mediaGroup.js +2 -2
  12. package/dist/es2019/plugins/media/nodeviews/mediaSingle.js +2 -2
  13. package/dist/es2019/plugins/media/utils/analytics.js +24 -0
  14. package/dist/es2019/ui/ContentStyles/index.js +19 -3
  15. package/dist/es2019/version-wrapper.js +1 -1
  16. package/dist/esm/labs/next/presets/universal.js +2 -1
  17. package/dist/esm/plugins/index.js +0 -1
  18. package/dist/esm/plugins/media/nodeviews/mediaGroup.js +2 -2
  19. package/dist/esm/plugins/media/nodeviews/mediaSingle.js +2 -2
  20. package/dist/esm/plugins/media/utils/analytics.js +22 -0
  21. package/dist/esm/ui/ContentStyles/index.js +10 -8
  22. package/dist/esm/version-wrapper.js +1 -1
  23. package/dist/types/plugins/index.d.ts +0 -1
  24. package/dist/types/plugins/insert-block/types.d.ts +1 -1
  25. package/dist/types/plugins/media/utils/analytics.d.ts +2 -1
  26. package/dist/types-ts4.5/plugins/index.d.ts +0 -1
  27. package/dist/types-ts4.5/plugins/insert-block/types.d.ts +1 -1
  28. package/dist/types-ts4.5/plugins/media/utils/analytics.d.ts +2 -1
  29. package/package.json +2 -1
  30. package/dist/cjs/plugins/rule/commands.js +0 -22
  31. package/dist/cjs/plugins/rule/index.js +0 -80
  32. package/dist/cjs/plugins/rule/pm-plugins/input-rule.js +0 -76
  33. package/dist/cjs/plugins/rule/pm-plugins/keymap.js +0 -21
  34. package/dist/cjs/plugins/rule/styles.js +0 -16
  35. package/dist/es2019/plugins/rule/commands.js +0 -11
  36. package/dist/es2019/plugins/rule/index.js +0 -71
  37. package/dist/es2019/plugins/rule/pm-plugins/input-rule.js +0 -73
  38. package/dist/es2019/plugins/rule/pm-plugins/keymap.js +0 -11
  39. package/dist/es2019/plugins/rule/styles.js +0 -20
  40. package/dist/esm/plugins/rule/commands.js +0 -15
  41. package/dist/esm/plugins/rule/index.js +0 -72
  42. package/dist/esm/plugins/rule/pm-plugins/input-rule.js +0 -67
  43. package/dist/esm/plugins/rule/pm-plugins/keymap.js +0 -13
  44. package/dist/esm/plugins/rule/styles.js +0 -8
  45. package/dist/types/plugins/rule/commands.d.ts +0 -3
  46. package/dist/types/plugins/rule/index.d.ts +0 -13
  47. package/dist/types/plugins/rule/pm-plugins/input-rule.d.ts +0 -9
  48. package/dist/types/plugins/rule/pm-plugins/keymap.d.ts +0 -5
  49. package/dist/types/plugins/rule/styles.d.ts +0 -2
  50. package/dist/types-ts4.5/plugins/rule/commands.d.ts +0 -3
  51. package/dist/types-ts4.5/plugins/rule/index.d.ts +0 -16
  52. package/dist/types-ts4.5/plugins/rule/pm-plugins/input-rule.d.ts +0 -9
  53. package/dist/types-ts4.5/plugins/rule/pm-plugins/keymap.d.ts +0 -5
  54. package/dist/types-ts4.5/plugins/rule/styles.d.ts +0 -2
@@ -1,22 +0,0 @@
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;
@@ -1,80 +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 _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 _inputRule = _interopRequireDefault(require("./pm-plugins/input-rule"));
14
- var _keymap = _interopRequireDefault(require("./pm-plugins/keymap"));
15
- var _commands = require("./commands");
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
- var _default = rulePlugin;
80
- exports.default = _default;
@@ -1,76 +0,0 @@
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 _model = require("@atlaskit/editor-prosemirror/model");
9
- var _prosemirrorInputRules = require("@atlaskit/prosemirror-input-rules");
10
- var _insert = require("@atlaskit/editor-common/insert");
11
- var _utils = require("@atlaskit/editor-prosemirror/utils");
12
- var _analytics = require("@atlaskit/editor-common/analytics");
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;
@@ -1,21 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- exports.keymapPlugin = keymapPlugin;
8
- var _keymap = require("@atlaskit/editor-prosemirror/keymap");
9
- var _keymaps = require("@atlaskit/editor-common/keymaps");
10
- var _analytics = require("@atlaskit/editor-common/analytics");
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;
@@ -1,16 +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.ruleStyles = void 0;
8
- var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
9
- var _react = require("@emotion/react");
10
- var _styles = require("@atlaskit/editor-common/styles");
11
- var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
12
- var _templateObject;
13
- var ruleStyles = function ruleStyles(props) {
14
- return (0, _react.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n .ProseMirror {\n ", ";\n\n hr {\n cursor: pointer;\n padding: 4px 0;\n margin: calc(", "em - 4px) 0;\n background-clip: content-box;\n\n &.", " {\n outline: none;\n background-color: ", ";\n }\n }\n }\n"])), (0, _styles.ruleSharedStyles)(props), _editorSharedStyles.akEditorLineHeight, _editorSharedStyles.akEditorSelectedNodeClassName, "var(--ds-border-selected, ".concat(_editorSharedStyles.akEditorSelectedBorderColor, ")"));
15
- };
16
- exports.ruleStyles = ruleStyles;
@@ -1,11 +0,0 @@
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
- };
@@ -1,71 +0,0 @@
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 inputRulePlugin from './pm-plugins/input-rule';
7
- import keymapPlugin from './pm-plugins/keymap';
8
- import { insertHorizontalRule } from './commands';
9
- 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
- };
71
- export default rulePlugin;
@@ -1,73 +0,0 @@
1
- import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
2
- import { createRule, createPlugin, leafNodeReplacementCharacter } from '@atlaskit/prosemirror-input-rules';
3
- import { safeInsert } from '@atlaskit/editor-common/insert';
4
- import { hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
5
- import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
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;
@@ -1,11 +0,0 @@
1
- import { keymap } from '@atlaskit/editor-prosemirror/keymap';
2
- import { bindKeymapWithCommand, insertRule, escape } from '@atlaskit/editor-common/keymaps';
3
- import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
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;
@@ -1,20 +0,0 @@
1
- import { css } from '@emotion/react';
2
- import { ruleSharedStyles } from '@atlaskit/editor-common/styles';
3
- import { akEditorLineHeight, akEditorSelectedBorderColor, akEditorSelectedNodeClassName } from '@atlaskit/editor-shared-styles';
4
- export const ruleStyles = props => css`
5
- .ProseMirror {
6
- ${ruleSharedStyles(props)};
7
-
8
- hr {
9
- cursor: pointer;
10
- padding: 4px 0;
11
- margin: calc(${akEditorLineHeight}em - 4px) 0;
12
- background-clip: content-box;
13
-
14
- &.${akEditorSelectedNodeClassName} {
15
- outline: none;
16
- background-color: ${`var(--ds-border-selected, ${akEditorSelectedBorderColor})`};
17
- }
18
- }
19
- }
20
- `;
@@ -1,15 +0,0 @@
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
- };
@@ -1,72 +0,0 @@
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 inputRulePlugin from './pm-plugins/input-rule';
7
- import keymapPlugin from './pm-plugins/keymap';
8
- import { insertHorizontalRule } from './commands';
9
- 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
- };
72
- export default rulePlugin;
@@ -1,67 +0,0 @@
1
- import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
2
- import { createRule, createPlugin, leafNodeReplacementCharacter } from '@atlaskit/prosemirror-input-rules';
3
- import { safeInsert } from '@atlaskit/editor-common/insert';
4
- import { hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
5
- import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
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;
@@ -1,13 +0,0 @@
1
- import { keymap } from '@atlaskit/editor-prosemirror/keymap';
2
- import { bindKeymapWithCommand, insertRule, escape } from '@atlaskit/editor-common/keymaps';
3
- import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
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;
@@ -1,8 +0,0 @@
1
- import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
2
- var _templateObject;
3
- import { css } from '@emotion/react';
4
- import { ruleSharedStyles } from '@atlaskit/editor-common/styles';
5
- import { akEditorLineHeight, akEditorSelectedBorderColor, akEditorSelectedNodeClassName } from '@atlaskit/editor-shared-styles';
6
- export var ruleStyles = function ruleStyles(props) {
7
- return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n .ProseMirror {\n ", ";\n\n hr {\n cursor: pointer;\n padding: 4px 0;\n margin: calc(", "em - 4px) 0;\n background-clip: content-box;\n\n &.", " {\n outline: none;\n background-color: ", ";\n }\n }\n }\n"])), ruleSharedStyles(props), akEditorLineHeight, akEditorSelectedNodeClassName, "var(--ds-border-selected, ".concat(akEditorSelectedBorderColor, ")"));
8
- };
@@ -1,3 +0,0 @@
1
- import type { FeatureFlags, Command } from '@atlaskit/editor-common/types';
2
- import type { INPUT_METHOD, EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
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;
@@ -1,13 +0,0 @@
1
- import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
2
- import { insertHorizontalRule } from './commands';
3
- import type { FeatureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
4
- import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
5
- export type RulePlugin = NextEditorPlugin<'rule', {
6
- pluginConfiguration: undefined;
7
- dependencies: [FeatureFlagsPlugin, OptionalPlugin<AnalyticsPlugin>];
8
- actions: {
9
- insertHorizontalRule: ReturnType<typeof insertHorizontalRule>;
10
- };
11
- }>;
12
- declare const rulePlugin: RulePlugin;
13
- export default rulePlugin;
@@ -1,9 +0,0 @@
1
- import type { Schema } from '@atlaskit/editor-prosemirror/model';
2
- import type { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
3
- import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
4
- import type { FeatureFlags } from '@atlaskit/editor-common/types';
5
- import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
6
- import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
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;
@@ -1,5 +0,0 @@
1
- import type { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
- import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
3
- import type { FeatureFlags } from '@atlaskit/editor-common/types';
4
- export declare function keymapPlugin(featureFlags: FeatureFlags, editorAnalyticsAPI: EditorAnalyticsAPI | undefined): SafePlugin;
5
- export default keymapPlugin;
@@ -1,2 +0,0 @@
1
- import { ThemeProps } from '@atlaskit/theme/types';
2
- export declare const ruleStyles: (props: ThemeProps) => import("@emotion/react").SerializedStyles;
@@ -1,3 +0,0 @@
1
- import type { FeatureFlags, Command } from '@atlaskit/editor-common/types';
2
- import type { INPUT_METHOD, EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
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;
@@ -1,16 +0,0 @@
1
- import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
2
- import { insertHorizontalRule } from './commands';
3
- import type { FeatureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
4
- import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
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
- declare const rulePlugin: RulePlugin;
16
- export default rulePlugin;