@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
@@ -1,201 +0,0 @@
1
- import React from 'react';
2
- import { blockquote, hardBreak, heading } from '@atlaskit/adf-schema';
3
- import { ToolbarSize } from '@atlaskit/editor-common/types';
4
- import { WithPluginState } from '@atlaskit/editor-common/with-plugin-state';
5
- import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
6
- import { IconHeading, IconQuote } from '@atlaskit/editor-common/quick-insert';
7
- import { tooltip, toggleBlockQuote, keymap } from '@atlaskit/editor-common/keymaps';
8
- import { createPlugin, pluginKey } from './pm-plugins/main';
9
- import keymapPlugin from './pm-plugins/keymap';
10
- import inputRulePlugin from './pm-plugins/input-rule';
11
- import ToolbarBlockType from './ui/ToolbarBlockType';
12
- import { setBlockTypeWithAnalytics } from './commands';
13
- import { messages } from './messages';
14
- import { insertBlockQuoteWithAnalytics } from './commands/block-type';
15
- const headingPluginOptions = ({
16
- formatMessage
17
- }, isAllowed, editorAnalyticsApi) => {
18
- if (!isAllowed) {
19
- return [];
20
- }
21
- return Array.from({
22
- length: 6
23
- }, (_v, idx) => {
24
- const level = idx + 1;
25
- const descriptionDescriptor = messages[`heading${level}Description`];
26
- const keyshortcut = tooltip(keymap[`toggleHeading${level}`]);
27
- const id = `heading${level}`;
28
- return {
29
- id,
30
- title: formatMessage(messages[id]),
31
- description: formatMessage(descriptionDescriptor),
32
- priority: 1300,
33
- keywords: [`h${level}`],
34
- keyshortcut,
35
- icon: () => /*#__PURE__*/React.createElement(IconHeading, {
36
- level: level
37
- }),
38
- action(insert, state) {
39
- const tr = insert(state.schema.nodes.heading.createChecked({
40
- level
41
- }));
42
- editorAnalyticsApi === null || editorAnalyticsApi === void 0 ? void 0 : editorAnalyticsApi.attachAnalyticsEvent({
43
- action: ACTION.FORMATTED,
44
- actionSubject: ACTION_SUBJECT.TEXT,
45
- eventType: EVENT_TYPE.TRACK,
46
- actionSubjectId: ACTION_SUBJECT_ID.FORMAT_HEADING,
47
- attributes: {
48
- inputMethod: INPUT_METHOD.QUICK_INSERT,
49
- newHeadingLevel: level
50
- }
51
- })(tr);
52
- return tr;
53
- }
54
- };
55
- });
56
- };
57
- const blockquotePluginOptions = ({
58
- formatMessage
59
- }, isAllowed, editorAnalyticsApi) => {
60
- if (!isAllowed) {
61
- return [];
62
- }
63
- return [{
64
- id: 'blockquote',
65
- title: formatMessage(messages.blockquote),
66
- description: formatMessage(messages.blockquoteDescription),
67
- priority: 1300,
68
- keyshortcut: tooltip(toggleBlockQuote),
69
- icon: () => /*#__PURE__*/React.createElement(IconQuote, null),
70
- action(insert, state) {
71
- const tr = insert(state.schema.nodes.blockquote.createChecked({}, state.schema.nodes.paragraph.createChecked()));
72
- editorAnalyticsApi === null || editorAnalyticsApi === void 0 ? void 0 : editorAnalyticsApi.attachAnalyticsEvent({
73
- action: ACTION.FORMATTED,
74
- actionSubject: ACTION_SUBJECT.TEXT,
75
- eventType: EVENT_TYPE.TRACK,
76
- actionSubjectId: ACTION_SUBJECT_ID.FORMAT_BLOCK_QUOTE,
77
- attributes: {
78
- inputMethod: INPUT_METHOD.QUICK_INSERT
79
- }
80
- })(tr);
81
- return tr;
82
- }
83
- }];
84
- };
85
- const blockTypePlugin = ({
86
- config: options,
87
- api
88
- }) => ({
89
- name: 'blockType',
90
- nodes() {
91
- const nodes = [{
92
- name: 'heading',
93
- node: heading
94
- }, {
95
- name: 'blockquote',
96
- node: blockquote
97
- }, {
98
- name: 'hardBreak',
99
- node: hardBreak
100
- }];
101
- if (options && options.allowBlockType) {
102
- const exclude = options.allowBlockType.exclude ? options.allowBlockType.exclude : [];
103
- return nodes.filter(node => exclude.indexOf(node.name) === -1);
104
- }
105
- return nodes;
106
- },
107
- pmPlugins() {
108
- return [{
109
- name: 'blockType',
110
- plugin: ({
111
- dispatch
112
- }) => {
113
- var _api$analytics;
114
- return 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);
115
- }
116
- }, {
117
- name: 'blockTypeInputRule',
118
- plugin: ({
119
- schema,
120
- featureFlags
121
- }) => {
122
- var _api$analytics2;
123
- return inputRulePlugin(api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions, schema, featureFlags);
124
- }
125
- },
126
- // Needs to be lower priority than editor-tables.tableEditing
127
- // plugin as it is currently swallowing right/down arrow events inside tables
128
- {
129
- name: 'blockTypeKeyMap',
130
- plugin: ({
131
- schema,
132
- featureFlags
133
- }) => {
134
- var _api$analytics3;
135
- return keymapPlugin(api === null || api === void 0 ? void 0 : (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions, schema, featureFlags);
136
- }
137
- }];
138
- },
139
- actions: {
140
- insertBlockQuote(inputMethod) {
141
- var _api$analytics4;
142
- return insertBlockQuoteWithAnalytics(inputMethod, api === null || api === void 0 ? void 0 : (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions);
143
- },
144
- setBlockType(name, inputMethod) {
145
- var _api$analytics5;
146
- return setBlockTypeWithAnalytics(name, inputMethod, api === null || api === void 0 ? void 0 : (_api$analytics5 = api.analytics) === null || _api$analytics5 === void 0 ? void 0 : _api$analytics5.actions);
147
- }
148
- },
149
- getSharedState(editorState) {
150
- if (!editorState) {
151
- return;
152
- }
153
- return pluginKey.getState(editorState);
154
- },
155
- primaryToolbarComponent({
156
- editorView,
157
- popupsMountPoint,
158
- popupsBoundariesElement,
159
- popupsScrollableElement,
160
- toolbarSize,
161
- disabled,
162
- isToolbarReducedSpacing,
163
- eventDispatcher
164
- }) {
165
- const isSmall = options && options.isUndoRedoButtonsEnabled ? toolbarSize < ToolbarSize.XXL : toolbarSize < ToolbarSize.XL;
166
- const boundSetBlockType = name => {
167
- var _api$analytics6;
168
- return setBlockTypeWithAnalytics(name, 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);
169
- };
170
- return /*#__PURE__*/React.createElement(WithPluginState, {
171
- editorView: editorView,
172
- eventDispatcher: eventDispatcher,
173
- plugins: {
174
- pluginState: pluginKey
175
- },
176
- render: ({
177
- pluginState
178
- }) => {
179
- return /*#__PURE__*/React.createElement(ToolbarBlockType, {
180
- isSmall: isSmall,
181
- isDisabled: disabled,
182
- isReducedSpacing: isToolbarReducedSpacing,
183
- setBlockType: boundSetBlockType,
184
- pluginState: pluginState,
185
- popupsMountPoint: popupsMountPoint,
186
- popupsBoundariesElement: popupsBoundariesElement,
187
- popupsScrollableElement: popupsScrollableElement
188
- });
189
- }
190
- });
191
- },
192
- pluginsOptions: {
193
- quickInsert: intl => {
194
- var _api$analytics7, _api$analytics8;
195
- const exclude = options && options.allowBlockType && options.allowBlockType.exclude ? options.allowBlockType.exclude : [];
196
- return [...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), ...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)];
197
- }
198
- }
199
- });
200
- export default blockTypePlugin;
201
- export { pluginKey } from './pm-plugins/main';
@@ -1,153 +0,0 @@
1
- import { defineMessages } from 'react-intl-next';
2
- export const messages = defineMessages({
3
- normal: {
4
- id: 'fabric.editor.normal',
5
- defaultMessage: 'Normal text',
6
- description: 'This is the default text style'
7
- },
8
- heading1: {
9
- id: 'fabric.editor.heading1',
10
- defaultMessage: 'Heading 1',
11
- description: 'Used for the title of a section of your document, headings run from 1 (largest size) to 6 (smallest size)'
12
- },
13
- heading1Description: {
14
- id: 'fabric.editor.heading1Description',
15
- defaultMessage: 'Use this for a top level heading',
16
- description: 'Description of the main heading, heading 1'
17
- },
18
- heading2: {
19
- id: 'fabric.editor.heading2',
20
- defaultMessage: 'Heading 2',
21
- description: 'Used for the title of a section of your document, headings run from 1 (largest size) to 6 (smallest size)'
22
- },
23
- heading2Description: {
24
- id: 'fabric.editor.heading2Description',
25
- defaultMessage: 'Use this for key sections',
26
- description: 'Description of a subtitle heading or secondary heading'
27
- },
28
- heading3: {
29
- id: 'fabric.editor.heading3',
30
- defaultMessage: 'Heading 3',
31
- description: 'Used for the title of a section of your document, headings run from 1 (largest size) to 6 (smallest size)'
32
- },
33
- heading3Description: {
34
- id: 'fabric.editor.heading3Description',
35
- defaultMessage: 'Use this for sub sections and group headings',
36
- description: ''
37
- },
38
- heading4: {
39
- id: 'fabric.editor.heading4',
40
- defaultMessage: 'Heading 4',
41
- description: 'Used for the title of a section of your document, headings run from 1 (largest size) to 6 (smallest size)'
42
- },
43
- heading4Description: {
44
- id: 'fabric.editor.heading4Description',
45
- defaultMessage: 'Use this for deep headings',
46
- description: ''
47
- },
48
- heading5: {
49
- id: 'fabric.editor.heading5',
50
- defaultMessage: 'Heading 5',
51
- description: 'Used for the title of a section of your document, headings run from 1 (largest size) to 6 (smallest size)'
52
- },
53
- heading5Description: {
54
- id: 'fabric.editor.heading5Description',
55
- defaultMessage: 'Use this for grouping list items',
56
- description: ''
57
- },
58
- heading6: {
59
- id: 'fabric.editor.heading6',
60
- defaultMessage: 'Heading 6',
61
- description: 'Used for the title of a section of your document, headings run from 1 (largest size) to 6 (smallest size)'
62
- },
63
- heading6Description: {
64
- id: 'fabric.editor.heading6Description',
65
- defaultMessage: 'Use this for low level headings',
66
- description: ''
67
- },
68
- blockquote: {
69
- id: 'fabric.editor.blockquote2',
70
- defaultMessage: 'Quote',
71
- description: 'Quote some text'
72
- },
73
- blockquoteDescription: {
74
- id: 'fabric.editor.blockquote.description',
75
- defaultMessage: 'Insert a quote or citation',
76
- description: 'Quote some text'
77
- },
78
- codeblock: {
79
- id: 'fabric.editor.codeblock',
80
- defaultMessage: 'Code snippet',
81
- description: 'Insert a snippet/segment of code (code block)'
82
- },
83
- codeblockDescription: {
84
- id: 'fabric.editor.codeblock.description',
85
- defaultMessage: 'Display code with syntax highlighting',
86
- description: 'Insert a snippet/segment of code (code block)'
87
- },
88
- infoPanel: {
89
- id: 'fabric.editor.infoPanel',
90
- defaultMessage: 'Info panel',
91
- description: 'Visually distinguishes your text by adding a background colour (blue, purple, yellow, green, red)'
92
- },
93
- infoPanelDescription: {
94
- id: 'fabric.editor.infoPanel.description',
95
- defaultMessage: 'Highlight information in a colored panel',
96
- description: 'Visually distinguishes your text by adding a background colour (blue, purple, yellow, green, red)'
97
- },
98
- notePanel: {
99
- id: 'fabric.editor.notePanel',
100
- defaultMessage: 'Note panel',
101
- description: 'Visually distinguishes your text by adding a note panel'
102
- },
103
- notePanelDescription: {
104
- id: 'fabric.editor.notePanel.description',
105
- defaultMessage: 'Add a note in a colored panel',
106
- description: 'Visually distinguishes your text by adding a note panel'
107
- },
108
- successPanel: {
109
- id: 'fabric.editor.successPanel',
110
- defaultMessage: 'Success panel',
111
- description: 'Visually distinguishes your text by adding a success panel'
112
- },
113
- successPanelDescription: {
114
- id: 'fabric.editor.successPanel.description',
115
- defaultMessage: 'Add tips in a colored panel',
116
- description: 'Visually distinguishes your text by adding a success panel'
117
- },
118
- warningPanel: {
119
- id: 'fabric.editor.warningPanel',
120
- defaultMessage: 'Warning panel',
121
- description: 'Visually distinguishes your text by adding a warning panel'
122
- },
123
- warningPanelDescription: {
124
- id: 'fabric.editor.warningPanel.description',
125
- defaultMessage: 'Add a note of caution in a colored panel',
126
- description: 'Visually distinguishes your text by adding a warning panel'
127
- },
128
- errorPanel: {
129
- id: 'fabric.editor.errorPanel',
130
- defaultMessage: 'Error panel',
131
- description: 'Visually distinguishes your text by adding a error panel'
132
- },
133
- errorPanelDescription: {
134
- id: 'fabric.editor.errorPanel.description',
135
- defaultMessage: 'Call out errors in a colored panel',
136
- description: 'Visually distinguishes your text by adding a error panel'
137
- },
138
- customPanel: {
139
- id: 'fabric.editor.customPanel',
140
- defaultMessage: 'Custom panel',
141
- description: 'Visually distinguishes your panel by adding a emoji icon and background color'
142
- },
143
- customPanelDescription: {
144
- id: 'fabric.editor.customPanel.description',
145
- defaultMessage: 'Add a note with an emoji and colored background',
146
- description: 'Visually distinguishes your panel by adding a emoji icon and background color '
147
- },
148
- other: {
149
- id: 'fabric.editor.other',
150
- defaultMessage: 'Others...',
151
- description: 'Other text formatting'
152
- }
153
- });
@@ -1,93 +0,0 @@
1
- import { createRule, createPlugin, leafNodeReplacementCharacter } from '@atlaskit/prosemirror-input-rules';
2
- import { INPUT_METHOD, ACTION, ACTION_SUBJECT, EVENT_TYPE, ACTION_SUBJECT_ID } from '@atlaskit/editor-common/analytics';
3
- import { inputRuleWithAnalytics } from '@atlaskit/editor-common/utils';
4
- import { insertBlock } from '@atlaskit/editor-common/commands';
5
- import { createJoinNodesRule, createWrappingTextBlockRule } from '../utils';
6
- const MAX_HEADING_LEVEL = 6;
7
- function getHeadingLevel(match) {
8
- return {
9
- level: match[1].length
10
- };
11
- }
12
- function headingRule(nodeType, maxLevel) {
13
- return createWrappingTextBlockRule({
14
- match: new RegExp('^(#{1,' + maxLevel + '})\\s$'),
15
- nodeType,
16
- getAttrs: getHeadingLevel
17
- });
18
- }
19
- function blockQuoteRule(nodeType) {
20
- return createJoinNodesRule(/^\s*>\s$/, nodeType);
21
- }
22
-
23
- /**
24
- * Get heading rules
25
- *
26
- * @param {Schema} schema
27
- * @returns {InputRuleWithHandler[]}
28
- */
29
- function getHeadingRules(editorAnalyticsAPI, schema) {
30
- // '# ' for h1, '## ' for h2 and etc
31
- const hashRule = headingRule(schema.nodes.heading, MAX_HEADING_LEVEL);
32
- const leftNodeReplacementHashRule = createRule(new RegExp(`${leafNodeReplacementCharacter}(#{1,6})\\s$`), (state, match, start, end) => {
33
- const level = match[1].length;
34
- return insertBlock(state, schema.nodes.heading, start, end, {
35
- level
36
- });
37
- });
38
-
39
- // New analytics handler
40
- const ruleWithHeadingAnalytics = inputRuleWithAnalytics((_state, matchResult) => ({
41
- action: ACTION.FORMATTED,
42
- actionSubject: ACTION_SUBJECT.TEXT,
43
- eventType: EVENT_TYPE.TRACK,
44
- actionSubjectId: ACTION_SUBJECT_ID.FORMAT_HEADING,
45
- attributes: {
46
- inputMethod: INPUT_METHOD.FORMATTING,
47
- newHeadingLevel: getHeadingLevel(matchResult).level
48
- }
49
- }), editorAnalyticsAPI);
50
- return [ruleWithHeadingAnalytics(hashRule), ruleWithHeadingAnalytics(leftNodeReplacementHashRule)];
51
- }
52
-
53
- /**
54
- * Get all block quote input rules
55
- *
56
- * @param {Schema} schema
57
- * @returns {InputRuleWithHandler[]}
58
- */
59
- function getBlockQuoteRules(editorAnalyticsAPI, schema) {
60
- // '> ' for blockquote
61
- const greatherThanRule = blockQuoteRule(schema.nodes.blockquote);
62
- const leftNodeReplacementGreatherRule = createRule(new RegExp(`${leafNodeReplacementCharacter}\\s*>\\s$`), (state, _match, start, end) => {
63
- return insertBlock(state, schema.nodes.blockquote, start, end);
64
- });
65
-
66
- // Analytics V3 handler
67
- const ruleWithBlockQuoteAnalytics = inputRuleWithAnalytics({
68
- action: ACTION.FORMATTED,
69
- actionSubject: ACTION_SUBJECT.TEXT,
70
- eventType: EVENT_TYPE.TRACK,
71
- actionSubjectId: ACTION_SUBJECT_ID.FORMAT_BLOCK_QUOTE,
72
- attributes: {
73
- inputMethod: INPUT_METHOD.FORMATTING
74
- }
75
- }, editorAnalyticsAPI);
76
- return [ruleWithBlockQuoteAnalytics(greatherThanRule), ruleWithBlockQuoteAnalytics(leftNodeReplacementGreatherRule)];
77
- }
78
- function inputRulePlugin(editorAnalyticsAPI, schema, featureFlags) {
79
- const rules = [];
80
- if (schema.nodes.heading) {
81
- rules.push(...getHeadingRules(editorAnalyticsAPI, schema));
82
- }
83
- if (schema.nodes.blockquote) {
84
- rules.push(...getBlockQuoteRules(editorAnalyticsAPI, schema));
85
- }
86
- if (rules.length !== 0) {
87
- return createPlugin('block-type', rules, {
88
- isBlockNodeRule: true
89
- });
90
- }
91
- return;
92
- }
93
- export default inputRulePlugin;
@@ -1,25 +0,0 @@
1
- import { redo, undo } from '@atlaskit/editor-prosemirror/history';
2
- import { chainCommands } from '@atlaskit/editor-prosemirror/commands';
3
- import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
4
- import { bindKeymapWithCommand, moveUp, moveDown, findKeyMapForBrowser, undo as undoKeymap, redo as redoKeymap, backspace, deleteKey, forwardDelete, toggleBlockQuote, keymap, insertNewLine, findShortcutByKeymap } from '@atlaskit/editor-common/keymaps';
5
- import { insertNewLineWithAnalytics, createNewParagraphAbove, createNewParagraphBelow, deleteEmptyParagraphAndMoveBlockUp } from '@atlaskit/editor-common/utils';
6
- import * as blockTypes from '../types';
7
- import { cleanUpAtTheStartOfDocument, deleteAndMoveCursor, deleteBlockContent, insertBlockQuoteWithAnalytics } from '../commands';
8
- import { isNodeAWrappingBlockNode } from '../utils';
9
- const backspaceCommand = chainCommands(cleanUpAtTheStartOfDocument, deleteBlockContent(isNodeAWrappingBlockNode), deleteAndMoveCursor);
10
- const del = chainCommands(deleteEmptyParagraphAndMoveBlockUp(isNodeAWrappingBlockNode), deleteBlockContent(isNodeAWrappingBlockNode), deleteAndMoveCursor);
11
- export default function keymapPlugin(editorAnalyticsApi, schema, _featureFlags) {
12
- const list = {};
13
- bindKeymapWithCommand(insertNewLine.common, insertNewLineWithAnalytics(editorAnalyticsApi), list);
14
- bindKeymapWithCommand(moveUp.common, createNewParagraphAbove, list);
15
- bindKeymapWithCommand(moveDown.common, createNewParagraphBelow, list);
16
- bindKeymapWithCommand(findKeyMapForBrowser(redoKeymap), redo, list);
17
- bindKeymapWithCommand(undoKeymap.common, undo, list);
18
- bindKeymapWithCommand(backspace.common, backspaceCommand, list);
19
- bindKeymapWithCommand(deleteKey.common, del, list);
20
- bindKeymapWithCommand(forwardDelete.mac, del, list);
21
- if (schema.nodes[blockTypes.BLOCK_QUOTE.nodeName]) {
22
- bindKeymapWithCommand(findShortcutByKeymap(toggleBlockQuote), insertBlockQuoteWithAnalytics(INPUT_METHOD.KEYBOARD, editorAnalyticsApi), list);
23
- }
24
- return keymap(list);
25
- }
@@ -1,137 +0,0 @@
1
- import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
- import { PluginKey } from '@atlaskit/editor-prosemirror/state';
3
- import { browser } from '@atlaskit/editor-common/utils';
4
- import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
5
- import { NORMAL_TEXT, HEADING_1, HEADING_2, HEADING_3, HEADING_4, HEADING_5, HEADING_6, BLOCK_QUOTE, CODE_BLOCK, PANEL, OTHER, TEXT_BLOCK_TYPES, WRAPPER_BLOCK_TYPES, HEADINGS_BY_LEVEL } from '../types';
6
- import { HEADING_KEYS } from '../consts';
7
- import { setHeadingWithAnalytics, setNormalTextWithAnalytics } from '../commands';
8
- import { areBlockTypesDisabled } from '../utils';
9
- const blockTypeForNode = (node, schema) => {
10
- if (node.type === schema.nodes.heading) {
11
- const maybeNode = HEADINGS_BY_LEVEL[node.attrs['level']];
12
- if (maybeNode) {
13
- return maybeNode;
14
- }
15
- } else if (node.type === schema.nodes.paragraph) {
16
- return NORMAL_TEXT;
17
- }
18
- return OTHER;
19
- };
20
- const isBlockTypeSchemaSupported = (blockType, state) => {
21
- switch (blockType) {
22
- case NORMAL_TEXT:
23
- return !!state.schema.nodes.paragraph;
24
- case HEADING_1:
25
- case HEADING_2:
26
- case HEADING_3:
27
- case HEADING_4:
28
- case HEADING_5:
29
- case HEADING_6:
30
- return !!state.schema.nodes.heading;
31
- case BLOCK_QUOTE:
32
- return !!state.schema.nodes.blockquote;
33
- case CODE_BLOCK:
34
- return !!state.schema.nodes.codeBlock;
35
- case PANEL:
36
- return !!state.schema.nodes.panel;
37
- }
38
- return;
39
- };
40
- const detectBlockType = (availableBlockTypes, state) => {
41
- // Before a document is loaded, there is no selection.
42
- if (!state.selection) {
43
- return NORMAL_TEXT;
44
- }
45
- let blockType;
46
- const {
47
- $from,
48
- $to
49
- } = state.selection;
50
- state.doc.nodesBetween($from.pos, $to.pos, node => {
51
- const nodeBlockType = availableBlockTypes.filter(blockType => blockType === blockTypeForNode(node, state.schema));
52
- if (nodeBlockType.length > 0) {
53
- if (!blockType) {
54
- blockType = nodeBlockType[0];
55
- } else if (blockType !== OTHER && blockType !== nodeBlockType[0]) {
56
- blockType = OTHER;
57
- }
58
- }
59
- });
60
- return blockType || OTHER;
61
- };
62
- const autoformatHeading = (headingLevel, view, editorAnalyticsApi) => {
63
- if (headingLevel === 0) {
64
- setNormalTextWithAnalytics(INPUT_METHOD.FORMATTING, editorAnalyticsApi)(view.state, view.dispatch);
65
- } else {
66
- setHeadingWithAnalytics(headingLevel, INPUT_METHOD.FORMATTING, editorAnalyticsApi)(view.state, view.dispatch);
67
- }
68
- return true;
69
- };
70
- export const pluginKey = new PluginKey('blockTypePlugin');
71
- export const createPlugin = (editorAnalyticsApi, dispatch, lastNodeMustBeParagraph) => {
72
- let altKeyLocation = 0;
73
- return new SafePlugin({
74
- appendTransaction(_transactions, _oldState, newState) {
75
- if (lastNodeMustBeParagraph) {
76
- const pos = newState.doc.resolve(newState.doc.content.size - 1);
77
- const lastNode = pos.node(1);
78
- const {
79
- paragraph
80
- } = newState.schema.nodes;
81
- if (lastNode && lastNode.isBlock && lastNode.type !== paragraph) {
82
- return newState.tr.insert(newState.doc.content.size, newState.schema.nodes.paragraph.create()).setMeta('addToHistory', false);
83
- }
84
- }
85
- },
86
- state: {
87
- init(_config, state) {
88
- const availableBlockTypes = TEXT_BLOCK_TYPES.filter(blockType => isBlockTypeSchemaSupported(blockType, state));
89
- const availableWrapperBlockTypes = WRAPPER_BLOCK_TYPES.filter(blockType => isBlockTypeSchemaSupported(blockType, state));
90
- return {
91
- currentBlockType: detectBlockType(availableBlockTypes, state),
92
- blockTypesDisabled: areBlockTypesDisabled(state),
93
- availableBlockTypes,
94
- availableWrapperBlockTypes
95
- };
96
- },
97
- apply(_tr, oldPluginState, _oldState, newState) {
98
- const newPluginState = {
99
- ...oldPluginState,
100
- currentBlockType: detectBlockType(oldPluginState.availableBlockTypes, newState),
101
- blockTypesDisabled: areBlockTypesDisabled(newState)
102
- };
103
- if (newPluginState.currentBlockType !== oldPluginState.currentBlockType || newPluginState.blockTypesDisabled !== oldPluginState.blockTypesDisabled) {
104
- dispatch(pluginKey, newPluginState);
105
- }
106
- return newPluginState;
107
- }
108
- },
109
- key: pluginKey,
110
- props: {
111
- /**
112
- * As we only want the left alt key to work for headings shortcuts on Windows
113
- * we can't use prosemirror-keymap and need to handle these shortcuts specially
114
- * Shortcut on Mac: Cmd-Opt-{heading level}
115
- * Shortcut on Windows: Ctrl-LeftAlt-{heading level}
116
- */
117
- handleKeyDown: (view, event) => {
118
- const headingLevel = HEADING_KEYS.indexOf(event.keyCode);
119
- if (headingLevel > -1 && event.altKey) {
120
- if (browser.mac && event.metaKey) {
121
- return autoformatHeading(headingLevel, view, editorAnalyticsApi);
122
- } else if (!browser.mac && event.ctrlKey && altKeyLocation !== event.DOM_KEY_LOCATION_RIGHT) {
123
- return autoformatHeading(headingLevel, view, editorAnalyticsApi);
124
- }
125
- } else if (event.key === 'Alt') {
126
- // event.location is for the current key only; when a user hits Ctrl-Alt-1 the
127
- // location refers to the location of the '1' key
128
- // We store the location of the Alt key when it is hit to check against later
129
- altKeyLocation = event.location;
130
- } else if (!event.altKey) {
131
- altKeyLocation = 0;
132
- }
133
- return false;
134
- }
135
- }
136
- });
137
- };
@@ -1,8 +0,0 @@
1
- import { css } from '@emotion/react';
2
- import { blockquoteSharedStyles, headingsSharedStyles } from '@atlaskit/editor-common/styles';
3
- export const blocktypeStyles = props => css`
4
- .ProseMirror {
5
- ${blockquoteSharedStyles};
6
- ${headingsSharedStyles(props)};
7
- }
8
- `;