@atlaskit/editor-core 187.41.8 → 187.42.3

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 (138) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/cjs/labs/next/presets/default.js +2 -2
  3. package/dist/cjs/plugins/code-block/index.js +1 -1
  4. package/dist/cjs/plugins/help-dialog/ui/index.js +1 -1
  5. package/dist/cjs/plugins/index.js +0 -7
  6. package/dist/cjs/plugins/insert-block/index.js +11 -11
  7. package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/create-items.js +1 -1
  8. package/dist/cjs/plugins/panel/index.js +1 -1
  9. package/dist/cjs/ui/ContentStyles/index.js +1 -1
  10. package/dist/cjs/version-wrapper.js +1 -1
  11. package/dist/es2019/index.js +0 -6
  12. package/dist/es2019/labs/next/presets/default.js +1 -1
  13. package/dist/es2019/plugins/code-block/index.js +1 -1
  14. package/dist/es2019/plugins/help-dialog/ui/index.js +1 -1
  15. package/dist/es2019/plugins/index.js +0 -1
  16. package/dist/es2019/plugins/insert-block/index.js +1 -1
  17. package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/create-items.js +1 -1
  18. package/dist/es2019/plugins/panel/index.js +1 -1
  19. package/dist/es2019/ui/ContentStyles/index.js +1 -1
  20. package/dist/es2019/version-wrapper.js +1 -1
  21. package/dist/esm/index.js +0 -6
  22. package/dist/esm/labs/next/presets/default.js +1 -1
  23. package/dist/esm/plugins/code-block/index.js +1 -1
  24. package/dist/esm/plugins/help-dialog/ui/index.js +1 -1
  25. package/dist/esm/plugins/index.js +0 -1
  26. package/dist/esm/plugins/insert-block/index.js +1 -1
  27. package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/create-items.js +1 -1
  28. package/dist/esm/plugins/panel/index.js +1 -1
  29. package/dist/esm/ui/ContentStyles/index.js +1 -1
  30. package/dist/esm/version-wrapper.js +1 -1
  31. package/dist/types/index.d.ts +0 -7
  32. package/dist/types/labs/next/presets/default.d.ts +1 -1
  33. package/dist/types/plugins/index.d.ts +0 -1
  34. package/dist/types/plugins/insert-block/types.d.ts +2 -2
  35. package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/create-items.d.ts +1 -1
  36. package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/types.d.ts +1 -1
  37. package/dist/types/types/editor-props.d.ts +1 -1
  38. package/dist/types/ui/Appearance/FullPage/StyledComponents.d.ts +1 -1
  39. package/dist/types/ui/ColorPickerButton/index.d.ts +1 -1
  40. package/dist/types/ui/ContentStyles/index.d.ts +2 -2
  41. package/dist/types-ts4.5/index.d.ts +0 -7
  42. package/dist/types-ts4.5/labs/next/presets/default.d.ts +1 -1
  43. package/dist/types-ts4.5/plugins/index.d.ts +0 -1
  44. package/dist/types-ts4.5/plugins/insert-block/types.d.ts +2 -2
  45. package/dist/types-ts4.5/plugins/insert-block/ui/ToolbarInsertBlock/create-items.d.ts +1 -1
  46. package/dist/types-ts4.5/plugins/insert-block/ui/ToolbarInsertBlock/types.d.ts +1 -1
  47. package/dist/types-ts4.5/types/editor-props.d.ts +1 -1
  48. package/dist/types-ts4.5/ui/Appearance/FullPage/StyledComponents.d.ts +1 -1
  49. package/dist/types-ts4.5/ui/ColorPickerButton/index.d.ts +1 -1
  50. package/dist/types-ts4.5/ui/ContentStyles/index.d.ts +2 -2
  51. package/package.json +9 -7
  52. package/report.api.md +1 -62
  53. package/tmp/api-report-tmp.d.ts +1 -51
  54. package/dist/cjs/plugins/block-type/commands/block-type.js +0 -202
  55. package/dist/cjs/plugins/block-type/commands/delete-and-move-cursor.js +0 -56
  56. package/dist/cjs/plugins/block-type/commands/delete-block-content.js +0 -45
  57. package/dist/cjs/plugins/block-type/commands/index.js +0 -68
  58. package/dist/cjs/plugins/block-type/consts.js +0 -15
  59. package/dist/cjs/plugins/block-type/index.js +0 -215
  60. package/dist/cjs/plugins/block-type/messages.js +0 -160
  61. package/dist/cjs/plugins/block-type/pm-plugins/input-rule.js +0 -104
  62. package/dist/cjs/plugins/block-type/pm-plugins/keymap.js +0 -34
  63. package/dist/cjs/plugins/block-type/pm-plugins/main.js +0 -151
  64. package/dist/cjs/plugins/block-type/styles.js +0 -15
  65. package/dist/cjs/plugins/block-type/types.js +0 -115
  66. package/dist/cjs/plugins/block-type/ui/ToolbarBlockType/blocktype-button.js +0 -54
  67. package/dist/cjs/plugins/block-type/ui/ToolbarBlockType/index.js +0 -193
  68. package/dist/cjs/plugins/block-type/ui/ToolbarBlockType/styled.js +0 -34
  69. package/dist/cjs/plugins/block-type/ui/ToolbarBlockType/toolbar-messages.js +0 -15
  70. package/dist/cjs/plugins/block-type/utils.js +0 -87
  71. package/dist/es2019/plugins/block-type/commands/block-type.js +0 -191
  72. package/dist/es2019/plugins/block-type/commands/delete-and-move-cursor.js +0 -54
  73. package/dist/es2019/plugins/block-type/commands/delete-block-content.js +0 -42
  74. package/dist/es2019/plugins/block-type/commands/index.js +0 -3
  75. package/dist/es2019/plugins/block-type/consts.js +0 -8
  76. package/dist/es2019/plugins/block-type/index.js +0 -201
  77. package/dist/es2019/plugins/block-type/messages.js +0 -153
  78. package/dist/es2019/plugins/block-type/pm-plugins/input-rule.js +0 -93
  79. package/dist/es2019/plugins/block-type/pm-plugins/keymap.js +0 -25
  80. package/dist/es2019/plugins/block-type/pm-plugins/main.js +0 -137
  81. package/dist/es2019/plugins/block-type/styles.js +0 -8
  82. package/dist/es2019/plugins/block-type/types.js +0 -93
  83. package/dist/es2019/plugins/block-type/ui/ToolbarBlockType/blocktype-button.js +0 -44
  84. package/dist/es2019/plugins/block-type/ui/ToolbarBlockType/index.js +0 -170
  85. package/dist/es2019/plugins/block-type/ui/ToolbarBlockType/styled.js +0 -49
  86. package/dist/es2019/plugins/block-type/ui/ToolbarBlockType/toolbar-messages.js +0 -8
  87. package/dist/es2019/plugins/block-type/utils.js +0 -76
  88. package/dist/esm/plugins/block-type/commands/block-type.js +0 -187
  89. package/dist/esm/plugins/block-type/commands/delete-and-move-cursor.js +0 -49
  90. package/dist/esm/plugins/block-type/commands/delete-block-content.js +0 -39
  91. package/dist/esm/plugins/block-type/commands/index.js +0 -3
  92. package/dist/esm/plugins/block-type/consts.js +0 -8
  93. package/dist/esm/plugins/block-type/index.js +0 -202
  94. package/dist/esm/plugins/block-type/messages.js +0 -153
  95. package/dist/esm/plugins/block-type/pm-plugins/input-rule.js +0 -96
  96. package/dist/esm/plugins/block-type/pm-plugins/keymap.js +0 -25
  97. package/dist/esm/plugins/block-type/pm-plugins/main.js +0 -142
  98. package/dist/esm/plugins/block-type/styles.js +0 -7
  99. package/dist/esm/plugins/block-type/types.js +0 -93
  100. package/dist/esm/plugins/block-type/ui/ToolbarBlockType/blocktype-button.js +0 -44
  101. package/dist/esm/plugins/block-type/ui/ToolbarBlockType/index.js +0 -186
  102. package/dist/esm/plugins/block-type/ui/ToolbarBlockType/styled.js +0 -20
  103. package/dist/esm/plugins/block-type/ui/ToolbarBlockType/toolbar-messages.js +0 -8
  104. package/dist/esm/plugins/block-type/utils.js +0 -77
  105. package/dist/types/plugins/block-type/commands/block-type.d.ts +0 -19
  106. package/dist/types/plugins/block-type/commands/delete-and-move-cursor.d.ts +0 -12
  107. package/dist/types/plugins/block-type/commands/delete-block-content.d.ts +0 -10
  108. package/dist/types/plugins/block-type/commands/index.d.ts +0 -4
  109. package/dist/types/plugins/block-type/consts.d.ts +0 -1
  110. package/dist/types/plugins/block-type/index.d.ts +0 -18
  111. package/dist/types/plugins/block-type/messages.d.ts +0 -152
  112. package/dist/types/plugins/block-type/pm-plugins/input-rule.d.ts +0 -6
  113. package/dist/types/plugins/block-type/pm-plugins/keymap.d.ts +0 -5
  114. package/dist/types/plugins/block-type/pm-plugins/main.d.ts +0 -17
  115. package/dist/types/plugins/block-type/styles.d.ts +0 -2
  116. package/dist/types/plugins/block-type/types.d.ts +0 -40
  117. package/dist/types/plugins/block-type/ui/ToolbarBlockType/blocktype-button.d.ts +0 -22
  118. package/dist/types/plugins/block-type/ui/ToolbarBlockType/index.d.ts +0 -29
  119. package/dist/types/plugins/block-type/ui/ToolbarBlockType/styled.d.ts +0 -8
  120. package/dist/types/plugins/block-type/ui/ToolbarBlockType/toolbar-messages.d.ts +0 -7
  121. package/dist/types/plugins/block-type/utils.d.ts +0 -16
  122. package/dist/types-ts4.5/plugins/block-type/commands/block-type.d.ts +0 -19
  123. package/dist/types-ts4.5/plugins/block-type/commands/delete-and-move-cursor.d.ts +0 -12
  124. package/dist/types-ts4.5/plugins/block-type/commands/delete-block-content.d.ts +0 -10
  125. package/dist/types-ts4.5/plugins/block-type/commands/index.d.ts +0 -4
  126. package/dist/types-ts4.5/plugins/block-type/consts.d.ts +0 -1
  127. package/dist/types-ts4.5/plugins/block-type/index.d.ts +0 -20
  128. package/dist/types-ts4.5/plugins/block-type/messages.d.ts +0 -152
  129. package/dist/types-ts4.5/plugins/block-type/pm-plugins/input-rule.d.ts +0 -6
  130. package/dist/types-ts4.5/plugins/block-type/pm-plugins/keymap.d.ts +0 -5
  131. package/dist/types-ts4.5/plugins/block-type/pm-plugins/main.d.ts +0 -17
  132. package/dist/types-ts4.5/plugins/block-type/styles.d.ts +0 -2
  133. package/dist/types-ts4.5/plugins/block-type/types.d.ts +0 -40
  134. package/dist/types-ts4.5/plugins/block-type/ui/ToolbarBlockType/blocktype-button.d.ts +0 -22
  135. package/dist/types-ts4.5/plugins/block-type/ui/ToolbarBlockType/index.d.ts +0 -29
  136. package/dist/types-ts4.5/plugins/block-type/ui/ToolbarBlockType/styled.d.ts +0 -8
  137. package/dist/types-ts4.5/plugins/block-type/ui/ToolbarBlockType/toolbar-messages.d.ts +0 -7
  138. package/dist/types-ts4.5/plugins/block-type/utils.d.ts +0 -16
