@atlaskit/editor-core 187.9.2 → 187.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +1 -0
- package/CHANGELOG.md +17 -0
- package/dist/cjs/commands/index.js +8 -134
- package/dist/cjs/labs/next/presets/default.js +2 -2
- package/dist/cjs/plugins/base/index.js +2 -2
- package/dist/cjs/plugins/block-type/commands/block-type.js +34 -36
- package/dist/cjs/plugins/block-type/commands/transform-to-code-block.js +1 -2
- package/dist/cjs/plugins/block-type/index.js +16 -13
- package/dist/cjs/plugins/block-type/pm-plugins/input-rule.js +19 -18
- package/dist/cjs/plugins/block-type/pm-plugins/keymap.js +12 -14
- package/dist/cjs/plugins/block-type/pm-plugins/main.js +9 -9
- package/dist/cjs/plugins/block-type/ui/ToolbarBlockType/blocktype-button.js +7 -7
- package/dist/cjs/plugins/block-type/ui/ToolbarBlockType/index.js +3 -4
- package/dist/cjs/plugins/block-type/ui/ToolbarBlockType/styled.js +13 -5
- package/dist/cjs/plugins/block-type/utils.js +73 -2
- package/dist/cjs/plugins/caption/pm-plugins/keymap.js +2 -2
- package/dist/cjs/plugins/floating-toolbar/index.js +154 -132
- package/dist/cjs/plugins/floating-toolbar/pm-plugins/force-focus/index.js +11 -10
- package/dist/cjs/plugins/floating-toolbar/ui/ExtensionsPlaceholder.js +14 -7
- package/dist/cjs/plugins/floating-toolbar/ui/Toolbar.js +6 -1
- package/dist/cjs/plugins/index.js +0 -7
- package/dist/cjs/plugins/media/pm-plugins/alt-text/ui/AltTextEdit.js +4 -1
- package/dist/cjs/plugins/media/toolbar/alt-text.js +6 -6
- package/dist/cjs/plugins/media/toolbar/linking.js +4 -1
- package/dist/cjs/plugins/media/ui/MediaLinkingToolbar.js +2 -2
- package/dist/cjs/plugins/media/utils/media-common.js +5 -5
- package/dist/cjs/plugins/undo-redo/pm-plugins/keymaps.js +2 -2
- package/dist/cjs/ui/ColorPickerButton/index.js +3 -3
- package/dist/cjs/ui/styles.js +4 -11
- package/dist/cjs/utils/index.js +4 -80
- package/dist/cjs/utils/input-rules.js +6 -66
- package/dist/cjs/utils/mark.js +2 -38
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/commands/index.js +1 -128
- package/dist/es2019/labs/next/presets/default.js +1 -1
- package/dist/es2019/plugins/base/index.js +1 -1
- package/dist/es2019/plugins/block-type/commands/block-type.js +11 -13
- package/dist/es2019/plugins/block-type/commands/transform-to-code-block.js +1 -2
- package/dist/es2019/plugins/block-type/index.js +21 -12
- package/dist/es2019/plugins/block-type/pm-plugins/input-rule.js +18 -18
- package/dist/es2019/plugins/block-type/pm-plugins/keymap.js +8 -9
- package/dist/es2019/plugins/block-type/pm-plugins/main.js +9 -9
- package/dist/es2019/plugins/block-type/ui/ToolbarBlockType/blocktype-button.js +2 -2
- package/dist/es2019/plugins/block-type/ui/ToolbarBlockType/index.js +2 -3
- package/dist/es2019/plugins/block-type/ui/ToolbarBlockType/styled.js +21 -2
- package/dist/es2019/plugins/block-type/utils.js +70 -1
- package/dist/es2019/plugins/caption/pm-plugins/keymap.js +1 -1
- package/dist/es2019/plugins/floating-toolbar/index.js +152 -128
- package/dist/es2019/plugins/floating-toolbar/pm-plugins/force-focus/index.js +12 -8
- package/dist/es2019/plugins/floating-toolbar/ui/ExtensionsPlaceholder.js +5 -4
- package/dist/es2019/plugins/floating-toolbar/ui/Toolbar.js +12 -1
- package/dist/es2019/plugins/index.js +0 -1
- package/dist/es2019/plugins/media/pm-plugins/alt-text/ui/AltTextEdit.js +3 -1
- package/dist/es2019/plugins/media/toolbar/alt-text.js +10 -6
- package/dist/es2019/plugins/media/toolbar/linking.js +8 -1
- package/dist/es2019/plugins/media/ui/MediaLinkingToolbar.js +5 -3
- package/dist/es2019/plugins/media/utils/media-common.js +1 -1
- package/dist/es2019/plugins/tasks-and-decisions/pm-plugins/keymaps.js +1 -1
- package/dist/es2019/plugins/undo-redo/pm-plugins/keymaps.js +1 -1
- package/dist/es2019/ui/ColorPickerButton/index.js +2 -2
- package/dist/es2019/ui/styles.js +0 -16
- package/dist/es2019/utils/index.js +0 -80
- package/dist/es2019/utils/input-rules.js +4 -61
- package/dist/es2019/utils/mark.js +0 -33
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/commands/index.js +7 -125
- package/dist/esm/labs/next/presets/default.js +1 -1
- package/dist/esm/plugins/base/index.js +1 -1
- package/dist/esm/plugins/block-type/commands/block-type.js +11 -13
- package/dist/esm/plugins/block-type/commands/transform-to-code-block.js +1 -2
- package/dist/esm/plugins/block-type/index.js +15 -12
- package/dist/esm/plugins/block-type/pm-plugins/input-rule.js +18 -18
- package/dist/esm/plugins/block-type/pm-plugins/keymap.js +8 -9
- package/dist/esm/plugins/block-type/pm-plugins/main.js +9 -9
- package/dist/esm/plugins/block-type/ui/ToolbarBlockType/blocktype-button.js +2 -2
- package/dist/esm/plugins/block-type/ui/ToolbarBlockType/index.js +2 -3
- package/dist/esm/plugins/block-type/ui/ToolbarBlockType/styled.js +8 -4
- package/dist/esm/plugins/block-type/utils.js +69 -1
- package/dist/esm/plugins/caption/pm-plugins/keymap.js +1 -1
- package/dist/esm/plugins/floating-toolbar/index.js +153 -131
- package/dist/esm/plugins/floating-toolbar/pm-plugins/force-focus/index.js +9 -7
- package/dist/esm/plugins/floating-toolbar/ui/ExtensionsPlaceholder.js +14 -7
- package/dist/esm/plugins/floating-toolbar/ui/Toolbar.js +6 -1
- package/dist/esm/plugins/index.js +0 -1
- package/dist/esm/plugins/media/pm-plugins/alt-text/ui/AltTextEdit.js +4 -1
- package/dist/esm/plugins/media/toolbar/alt-text.js +6 -6
- package/dist/esm/plugins/media/toolbar/linking.js +4 -1
- package/dist/esm/plugins/media/ui/MediaLinkingToolbar.js +2 -2
- package/dist/esm/plugins/media/utils/media-common.js +1 -1
- package/dist/esm/plugins/tasks-and-decisions/pm-plugins/keymaps.js +1 -1
- package/dist/esm/plugins/undo-redo/pm-plugins/keymaps.js +1 -1
- package/dist/esm/ui/ColorPickerButton/index.js +3 -3
- package/dist/esm/ui/styles.js +3 -6
- package/dist/esm/utils/index.js +3 -77
- package/dist/esm/utils/input-rules.js +4 -61
- package/dist/esm/utils/mark.js +0 -35
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/commands/index.d.ts +0 -6
- package/dist/types/labs/next/presets/default.d.ts +40 -8
- package/dist/types/plugins/block-type/commands/block-type.d.ts +5 -6
- package/dist/types/plugins/block-type/commands/delete-and-move-cursor.d.ts +1 -1
- package/dist/types/plugins/block-type/commands/delete-block-content.d.ts +1 -1
- package/dist/types/plugins/block-type/index.d.ts +1 -1
- package/dist/types/plugins/block-type/pm-plugins/input-rule.d.ts +3 -2
- package/dist/types/plugins/block-type/pm-plugins/keymap.d.ts +2 -2
- package/dist/types/plugins/block-type/pm-plugins/main.d.ts +2 -1
- package/dist/types/plugins/block-type/styles.d.ts +1 -1
- package/dist/types/plugins/block-type/types.d.ts +2 -3
- package/dist/types/plugins/block-type/ui/ToolbarBlockType/blocktype-button.d.ts +1 -2
- package/dist/types/plugins/block-type/ui/ToolbarBlockType/index.d.ts +2 -2
- package/dist/types/plugins/block-type/ui/ToolbarBlockType/styled.d.ts +5 -1
- package/dist/types/plugins/block-type/utils.d.ts +15 -1
- package/dist/types/plugins/date/index.d.ts +2 -2
- package/dist/types/plugins/floating-toolbar/index.d.ts +1 -7
- package/dist/types/plugins/floating-toolbar/pm-plugins/force-focus/index.d.ts +2 -1
- package/dist/types/plugins/floating-toolbar/pm-plugins/toolbar-data/plugin-factory.d.ts +1 -1
- package/dist/types/plugins/floating-toolbar/pm-plugins/toolbar-data/plugin-key.d.ts +1 -1
- package/dist/types/plugins/floating-toolbar/pm-plugins/toolbar-data/plugin.d.ts +1 -1
- package/dist/types/plugins/floating-toolbar/pm-plugins/toolbar-data/reducer.d.ts +2 -1
- package/dist/types/plugins/floating-toolbar/pm-plugins/toolbar-data/types.d.ts +0 -3
- package/dist/types/plugins/floating-toolbar/ui/ExtensionsPlaceholder.d.ts +1 -1
- package/dist/types/plugins/floating-toolbar/ui/Toolbar.d.ts +1 -1
- package/dist/types/plugins/index.d.ts +0 -1
- package/dist/types/plugins/media/index.d.ts +2 -2
- package/dist/types/plugins/media/pm-plugins/alt-text/ui/AltTextEdit.d.ts +1 -0
- package/dist/types/plugins/media/ui/MediaLinkingToolbar.d.ts +3 -3
- package/dist/types/plugins/undo-redo/pm-plugins/keymaps.d.ts +1 -1
- package/dist/types/plugins/view-update-subscription/subscribe/toolbarAndPickerUpdates.d.ts +1 -1
- package/dist/types/types/index.d.ts +1 -1
- package/dist/types/ui/Appearance/FullPage/StyledComponents.d.ts +1 -1
- package/dist/types/ui/ColorPickerButton/index.d.ts +2 -2
- package/dist/types/ui/ContentStyles/index.d.ts +2 -2
- package/dist/types/ui/styles.d.ts +0 -3
- package/dist/types/utils/index.d.ts +0 -6
- package/dist/types/utils/input-rules.d.ts +4 -16
- package/dist/types/utils/mark.d.ts +0 -1
- package/dist/types-ts4.5/commands/index.d.ts +0 -6
- package/dist/types-ts4.5/labs/next/presets/default.d.ts +44 -8
- package/dist/types-ts4.5/plugins/block-type/commands/block-type.d.ts +5 -6
- package/dist/types-ts4.5/plugins/block-type/commands/delete-and-move-cursor.d.ts +1 -1
- package/dist/types-ts4.5/plugins/block-type/commands/delete-block-content.d.ts +1 -1
- package/dist/types-ts4.5/plugins/block-type/index.d.ts +1 -1
- package/dist/types-ts4.5/plugins/block-type/pm-plugins/input-rule.d.ts +3 -2
- package/dist/types-ts4.5/plugins/block-type/pm-plugins/keymap.d.ts +2 -2
- package/dist/types-ts4.5/plugins/block-type/pm-plugins/main.d.ts +2 -1
- package/dist/types-ts4.5/plugins/block-type/styles.d.ts +1 -1
- package/dist/types-ts4.5/plugins/block-type/types.d.ts +2 -3
- package/dist/types-ts4.5/plugins/block-type/ui/ToolbarBlockType/blocktype-button.d.ts +1 -2
- package/dist/types-ts4.5/plugins/block-type/ui/ToolbarBlockType/index.d.ts +2 -2
- package/dist/types-ts4.5/plugins/block-type/ui/ToolbarBlockType/styled.d.ts +5 -1
- package/dist/types-ts4.5/plugins/block-type/utils.d.ts +15 -1
- package/dist/types-ts4.5/plugins/date/index.d.ts +2 -2
- package/dist/types-ts4.5/plugins/floating-toolbar/index.d.ts +1 -7
- package/dist/types-ts4.5/plugins/floating-toolbar/pm-plugins/force-focus/index.d.ts +2 -1
- package/dist/types-ts4.5/plugins/floating-toolbar/pm-plugins/toolbar-data/plugin-factory.d.ts +1 -1
- package/dist/types-ts4.5/plugins/floating-toolbar/pm-plugins/toolbar-data/plugin-key.d.ts +1 -1
- package/dist/types-ts4.5/plugins/floating-toolbar/pm-plugins/toolbar-data/plugin.d.ts +1 -1
- package/dist/types-ts4.5/plugins/floating-toolbar/pm-plugins/toolbar-data/reducer.d.ts +2 -1
- package/dist/types-ts4.5/plugins/floating-toolbar/pm-plugins/toolbar-data/types.d.ts +0 -3
- package/dist/types-ts4.5/plugins/floating-toolbar/ui/ExtensionsPlaceholder.d.ts +1 -1
- package/dist/types-ts4.5/plugins/floating-toolbar/ui/Toolbar.d.ts +1 -1
- package/dist/types-ts4.5/plugins/index.d.ts +0 -1
- package/dist/types-ts4.5/plugins/media/index.d.ts +2 -2
- package/dist/types-ts4.5/plugins/media/pm-plugins/alt-text/ui/AltTextEdit.d.ts +1 -0
- package/dist/types-ts4.5/plugins/media/ui/MediaLinkingToolbar.d.ts +3 -3
- package/dist/types-ts4.5/plugins/undo-redo/pm-plugins/keymaps.d.ts +1 -1
- package/dist/types-ts4.5/plugins/view-update-subscription/subscribe/toolbarAndPickerUpdates.d.ts +1 -1
- package/dist/types-ts4.5/types/index.d.ts +1 -1
- package/dist/types-ts4.5/ui/Appearance/FullPage/StyledComponents.d.ts +1 -1
- package/dist/types-ts4.5/ui/ColorPickerButton/index.d.ts +2 -2
- package/dist/types-ts4.5/ui/ContentStyles/index.d.ts +2 -2
- package/dist/types-ts4.5/ui/styles.d.ts +0 -3
- package/dist/types-ts4.5/utils/index.d.ts +0 -6
- package/dist/types-ts4.5/utils/input-rules.d.ts +4 -16
- package/dist/types-ts4.5/utils/mark.d.ts +0 -1
- package/package.json +6 -5
- package/report.api.md +9 -37
- package/tmp/api-report-tmp.d.ts +8 -34
- package/dist/cjs/plugins/editor-disabled/index.js +0 -75
- package/dist/cjs/types/allowed-block-types.js +0 -5
- package/dist/cjs/utils/keymap.js +0 -38
- package/dist/es2019/plugins/editor-disabled/index.js +0 -62
- package/dist/es2019/types/allowed-block-types.js +0 -1
- package/dist/es2019/utils/keymap.js +0 -33
- package/dist/esm/plugins/editor-disabled/index.js +0 -66
- package/dist/esm/types/allowed-block-types.js +0 -1
- package/dist/esm/utils/keymap.js +0 -33
- package/dist/types/plugins/editor-disabled/index.d.ts +0 -13
- package/dist/types/types/allowed-block-types.d.ts +0 -1
- package/dist/types/utils/keymap.d.ts +0 -11
- package/dist/types-ts4.5/plugins/editor-disabled/index.d.ts +0 -13
- package/dist/types-ts4.5/types/allowed-block-types.d.ts +0 -1
- package/dist/types-ts4.5/utils/keymap.d.ts +0 -11
- /package/dist/cjs/{keymaps → plugins/block-type}/consts.js +0 -0
- /package/dist/es2019/{keymaps → plugins/block-type}/consts.js +0 -0
- /package/dist/esm/{keymaps → plugins/block-type}/consts.js +0 -0
- /package/dist/types/{keymaps → plugins/block-type}/consts.d.ts +0 -0
- /package/dist/types-ts4.5/{keymaps → plugins/block-type}/consts.d.ts +0 -0
|
@@ -3,15 +3,13 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
3
3
|
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; }
|
|
4
4
|
import { findWrapping } from '@atlaskit/editor-prosemirror/transform';
|
|
5
5
|
import { safeInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
6
|
+
import { PanelType } from '@atlaskit/adf-schema';
|
|
7
|
+
import { CellSelection } from '@atlaskit/editor-tables';
|
|
8
8
|
import { shouldSplitSelectedNodeOnNodeInsertion } from '@atlaskit/editor-common/insert';
|
|
9
|
-
import { withAnalytics as withAnalyticsDeprecated } from '../../analytics';
|
|
10
9
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
11
10
|
import { withAnalytics } from '@atlaskit/editor-common/editor-analytics';
|
|
12
|
-
import { filterChildrenBetween } from '@atlaskit/editor-common/
|
|
13
|
-
import {
|
|
14
|
-
import { CellSelection } from '@atlaskit/editor-tables';
|
|
11
|
+
import { filterChildrenBetween, removeBlockMarks } from '@atlaskit/editor-common/utils';
|
|
12
|
+
import { CODE_BLOCK, BLOCK_QUOTE, PANEL, HEADINGS_BY_NAME, NORMAL_TEXT } from '../types';
|
|
15
13
|
import { transformToCodeBlockAction } from './transform-to-code-block';
|
|
16
14
|
export function setBlockType(name) {
|
|
17
15
|
return function (state, dispatch) {
|
|
@@ -26,15 +24,15 @@ export function setBlockType(name) {
|
|
|
26
24
|
return false;
|
|
27
25
|
};
|
|
28
26
|
}
|
|
29
|
-
export function setBlockTypeWithAnalytics(name, inputMethod) {
|
|
27
|
+
export function setBlockTypeWithAnalytics(name, inputMethod, editorAnalyticsApi) {
|
|
30
28
|
return function (state, dispatch) {
|
|
31
29
|
var nodes = state.schema.nodes;
|
|
32
30
|
if (name === NORMAL_TEXT.name && nodes.paragraph) {
|
|
33
|
-
return setNormalTextWithAnalytics(inputMethod)(state, dispatch);
|
|
31
|
+
return setNormalTextWithAnalytics(inputMethod, editorAnalyticsApi)(state, dispatch);
|
|
34
32
|
}
|
|
35
33
|
var headingBlockType = HEADINGS_BY_NAME[name];
|
|
36
34
|
if (headingBlockType && nodes.heading && headingBlockType.level) {
|
|
37
|
-
return setHeadingWithAnalytics(headingBlockType.level, inputMethod)(state, dispatch);
|
|
35
|
+
return setHeadingWithAnalytics(headingBlockType.level, inputMethod, editorAnalyticsApi)(state, dispatch);
|
|
38
36
|
}
|
|
39
37
|
return false;
|
|
40
38
|
};
|
|
@@ -90,9 +88,9 @@ function withCurrentHeadingLevel(fn) {
|
|
|
90
88
|
return fn(level)(state, dispatch, view);
|
|
91
89
|
};
|
|
92
90
|
}
|
|
93
|
-
export function setNormalTextWithAnalytics(inputMethod) {
|
|
91
|
+
export function setNormalTextWithAnalytics(inputMethod, editorAnalyticsApi) {
|
|
94
92
|
return withCurrentHeadingLevel(function (previousHeadingLevel) {
|
|
95
|
-
return
|
|
93
|
+
return withAnalytics(editorAnalyticsApi, {
|
|
96
94
|
action: ACTION.FORMATTED,
|
|
97
95
|
actionSubject: ACTION_SUBJECT.TEXT,
|
|
98
96
|
eventType: EVENT_TYPE.TRACK,
|
|
@@ -124,9 +122,9 @@ export function setHeading(level) {
|
|
|
124
122
|
return true;
|
|
125
123
|
};
|
|
126
124
|
}
|
|
127
|
-
export var setHeadingWithAnalytics = function setHeadingWithAnalytics(newHeadingLevel, inputMethod) {
|
|
125
|
+
export var setHeadingWithAnalytics = function setHeadingWithAnalytics(newHeadingLevel, inputMethod, editorAnalyticsApi) {
|
|
128
126
|
return withCurrentHeadingLevel(function (previousHeadingLevel) {
|
|
129
|
-
return
|
|
127
|
+
return withAnalytics(editorAnalyticsApi, {
|
|
130
128
|
action: ACTION.FORMATTED,
|
|
131
129
|
actionSubject: ACTION_SUBJECT.TEXT,
|
|
132
130
|
eventType: EVENT_TYPE.TRACK,
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
-
import { mapSlice } from '../../../utils/slice';
|
|
3
2
|
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
4
|
-
import { timestampToString } from '@atlaskit/editor-common/utils';
|
|
3
|
+
import { timestampToString, mapSlice } from '@atlaskit/editor-common/utils';
|
|
5
4
|
export function transformToCodeBlockAction(state, start, attrs) {
|
|
6
5
|
var startOfCodeBlockText = state.selection.$from;
|
|
7
6
|
var endPosition = state.selection.empty ? startOfCodeBlockText.end() : state.selection.$to.pos;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { blockquote, hardBreak, heading } from '@atlaskit/adf-schema';
|
|
4
|
+
import { ToolbarSize } from '@atlaskit/editor-common/types';
|
|
5
|
+
import { WithPluginState } from '@atlaskit/editor-common/with-plugin-state';
|
|
6
|
+
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
7
|
+
import { IconHeading, IconQuote } from '@atlaskit/editor-common/quick-insert';
|
|
8
|
+
import * as keymaps from '@atlaskit/editor-common/keymaps';
|
|
4
9
|
import { createPlugin, pluginKey } from './pm-plugins/main';
|
|
5
10
|
import keymapPlugin from './pm-plugins/keymap';
|
|
6
11
|
import inputRulePlugin from './pm-plugins/input-rule';
|
|
7
12
|
import ToolbarBlockType from './ui/ToolbarBlockType';
|
|
8
|
-
import WithPluginState from '../../ui/WithPluginState';
|
|
9
13
|
import { setBlockTypeWithAnalytics } from './commands';
|
|
10
|
-
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
11
|
-
import * as keymaps from '../../keymaps';
|
|
12
|
-
import { IconHeading, IconQuote } from '@atlaskit/editor-common/quick-insert';
|
|
13
14
|
import { messages } from './messages';
|
|
14
|
-
import { ToolbarSize } from '../../ui/Toolbar/types';
|
|
15
15
|
var headingPluginOptions = function headingPluginOptions(_ref, isAllowed, editorAnalyticsApi) {
|
|
16
16
|
var formatMessage = _ref.formatMessage;
|
|
17
17
|
if (!isAllowed) {
|
|
@@ -110,15 +110,17 @@ var blockTypePlugin = function blockTypePlugin(options, api) {
|
|
|
110
110
|
return [{
|
|
111
111
|
name: 'blockType',
|
|
112
112
|
plugin: function plugin(_ref3) {
|
|
113
|
+
var _api$dependencies$ana;
|
|
113
114
|
var dispatch = _ref3.dispatch;
|
|
114
|
-
return createPlugin(dispatch, options && options.lastNodeMustBeParagraph);
|
|
115
|
+
return createPlugin(api === null || api === void 0 ? void 0 : (_api$dependencies$ana = api.dependencies.analytics) === null || _api$dependencies$ana === void 0 ? void 0 : _api$dependencies$ana.actions, dispatch, options && options.lastNodeMustBeParagraph);
|
|
115
116
|
}
|
|
116
117
|
}, {
|
|
117
118
|
name: 'blockTypeInputRule',
|
|
118
119
|
plugin: function plugin(_ref4) {
|
|
120
|
+
var _api$dependencies$ana2;
|
|
119
121
|
var schema = _ref4.schema,
|
|
120
122
|
featureFlags = _ref4.featureFlags;
|
|
121
|
-
return inputRulePlugin(schema, featureFlags);
|
|
123
|
+
return inputRulePlugin(api === null || api === void 0 ? void 0 : (_api$dependencies$ana2 = api.dependencies.analytics) === null || _api$dependencies$ana2 === void 0 ? void 0 : _api$dependencies$ana2.actions, schema, featureFlags);
|
|
122
124
|
}
|
|
123
125
|
},
|
|
124
126
|
// Needs to be lower priority than editor-tables.tableEditing
|
|
@@ -126,10 +128,10 @@ var blockTypePlugin = function blockTypePlugin(options, api) {
|
|
|
126
128
|
{
|
|
127
129
|
name: 'blockTypeKeyMap',
|
|
128
130
|
plugin: function plugin(_ref5) {
|
|
129
|
-
var _api$dependencies$
|
|
131
|
+
var _api$dependencies$ana3;
|
|
130
132
|
var schema = _ref5.schema,
|
|
131
133
|
featureFlags = _ref5.featureFlags;
|
|
132
|
-
return keymapPlugin(
|
|
134
|
+
return keymapPlugin(api === null || api === void 0 ? void 0 : (_api$dependencies$ana3 = api.dependencies.analytics) === null || _api$dependencies$ana3 === void 0 ? void 0 : _api$dependencies$ana3.actions, schema, featureFlags);
|
|
133
135
|
}
|
|
134
136
|
}];
|
|
135
137
|
},
|
|
@@ -144,7 +146,8 @@ var blockTypePlugin = function blockTypePlugin(options, api) {
|
|
|
144
146
|
eventDispatcher = _ref6.eventDispatcher;
|
|
145
147
|
var isSmall = options && options.isUndoRedoButtonsEnabled ? toolbarSize < ToolbarSize.XXL : toolbarSize < ToolbarSize.XL;
|
|
146
148
|
var boundSetBlockType = function boundSetBlockType(name) {
|
|
147
|
-
|
|
149
|
+
var _api$dependencies$ana4;
|
|
150
|
+
return setBlockTypeWithAnalytics(name, INPUT_METHOD.TOOLBAR, api === null || api === void 0 ? void 0 : (_api$dependencies$ana4 = api.dependencies.analytics) === null || _api$dependencies$ana4 === void 0 ? void 0 : _api$dependencies$ana4.actions)(editorView.state, editorView.dispatch);
|
|
148
151
|
};
|
|
149
152
|
return /*#__PURE__*/React.createElement(WithPluginState, {
|
|
150
153
|
editorView: editorView,
|
|
@@ -169,9 +172,9 @@ var blockTypePlugin = function blockTypePlugin(options, api) {
|
|
|
169
172
|
},
|
|
170
173
|
pluginsOptions: {
|
|
171
174
|
quickInsert: function quickInsert(intl) {
|
|
172
|
-
var _api$dependencies$
|
|
175
|
+
var _api$dependencies$ana5, _api$dependencies$ana6;
|
|
173
176
|
var exclude = options && options.allowBlockType && options.allowBlockType.exclude ? options.allowBlockType.exclude : [];
|
|
174
|
-
return [].concat(_toConsumableArray(blockquotePluginOptions(intl, exclude.indexOf('blockquote') === -1, api === null || api === void 0 ? void 0 : (_api$dependencies$
|
|
177
|
+
return [].concat(_toConsumableArray(blockquotePluginOptions(intl, exclude.indexOf('blockquote') === -1, api === null || api === void 0 ? void 0 : (_api$dependencies$ana5 = api.dependencies.analytics) === null || _api$dependencies$ana5 === void 0 ? void 0 : _api$dependencies$ana5.actions)), _toConsumableArray(headingPluginOptions(intl, exclude.indexOf('heading') === -1, api === null || api === void 0 ? void 0 : (_api$dependencies$ana6 = api.dependencies.analytics) === null || _api$dependencies$ana6 === void 0 ? void 0 : _api$dependencies$ana6.actions)));
|
|
175
178
|
}
|
|
176
179
|
}
|
|
177
180
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
-
import { createJoinNodesRule, createWrappingTextBlockRule, ruleWithAnalytics } from '../../../utils/input-rules';
|
|
3
|
-
import { createRule, createPlugin } from '@atlaskit/prosemirror-input-rules';
|
|
4
|
-
import { leafNodeReplacementCharacter } from '@atlaskit/prosemirror-input-rules';
|
|
5
|
-
import { isConvertableToCodeBlock, transformToCodeBlockAction } from '../commands/transform-to-code-block';
|
|
6
|
-
import { insertBlock } from '../commands/insert-block';
|
|
7
2
|
import { safeInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
3
|
+
import { createRule, createPlugin, leafNodeReplacementCharacter } from '@atlaskit/prosemirror-input-rules';
|
|
8
4
|
import { INPUT_METHOD, ACTION, ACTION_SUBJECT, EVENT_TYPE, ACTION_SUBJECT_ID } from '@atlaskit/editor-common/analytics';
|
|
5
|
+
import { inputRuleWithAnalytics } from '@atlaskit/editor-common/utils';
|
|
6
|
+
import { isConvertableToCodeBlock, transformToCodeBlockAction } from '../commands/transform-to-code-block';
|
|
7
|
+
import { insertBlock } from '../commands/insert-block';
|
|
8
|
+
import { createJoinNodesRule, createWrappingTextBlockRule } from '../utils';
|
|
9
9
|
var MAX_HEADING_LEVEL = 6;
|
|
10
10
|
function getHeadingLevel(match) {
|
|
11
11
|
return {
|
|
@@ -29,7 +29,7 @@ function blockQuoteRule(nodeType) {
|
|
|
29
29
|
* @param {Schema} schema
|
|
30
30
|
* @returns {InputRuleWithHandler[]}
|
|
31
31
|
*/
|
|
32
|
-
function getHeadingRules(schema) {
|
|
32
|
+
function getHeadingRules(editorAnalyticsAPI, schema) {
|
|
33
33
|
// '# ' for h1, '## ' for h2 and etc
|
|
34
34
|
var hashRule = headingRule(schema.nodes.heading, MAX_HEADING_LEVEL);
|
|
35
35
|
var leftNodeReplacementHashRule = createRule(new RegExp("".concat(leafNodeReplacementCharacter, "(#{1,6})\\s$")), function (state, match, start, end) {
|
|
@@ -40,7 +40,7 @@ function getHeadingRules(schema) {
|
|
|
40
40
|
});
|
|
41
41
|
|
|
42
42
|
// New analytics handler
|
|
43
|
-
var ruleWithHeadingAnalytics =
|
|
43
|
+
var ruleWithHeadingAnalytics = inputRuleWithAnalytics(function (_state, matchResult) {
|
|
44
44
|
return {
|
|
45
45
|
action: ACTION.FORMATTED,
|
|
46
46
|
actionSubject: ACTION_SUBJECT.TEXT,
|
|
@@ -51,7 +51,7 @@ function getHeadingRules(schema) {
|
|
|
51
51
|
newHeadingLevel: getHeadingLevel(matchResult).level
|
|
52
52
|
}
|
|
53
53
|
};
|
|
54
|
-
});
|
|
54
|
+
}, editorAnalyticsAPI);
|
|
55
55
|
return [ruleWithHeadingAnalytics(hashRule), ruleWithHeadingAnalytics(leftNodeReplacementHashRule)];
|
|
56
56
|
}
|
|
57
57
|
|
|
@@ -61,7 +61,7 @@ function getHeadingRules(schema) {
|
|
|
61
61
|
* @param {Schema} schema
|
|
62
62
|
* @returns {InputRuleWithHandler[]}
|
|
63
63
|
*/
|
|
64
|
-
function getBlockQuoteRules(schema) {
|
|
64
|
+
function getBlockQuoteRules(editorAnalyticsAPI, schema) {
|
|
65
65
|
// '> ' for blockquote
|
|
66
66
|
var greatherThanRule = blockQuoteRule(schema.nodes.blockquote);
|
|
67
67
|
var leftNodeReplacementGreatherRule = createRule(new RegExp("".concat(leafNodeReplacementCharacter, "\\s*>\\s$")), function (state, _match, start, end) {
|
|
@@ -69,7 +69,7 @@ function getBlockQuoteRules(schema) {
|
|
|
69
69
|
});
|
|
70
70
|
|
|
71
71
|
// Analytics V3 handler
|
|
72
|
-
var ruleWithBlockQuoteAnalytics =
|
|
72
|
+
var ruleWithBlockQuoteAnalytics = inputRuleWithAnalytics({
|
|
73
73
|
action: ACTION.FORMATTED,
|
|
74
74
|
actionSubject: ACTION_SUBJECT.TEXT,
|
|
75
75
|
eventType: EVENT_TYPE.TRACK,
|
|
@@ -77,7 +77,7 @@ function getBlockQuoteRules(schema) {
|
|
|
77
77
|
attributes: {
|
|
78
78
|
inputMethod: INPUT_METHOD.FORMATTING
|
|
79
79
|
}
|
|
80
|
-
});
|
|
80
|
+
}, editorAnalyticsAPI);
|
|
81
81
|
return [ruleWithBlockQuoteAnalytics(greatherThanRule), ruleWithBlockQuoteAnalytics(leftNodeReplacementGreatherRule)];
|
|
82
82
|
}
|
|
83
83
|
|
|
@@ -87,8 +87,8 @@ function getBlockQuoteRules(schema) {
|
|
|
87
87
|
* @param {Schema} schema
|
|
88
88
|
* @returns {InputRuleWithHandler[]}
|
|
89
89
|
*/
|
|
90
|
-
function getCodeBlockRules(schema) {
|
|
91
|
-
var ruleAnalytics =
|
|
90
|
+
function getCodeBlockRules(editorAnalyticsAPI, schema) {
|
|
91
|
+
var ruleAnalytics = inputRuleWithAnalytics({
|
|
92
92
|
action: ACTION.INSERTED,
|
|
93
93
|
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
94
94
|
actionSubjectId: ACTION_SUBJECT_ID.CODE_BLOCK,
|
|
@@ -96,7 +96,7 @@ function getCodeBlockRules(schema) {
|
|
|
96
96
|
inputMethod: INPUT_METHOD.FORMATTING
|
|
97
97
|
},
|
|
98
98
|
eventType: EVENT_TYPE.TRACK
|
|
99
|
-
});
|
|
99
|
+
}, editorAnalyticsAPI);
|
|
100
100
|
var validMatchLength = function validMatchLength(match) {
|
|
101
101
|
return match.length > 0 && match[0].length === 3;
|
|
102
102
|
};
|
|
@@ -130,16 +130,16 @@ function getCodeBlockRules(schema) {
|
|
|
130
130
|
});
|
|
131
131
|
return [ruleAnalytics(threeTildeRule), ruleAnalytics(leftNodeReplacementThreeTildeRule)];
|
|
132
132
|
}
|
|
133
|
-
function inputRulePlugin(schema, featureFlags) {
|
|
133
|
+
function inputRulePlugin(editorAnalyticsAPI, schema, featureFlags) {
|
|
134
134
|
var rules = [];
|
|
135
135
|
if (schema.nodes.heading) {
|
|
136
|
-
rules.push.apply(rules, _toConsumableArray(getHeadingRules(schema)));
|
|
136
|
+
rules.push.apply(rules, _toConsumableArray(getHeadingRules(editorAnalyticsAPI, schema)));
|
|
137
137
|
}
|
|
138
138
|
if (schema.nodes.blockquote) {
|
|
139
|
-
rules.push.apply(rules, _toConsumableArray(getBlockQuoteRules(schema)));
|
|
139
|
+
rules.push.apply(rules, _toConsumableArray(getBlockQuoteRules(editorAnalyticsAPI, schema)));
|
|
140
140
|
}
|
|
141
141
|
if (schema.nodes.codeBlock) {
|
|
142
|
-
rules.push.apply(rules, _toConsumableArray(getCodeBlockRules(schema)));
|
|
142
|
+
rules.push.apply(rules, _toConsumableArray(getCodeBlockRules(editorAnalyticsAPI, schema)));
|
|
143
143
|
}
|
|
144
144
|
if (rules.length !== 0) {
|
|
145
145
|
return createPlugin('block-type', rules, {
|
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
import { redo, undo } from '@atlaskit/editor-prosemirror/history';
|
|
2
2
|
import { chainCommands } from '@atlaskit/editor-prosemirror/commands';
|
|
3
|
-
import
|
|
4
|
-
import * as
|
|
3
|
+
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
4
|
+
import * as keymaps from '@atlaskit/editor-common/keymaps';
|
|
5
|
+
import { keymap } from '@atlaskit/editor-common/keymaps';
|
|
6
|
+
import { insertNewLineWithAnalytics, createNewParagraphAbove, createNewParagraphBelow, deleteEmptyParagraphAndMoveBlockUp } from '@atlaskit/editor-common/utils';
|
|
5
7
|
import * as blockTypes from '../types';
|
|
6
|
-
import { keymap } from '../../../utils/keymap';
|
|
7
8
|
import { cleanUpAtTheStartOfDocument, deleteAndMoveCursor, deleteBlockContent, insertBlockTypesWithAnalytics } from '../commands';
|
|
8
|
-
import { deleteEmptyParagraphAndMoveBlockUp } from '@atlaskit/editor-common/utils';
|
|
9
|
-
import { INPUT_METHOD } from '../../analytics';
|
|
10
9
|
import { isNodeAWrappingBlockNode } from '../utils';
|
|
11
10
|
var backspace = chainCommands(cleanUpAtTheStartOfDocument, deleteBlockContent(isNodeAWrappingBlockNode), deleteAndMoveCursor);
|
|
12
11
|
var del = chainCommands(deleteEmptyParagraphAndMoveBlockUp(isNodeAWrappingBlockNode), deleteBlockContent(isNodeAWrappingBlockNode), deleteAndMoveCursor);
|
|
13
|
-
export default function keymapPlugin(
|
|
12
|
+
export default function keymapPlugin(editorAnalyticsApi, schema, _featureFlags) {
|
|
14
13
|
var list = {};
|
|
15
|
-
keymaps.bindKeymapWithCommand(keymaps.insertNewLine.common,
|
|
16
|
-
keymaps.bindKeymapWithCommand(keymaps.moveUp.common,
|
|
17
|
-
keymaps.bindKeymapWithCommand(keymaps.moveDown.common,
|
|
14
|
+
keymaps.bindKeymapWithCommand(keymaps.insertNewLine.common, insertNewLineWithAnalytics(editorAnalyticsApi), list);
|
|
15
|
+
keymaps.bindKeymapWithCommand(keymaps.moveUp.common, createNewParagraphAbove, list);
|
|
16
|
+
keymaps.bindKeymapWithCommand(keymaps.moveDown.common, createNewParagraphBelow, list);
|
|
18
17
|
keymaps.bindKeymapWithCommand(keymaps.findKeyMapForBrowser(keymaps.redo), redo, list);
|
|
19
18
|
keymaps.bindKeymapWithCommand(keymaps.undo.common, undo, list);
|
|
20
19
|
keymaps.bindKeymapWithCommand(keymaps.backspace.common, backspace, list);
|
|
@@ -4,11 +4,11 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
4
4
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
5
5
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
6
6
|
import { browser } from '@atlaskit/editor-common/utils';
|
|
7
|
+
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
7
8
|
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';
|
|
8
|
-
import {
|
|
9
|
+
import { HEADING_KEYS } from '../consts';
|
|
9
10
|
import { setHeadingWithAnalytics, setNormalTextWithAnalytics } from '../commands';
|
|
10
|
-
import {
|
|
11
|
-
import { HEADING_KEYS } from '../../../keymaps/consts';
|
|
11
|
+
import { areBlockTypesDisabled } from '../utils';
|
|
12
12
|
var blockTypeForNode = function blockTypeForNode(node, schema) {
|
|
13
13
|
if (node.type === schema.nodes.heading) {
|
|
14
14
|
var maybeNode = HEADINGS_BY_LEVEL[node.attrs['level']];
|
|
@@ -63,16 +63,16 @@ var detectBlockType = function detectBlockType(availableBlockTypes, state) {
|
|
|
63
63
|
});
|
|
64
64
|
return blockType || OTHER;
|
|
65
65
|
};
|
|
66
|
-
var autoformatHeading = function autoformatHeading(headingLevel, view) {
|
|
66
|
+
var autoformatHeading = function autoformatHeading(headingLevel, view, editorAnalyticsApi) {
|
|
67
67
|
if (headingLevel === 0) {
|
|
68
|
-
setNormalTextWithAnalytics(INPUT_METHOD.FORMATTING)(view.state, view.dispatch);
|
|
68
|
+
setNormalTextWithAnalytics(INPUT_METHOD.FORMATTING, editorAnalyticsApi)(view.state, view.dispatch);
|
|
69
69
|
} else {
|
|
70
|
-
setHeadingWithAnalytics(headingLevel, INPUT_METHOD.FORMATTING)(view.state, view.dispatch);
|
|
70
|
+
setHeadingWithAnalytics(headingLevel, INPUT_METHOD.FORMATTING, editorAnalyticsApi)(view.state, view.dispatch);
|
|
71
71
|
}
|
|
72
72
|
return true;
|
|
73
73
|
};
|
|
74
74
|
export var pluginKey = new PluginKey('blockTypePlugin');
|
|
75
|
-
export var createPlugin = function createPlugin(dispatch, lastNodeMustBeParagraph) {
|
|
75
|
+
export var createPlugin = function createPlugin(editorAnalyticsApi, dispatch, lastNodeMustBeParagraph) {
|
|
76
76
|
var altKeyLocation = 0;
|
|
77
77
|
return new SafePlugin({
|
|
78
78
|
appendTransaction: function appendTransaction(_transactions, _oldState, newState) {
|
|
@@ -123,9 +123,9 @@ export var createPlugin = function createPlugin(dispatch, lastNodeMustBeParagrap
|
|
|
123
123
|
var headingLevel = HEADING_KEYS.indexOf(event.keyCode);
|
|
124
124
|
if (headingLevel > -1 && event.altKey) {
|
|
125
125
|
if (browser.mac && event.metaKey) {
|
|
126
|
-
return autoformatHeading(headingLevel, view);
|
|
126
|
+
return autoformatHeading(headingLevel, view, editorAnalyticsApi);
|
|
127
127
|
} else if (!browser.mac && event.ctrlKey && altKeyLocation !== event.DOM_KEY_LOCATION_RIGHT) {
|
|
128
|
-
return autoformatHeading(headingLevel, view);
|
|
128
|
+
return autoformatHeading(headingLevel, view, editorAnalyticsApi);
|
|
129
129
|
}
|
|
130
130
|
} else if (event.key === 'Alt') {
|
|
131
131
|
// event.location is for the current key only; when a user hits Ctrl-Alt-1 the
|
|
@@ -4,10 +4,10 @@ import { jsx } from '@emotion/react';
|
|
|
4
4
|
import { FormattedMessage, defineMessages } from 'react-intl-next';
|
|
5
5
|
import ExpandIcon from '@atlaskit/icon/glyph/chevron-down';
|
|
6
6
|
import TextStyleIcon from '@atlaskit/icon/glyph/editor/text-style';
|
|
7
|
-
import ToolbarButton from '../../../../ui/ToolbarButton';
|
|
8
|
-
import { buttonContentStyle, buttonContentReducedSpacingStyle, wrapperSmallStyle, expandIconWrapperStyle } from '../../../../ui/styles';
|
|
9
7
|
import { wrapperStyle } from '@atlaskit/editor-common/styles';
|
|
8
|
+
import { ToolbarButton } from '@atlaskit/editor-common/ui-menu';
|
|
10
9
|
import { NORMAL_TEXT } from '../../types';
|
|
10
|
+
import { buttonContentStyle, buttonContentReducedSpacingStyle, wrapperSmallStyle, expandIconWrapperStyle } from './styled';
|
|
11
11
|
export var messages = defineMessages({
|
|
12
12
|
textStyles: {
|
|
13
13
|
id: 'fabric.editor.textStyles',
|
|
@@ -14,12 +14,11 @@ import React from 'react';
|
|
|
14
14
|
import { jsx } from '@emotion/react';
|
|
15
15
|
import { injectIntl } from 'react-intl-next';
|
|
16
16
|
import { akEditorMenuZIndex } from '@atlaskit/editor-shared-styles';
|
|
17
|
-
import {
|
|
17
|
+
import { getAriaKeyshortcuts, tooltip, findKeymapByDescription } from '@atlaskit/editor-common/keymaps';
|
|
18
18
|
import { separatorStyles, wrapperStyle } from '@atlaskit/editor-common/styles';
|
|
19
|
+
import { DropdownMenuWithKeyboardNavigation as DropdownMenu } from '@atlaskit/editor-common/ui-menu';
|
|
19
20
|
import { blockTypeMenuItemStyle, keyboardShortcut, keyboardShortcutSelect } from './styled';
|
|
20
|
-
import { tooltip, findKeymapByDescription } from '../../../../keymaps';
|
|
21
21
|
import { BlockTypeButton } from './blocktype-button';
|
|
22
|
-
import { getAriaKeyshortcuts } from '@atlaskit/editor-common/keymaps';
|
|
23
22
|
var ToolbarBlockType = /*#__PURE__*/function (_React$PureComponent) {
|
|
24
23
|
_inherits(ToolbarBlockType, _React$PureComponent);
|
|
25
24
|
var _super = _createSuper(ToolbarBlockType);
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
2
|
-
var _templateObject, _templateObject2, _templateObject3;
|
|
2
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7;
|
|
3
3
|
/** @jsx jsx */
|
|
4
4
|
import { css } from '@emotion/react';
|
|
5
5
|
import { N400 } from '@atlaskit/theme/colors';
|
|
6
6
|
import { headingsSharedStyles } from '@atlaskit/editor-common/styles';
|
|
7
|
-
import { shortcutStyle } from '
|
|
7
|
+
import { shortcutStyle } from '@atlaskit/editor-shared-styles/shortcut';
|
|
8
8
|
export var blockTypeMenuItemStyle = function blockTypeMenuItemStyle(tagName, selected) {
|
|
9
9
|
// TEMP FIX: See https://product-fabric.atlassian.net/browse/ED-13878
|
|
10
10
|
var selectedStyle = selected ? "".concat(tagName, " { color: ", "var(--ds-text, white)", " !important; }") : '';
|
|
@@ -12,5 +12,9 @@ export var blockTypeMenuItemStyle = function blockTypeMenuItemStyle(tagName, sel
|
|
|
12
12
|
return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n ", ";\n > {\n h1,\n h2,\n h3,\n h4,\n h5,\n h6 {\n margin-top: 0;\n }\n }\n ", ";\n "])), headingsSharedStyles(themeProps), selectedStyle);
|
|
13
13
|
};
|
|
14
14
|
};
|
|
15
|
-
export var keyboardShortcut = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n ", "\n margin-left:
|
|
16
|
-
export var keyboardShortcutSelect = css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n color: ", ";\n"])), "var(--ds-icon, ".concat(N400, ")"));
|
|
15
|
+
export var keyboardShortcut = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n ", "\n margin-left: ", ";\n"])), shortcutStyle, "var(--ds-space-200, 16px)");
|
|
16
|
+
export var keyboardShortcutSelect = css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n color: ", ";\n"])), "var(--ds-icon, ".concat(N400, ")"));
|
|
17
|
+
export var buttonContentStyle = css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n display: flex;\n min-width: 80px;\n align-items: center;\n overflow: hidden;\n justify-content: center;\n flex-direction: column;\n padding: ", ";\n"])), "var(--ds-space-075, 6px)");
|
|
18
|
+
export var buttonContentReducedSpacingStyle = css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n padding: ", ";\n"])), "var(--ds-space-100, 8px)");
|
|
19
|
+
export var wrapperSmallStyle = css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n margin-left: ", ";\n min-width: 40px;\n"])), "var(--ds-space-050, 4px)");
|
|
20
|
+
export var expandIconWrapperStyle = css(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n margin-left: -8px;\n"])));
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { createRule } from '@atlaskit/prosemirror-input-rules';
|
|
2
|
+
import { createWrappingJoinRule } from '@atlaskit/editor-common/utils';
|
|
1
3
|
import { WRAPPER_BLOCK_TYPES } from './types';
|
|
2
4
|
export var isNodeAWrappingBlockNode = function isNodeAWrappingBlockNode(node) {
|
|
3
5
|
if (!node) {
|
|
@@ -6,4 +8,70 @@ export var isNodeAWrappingBlockNode = function isNodeAWrappingBlockNode(node) {
|
|
|
6
8
|
return WRAPPER_BLOCK_TYPES.some(function (blockNode) {
|
|
7
9
|
return blockNode.name === node.type.name;
|
|
8
10
|
});
|
|
9
|
-
};
|
|
11
|
+
};
|
|
12
|
+
export var createJoinNodesRule = function createJoinNodesRule(match, nodeType) {
|
|
13
|
+
return createWrappingJoinRule({
|
|
14
|
+
nodeType: nodeType,
|
|
15
|
+
match: match,
|
|
16
|
+
getAttrs: {},
|
|
17
|
+
joinPredicate: function joinPredicate(_, node) {
|
|
18
|
+
return node.type === nodeType;
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
export var createWrappingTextBlockRule = function createWrappingTextBlockRule(_ref) {
|
|
23
|
+
var match = _ref.match,
|
|
24
|
+
nodeType = _ref.nodeType,
|
|
25
|
+
getAttrs = _ref.getAttrs;
|
|
26
|
+
var handler = function handler(state, match, start, end) {
|
|
27
|
+
var fixedStart = Math.max(start, 1);
|
|
28
|
+
var $start = state.doc.resolve(fixedStart);
|
|
29
|
+
var attrs = getAttrs instanceof Function ? getAttrs(match) : getAttrs;
|
|
30
|
+
var nodeBefore = $start.node(-1);
|
|
31
|
+
if (nodeBefore && !nodeBefore.canReplaceWith($start.index(-1), $start.indexAfter(-1), nodeType)) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
return state.tr.delete(fixedStart, end).setBlockType(fixedStart, fixedStart, nodeType, attrs);
|
|
35
|
+
};
|
|
36
|
+
return createRule(match, handler);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Function will create a list of wrapper blocks present in a selection.
|
|
41
|
+
*/
|
|
42
|
+
function getSelectedWrapperNodes(state) {
|
|
43
|
+
var nodes = [];
|
|
44
|
+
if (state.selection) {
|
|
45
|
+
var _state$selection = state.selection,
|
|
46
|
+
$from = _state$selection.$from,
|
|
47
|
+
$to = _state$selection.$to;
|
|
48
|
+
var _state$schema$nodes = state.schema.nodes,
|
|
49
|
+
blockquote = _state$schema$nodes.blockquote,
|
|
50
|
+
panel = _state$schema$nodes.panel,
|
|
51
|
+
orderedList = _state$schema$nodes.orderedList,
|
|
52
|
+
bulletList = _state$schema$nodes.bulletList,
|
|
53
|
+
listItem = _state$schema$nodes.listItem,
|
|
54
|
+
codeBlock = _state$schema$nodes.codeBlock,
|
|
55
|
+
decisionItem = _state$schema$nodes.decisionItem,
|
|
56
|
+
decisionList = _state$schema$nodes.decisionList,
|
|
57
|
+
taskItem = _state$schema$nodes.taskItem,
|
|
58
|
+
taskList = _state$schema$nodes.taskList;
|
|
59
|
+
state.doc.nodesBetween($from.pos, $to.pos, function (node) {
|
|
60
|
+
if (node.isBlock && [blockquote, panel, orderedList, bulletList, listItem, codeBlock, decisionItem, decisionList, taskItem, taskList].indexOf(node.type) >= 0) {
|
|
61
|
+
nodes.push(node.type);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
return nodes;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Function will check if changing block types: Paragraph, Heading is enabled.
|
|
70
|
+
*/
|
|
71
|
+
export function areBlockTypesDisabled(state) {
|
|
72
|
+
var nodesTypes = getSelectedWrapperNodes(state);
|
|
73
|
+
var panel = state.schema.nodes.panel;
|
|
74
|
+
return nodesTypes.filter(function (type) {
|
|
75
|
+
return type !== panel;
|
|
76
|
+
}).length > 0;
|
|
77
|
+
}
|
|
@@ -2,7 +2,7 @@ import { keymap } from '@atlaskit/editor-prosemirror/keymap';
|
|
|
2
2
|
import { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
3
3
|
import * as keymaps from '../../../keymaps';
|
|
4
4
|
import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
5
|
-
import { createNewParagraphBelow } from '
|
|
5
|
+
import { createNewParagraphBelow } from '@atlaskit/editor-common/utils';
|
|
6
6
|
import { GapCursorSelection } from '../../selection/gap-cursor/selection';
|
|
7
7
|
export function captionKeymap() {
|
|
8
8
|
var list = {};
|