@atlaskit/editor-core 187.34.2 → 187.35.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/CHANGELOG.md +18 -0
- package/dist/cjs/index.js +10 -42
- package/dist/cjs/plugins/block-type/commands/block-type.js +19 -211
- package/dist/cjs/plugins/block-type/commands/index.js +2 -28
- package/dist/cjs/plugins/block-type/index.js +21 -4
- package/dist/cjs/plugins/block-type/pm-plugins/input-rule.js +9 -64
- package/dist/cjs/plugins/block-type/pm-plugins/keymap.js +1 -1
- package/dist/cjs/plugins/code-block/actions.js +83 -6
- package/dist/cjs/plugins/code-block/index.js +27 -12
- package/dist/cjs/plugins/code-block/pm-plugins/input-rule.js +68 -0
- package/dist/cjs/plugins/date/ui/DatePicker/index.js +3 -2
- package/dist/cjs/plugins/expand/commands.js +3 -3
- package/dist/cjs/plugins/expand/index.js +2 -2
- package/dist/cjs/plugins/index.js +1 -7
- package/dist/cjs/plugins/insert-block/index.js +34 -29
- package/dist/cjs/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +36 -26
- package/dist/cjs/plugins/panel/actions.js +26 -2
- package/dist/cjs/plugins/panel/index.js +9 -5
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/es2019/index.js +16 -2
- package/dist/es2019/plugins/block-type/commands/block-type.js +15 -217
- package/dist/es2019/plugins/block-type/commands/index.js +1 -3
- package/dist/es2019/plugins/block-type/index.js +21 -4
- package/dist/es2019/plugins/block-type/pm-plugins/input-rule.js +3 -56
- package/dist/es2019/plugins/block-type/pm-plugins/keymap.js +2 -2
- package/dist/es2019/plugins/code-block/actions.js +84 -3
- package/dist/es2019/plugins/code-block/index.js +22 -7
- package/dist/es2019/plugins/code-block/pm-plugins/input-rule.js +60 -0
- package/dist/es2019/plugins/date/ui/DatePicker/index.js +3 -2
- package/dist/es2019/plugins/expand/commands.js +1 -1
- package/dist/es2019/plugins/expand/index.js +1 -1
- package/dist/es2019/plugins/index.js +0 -1
- package/dist/es2019/plugins/insert-block/index.js +47 -42
- package/dist/es2019/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +35 -26
- package/dist/es2019/plugins/panel/actions.js +26 -2
- package/dist/es2019/plugins/panel/index.js +8 -4
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/esm/index.js +16 -2
- package/dist/esm/plugins/block-type/commands/block-type.js +17 -205
- package/dist/esm/plugins/block-type/commands/index.js +1 -3
- package/dist/esm/plugins/block-type/index.js +21 -4
- package/dist/esm/plugins/block-type/pm-plugins/input-rule.js +3 -58
- package/dist/esm/plugins/block-type/pm-plugins/keymap.js +2 -2
- package/dist/esm/plugins/code-block/actions.js +76 -3
- package/dist/esm/plugins/code-block/index.js +25 -11
- package/dist/esm/plugins/code-block/pm-plugins/input-rule.js +62 -0
- package/dist/esm/plugins/date/ui/DatePicker/index.js +3 -2
- package/dist/esm/plugins/expand/commands.js +1 -1
- package/dist/esm/plugins/expand/index.js +1 -1
- package/dist/esm/plugins/index.js +0 -1
- package/dist/esm/plugins/insert-block/index.js +27 -22
- package/dist/esm/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +37 -27
- package/dist/esm/plugins/panel/actions.js +24 -2
- package/dist/esm/plugins/panel/index.js +8 -4
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/types/index.d.ts +16 -3
- package/dist/types/labs/next/presets/default.d.ts +6 -0
- package/dist/types/plugins/block-type/commands/block-type.d.ts +1 -25
- package/dist/types/plugins/block-type/commands/index.d.ts +1 -3
- package/dist/types/plugins/block-type/index.d.ts +10 -2
- package/dist/types/plugins/code-block/actions.d.ts +11 -0
- package/dist/types/plugins/code-block/index.d.ts +6 -1
- package/dist/types/plugins/code-block/pm-plugins/input-rule.d.ts +3 -0
- package/dist/types/plugins/date/ui/DatePicker/index.d.ts +2 -2
- package/dist/types/plugins/index.d.ts +0 -2
- package/dist/types/plugins/insert-block/types.d.ts +7 -1
- package/dist/types/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.d.ts +1 -3
- package/dist/types/plugins/panel/actions.d.ts +4 -1
- package/dist/types/plugins/panel/index.d.ts +11 -2
- package/dist/types-ts4.5/index.d.ts +16 -3
- package/dist/types-ts4.5/labs/next/presets/default.d.ts +6 -0
- package/dist/types-ts4.5/plugins/block-type/commands/block-type.d.ts +1 -25
- package/dist/types-ts4.5/plugins/block-type/commands/index.d.ts +1 -3
- package/dist/types-ts4.5/plugins/block-type/index.d.ts +10 -2
- package/dist/types-ts4.5/plugins/code-block/actions.d.ts +11 -0
- package/dist/types-ts4.5/plugins/code-block/index.d.ts +6 -1
- package/dist/types-ts4.5/plugins/code-block/pm-plugins/input-rule.d.ts +3 -0
- package/dist/types-ts4.5/plugins/date/ui/DatePicker/index.d.ts +2 -2
- package/dist/types-ts4.5/plugins/index.d.ts +0 -2
- package/dist/types-ts4.5/plugins/insert-block/types.d.ts +7 -1
- package/dist/types-ts4.5/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.d.ts +1 -3
- package/dist/types-ts4.5/plugins/panel/actions.d.ts +4 -1
- package/dist/types-ts4.5/plugins/panel/index.d.ts +9 -2
- package/package.json +3 -3
- package/report.api.md +62 -23
- package/tmp/api-report-tmp.d.ts +49 -15
- package/dist/cjs/plugins/block-type/commands/insert-block.js +0 -60
- package/dist/es2019/plugins/block-type/commands/insert-block.js +0 -55
- package/dist/esm/plugins/block-type/commands/insert-block.js +0 -53
- package/dist/types/plugins/block-type/commands/insert-block.d.ts +0 -5
- package/dist/types-ts4.5/plugins/block-type/commands/insert-block.d.ts +0 -5
- /package/dist/cjs/plugins/{block-type/commands → code-block}/transform-to-code-block.js +0 -0
- /package/dist/es2019/plugins/{block-type/commands → code-block}/transform-to-code-block.js +0 -0
- /package/dist/esm/plugins/{block-type/commands → code-block}/transform-to-code-block.js +0 -0
- /package/dist/types/plugins/{block-type/commands → code-block}/transform-to-code-block.d.ts +0 -0
- /package/dist/types-ts4.5/plugins/{block-type/commands → code-block}/transform-to-code-block.d.ts +0 -0
|
@@ -9,10 +9,8 @@ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, INPUT_METHOD, EVENT_TYPE } f
|
|
|
9
9
|
import { IconCode } from '@atlaskit/editor-common/quick-insert';
|
|
10
10
|
import { messages } from '../block-type/messages';
|
|
11
11
|
import refreshBrowserSelectionOnChange from './refresh-browser-selection';
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
// tslint-ignore-next-line
|
|
15
|
-
import { createInsertCodeBlockTransaction } from '../block-type/commands/block-type';
|
|
12
|
+
import { createInsertCodeBlockTransaction, insertCodeBlockWithAnalytics } from './actions';
|
|
13
|
+
import { createCodeBlockInputRule } from './pm-plugins/input-rule';
|
|
16
14
|
const codeBlockPlugin = ({
|
|
17
15
|
config: options,
|
|
18
16
|
api
|
|
@@ -37,6 +35,14 @@ const codeBlockPlugin = ({
|
|
|
37
35
|
appearance: (_options$appearance = options === null || options === void 0 ? void 0 : options.appearance) !== null && _options$appearance !== void 0 ? _options$appearance : 'comment'
|
|
38
36
|
});
|
|
39
37
|
}
|
|
38
|
+
}, {
|
|
39
|
+
name: 'codeBlockInputRule',
|
|
40
|
+
plugin: ({
|
|
41
|
+
schema
|
|
42
|
+
}) => {
|
|
43
|
+
var _api$analytics;
|
|
44
|
+
return createCodeBlockInputRule(schema, api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions);
|
|
45
|
+
}
|
|
40
46
|
}, {
|
|
41
47
|
name: 'codeBlockIDEKeyBindings',
|
|
42
48
|
plugin: () => ideUX(api)
|
|
@@ -55,6 +61,15 @@ const codeBlockPlugin = ({
|
|
|
55
61
|
onEditorViewStateUpdated(props) {
|
|
56
62
|
refreshBrowserSelectionOnChange(props.originalTransaction, props.newEditorState);
|
|
57
63
|
},
|
|
64
|
+
actions: {
|
|
65
|
+
/*
|
|
66
|
+
* Function will insert code block at current selection if block is empty or below current selection and set focus on it.
|
|
67
|
+
*/
|
|
68
|
+
insertCodeBlock: inputMethod => {
|
|
69
|
+
var _api$analytics2;
|
|
70
|
+
return insertCodeBlockWithAnalytics(inputMethod, api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions);
|
|
71
|
+
}
|
|
72
|
+
},
|
|
58
73
|
pluginsOptions: {
|
|
59
74
|
quickInsert: ({
|
|
60
75
|
formatMessage
|
|
@@ -66,12 +81,12 @@ const codeBlockPlugin = ({
|
|
|
66
81
|
priority: 700,
|
|
67
82
|
keyshortcut: '```',
|
|
68
83
|
icon: () => /*#__PURE__*/React.createElement(IconCode, null),
|
|
69
|
-
action(
|
|
70
|
-
var _api$
|
|
84
|
+
action(_insert, state) {
|
|
85
|
+
var _api$analytics3;
|
|
71
86
|
const tr = createInsertCodeBlockTransaction({
|
|
72
87
|
state
|
|
73
88
|
});
|
|
74
|
-
api === null || api === void 0 ? void 0 : (_api$
|
|
89
|
+
api === null || api === void 0 ? void 0 : (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions.attachAnalyticsEvent({
|
|
75
90
|
action: ACTION.INSERTED,
|
|
76
91
|
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
77
92
|
actionSubjectId: ACTION_SUBJECT_ID.CODE_BLOCK,
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { safeInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
2
|
+
import { createRule, createPlugin, leafNodeReplacementCharacter } from '@atlaskit/prosemirror-input-rules';
|
|
3
|
+
import { INPUT_METHOD, ACTION, ACTION_SUBJECT, EVENT_TYPE, ACTION_SUBJECT_ID } from '@atlaskit/editor-common/analytics';
|
|
4
|
+
import { inputRuleWithAnalytics } from '@atlaskit/editor-common/utils';
|
|
5
|
+
import { isConvertableToCodeBlock, transformToCodeBlockAction } from '../transform-to-code-block';
|
|
6
|
+
import { insertBlock } from '@atlaskit/editor-common/commands';
|
|
7
|
+
export function createCodeBlockInputRule(schema, editorAnalyticsAPI) {
|
|
8
|
+
const rules = getCodeBlockRules(editorAnalyticsAPI, schema);
|
|
9
|
+
return createPlugin('code-block-input-rule', rules, {
|
|
10
|
+
isBlockNodeRule: true
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Get all code block input rules
|
|
16
|
+
*
|
|
17
|
+
* @param {Schema} schema
|
|
18
|
+
* @returns {InputRuleWithHandler[]}
|
|
19
|
+
*/
|
|
20
|
+
function getCodeBlockRules(editorAnalyticsAPI, schema) {
|
|
21
|
+
const ruleAnalytics = inputRuleWithAnalytics({
|
|
22
|
+
action: ACTION.INSERTED,
|
|
23
|
+
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
24
|
+
actionSubjectId: ACTION_SUBJECT_ID.CODE_BLOCK,
|
|
25
|
+
attributes: {
|
|
26
|
+
inputMethod: INPUT_METHOD.FORMATTING
|
|
27
|
+
},
|
|
28
|
+
eventType: EVENT_TYPE.TRACK
|
|
29
|
+
}, editorAnalyticsAPI);
|
|
30
|
+
const validMatchLength = match => match.length > 0 && match[0].length === 3;
|
|
31
|
+
const threeTildeRule = createRule(/(?!\s)(`{3,})$/, (state, match, start, end) => {
|
|
32
|
+
if (!validMatchLength(match)) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
const attributes = {};
|
|
36
|
+
if (match[4]) {
|
|
37
|
+
attributes.language = match[4];
|
|
38
|
+
}
|
|
39
|
+
if (isConvertableToCodeBlock(state)) {
|
|
40
|
+
return transformToCodeBlockAction(state, start, attributes);
|
|
41
|
+
}
|
|
42
|
+
const tr = state.tr;
|
|
43
|
+
tr.delete(start, end);
|
|
44
|
+
const codeBlock = tr.doc.type.schema.nodes.codeBlock.createChecked();
|
|
45
|
+
safeInsert(codeBlock)(tr);
|
|
46
|
+
return tr;
|
|
47
|
+
});
|
|
48
|
+
const leftNodeReplacementThreeTildeRule = createRule(new RegExp(`((${leafNodeReplacementCharacter}\`{3,})|^\\s(\`{3,}))(\\S*)$`), (state, match, start, end) => {
|
|
49
|
+
if (!validMatchLength(match)) {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
const attributes = {};
|
|
53
|
+
if (match[4]) {
|
|
54
|
+
attributes.language = match[4];
|
|
55
|
+
}
|
|
56
|
+
const inlineStart = Math.max(match.index + state.selection.$from.start(), 1);
|
|
57
|
+
return insertBlock(state, schema.nodes.codeBlock, inlineStart, end, attributes);
|
|
58
|
+
});
|
|
59
|
+
return [ruleAnalytics(threeTildeRule), ruleAnalytics(leftNodeReplacementThreeTildeRule)];
|
|
60
|
+
}
|
|
@@ -15,7 +15,7 @@ import { INPUT_METHOD } from '../../../analytics/types/enums';
|
|
|
15
15
|
import { injectIntl } from 'react-intl-next';
|
|
16
16
|
import DatePickerInput from './date-picker-input';
|
|
17
17
|
const popupContentWrapper = css`
|
|
18
|
-
padding: 2px;
|
|
18
|
+
padding: ${"var(--ds-space-025, 2px)"};
|
|
19
19
|
border-radius: ${borderRadius()}px;
|
|
20
20
|
box-shadow: ${`var(--ds-shadow-overlay, ${`0 4px 8px -2px ${N60A}, 0 0 1px ${N60A}`})`};
|
|
21
21
|
background-color: ${`var(--ds-surface-overlay, ${N0})`};
|
|
@@ -143,7 +143,8 @@ class DatePicker extends React.Component {
|
|
|
143
143
|
year: year,
|
|
144
144
|
selected: selected,
|
|
145
145
|
ref: this.handleRef,
|
|
146
|
-
weekStartDay: weekStartDay
|
|
146
|
+
weekStartDay: weekStartDay,
|
|
147
|
+
testId: 'datepicker'
|
|
147
148
|
})));
|
|
148
149
|
}
|
|
149
150
|
}
|
|
@@ -4,7 +4,7 @@ import { addAnalytics, ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, INPUT_METHOD,
|
|
|
4
4
|
import { GapCursorSelection, Side } from '../selection/gap-cursor-selection';
|
|
5
5
|
import { findExpand } from './utils';
|
|
6
6
|
import { createCommand } from './pm-plugins/plugin-factory';
|
|
7
|
-
import { createWrapSelectionTransaction } from '
|
|
7
|
+
import { createWrapSelectionTransaction } from '@atlaskit/editor-common/utils';
|
|
8
8
|
import { safeInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
9
9
|
export const setExpandRef = ref => createCommand({
|
|
10
10
|
type: 'SET_EXPAND_REF',
|
|
@@ -7,7 +7,7 @@ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, addAnalytics, EVENT_TYPE, IN
|
|
|
7
7
|
import { getToolbarConfig } from './toolbar';
|
|
8
8
|
import { createExpandNode } from './commands';
|
|
9
9
|
import { messages } from '../insert-block/ui/ToolbarInsertBlock/messages';
|
|
10
|
-
import { createWrapSelectionTransaction } from '
|
|
10
|
+
import { createWrapSelectionTransaction } from '@atlaskit/editor-common/utils';
|
|
11
11
|
const expandPlugin = ({
|
|
12
12
|
config: options = {},
|
|
13
13
|
api
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export { basePlugin } from './base';
|
|
2
2
|
export { default as blockTypePlugin } from './block-type';
|
|
3
|
-
export { pluginKey as blockPluginStateKey } from './block-type';
|
|
4
3
|
export { default as betterTypeHistoryPlugin } from './better-type-history';
|
|
5
4
|
export { default as clearMarksOnChangeToEmptyDocumentPlugin } from './clear-marks-on-change-to-empty-document';
|
|
6
5
|
export { default as codeBlockPlugin } from './code-block';
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { WithProviders } from '@atlaskit/editor-common/provider-factory';
|
|
3
|
-
import { pluginKey as blockTypeStateKey } from '../block-type/pm-plugins/main';
|
|
4
3
|
import { stateKey as mediaStateKey } from '../media/pm-plugins/plugin-key';
|
|
5
4
|
import { isTypeAheadAllowed } from '../type-ahead/utils';
|
|
6
5
|
import { pluginKey as layoutStateKey } from '../layout';
|
|
@@ -8,7 +7,7 @@ import { insertMacroFromMacroBrowser } from '../macro';
|
|
|
8
7
|
import WithPluginState from '../../ui/WithPluginState';
|
|
9
8
|
import ToolbarInsertBlock from './ui/ToolbarInsertBlock';
|
|
10
9
|
import { pluginKey as typeAheadPluginKey } from '../type-ahead/pm-plugins/key';
|
|
11
|
-
import {
|
|
10
|
+
import { BLOCK_QUOTE, CODE_BLOCK, PANEL } from '../block-type/types';
|
|
12
11
|
import { INPUT_METHOD } from '../analytics';
|
|
13
12
|
import { pluginKey as placeholderTextStateKey } from '../placeholder-text/plugin-key';
|
|
14
13
|
import { pluginKey as macroStateKey } from '../macro/plugin-key';
|
|
@@ -27,6 +26,24 @@ const toolbarSizeToButtons = toolbarSize => {
|
|
|
27
26
|
return 0;
|
|
28
27
|
}
|
|
29
28
|
};
|
|
29
|
+
/**
|
|
30
|
+
* Wrapper over insertBlockTypeWithAnalytics to autobind toolbar input method
|
|
31
|
+
* @param name Block name
|
|
32
|
+
*/
|
|
33
|
+
function handleInsertBlockType(insertCodeBlock, insertPanel, insertBlockQuote) {
|
|
34
|
+
return name => {
|
|
35
|
+
if (name === CODE_BLOCK.name && insertCodeBlock) {
|
|
36
|
+
return insertCodeBlock(INPUT_METHOD.TOOLBAR);
|
|
37
|
+
}
|
|
38
|
+
if (name === PANEL.name && insertPanel) {
|
|
39
|
+
return insertPanel(INPUT_METHOD.TOOLBAR);
|
|
40
|
+
}
|
|
41
|
+
if (name === BLOCK_QUOTE.name && insertBlockQuote) {
|
|
42
|
+
return insertBlockQuote(INPUT_METHOD.TOOLBAR);
|
|
43
|
+
}
|
|
44
|
+
return () => false;
|
|
45
|
+
};
|
|
46
|
+
}
|
|
30
47
|
const insertBlockPlugin = ({
|
|
31
48
|
config: options = {},
|
|
32
49
|
api
|
|
@@ -54,41 +71,39 @@ const insertBlockPlugin = ({
|
|
|
54
71
|
return /*#__PURE__*/React.createElement(WithPluginState, {
|
|
55
72
|
plugins: {
|
|
56
73
|
typeAheadState: typeAheadPluginKey,
|
|
57
|
-
// needed to check isTypeAheadAllowed in ToolbarInsertBlock
|
|
58
|
-
blockTypeState: blockTypeStateKey,
|
|
59
74
|
mediaState: mediaStateKey,
|
|
60
75
|
macroState: macroStateKey,
|
|
61
76
|
placeholderTextState: placeholderTextStateKey,
|
|
62
77
|
layoutState: layoutStateKey
|
|
63
78
|
},
|
|
64
79
|
render: ({
|
|
65
|
-
blockTypeState,
|
|
66
80
|
mediaState,
|
|
67
81
|
macroState = {},
|
|
68
82
|
placeholderTextState,
|
|
69
83
|
layoutState
|
|
70
|
-
}) =>
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
84
|
+
}) => {
|
|
85
|
+
return /*#__PURE__*/React.createElement(ToolbarInsertBlockWithInjectionApi, {
|
|
86
|
+
pluginInjectionApi: api,
|
|
87
|
+
editorView: editorView,
|
|
88
|
+
editorActions: editorActions,
|
|
89
|
+
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
90
|
+
providerFactory: providerFactory,
|
|
91
|
+
popupsMountPoint: popupsMountPoint,
|
|
92
|
+
popupsBoundariesElement: popupsBoundariesElement,
|
|
93
|
+
popupsScrollableElement: popupsScrollableElement,
|
|
94
|
+
toolbarSize: toolbarSize,
|
|
95
|
+
disabled: disabled,
|
|
96
|
+
isToolbarReducedSpacing: isToolbarReducedSpacing,
|
|
97
|
+
isLastItem: isLastItem,
|
|
98
|
+
featureFlags: featureFlags,
|
|
99
|
+
mediaState: mediaState,
|
|
100
|
+
macroState: macroState,
|
|
101
|
+
placeholderTextState: placeholderTextState,
|
|
102
|
+
layoutState: layoutState,
|
|
103
|
+
providers: providers,
|
|
104
|
+
options: options
|
|
105
|
+
});
|
|
106
|
+
}
|
|
92
107
|
});
|
|
93
108
|
};
|
|
94
109
|
return /*#__PURE__*/React.createElement(WithProviders, {
|
|
@@ -103,7 +118,6 @@ function ToolbarInsertBlockWithInjectionApi({
|
|
|
103
118
|
editorView,
|
|
104
119
|
editorActions,
|
|
105
120
|
dispatchAnalyticsEvent,
|
|
106
|
-
providerFactory,
|
|
107
121
|
popupsMountPoint,
|
|
108
122
|
popupsBoundariesElement,
|
|
109
123
|
popupsScrollableElement,
|
|
@@ -114,31 +128,22 @@ function ToolbarInsertBlockWithInjectionApi({
|
|
|
114
128
|
providers,
|
|
115
129
|
pluginInjectionApi,
|
|
116
130
|
options,
|
|
117
|
-
blockTypeState,
|
|
118
131
|
mediaState,
|
|
119
132
|
macroState,
|
|
120
133
|
placeholderTextState,
|
|
121
134
|
layoutState,
|
|
122
135
|
featureFlags
|
|
123
136
|
}) {
|
|
124
|
-
var _pluginInjectionApi$
|
|
137
|
+
var _pluginInjectionApi$i, _pluginInjectionApi$c, _pluginInjectionApi$p, _pluginInjectionApi$b;
|
|
125
138
|
const buttons = toolbarSizeToButtons(toolbarSize);
|
|
126
139
|
const {
|
|
127
140
|
dateState,
|
|
128
141
|
hyperlinkState,
|
|
129
142
|
imageUploadState,
|
|
130
143
|
mentionState,
|
|
131
|
-
emojiState
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* Wrapper over insertBlockTypeWithAnalytics to autobind toolbar input method
|
|
136
|
-
* @param name Block name
|
|
137
|
-
*/
|
|
138
|
-
const handleInsertBlockType = React.useCallback(name => {
|
|
139
|
-
var _pluginInjectionApi$a;
|
|
140
|
-
return insertBlockTypesWithAnalytics(name, INPUT_METHOD.TOOLBAR, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions);
|
|
141
|
-
}, [pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a2 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a2 === void 0 ? void 0 : _pluginInjectionApi$a2.actions]);
|
|
144
|
+
emojiState,
|
|
145
|
+
blockTypeState
|
|
146
|
+
} = useSharedPluginState(pluginInjectionApi, ['hyperlink', 'date', 'imageUpload', 'mention', 'emoji', 'blockType']);
|
|
142
147
|
return /*#__PURE__*/React.createElement(ToolbarInsertBlock, {
|
|
143
148
|
pluginInjectionApi: pluginInjectionApi,
|
|
144
149
|
buttons: buttons,
|
|
@@ -168,7 +173,7 @@ function ToolbarInsertBlockWithInjectionApi({
|
|
|
168
173
|
emojiProvider: providers.emojiProvider,
|
|
169
174
|
nativeStatusSupported: options.nativeStatusSupported,
|
|
170
175
|
horizontalRuleEnabled: options.horizontalRuleEnabled,
|
|
171
|
-
onInsertBlockType: handleInsertBlockType,
|
|
176
|
+
onInsertBlockType: handleInsertBlockType(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$c = pluginInjectionApi.codeBlock) === null || _pluginInjectionApi$c === void 0 ? void 0 : _pluginInjectionApi$c.actions.insertCodeBlock, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$p = pluginInjectionApi.panel) === null || _pluginInjectionApi$p === void 0 ? void 0 : _pluginInjectionApi$p.actions.insertPanel, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$b = pluginInjectionApi.blockType) === null || _pluginInjectionApi$b === void 0 ? void 0 : _pluginInjectionApi$b.actions.insertBlockQuote),
|
|
172
177
|
onInsertMacroFromMacroBrowser: insertMacroFromMacroBrowser,
|
|
173
178
|
macroProvider: macroState.macroProvider,
|
|
174
179
|
popupsMountPoint: popupsMountPoint,
|
|
@@ -2,7 +2,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
2
2
|
/** @jsx jsx */
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import { jsx } from '@emotion/react';
|
|
5
|
-
import { findParentNodeOfTypeClosestToPos
|
|
5
|
+
import { findParentNodeOfTypeClosestToPos } from '@atlaskit/editor-prosemirror/utils';
|
|
6
6
|
import { getMediaClient } from '@atlaskit/media-client';
|
|
7
7
|
import { calcPctFromPx, wrappedLayouts, handleSides, imageAlignmentMap } from '@atlaskit/editor-common/ui';
|
|
8
8
|
import { nonWrappedLayouts, setNodeSelection } from '@atlaskit/editor-common/utils';
|
|
@@ -58,9 +58,6 @@ class ResizableMediaSingleNext extends React.Component {
|
|
|
58
58
|
_defineProperty(this, "calcNewSize", (newWidth, stop) => {
|
|
59
59
|
const {
|
|
60
60
|
layout,
|
|
61
|
-
view: {
|
|
62
|
-
state
|
|
63
|
-
},
|
|
64
61
|
containerWidth,
|
|
65
62
|
lineLength,
|
|
66
63
|
fullWidthMode
|
|
@@ -69,29 +66,32 @@ class ResizableMediaSingleNext extends React.Component {
|
|
|
69
66
|
this.setState({
|
|
70
67
|
resizedPctWidth: newPct
|
|
71
68
|
});
|
|
72
|
-
let newLayout =
|
|
69
|
+
let newLayout = this.calcUnwrappedLayout(newWidth, containerWidth, lineLength, fullWidthMode, this.isNestedNode());
|
|
73
70
|
if (newPct <= 100) {
|
|
74
71
|
if (this.wrappedLayout && (stop ? newPct !== 100 : true)) {
|
|
75
72
|
newLayout = layout;
|
|
76
73
|
}
|
|
77
74
|
return {
|
|
78
|
-
width: newPct,
|
|
79
75
|
layout: newLayout
|
|
80
76
|
};
|
|
81
77
|
} else {
|
|
82
78
|
return {
|
|
83
|
-
width: this.props.pctWidth || null,
|
|
84
79
|
layout: newLayout
|
|
85
80
|
};
|
|
86
81
|
}
|
|
87
82
|
});
|
|
88
|
-
_defineProperty(this, "calcUnwrappedLayout", (width, containerWidth, contentWidth, fullWidthMode) => {
|
|
83
|
+
_defineProperty(this, "calcUnwrappedLayout", (width, containerWidth, contentWidth, fullWidthMode, isNestedNode) => {
|
|
84
|
+
if (isNestedNode) {
|
|
85
|
+
return 'center';
|
|
86
|
+
}
|
|
89
87
|
if (fullWidthMode) {
|
|
90
88
|
if (width < contentWidth) {
|
|
91
89
|
return 'center';
|
|
92
90
|
}
|
|
93
91
|
return 'full-width';
|
|
94
92
|
}
|
|
93
|
+
|
|
94
|
+
// handle top-level node in fixed-width editor
|
|
95
95
|
if (width <= contentWidth) {
|
|
96
96
|
return 'center';
|
|
97
97
|
}
|
|
@@ -137,7 +137,7 @@ class ResizableMediaSingleNext extends React.Component {
|
|
|
137
137
|
return dispatch(tr);
|
|
138
138
|
}, MEDIA_SINGLE_RESIZE_THROTTLE_TIME));
|
|
139
139
|
_defineProperty(this, "calcMaxWidth", memoizeOne((contentWidth, containerWidth, fullWidthMode) => {
|
|
140
|
-
if (fullWidthMode) {
|
|
140
|
+
if (this.isNestedNode() || fullWidthMode) {
|
|
141
141
|
return contentWidth;
|
|
142
142
|
}
|
|
143
143
|
return calcMediaSingleMaxWidth(containerWidth);
|
|
@@ -252,14 +252,20 @@ class ResizableMediaSingleNext extends React.Component {
|
|
|
252
252
|
}
|
|
253
253
|
this.setIsResizing(false);
|
|
254
254
|
this.displayGuideline([]);
|
|
255
|
+
let newWidth = width;
|
|
256
|
+
if (calculatedWidthWithLayout.layout === 'full-width') {
|
|
257
|
+
// When a node reaches full width in current viewport,
|
|
258
|
+
// update its width with 1800 to align with pixel entry
|
|
259
|
+
newWidth = akEditorFullWidthLayoutWidth;
|
|
260
|
+
}
|
|
255
261
|
this.setState({
|
|
256
262
|
isResizing: false,
|
|
257
263
|
size: {
|
|
258
|
-
width,
|
|
264
|
+
width: newWidth,
|
|
259
265
|
height
|
|
260
266
|
}
|
|
261
267
|
}, () => {
|
|
262
|
-
updateSize(
|
|
268
|
+
updateSize(newWidth, calculatedWidthWithLayout.layout);
|
|
263
269
|
});
|
|
264
270
|
});
|
|
265
271
|
const initialWidth = props.mediaSingleWidth || DEFAULT_IMAGE_WIDTH;
|
|
@@ -303,18 +309,6 @@ class ResizableMediaSingleNext extends React.Component {
|
|
|
303
309
|
}
|
|
304
310
|
});
|
|
305
311
|
}
|
|
306
|
-
if (this.props.layout === 'full-width' && !this.isNestedNode() && prevProps.containerWidth !== this.props.containerWidth) {
|
|
307
|
-
// To achieve edge-to-edge for full-width, we need to update its width according to containerWidth
|
|
308
|
-
// Update state to allow resizer to get most up-to-date width to avoid jumping when start resizing
|
|
309
|
-
this.setState(prevState => {
|
|
310
|
-
return {
|
|
311
|
-
size: {
|
|
312
|
-
width: calcMediaSingleMaxWidth(this.props.containerWidth),
|
|
313
|
-
height: prevState.size.height
|
|
314
|
-
}
|
|
315
|
-
};
|
|
316
|
-
});
|
|
317
|
-
}
|
|
318
312
|
return true;
|
|
319
313
|
}
|
|
320
314
|
async componentDidMount() {
|
|
@@ -452,9 +446,23 @@ class ResizableMediaSingleNext extends React.Component {
|
|
|
452
446
|
'rich-media-wrapped': layout === 'wrap-left' || layout === 'wrap-right'
|
|
453
447
|
});
|
|
454
448
|
const resizerNextClassName = classnames(className, resizerStyles);
|
|
455
|
-
const maxWidth = this.isNestedNode() ?
|
|
456
|
-
|
|
449
|
+
const maxWidth = !isResizing && this.isNestedNode() ?
|
|
450
|
+
// set undefined to fall back to 100%
|
|
451
|
+
undefined : this.calcMaxWidth(lineLength, containerWidth, fullWidthMode);
|
|
457
452
|
const minWidth = this.calcMinWidth(isVideoFile, lineLength);
|
|
453
|
+
const nestedHandleStyles = isNestedNode => {
|
|
454
|
+
if (!isNestedNode) {
|
|
455
|
+
return;
|
|
456
|
+
}
|
|
457
|
+
return {
|
|
458
|
+
left: {
|
|
459
|
+
left: `calc(${"var(--ds-space-075, 0.375em)"} * -1)`
|
|
460
|
+
},
|
|
461
|
+
right: {
|
|
462
|
+
right: `calc(${"var(--ds-space-075, 0.375em)"} * -1)`
|
|
463
|
+
}
|
|
464
|
+
};
|
|
465
|
+
};
|
|
458
466
|
return jsx("div", {
|
|
459
467
|
ref: this.saveWrapper,
|
|
460
468
|
css: wrapperStyle({
|
|
@@ -480,7 +488,8 @@ class ResizableMediaSingleNext extends React.Component {
|
|
|
480
488
|
resizeRatio: nonWrappedLayouts.includes(layout) ? 2 : 1,
|
|
481
489
|
handleComponent: handleComponent,
|
|
482
490
|
"data-testid": resizerNextTestId,
|
|
483
|
-
isHandleVisible: selected
|
|
491
|
+
isHandleVisible: selected,
|
|
492
|
+
handleStyles: nestedHandleStyles(this.isNestedNode())
|
|
484
493
|
}, children));
|
|
485
494
|
}
|
|
486
495
|
}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { removeParentNodeOfType, findSelectedNodeOfType, removeSelectedNode, findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
2
2
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
-
import {
|
|
3
|
+
import { PanelType } from '@atlaskit/adf-schema';
|
|
4
|
+
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, INPUT_METHOD, EVENT_TYPE, addAnalytics } from '../analytics';
|
|
4
5
|
import { findPanel } from './utils';
|
|
5
6
|
import { getPanelTypeBackgroundNoTokens } from '@atlaskit/editor-common/panel';
|
|
7
|
+
import { withAnalytics } from '@atlaskit/editor-common/editor-analytics';
|
|
8
|
+
import { wrapSelectionIn } from '@atlaskit/editor-common/utils';
|
|
6
9
|
export const removePanel = () => (state, dispatch) => {
|
|
7
10
|
const {
|
|
8
11
|
schema: {
|
|
@@ -88,4 +91,25 @@ export const changePanelType = (panelType, panelOptions = {}, allowCustomPanel =
|
|
|
88
91
|
dispatch(changePanelTypeTr);
|
|
89
92
|
}
|
|
90
93
|
return true;
|
|
91
|
-
};
|
|
94
|
+
};
|
|
95
|
+
export function insertPanelWithAnalytics(inputMethod, analyticsAPI) {
|
|
96
|
+
return withAnalytics(analyticsAPI, {
|
|
97
|
+
action: ACTION.INSERTED,
|
|
98
|
+
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
99
|
+
actionSubjectId: ACTION_SUBJECT_ID.PANEL,
|
|
100
|
+
attributes: {
|
|
101
|
+
inputMethod: inputMethod,
|
|
102
|
+
panelType: PanelType.INFO // only info panels can be inserted via this action
|
|
103
|
+
},
|
|
104
|
+
|
|
105
|
+
eventType: EVENT_TYPE.TRACK
|
|
106
|
+
})(function (state, dispatch) {
|
|
107
|
+
const {
|
|
108
|
+
nodes
|
|
109
|
+
} = state.schema;
|
|
110
|
+
if (nodes.panel && nodes.paragraph) {
|
|
111
|
+
return wrapSelectionIn(nodes.panel)(state, dispatch);
|
|
112
|
+
}
|
|
113
|
+
return false;
|
|
114
|
+
});
|
|
115
|
+
}
|
|
@@ -5,13 +5,11 @@ import { getToolbarConfig } from './toolbar';
|
|
|
5
5
|
import keymap from './pm-plugins/keymaps';
|
|
6
6
|
import { addAnalytics, ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, INPUT_METHOD, EVENT_TYPE } from '../analytics';
|
|
7
7
|
import { IconPanel, IconPanelNote, IconPanelSuccess, IconPanelWarning, IconPanelError } from '@atlaskit/editor-common/quick-insert';
|
|
8
|
+
import { createWrapSelectionTransaction } from '@atlaskit/editor-common/utils';
|
|
8
9
|
import { messages } from '../block-type/messages';
|
|
9
10
|
import { IconCustomPanel } from '@atlaskit/editor-common/quick-insert';
|
|
10
11
|
import { T50 } from '@atlaskit/theme/colors';
|
|
11
|
-
|
|
12
|
-
// Insertions via the drop down menu
|
|
13
|
-
// tslint-ignore-next-line
|
|
14
|
-
import { createWrapSelectionTransaction } from '../block-type/commands/block-type';
|
|
12
|
+
import { insertPanelWithAnalytics } from './actions';
|
|
15
13
|
const panelPlugin = ({
|
|
16
14
|
config: options = {},
|
|
17
15
|
api
|
|
@@ -36,6 +34,12 @@ const panelPlugin = ({
|
|
|
36
34
|
plugin: () => keymap()
|
|
37
35
|
}];
|
|
38
36
|
},
|
|
37
|
+
actions: {
|
|
38
|
+
insertPanel(inputMethod) {
|
|
39
|
+
var _api$analytics;
|
|
40
|
+
return insertPanelWithAnalytics(inputMethod, api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions);
|
|
41
|
+
}
|
|
42
|
+
},
|
|
39
43
|
pluginsOptions: {
|
|
40
44
|
quickInsert: ({
|
|
41
45
|
formatMessage
|
package/dist/esm/index.js
CHANGED
|
@@ -20,10 +20,24 @@ export { mentionPluginKey } from './plugins/mentions';
|
|
|
20
20
|
export { textColorPluginKey } from './plugins/text-color';
|
|
21
21
|
export { changeColor } from './plugins/text-color/commands/change-color';
|
|
22
22
|
export { insertHorizontalRule } from './plugins/rule/commands';
|
|
23
|
-
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @private
|
|
26
|
+
* @deprecated DO NOT USE, temporary solution while decoupling plugins from editor-core
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @private
|
|
31
|
+
* @deprecated DO NOT USE, temporary solution while decoupling plugins from editor-core
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* @private
|
|
36
|
+
* @deprecated DO NOT USE, temporary solution while decoupling plugins from editor-core
|
|
37
|
+
*/
|
|
38
|
+
|
|
24
39
|
export { subscribeToToolbarAndPickerUpdates } from './plugins/view-update-subscription/subscribe/toolbarAndPickerUpdates';
|
|
25
40
|
export { subscribeTypeAheadUpdates } from './plugins/view-update-subscription/subscribe/type-ahead-updates';
|
|
26
|
-
export { insertBlockType, insertBlockTypesWithAnalytics, setBlockType, setBlockTypeWithAnalytics } from './plugins/block-type/commands';
|
|
27
41
|
export { createTable } from '@atlaskit/editor-plugin-table/commands';
|
|
28
42
|
export { insertTaskDecisionCommand } from './plugins/tasks-and-decisions/commands';
|
|
29
43
|
export { EventDispatcher } from './event-dispatcher';
|