@@ -13,12 +13,12 @@ import { ACTION_SUBJECT } from '@atlaskit/editor-common/analytics';
13
13
  import { ACTION_SUBJECT_ID } from '@atlaskit/editor-common/analytics';
14
14
  import type { ActivityProvider } from '@atlaskit/activity-provider';
15
15
  import type { AllEditorPresetPluginTypes } from '@atlaskit/editor-common/types';
16
- import type { AllowedBlockTypes } from '@atlaskit/editor-common/types';
17
16
  import { AnalyticsEventPayload } from '@atlaskit/editor-common/analytics';
18
17
  import type { AnalyticsEventPayload as AnalyticsEventPayload_2 } from '@atlaskit/analytics-next/AnalyticsEvent';
19
18
  import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
20
19
  import type { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
21
20
  import type { AnnotationTypes } from '@atlaskit/adf-schema';
21
+ import type { BlockTypePluginOptions } from '@atlaskit/editor-plugin-block-type';
22
22
  import { BrowserFreezetracking } from '@atlaskit/editor-common/types';
23
23
  import type { CardOptions } from '@atlaskit/editor-common/card';
24
24
  import { CardProvider } from '@atlaskit/editor-common/provider-factory';
@@ -76,7 +76,6 @@ import { Side as GapCursorSide } from '@atlaskit/editor-common/selection';
76
76
  import type { GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
77
77
  import type { GridPlugin } from '@atlaskit/editor-plugin-grid';
78
78
  import type { GuidelinePlugin } from '@atlaskit/editor-plugin-guideline';
79
- import type { HeadingLevelsAndNormalText } from '@atlaskit/editor-common/types';
80
79
  import type { HyperlinkPluginOptions } from '@atlaskit/editor-common/types';
81
80
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
82
81
  import type { InputMethodInsertMedia } from '@atlaskit/editor-common/analytics';
@@ -99,7 +98,6 @@ import { MentionProvider } from '@atlaskit/mention/resource';
99
98
  import type { MentionProvider as MentionProvider_2 } from '@atlaskit/mention';
100
99
  import { MentionResource } from '@atlaskit/mention/resource';
101
100
  import type { MenuItem } from '@atlaskit/editor-common/ui-menu';
102
- import type { MessageDescriptor } from 'react-intl-next';
103
101
  import { default as messages } from '@atlaskit/editor-common/messages';
104
102
  import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
105
103
  import { Node as Node_2 } from '@atlaskit/editor-prosemirror/model';
@@ -268,54 +266,6 @@ type BeforeAndAfterToolbarComponents = {
268
266
  after: ReactComponents;
269
267
  };
270
268
 
271
- // @public (undocumented)
272
- interface BlockType {
273
- // (undocumented)
274
- level?: HeadingLevelsAndNormalText;
275
- // (undocumented)
276
- name: string;
277
- // (undocumented)
278
- nodeName: string;
279
- // (undocumented)
280
- tagName?: string;
281
- // (undocumented)
282
- title: MessageDescriptor;
283
- }
284
-
285
- // @public (undocumented)
286
- export type BlockTypeInputMethod = INPUT_METHOD.FORMATTING | INPUT_METHOD.INSERT_MENU | INPUT_METHOD.KEYBOARD | INPUT_METHOD.SHORTCUT | INPUT_METHOD.TOOLBAR;
287
-
288
- // @public (undocumented)
289
- export type BlockTypePlugin = NextEditorPlugin<'blockType', {
290
- pluginConfiguration: BlockTypePluginOptions | undefined;
291
- dependencies: [OptionalPlugin<typeof analyticsPlugin>];
292
- sharedState: BlockTypeState | undefined;
293
- actions: {
294
- insertBlockQuote: (inputMethod: BlockTypeInputMethod) => Command_2;
295
- setBlockType: (name: string, inputMethod: BlockTypeInputMethod) => Command_2;
296
- };
297
- }>;
298
-
299
- // @public (undocumented)
300
- interface BlockTypePluginOptions {
301
- // (undocumented)
302
- allowBlockType?: {
303
- exclude?: Array<AllowedBlockTypes>;
304
- };
305
- // (undocumented)
306
- isUndoRedoButtonsEnabled?: boolean;
307
- // (undocumented)
308
- lastNodeMustBeParagraph?: boolean;
309
- }
310
-
311
- // @public (undocumented)
312
- export type BlockTypeState = {
313
- currentBlockType: BlockType;
314
- blockTypesDisabled: boolean;
315
- availableBlockTypes: BlockType[];
316
- availableWrapperBlockTypes: BlockType[];
317
- };
318
-
319
269
  export { CardProvider }
320
270
 
321
271
  // @public (undocumented)
@@ -1,202 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.insertBlockQuoteWithAnalytics = exports.cleanUpAtTheStartOfDocument = void 0;
7
- exports.setBlockType = setBlockType;
8
- exports.setBlockTypeWithAnalytics = setBlockTypeWithAnalytics;
9
- exports.setHeading = setHeading;
10
- exports.setHeadingWithAnalytics = void 0;
11
- exports.setNormalText = setNormalText;
12
- exports.setNormalTextWithAnalytics = setNormalTextWithAnalytics;
13
- var _editorTables = require("@atlaskit/editor-tables");
14
- var _analytics = require("@atlaskit/editor-common/analytics");
15
- var _editorAnalytics = require("@atlaskit/editor-common/editor-analytics");
16
- var _utils = require("@atlaskit/editor-common/utils");
17
- var _types = require("../types");
18
- function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
19
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
20
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
21
- function setBlockType(name) {
22
- return function (state, dispatch) {
23
- var nodes = state.schema.nodes;
24
- if (name === _types.NORMAL_TEXT.name && nodes.paragraph) {
25
- return setNormalText()(state, dispatch);
26
- }
27
- var headingBlockType = _types.HEADINGS_BY_NAME[name];
28
- if (headingBlockType && nodes.heading && headingBlockType.level) {
29
- return setHeading(headingBlockType.level)(state, dispatch);
30
- }
31
- return false;
32
- };
33
- }
34
- function setBlockTypeWithAnalytics(name, inputMethod, editorAnalyticsApi) {
35
- return function (state, dispatch) {
36
- var nodes = state.schema.nodes;
37
- if (name === _types.NORMAL_TEXT.name && nodes.paragraph) {
38
- return setNormalTextWithAnalytics(inputMethod, editorAnalyticsApi)(state, dispatch);
39
- }
40
- var headingBlockType = _types.HEADINGS_BY_NAME[name];
41
- if (headingBlockType && nodes.heading && headingBlockType.level) {
42
- return setHeadingWithAnalytics(headingBlockType.level, inputMethod, editorAnalyticsApi)(state, dispatch);
43
- }
44
- return false;
45
- };
46
- }
47
- function setNormalText() {
48
- return function (state, dispatch) {
49
- var selection = state.selection,
50
- schema = state.schema,
51
- tr = state.tr;
52
- var ranges = selection instanceof _editorTables.CellSelection ? selection.ranges : [selection];
53
- ranges.forEach(function (_ref) {
54
- var $from = _ref.$from,
55
- $to = _ref.$to;
56
- tr.setBlockType($from.pos, $to.pos, schema.nodes.paragraph);
57
- });
58
- if (dispatch) {
59
- dispatch(tr);
60
- }
61
- return true;
62
- };
63
- }
64
- function withCurrentHeadingLevel(fn) {
65
- return function (state, dispatch, view) {
66
- // Find all headings and paragraphs of text
67
- var _state$schema$nodes = state.schema.nodes,
68
- heading = _state$schema$nodes.heading,
69
- paragraph = _state$schema$nodes.paragraph;
70
- var nodes = (0, _utils.filterChildrenBetween)(state.doc, state.selection.from, state.selection.to, function (node) {
71
- return node.type === heading || node.type === paragraph;
72
- });
73
-
74
- // Check each paragraph and/or heading and check for consistent level
75
- var level;
76
- var _iterator = _createForOfIteratorHelper(nodes),
77
- _step;
78
- try {
79
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
80
- var node = _step.value;
81
- var nodeLevel = node.node.type === heading ? node.node.attrs.level : 0;
82
- if (!level) {
83
- level = nodeLevel;
84
- } else if (nodeLevel !== level) {
85
- // Conflict in level, therefore inconsistent and undefined
86
- level = undefined;
87
- break;
88
- }
89
- }
90
- } catch (err) {
91
- _iterator.e(err);
92
- } finally {
93
- _iterator.f();
94
- }
95
- return fn(level)(state, dispatch, view);
96
- };
97
- }
98
- function setNormalTextWithAnalytics(inputMethod, editorAnalyticsApi) {
99
- return withCurrentHeadingLevel(function (previousHeadingLevel) {
100
- return (0, _editorAnalytics.withAnalytics)(editorAnalyticsApi, {
101
- action: _analytics.ACTION.FORMATTED,
102
- actionSubject: _analytics.ACTION_SUBJECT.TEXT,
103
- eventType: _analytics.EVENT_TYPE.TRACK,
104
- actionSubjectId: _analytics.ACTION_SUBJECT_ID.FORMAT_HEADING,
105
- attributes: {
106
- inputMethod: inputMethod,
107
- newHeadingLevel: 0,
108
- previousHeadingLevel: previousHeadingLevel
109
- }
110
- })(setNormalText());
111
- });
112
- }
113
- function setHeading(level) {
114
- return function (state, dispatch) {
115
- var selection = state.selection,
116
- schema = state.schema,
117
- tr = state.tr;
118
- var ranges = selection instanceof _editorTables.CellSelection ? selection.ranges : [selection];
119
- ranges.forEach(function (_ref2) {
120
- var $from = _ref2.$from,
121
- $to = _ref2.$to;
122
- tr.setBlockType($from.pos, $to.pos, schema.nodes.heading, {
123
- level: level
124
- });
125
- });
126
- if (dispatch) {
127
- dispatch(tr);
128
- }
129
- return true;
130
- };
131
- }
132
- var setHeadingWithAnalytics = function setHeadingWithAnalytics(newHeadingLevel, inputMethod, editorAnalyticsApi) {
133
- return withCurrentHeadingLevel(function (previousHeadingLevel) {
134
- return (0, _editorAnalytics.withAnalytics)(editorAnalyticsApi, {
135
- action: _analytics.ACTION.FORMATTED,
136
- actionSubject: _analytics.ACTION_SUBJECT.TEXT,
137
- eventType: _analytics.EVENT_TYPE.TRACK,
138
- actionSubjectId: _analytics.ACTION_SUBJECT_ID.FORMAT_HEADING,
139
- attributes: {
140
- inputMethod: inputMethod,
141
- newHeadingLevel: newHeadingLevel,
142
- previousHeadingLevel: previousHeadingLevel
143
- }
144
- })(setHeading(newHeadingLevel));
145
- });
146
- };
147
- exports.setHeadingWithAnalytics = setHeadingWithAnalytics;
148
- function insertBlockQuote() {
149
- return function (state, dispatch) {
150
- var nodes = state.schema.nodes;
151
- if (nodes.paragraph && nodes.blockquote) {
152
- return (0, _utils.wrapSelectionIn)(nodes.blockquote)(state, dispatch);
153
- }
154
- return false;
155
- };
156
- }
157
-
158
- /**
159
- *
160
- * @param name - block type name
161
- * @param inputMethod - input method
162
- * @param editorAnalyticsApi - analytics api, undefined if not available either because it failed to load or wasn't added
163
- * otherwise Editor becomes very sad and crashes
164
- * @returns - command that inserts block type
165
- */
166
- var insertBlockQuoteWithAnalytics = function insertBlockQuoteWithAnalytics(inputMethod, editorAnalyticsApi) {
167
- return (0, _editorAnalytics.withAnalytics)(editorAnalyticsApi, {
168
- action: _analytics.ACTION.FORMATTED,
169
- actionSubject: _analytics.ACTION_SUBJECT.TEXT,
170
- eventType: _analytics.EVENT_TYPE.TRACK,
171
- actionSubjectId: _analytics.ACTION_SUBJECT_ID.FORMAT_BLOCK_QUOTE,
172
- attributes: {
173
- inputMethod: inputMethod
174
- }
175
- })(insertBlockQuote());
176
- };
177
- exports.insertBlockQuoteWithAnalytics = insertBlockQuoteWithAnalytics;
178
- var cleanUpAtTheStartOfDocument = function cleanUpAtTheStartOfDocument(state, dispatch) {
179
- var _ref3 = state.selection,
180
- $cursor = _ref3.$cursor;
181
- if ($cursor && !$cursor.nodeBefore && !$cursor.nodeAfter && $cursor.pos === 1) {
182
- var tr = state.tr,
183
- schema = state.schema;
184
- var paragraph = schema.nodes.paragraph;
185
- var parent = $cursor.parent;
186
-
187
- /**
188
- * Use cases:
189
- * 1. Change `heading` to `paragraph`
190
- * 2. Remove block marks
191
- *
192
- * NOTE: We already know it's an empty doc so it's safe to use 0
193
- */
194
- tr.setNodeMarkup(0, paragraph, parent.attrs, []);
195
- if (dispatch) {
196
- dispatch(tr);
197
- }
198
- return true;
199
- }
200
- return false;
201
- };
202
- exports.cleanUpAtTheStartOfDocument = cleanUpAtTheStartOfDocument;
@@ -1,56 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.deleteAndMoveCursor = void 0;
7
- var _state = require("@atlaskit/editor-prosemirror/state");
8
- // We should override default behaviour when selection spans node depths or
9
- // ends at a node junction
10
- var shouldMoveCursorAfterDelete = function shouldMoveCursorAfterDelete(state) {
11
- var _state$selection = state.selection,
12
- $from = _state$selection.$from,
13
- $to = _state$selection.$to;
14
- var nodeRange = $from.blockRange($to);
15
- if (!nodeRange) {
16
- return false;
17
- }
18
- var hasSameAncestor = $from.depth === $to.depth && $from.depth - 1 === nodeRange.depth;
19
- var toPositionHasNodeAfter = !!$to.nodeAfter;
20
- if (hasSameAncestor || toPositionHasNodeAfter) {
21
- return false;
22
- }
23
- return true;
24
- };
25
-
26
- /**
27
- * Fixes cursor position after delete for list/task in panel and table
28
- *
29
- * ED-13873 fixes a bug where after deleting a list the cursor would move
30
- * to the cell to the right. Uses setSelection to position the cursor as expected after deleting.
31
- *
32
- * @param state EditorState
33
- * @param dispatch CommandDispatch
34
- * @returns boolean
35
- */
36
- var deleteAndMoveCursor = function deleteAndMoveCursor(state, dispatch) {
37
- if (state.selection.empty || !(state.selection instanceof _state.TextSelection)) {
38
- return false;
39
- }
40
- if (!shouldMoveCursorAfterDelete(state)) {
41
- return false;
42
- }
43
- var tr = state.tr;
44
- tr.deleteSelection();
45
-
46
- // Make sure the next position is not out of boundaries
47
- var previousPosition = Math.min(Math.max(state.selection.$from.pos, 0), tr.doc.content.size);
48
- // Override default delete behaviour that moves the cursor to first suitable position after selection (postive bias).
49
- // See. selectionToInsertionEnd. We will override behavior with negative bias (search for suitable cursor position backwards).
50
- tr.setSelection(_state.Selection.near(tr.doc.resolve(previousPosition), -1));
51
- if (dispatch) {
52
- dispatch(tr.scrollIntoView());
53
- }
54
- return true;
55
- };
56
- exports.deleteAndMoveCursor = deleteAndMoveCursor;
@@ -1,45 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.deleteBlockContent = deleteBlockContent;
7
- /**
8
- * Prevent removing the block when deleting block content
9
- *
10
- * @param state EditorState
11
- * @param dispatch CommandDispatch
12
- * @returns boolean
13
- */
14
- function deleteBlockContent(isNodeAWrappingBlockNode) {
15
- return function (state, dispatch) {
16
- var tr = state.tr,
17
- _state$selection = state.selection,
18
- $from = _state$selection.$from,
19
- $to = _state$selection.$to,
20
- doc = state.doc;
21
- if ($from.pos === $to.pos) {
22
- return false;
23
- }
24
- var selectionCrossesWrappingBlockNode = false;
25
- doc.nodesBetween($from.pos, $to.pos, function (node, pos) {
26
- // Optimisation. If selection crosses wrapping block node
27
- // short circuit the loop by returning false
28
- if (selectionCrossesWrappingBlockNode) {
29
- return false;
30
- }
31
- if (isNodeAWrappingBlockNode(node)) {
32
- selectionCrossesWrappingBlockNode = true;
33
- return false;
34
- }
35
- });
36
- if (!selectionCrossesWrappingBlockNode) {
37
- return false;
38
- }
39
- tr.delete($from.pos, $to.pos);
40
- if (dispatch) {
41
- dispatch(tr);
42
- }
43
- return true;
44
- };
45
- }
@@ -1,68 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "cleanUpAtTheStartOfDocument", {
7
- enumerable: true,
8
- get: function get() {
9
- return _blockType.cleanUpAtTheStartOfDocument;
10
- }
11
- });
12
- Object.defineProperty(exports, "deleteAndMoveCursor", {
13
- enumerable: true,
14
- get: function get() {
15
- return _deleteAndMoveCursor.deleteAndMoveCursor;
16
- }
17
- });
18
- Object.defineProperty(exports, "deleteBlockContent", {
19
- enumerable: true,
20
- get: function get() {
21
- return _deleteBlockContent.deleteBlockContent;
22
- }
23
- });
24
- Object.defineProperty(exports, "insertBlockQuoteWithAnalytics", {
25
- enumerable: true,
26
- get: function get() {
27
- return _blockType.insertBlockQuoteWithAnalytics;
28
- }
29
- });
30
- Object.defineProperty(exports, "setBlockType", {
31
- enumerable: true,
32
- get: function get() {
33
- return _blockType.setBlockType;
34
- }
35
- });
36
- Object.defineProperty(exports, "setBlockTypeWithAnalytics", {
37
- enumerable: true,
38
- get: function get() {
39
- return _blockType.setBlockTypeWithAnalytics;
40
- }
41
- });
42
- Object.defineProperty(exports, "setHeading", {
43
- enumerable: true,
44
- get: function get() {
45
- return _blockType.setHeading;
46
- }
47
- });
48
- Object.defineProperty(exports, "setHeadingWithAnalytics", {
49
- enumerable: true,
50
- get: function get() {
51
- return _blockType.setHeadingWithAnalytics;
52
- }
53
- });
54
- Object.defineProperty(exports, "setNormalText", {
55
- enumerable: true,
56
- get: function get() {
57
- return _blockType.setNormalText;
58
- }
59
- });
60
- Object.defineProperty(exports, "setNormalTextWithAnalytics", {
61
- enumerable: true,
62
- get: function get() {
63
- return _blockType.setNormalTextWithAnalytics;
64
- }
65
- });
66
- var _blockType = require("./block-type");
67
- var _deleteAndMoveCursor = require("./delete-and-move-cursor");
68
- var _deleteBlockContent = require("./delete-block-content");
@@ -1,15 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.HEADING_KEYS = void 0;
7
- var KEY_0 = 48;
8
- var KEY_1 = 49;
9
- var KEY_2 = 50;
10
- var KEY_3 = 51;
11
- var KEY_4 = 52;
12
- var KEY_5 = 53;
13
- var KEY_6 = 54;
14
- var HEADING_KEYS = [KEY_0, KEY_1, KEY_2, KEY_3, KEY_4, KEY_5, KEY_6];
15
- exports.HEADING_KEYS = HEADING_KEYS;
@@ -1,215 +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
- Object.defineProperty(exports, "pluginKey", {
9
- enumerable: true,
10
- get: function get() {
11
- return _main.pluginKey;
12
- }
13
- });
14
- var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
15
- var _react = _interopRequireDefault(require("react"));
16
- var _adfSchema = require("@atlaskit/adf-schema");
17
- var _types = require("@atlaskit/editor-common/types");
18
- var _withPluginState = require("@atlaskit/editor-common/with-plugin-state");
19
- var _analytics = require("@atlaskit/editor-common/analytics");
20
- var _quickInsert = require("@atlaskit/editor-common/quick-insert");
21
- var _keymaps = require("@atlaskit/editor-common/keymaps");
22
- var _main = require("./pm-plugins/main");
23
- var _keymap = _interopRequireDefault(require("./pm-plugins/keymap"));
24
- var _inputRule = _interopRequireDefault(require("./pm-plugins/input-rule"));
25
- var _ToolbarBlockType = _interopRequireDefault(require("./ui/ToolbarBlockType"));
26
- var _commands = require("./commands");
27
- var _messages = require("./messages");
28
- var _blockType = require("./commands/block-type");
29
- var headingPluginOptions = function headingPluginOptions(_ref, isAllowed, editorAnalyticsApi) {
30
- var formatMessage = _ref.formatMessage;
31
- if (!isAllowed) {
32
- return [];
33
- }
34
- return Array.from({
35
- length: 6
36
- }, function (_v, idx) {
37
- var level = idx + 1;
38
- var descriptionDescriptor = _messages.messages["heading".concat(level, "Description")];
39
- var keyshortcut = (0, _keymaps.tooltip)(_keymaps.keymap["toggleHeading".concat(level)]);
40
- var id = "heading".concat(level);
41
- return {
42
- id: id,
43
- title: formatMessage(_messages.messages[id]),
44
- description: formatMessage(descriptionDescriptor),
45
- priority: 1300,
46
- keywords: ["h".concat(level)],
47
- keyshortcut: keyshortcut,
48
- icon: function icon() {
49
- return /*#__PURE__*/_react.default.createElement(_quickInsert.IconHeading, {
50
- level: level
51
- });
52
- },
53
- action: function action(insert, state) {
54
- var tr = insert(state.schema.nodes.heading.createChecked({
55
- level: level
56
- }));
57
- editorAnalyticsApi === null || editorAnalyticsApi === void 0 ? void 0 : editorAnalyticsApi.attachAnalyticsEvent({
58
- action: _analytics.ACTION.FORMATTED,
59
- actionSubject: _analytics.ACTION_SUBJECT.TEXT,
60
- eventType: _analytics.EVENT_TYPE.TRACK,
61
- actionSubjectId: _analytics.ACTION_SUBJECT_ID.FORMAT_HEADING,
62
- attributes: {
63
- inputMethod: _analytics.INPUT_METHOD.QUICK_INSERT,
64
- newHeadingLevel: level
65
- }
66
- })(tr);
67
- return tr;
68
- }
69
- };
70
- });
71
- };
72
- var blockquotePluginOptions = function blockquotePluginOptions(_ref2, isAllowed, editorAnalyticsApi) {
73
- var formatMessage = _ref2.formatMessage;
74
- if (!isAllowed) {
75
- return [];
76
- }
77
- return [{
78
- id: 'blockquote',
79
- title: formatMessage(_messages.messages.blockquote),
80
- description: formatMessage(_messages.messages.blockquoteDescription),
81
- priority: 1300,
82
- keyshortcut: (0, _keymaps.tooltip)(_keymaps.toggleBlockQuote),
83
- icon: function icon() {
84
- return /*#__PURE__*/_react.default.createElement(_quickInsert.IconQuote, null);
85
- },
86
- action: function action(insert, state) {
87
- var tr = insert(state.schema.nodes.blockquote.createChecked({}, state.schema.nodes.paragraph.createChecked()));
88
- editorAnalyticsApi === null || editorAnalyticsApi === void 0 ? void 0 : editorAnalyticsApi.attachAnalyticsEvent({
89
- action: _analytics.ACTION.FORMATTED,
90
- actionSubject: _analytics.ACTION_SUBJECT.TEXT,
91
- eventType: _analytics.EVENT_TYPE.TRACK,
92
- actionSubjectId: _analytics.ACTION_SUBJECT_ID.FORMAT_BLOCK_QUOTE,
93
- attributes: {
94
- inputMethod: _analytics.INPUT_METHOD.QUICK_INSERT
95
- }
96
- })(tr);
97
- return tr;
98
- }
99
- }];
100
- };
101
- var blockTypePlugin = function blockTypePlugin(_ref3) {
102
- var options = _ref3.config,
103
- api = _ref3.api;
104
- return {
105
- name: 'blockType',
106
- nodes: function nodes() {
107
- var nodes = [{
108
- name: 'heading',
109
- node: _adfSchema.heading
110
- }, {
111
- name: 'blockquote',
112
- node: _adfSchema.blockquote
113
- }, {
114
- name: 'hardBreak',
115
- node: _adfSchema.hardBreak
116
- }];
117
- if (options && options.allowBlockType) {
118
- var exclude = options.allowBlockType.exclude ? options.allowBlockType.exclude : [];
119
- return nodes.filter(function (node) {
120
- return exclude.indexOf(node.name) === -1;
121
- });
122
- }
123
- return nodes;
124
- },
125
- pmPlugins: function pmPlugins() {
126
- return [{
127
- name: 'blockType',
128
- plugin: function plugin(_ref4) {
129
- var _api$analytics;
130
- var dispatch = _ref4.dispatch;
131
- return (0, _main.createPlugin)(api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions, dispatch, options && options.lastNodeMustBeParagraph);
132
- }
133
- }, {
134
- name: 'blockTypeInputRule',
135
- plugin: function plugin(_ref5) {
136
- var _api$analytics2;
137
- var schema = _ref5.schema,
138
- featureFlags = _ref5.featureFlags;
139
- return (0, _inputRule.default)(api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions, schema, featureFlags);
140
- }
141
- },
142
- // Needs to be lower priority than editor-tables.tableEditing
143
- // plugin as it is currently swallowing right/down arrow events inside tables
144
- {
145
- name: 'blockTypeKeyMap',
146
- plugin: function plugin(_ref6) {
147
- var _api$analytics3;
148
- var schema = _ref6.schema,
149
- featureFlags = _ref6.featureFlags;
150
- return (0, _keymap.default)(api === null || api === void 0 ? void 0 : (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions, schema, featureFlags);
151
- }
152
- }];
153
- },
154
- actions: {
155
- insertBlockQuote: function insertBlockQuote(inputMethod) {
156
- var _api$analytics4;
157
- return (0, _blockType.insertBlockQuoteWithAnalytics)(inputMethod, api === null || api === void 0 ? void 0 : (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions);
158
- },
159
- setBlockType: function setBlockType(name, inputMethod) {
160
- var _api$analytics5;
161
- return (0, _commands.setBlockTypeWithAnalytics)(name, inputMethod, api === null || api === void 0 ? void 0 : (_api$analytics5 = api.analytics) === null || _api$analytics5 === void 0 ? void 0 : _api$analytics5.actions);
162
- }
163
- },
164
- getSharedState: function getSharedState(editorState) {
165
- if (!editorState) {
166
- return;
167
- }
168
- return _main.pluginKey.getState(editorState);
169
- },
170
- primaryToolbarComponent: function primaryToolbarComponent(_ref7) {
171
- var editorView = _ref7.editorView,
172
- popupsMountPoint = _ref7.popupsMountPoint,
173
- popupsBoundariesElement = _ref7.popupsBoundariesElement,
174
- popupsScrollableElement = _ref7.popupsScrollableElement,
175
- toolbarSize = _ref7.toolbarSize,
176
- disabled = _ref7.disabled,
177
- isToolbarReducedSpacing = _ref7.isToolbarReducedSpacing,
178
- eventDispatcher = _ref7.eventDispatcher;
179
- var isSmall = options && options.isUndoRedoButtonsEnabled ? toolbarSize < _types.ToolbarSize.XXL : toolbarSize < _types.ToolbarSize.XL;
180
- var boundSetBlockType = function boundSetBlockType(name) {
181
- var _api$analytics6;
182
- return (0, _commands.setBlockTypeWithAnalytics)(name, _analytics.INPUT_METHOD.TOOLBAR, api === null || api === void 0 ? void 0 : (_api$analytics6 = api.analytics) === null || _api$analytics6 === void 0 ? void 0 : _api$analytics6.actions)(editorView.state, editorView.dispatch);
183
- };
184
- return /*#__PURE__*/_react.default.createElement(_withPluginState.WithPluginState, {
185
- editorView: editorView,
186
- eventDispatcher: eventDispatcher,
187
- plugins: {
188
- pluginState: _main.pluginKey
189
- },
190
- render: function render(_ref8) {
191
- var pluginState = _ref8.pluginState;
192
- return /*#__PURE__*/_react.default.createElement(_ToolbarBlockType.default, {
193
- isSmall: isSmall,
194
- isDisabled: disabled,
195
- isReducedSpacing: isToolbarReducedSpacing,
196
- setBlockType: boundSetBlockType,
197
- pluginState: pluginState,
198
- popupsMountPoint: popupsMountPoint,
199
- popupsBoundariesElement: popupsBoundariesElement,
200
- popupsScrollableElement: popupsScrollableElement
201
- });
202
- }
203
- });
204
- },
205
- pluginsOptions: {
206
- quickInsert: function quickInsert(intl) {
207
- var _api$analytics7, _api$analytics8;
208
- var exclude = options && options.allowBlockType && options.allowBlockType.exclude ? options.allowBlockType.exclude : [];
209
- return [].concat((0, _toConsumableArray2.default)(blockquotePluginOptions(intl, exclude.indexOf('blockquote') === -1, api === null || api === void 0 ? void 0 : (_api$analytics7 = api.analytics) === null || _api$analytics7 === void 0 ? void 0 : _api$analytics7.actions)), (0, _toConsumableArray2.default)(headingPluginOptions(intl, exclude.indexOf('heading') === -1, api === null || api === void 0 ? void 0 : (_api$analytics8 = api.analytics) === null || _api$analytics8 === void 0 ? void 0 : _api$analytics8.actions)));
210
- }
211
- }
212
- };
213
- };
214
- var _default = blockTypePlugin;
215
- exports.default = _default;