@atlaskit/editor-core 187.23.1 → 187.24.0
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 +17 -0
- package/dist/cjs/create-editor/ReactEditorViewInternal.js +2 -1
- package/dist/cjs/editor-next/editor-internal.js +3 -0
- package/dist/cjs/plugins/block-type/index.js +3 -6
- package/dist/cjs/plugins/block-type/pm-plugins/keymap.js +12 -12
- package/dist/cjs/plugins/caption/pm-plugins/keymap.js +9 -12
- package/dist/cjs/plugins/help-dialog/index.js +3 -6
- package/dist/cjs/plugins/media/pm-plugins/alt-text/keymap.js +3 -6
- package/dist/cjs/plugins/media/pm-plugins/alt-text/ui/AltTextEdit.js +4 -6
- package/dist/cjs/plugins/media/pm-plugins/keymap.js +8 -11
- package/dist/cjs/plugins/media/pm-plugins/linking/keymap.js +2 -5
- package/dist/cjs/plugins/status/keymap.js +3 -6
- package/dist/cjs/plugins/submit-editor/index.js +3 -6
- package/dist/cjs/plugins/text-color/commands/toggle-color.js +1 -1
- package/dist/cjs/presets/context.js +40 -0
- package/dist/cjs/ui/EditorContext/index.js +2 -1
- package/dist/cjs/use-preset.js +51 -0
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/create-editor/ReactEditorViewInternal.js +2 -1
- package/dist/es2019/editor-next/editor-internal.js +3 -0
- package/dist/es2019/plugins/block-type/index.js +3 -3
- package/dist/es2019/plugins/block-type/pm-plugins/keymap.js +11 -12
- package/dist/es2019/plugins/caption/pm-plugins/keymap.js +9 -9
- package/dist/es2019/plugins/help-dialog/index.js +2 -3
- package/dist/es2019/plugins/media/pm-plugins/alt-text/keymap.js +3 -3
- package/dist/es2019/plugins/media/pm-plugins/alt-text/ui/AltTextEdit.js +2 -2
- package/dist/es2019/plugins/media/pm-plugins/keymap.js +8 -8
- package/dist/es2019/plugins/media/pm-plugins/linking/keymap.js +2 -2
- package/dist/es2019/plugins/status/keymap.js +3 -3
- package/dist/es2019/plugins/submit-editor/index.js +3 -3
- package/dist/es2019/plugins/text-color/commands/toggle-color.js +2 -2
- package/dist/es2019/presets/context.js +25 -0
- package/dist/es2019/ui/EditorContext/index.js +2 -1
- package/dist/es2019/use-preset.js +45 -0
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/create-editor/ReactEditorViewInternal.js +2 -1
- package/dist/esm/editor-next/editor-internal.js +3 -0
- package/dist/esm/plugins/block-type/index.js +3 -3
- package/dist/esm/plugins/block-type/pm-plugins/keymap.js +11 -12
- package/dist/esm/plugins/caption/pm-plugins/keymap.js +9 -9
- package/dist/esm/plugins/help-dialog/index.js +2 -3
- package/dist/esm/plugins/media/pm-plugins/alt-text/keymap.js +3 -3
- package/dist/esm/plugins/media/pm-plugins/alt-text/ui/AltTextEdit.js +2 -2
- package/dist/esm/plugins/media/pm-plugins/keymap.js +8 -8
- package/dist/esm/plugins/media/pm-plugins/linking/keymap.js +2 -2
- package/dist/esm/plugins/status/keymap.js +3 -3
- package/dist/esm/plugins/submit-editor/index.js +3 -3
- package/dist/esm/plugins/text-color/commands/toggle-color.js +2 -2
- package/dist/esm/presets/context.js +26 -0
- package/dist/esm/ui/EditorContext/index.js +2 -1
- package/dist/esm/use-preset.js +45 -0
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/create-editor/ReactEditorViewInternal.d.ts +2 -0
- package/dist/types/labs/next/presets/default.d.ts +28 -28
- package/dist/types/plugins/emoji/commands/insert-emoji.d.ts +2 -2
- package/dist/types/plugins/emoji/index.d.ts +2 -2
- package/dist/types/plugins/find-replace/index.d.ts +1 -1
- package/dist/types/presets/context.d.ts +15 -0
- package/dist/types/use-preset.d.ts +48 -0
- package/dist/types-ts4.5/create-editor/ReactEditorViewInternal.d.ts +2 -0
- package/dist/types-ts4.5/labs/next/presets/default.d.ts +28 -28
- package/dist/types-ts4.5/plugins/emoji/commands/insert-emoji.d.ts +2 -2
- package/dist/types-ts4.5/plugins/emoji/index.d.ts +2 -2
- package/dist/types-ts4.5/plugins/find-replace/index.d.ts +1 -1
- package/dist/types-ts4.5/presets/context.d.ts +15 -0
- package/dist/types-ts4.5/use-preset.d.ts +52 -0
- package/package.json +4 -4
- package/report.api.md +6 -0
- package/tmp/api-report-tmp.d.ts +6 -0
- package/use-preset/package.json +15 -0
|
@@ -4,7 +4,7 @@ import { ToolbarSize } from '@atlaskit/editor-common/types';
|
|
|
4
4
|
import { WithPluginState } from '@atlaskit/editor-common/with-plugin-state';
|
|
5
5
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
6
6
|
import { IconHeading, IconQuote } from '@atlaskit/editor-common/quick-insert';
|
|
7
|
-
import
|
|
7
|
+
import { tooltip, toggleBlockQuote, keymap } from '@atlaskit/editor-common/keymaps';
|
|
8
8
|
import { createPlugin, pluginKey } from './pm-plugins/main';
|
|
9
9
|
import keymapPlugin from './pm-plugins/keymap';
|
|
10
10
|
import inputRulePlugin from './pm-plugins/input-rule';
|
|
@@ -22,7 +22,7 @@ const headingPluginOptions = ({
|
|
|
22
22
|
}, (_v, idx) => {
|
|
23
23
|
const level = idx + 1;
|
|
24
24
|
const descriptionDescriptor = messages[`heading${level}Description`];
|
|
25
|
-
const keyshortcut =
|
|
25
|
+
const keyshortcut = tooltip(keymap[`toggleHeading${level}`]);
|
|
26
26
|
const id = `heading${level}`;
|
|
27
27
|
return {
|
|
28
28
|
id,
|
|
@@ -64,7 +64,7 @@ const blockquotePluginOptions = ({
|
|
|
64
64
|
title: formatMessage(messages.blockquote),
|
|
65
65
|
description: formatMessage(messages.blockquoteDescription),
|
|
66
66
|
priority: 1300,
|
|
67
|
-
keyshortcut:
|
|
67
|
+
keyshortcut: tooltip(toggleBlockQuote),
|
|
68
68
|
icon: () => /*#__PURE__*/React.createElement(IconQuote, null),
|
|
69
69
|
action(insert, state) {
|
|
70
70
|
const tr = insert(state.schema.nodes.blockquote.createChecked({}, state.schema.nodes.paragraph.createChecked()));
|
|
@@ -1,26 +1,25 @@
|
|
|
1
1
|
import { redo, undo } from '@atlaskit/editor-prosemirror/history';
|
|
2
2
|
import { chainCommands } from '@atlaskit/editor-prosemirror/commands';
|
|
3
3
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
4
|
-
import
|
|
5
|
-
import { keymap } from '@atlaskit/editor-common/keymaps';
|
|
4
|
+
import { bindKeymapWithCommand, moveUp, moveDown, findKeyMapForBrowser, undo as undoKeymap, redo as redoKeymap, backspace, deleteKey, forwardDelete, toggleBlockQuote, keymap, insertNewLine, findShortcutByKeymap } from '@atlaskit/editor-common/keymaps';
|
|
6
5
|
import { insertNewLineWithAnalytics, createNewParagraphAbove, createNewParagraphBelow, deleteEmptyParagraphAndMoveBlockUp } from '@atlaskit/editor-common/utils';
|
|
7
6
|
import * as blockTypes from '../types';
|
|
8
7
|
import { cleanUpAtTheStartOfDocument, deleteAndMoveCursor, deleteBlockContent, insertBlockTypesWithAnalytics } from '../commands';
|
|
9
8
|
import { isNodeAWrappingBlockNode } from '../utils';
|
|
10
|
-
const
|
|
9
|
+
const backspaceCommand = chainCommands(cleanUpAtTheStartOfDocument, deleteBlockContent(isNodeAWrappingBlockNode), deleteAndMoveCursor);
|
|
11
10
|
const del = chainCommands(deleteEmptyParagraphAndMoveBlockUp(isNodeAWrappingBlockNode), deleteBlockContent(isNodeAWrappingBlockNode), deleteAndMoveCursor);
|
|
12
11
|
export default function keymapPlugin(editorAnalyticsApi, schema, _featureFlags) {
|
|
13
12
|
const list = {};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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);
|
|
22
21
|
if (schema.nodes[blockTypes.BLOCK_QUOTE.nodeName]) {
|
|
23
|
-
|
|
22
|
+
bindKeymapWithCommand(findShortcutByKeymap(toggleBlockQuote), insertBlockTypesWithAnalytics(blockTypes.BLOCK_QUOTE.name, INPUT_METHOD.KEYBOARD, editorAnalyticsApi), list);
|
|
24
23
|
}
|
|
25
24
|
return keymap(list);
|
|
26
25
|
}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { keymap } from '@atlaskit/editor-prosemirror/keymap';
|
|
2
2
|
import { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
-
import
|
|
3
|
+
import { bindKeymapWithCommand, moveDown, enter, moveUp, shiftTab, tab, moveLeft } from '@atlaskit/editor-common/keymaps';
|
|
4
4
|
import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
5
5
|
import { createNewParagraphBelow } from '@atlaskit/editor-common/utils';
|
|
6
6
|
import { GapCursorSelection } from '../../selection/gap-cursor/selection';
|
|
7
7
|
export function captionKeymap() {
|
|
8
8
|
const list = {};
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
9
|
+
bindKeymapWithCommand(moveDown.common, createNewParagraphBelowCaption, list);
|
|
10
|
+
bindKeymapWithCommand(enter.common, createNewParagraphBelowCaption, list);
|
|
11
|
+
bindKeymapWithCommand(moveDown.common, getOutOfCaption, list);
|
|
12
|
+
bindKeymapWithCommand(enter.common, getOutOfCaption, list);
|
|
13
|
+
bindKeymapWithCommand(moveUp.common, selectParentMediaSingle, list);
|
|
14
|
+
bindKeymapWithCommand(shiftTab.common, selectParentMediaSingle, list);
|
|
15
|
+
bindKeymapWithCommand(tab.common, getOutOfCaption, list);
|
|
16
|
+
bindKeymapWithCommand(moveLeft.common, gapCursorSelectLeftParentMediaSingle, list);
|
|
17
17
|
return keymap(list);
|
|
18
18
|
}
|
|
19
19
|
const createNewParagraphBelowCaption = (state, dispatch) => {
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { keymap } from '@atlaskit/editor-prosemirror/keymap';
|
|
3
3
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
4
|
-
import
|
|
5
|
-
import { openHelp, tooltip } from '../../keymaps';
|
|
4
|
+
import { bindKeymapWithCommand, openHelp, tooltip } from '@atlaskit/editor-common/keymaps';
|
|
6
5
|
import WithPluginState from '../../ui/WithPluginState';
|
|
7
6
|
import { HelpDialogLoader } from './ui/HelpDialogLoader';
|
|
8
7
|
import { pluginKey as quickInsertPluginKey } from '../quick-insert';
|
|
@@ -105,7 +104,7 @@ const helpDialog = (imageUploadProviderExists = false, api) => ({
|
|
|
105
104
|
});
|
|
106
105
|
const keymapPlugin = editorAnalyticsAPI => {
|
|
107
106
|
const list = {};
|
|
108
|
-
|
|
107
|
+
bindKeymapWithCommand(openHelp.common, (state, dispatch) => {
|
|
109
108
|
let {
|
|
110
109
|
tr
|
|
111
110
|
} = state;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { keymap } from '@atlaskit/editor-prosemirror/keymap';
|
|
2
|
-
import
|
|
2
|
+
import { bindKeymapWithCommand, addAltText, escape } from '@atlaskit/editor-common/keymaps';
|
|
3
3
|
import { openMediaAltTextMenu, closeMediaAltTextMenu } from './commands';
|
|
4
4
|
export default function keymapPlugin(schema, editorAnalyticsAPI) {
|
|
5
5
|
const list = {};
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
bindKeymapWithCommand(addAltText.common, openMediaAltTextMenu(editorAnalyticsAPI), list);
|
|
7
|
+
bindKeymapWithCommand(escape.common, closeMediaAltTextMenu, list);
|
|
8
8
|
return keymap(list);
|
|
9
9
|
}
|
|
@@ -10,7 +10,7 @@ import { messages } from '../messages';
|
|
|
10
10
|
import { injectIntl } from 'react-intl-next';
|
|
11
11
|
import { FloatingToolbarButton as Button } from '@atlaskit/editor-common/ui';
|
|
12
12
|
import { PanelTextInput } from '@atlaskit/editor-common/ui';
|
|
13
|
-
import
|
|
13
|
+
import { escape } from '@atlaskit/editor-common/keymaps';
|
|
14
14
|
import { ToolTipContent } from '../../../../../keymaps';
|
|
15
15
|
import { closeMediaAltTextMenu, updateAltText } from '../commands';
|
|
16
16
|
import { withAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
@@ -157,7 +157,7 @@ export class AltTextEditComponent extends React.Component {
|
|
|
157
157
|
const backButtonMessage = formatMessage(messages.back);
|
|
158
158
|
const backButtonMessageComponent = jsx(ToolTipContent, {
|
|
159
159
|
description: backButtonMessage,
|
|
160
|
-
keymap:
|
|
160
|
+
keymap: escape,
|
|
161
161
|
shortcutOverride: "Esc"
|
|
162
162
|
});
|
|
163
163
|
const errorsList = (this.state.validationErrors || []).map(function (error, index) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { keymap } from '@atlaskit/editor-prosemirror/keymap';
|
|
2
2
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
-
import
|
|
3
|
+
import { bindKeymapWithCommand, undo, enter, tab, moveLeft, moveRight, moveDown, insertNewLine } from '@atlaskit/editor-common/keymaps';
|
|
4
4
|
import { stateKey } from '../pm-plugins/plugin-key';
|
|
5
5
|
import { getMediaFeatureFlag } from '@atlaskit/media-common';
|
|
6
6
|
import { GapCursorSelection, Side } from '@atlaskit/editor-common/selection';
|
|
@@ -10,15 +10,15 @@ export function keymapPlugin(options, editorAnalyticsAPI) {
|
|
|
10
10
|
const {
|
|
11
11
|
featureFlags
|
|
12
12
|
} = options || {};
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
bindKeymapWithCommand(undo.common, ignoreLinksInSteps, list);
|
|
14
|
+
bindKeymapWithCommand(enter.common, splitMediaGroup, list);
|
|
15
15
|
if (getMediaFeatureFlag('captions', featureFlags)) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
bindKeymapWithCommand(moveDown.common, insertAndSelectCaption(editorAnalyticsAPI), list);
|
|
17
|
+
bindKeymapWithCommand(tab.common, insertAndSelectCaption(editorAnalyticsAPI), list);
|
|
18
|
+
bindKeymapWithCommand(moveLeft.common, arrowLeftFromMediaSingle(options === null || options === void 0 ? void 0 : options.editorSelectionAPI), list);
|
|
19
|
+
bindKeymapWithCommand(moveRight.common, arrowRightFromMediaSingle(options === null || options === void 0 ? void 0 : options.editorSelectionAPI), list);
|
|
20
20
|
}
|
|
21
|
-
|
|
21
|
+
bindKeymapWithCommand(insertNewLine.common, splitMediaGroup, list);
|
|
22
22
|
return keymap(list);
|
|
23
23
|
}
|
|
24
24
|
const ignoreLinksInSteps = state => {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { keymap } from '@atlaskit/editor-prosemirror/keymap';
|
|
2
|
-
import
|
|
2
|
+
import { bindKeymapWithCommand, addLink } from '@atlaskit/editor-common/keymaps';
|
|
3
3
|
import { showLinkingToolbarWithMediaTypeCheck } from '../../commands/linking';
|
|
4
4
|
export default function keymapPlugin(schema) {
|
|
5
5
|
const list = {};
|
|
6
|
-
|
|
6
|
+
bindKeymapWithCommand(addLink.common, showLinkingToolbarWithMediaTypeCheck, list);
|
|
7
7
|
return keymap(list);
|
|
8
8
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { keymap } from '@atlaskit/editor-prosemirror/keymap';
|
|
2
|
-
import
|
|
2
|
+
import { bindKeymapWithCommand, enter, tab } from '../../keymaps';
|
|
3
3
|
import { mayGetStatusAtSelection } from './utils';
|
|
4
4
|
export function keymapPlugin() {
|
|
5
5
|
const list = {};
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
bindKeymapWithCommand(enter.common, consumeKeyEvent, list);
|
|
7
|
+
bindKeymapWithCommand(tab.common, consumeKeyEvent, list);
|
|
8
8
|
return keymap(list);
|
|
9
9
|
}
|
|
10
10
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { keymap } from '@atlaskit/editor-prosemirror/keymap';
|
|
2
|
-
import
|
|
3
|
-
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '
|
|
2
|
+
import { submit } from '@atlaskit/editor-common/keymaps';
|
|
3
|
+
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
4
4
|
import { stateKey as mediaPluginKey } from '../../plugins/media/pm-plugins/plugin-key';
|
|
5
5
|
import { analyticsEventKey } from '../analytics/consts';
|
|
6
6
|
export function createPlugin(eventDispatch, onSave) {
|
|
@@ -8,7 +8,7 @@ export function createPlugin(eventDispatch, onSave) {
|
|
|
8
8
|
return;
|
|
9
9
|
}
|
|
10
10
|
return keymap({
|
|
11
|
-
[`${
|
|
11
|
+
[`${submit.common}`]: (state, _dispatch, editorView) => {
|
|
12
12
|
const mediaState = mediaPluginKey.getState(state);
|
|
13
13
|
if (mediaState && mediaState.waitForMediaUpload && !mediaState.allUploadsFinished) {
|
|
14
14
|
return true;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { toggleMark } from '@atlaskit/editor-common/mark';
|
|
2
2
|
import { ACTIONS, pluginKey } from '../pm-plugins/main';
|
|
3
3
|
import { getDisabledState } from '../utils/disabled';
|
|
4
|
-
import {
|
|
4
|
+
import { editorCommandToPMCommand } from '@atlaskit/editor-common/preset';
|
|
5
5
|
export const toggleColor = color => (state, dispatch) => {
|
|
6
6
|
const {
|
|
7
7
|
textColor
|
|
@@ -22,7 +22,7 @@ export const toggleColor = color => (state, dispatch) => {
|
|
|
22
22
|
color
|
|
23
23
|
});
|
|
24
24
|
state.tr.scrollIntoView();
|
|
25
|
-
|
|
25
|
+
editorCommandToPMCommand(toggleMark(textColor, {
|
|
26
26
|
color
|
|
27
27
|
}))(state, dispatch);
|
|
28
28
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React, { useState, useContext } from 'react';
|
|
2
|
+
export const EditorAPIContext = /*#__PURE__*/React.createContext({});
|
|
3
|
+
export const PresetContextProvider = ({
|
|
4
|
+
children
|
|
5
|
+
}) => {
|
|
6
|
+
const [editorApi, setEditorApi] = useState();
|
|
7
|
+
return /*#__PURE__*/React.createElement(EditorAPIContext.Provider, {
|
|
8
|
+
value: {
|
|
9
|
+
editorApi,
|
|
10
|
+
setEditorApi
|
|
11
|
+
}
|
|
12
|
+
}, children);
|
|
13
|
+
};
|
|
14
|
+
export const usePresetContext = () => {
|
|
15
|
+
const {
|
|
16
|
+
editorApi
|
|
17
|
+
} = useContext(EditorAPIContext);
|
|
18
|
+
return editorApi;
|
|
19
|
+
};
|
|
20
|
+
export const useSetPresetContext = () => {
|
|
21
|
+
const {
|
|
22
|
+
setEditorApi
|
|
23
|
+
} = useContext(EditorAPIContext);
|
|
24
|
+
return setEditorApi;
|
|
25
|
+
};
|
|
@@ -2,6 +2,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import EditorActions from '../../actions';
|
|
5
|
+
import { PresetContextProvider } from '../../presets/context';
|
|
5
6
|
const EditorContext = /*#__PURE__*/React.createContext({});
|
|
6
7
|
export const useEditorContext = () => React.useContext(EditorContext);
|
|
7
8
|
export default class LegacyEditorContext extends React.Component {
|
|
@@ -17,7 +18,7 @@ export default class LegacyEditorContext extends React.Component {
|
|
|
17
18
|
render() {
|
|
18
19
|
return /*#__PURE__*/React.createElement(EditorContext.Provider, {
|
|
19
20
|
value: this.getChildContext()
|
|
20
|
-
}, this.props.children);
|
|
21
|
+
}, /*#__PURE__*/React.createElement(PresetContextProvider, null, this.props.children));
|
|
21
22
|
}
|
|
22
23
|
}
|
|
23
24
|
_defineProperty(LegacyEditorContext, "childContextTypes", {
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import { usePresetContext } from './presets/context';
|
|
3
|
+
/**
|
|
4
|
+
* Creates a preset.
|
|
5
|
+
*
|
|
6
|
+
* Takes an input function that returns a preset (and memoizes it) depending
|
|
7
|
+
* on the dependency array provided.
|
|
8
|
+
*
|
|
9
|
+
* Returns a pluginInjectionApi in order to apply actions and subscribe to plugin
|
|
10
|
+
* changes outside of the editor.
|
|
11
|
+
*
|
|
12
|
+
* @param createPreset
|
|
13
|
+
* @param dependencies
|
|
14
|
+
* @returns PresetAPI ({ pluginInjectionApi, preset, actionBuilder })
|
|
15
|
+
*
|
|
16
|
+
* Example:
|
|
17
|
+
* ```ts
|
|
18
|
+
* function ExampleEditor() {
|
|
19
|
+
* const { preset, editorApi } = usePreset(() =>
|
|
20
|
+
* new EditorPresetBuilder().add(plugin1).add(plugin2)
|
|
21
|
+
* , []);
|
|
22
|
+
*
|
|
23
|
+
* // Can execute typesafe commands based on plugin1 or 2
|
|
24
|
+
* const runCommand = () => editorApi.executeCommand(
|
|
25
|
+
* editorApi.dependencies.plugin1.commands.doSomething()
|
|
26
|
+
* )
|
|
27
|
+
* return (
|
|
28
|
+
* <>
|
|
29
|
+
* <Editor preset={preset} />
|
|
30
|
+
* <Button onClick={runCommand}>Run command</Button>
|
|
31
|
+
* </>
|
|
32
|
+
* )
|
|
33
|
+
* }
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export function usePreset(createPreset, dependencies) {
|
|
37
|
+
const editorApi = usePresetContext();
|
|
38
|
+
|
|
39
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
40
|
+
const preset = useMemo(createPreset, dependencies);
|
|
41
|
+
return {
|
|
42
|
+
editorApi,
|
|
43
|
+
preset
|
|
44
|
+
};
|
|
45
|
+
}
|
package/dist/es2019/version.json
CHANGED
|
@@ -80,7 +80,7 @@ export var ReactEditorView = /*#__PURE__*/function (_React$Component) {
|
|
|
80
80
|
_inherits(ReactEditorView, _React$Component);
|
|
81
81
|
var _super = _createSuper(ReactEditorView);
|
|
82
82
|
function ReactEditorView(props, context) {
|
|
83
|
-
var _props$editorProps, _props$editorProps$pe, _props$editorProps$pe2;
|
|
83
|
+
var _props$setEditorApi, _props$editorProps, _props$editorProps$pe, _props$editorProps$pe2;
|
|
84
84
|
var _this;
|
|
85
85
|
_classCallCheck(this, ReactEditorView);
|
|
86
86
|
_this = _super.call(this, props, context);
|
|
@@ -529,6 +529,7 @@ export var ReactEditorView = /*#__PURE__*/function (_React$Component) {
|
|
|
529
529
|
getEditorState: _this.getEditorState,
|
|
530
530
|
getEditorView: _this.getEditorView
|
|
531
531
|
});
|
|
532
|
+
(_props$setEditorApi = props.setEditorApi) === null || _props$setEditorApi === void 0 ? void 0 : _props$setEditorApi.call(props, _this.pluginInjectionAPI.api());
|
|
532
533
|
_this.eventDispatcher = new EventDispatcher();
|
|
533
534
|
_this.dispatch = createDispatch(_this.eventDispatcher);
|
|
534
535
|
_this.errorReporter = createErrorReporter(props.editorProps.errorReporterHandler);
|
|
@@ -13,6 +13,7 @@ import { createFeatureFlagsFromProps } from '../create-editor/feature-flags-from
|
|
|
13
13
|
import ReactEditorView from '../create-editor/ReactEditorViewNext';
|
|
14
14
|
import { ContextAdapter } from '../nodeviews/context-adapter';
|
|
15
15
|
import EditorContext from '../ui/EditorContext';
|
|
16
|
+
import { useSetPresetContext } from '../presets/context';
|
|
16
17
|
import { RenderTracking } from '../utils/performance/components/RenderTracking';
|
|
17
18
|
import useMeasureEditorMountTime from './hooks/useMeasureEditorMountTime';
|
|
18
19
|
import useProviderFactory from './hooks/useProviderFactory';
|
|
@@ -50,6 +51,7 @@ export function EditorInternalWithoutHooks(_ref) {
|
|
|
50
51
|
onEditorDestroyed = _ref.onEditorDestroyed,
|
|
51
52
|
preset = _ref.preset;
|
|
52
53
|
var Component = getUiComponent(props.appearance);
|
|
54
|
+
var setEditorApi = useSetPresetContext();
|
|
53
55
|
var overriddenEditorProps = _objectSpread(_objectSpread({}, props), {}, {
|
|
54
56
|
onSave: props.onSave ? handleSave : undefined,
|
|
55
57
|
// noop all analytic events, even if a handler is still passed.
|
|
@@ -94,6 +96,7 @@ export function EditorInternalWithoutHooks(_ref) {
|
|
|
94
96
|
onEditorDestroyed: onEditorDestroyed,
|
|
95
97
|
disabled: props.disabled,
|
|
96
98
|
preset: preset,
|
|
99
|
+
setEditorApi: setEditorApi,
|
|
97
100
|
render: function render(_ref2) {
|
|
98
101
|
var _props$featureFlags, _props$featureFlags2;
|
|
99
102
|
var editor = _ref2.editor,
|
|
@@ -5,7 +5,7 @@ import { ToolbarSize } from '@atlaskit/editor-common/types';
|
|
|
5
5
|
import { WithPluginState } from '@atlaskit/editor-common/with-plugin-state';
|
|
6
6
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
7
7
|
import { IconHeading, IconQuote } from '@atlaskit/editor-common/quick-insert';
|
|
8
|
-
import
|
|
8
|
+
import { tooltip, toggleBlockQuote, keymap } from '@atlaskit/editor-common/keymaps';
|
|
9
9
|
import { createPlugin, pluginKey } from './pm-plugins/main';
|
|
10
10
|
import keymapPlugin from './pm-plugins/keymap';
|
|
11
11
|
import inputRulePlugin from './pm-plugins/input-rule';
|
|
@@ -22,7 +22,7 @@ var headingPluginOptions = function headingPluginOptions(_ref, isAllowed, editor
|
|
|
22
22
|
}, function (_v, idx) {
|
|
23
23
|
var level = idx + 1;
|
|
24
24
|
var descriptionDescriptor = messages["heading".concat(level, "Description")];
|
|
25
|
-
var keyshortcut =
|
|
25
|
+
var keyshortcut = tooltip(keymap["toggleHeading".concat(level)]);
|
|
26
26
|
var id = "heading".concat(level);
|
|
27
27
|
return {
|
|
28
28
|
id: id,
|
|
@@ -65,7 +65,7 @@ var blockquotePluginOptions = function blockquotePluginOptions(_ref2, isAllowed,
|
|
|
65
65
|
title: formatMessage(messages.blockquote),
|
|
66
66
|
description: formatMessage(messages.blockquoteDescription),
|
|
67
67
|
priority: 1300,
|
|
68
|
-
keyshortcut:
|
|
68
|
+
keyshortcut: tooltip(toggleBlockQuote),
|
|
69
69
|
icon: function icon() {
|
|
70
70
|
return /*#__PURE__*/React.createElement(IconQuote, null);
|
|
71
71
|
},
|
|
@@ -1,26 +1,25 @@
|
|
|
1
1
|
import { redo, undo } from '@atlaskit/editor-prosemirror/history';
|
|
2
2
|
import { chainCommands } from '@atlaskit/editor-prosemirror/commands';
|
|
3
3
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
4
|
-
import
|
|
5
|
-
import { keymap } from '@atlaskit/editor-common/keymaps';
|
|
4
|
+
import { bindKeymapWithCommand, moveUp, moveDown, findKeyMapForBrowser, undo as undoKeymap, redo as redoKeymap, backspace, deleteKey, forwardDelete, toggleBlockQuote, keymap, insertNewLine, findShortcutByKeymap } from '@atlaskit/editor-common/keymaps';
|
|
6
5
|
import { insertNewLineWithAnalytics, createNewParagraphAbove, createNewParagraphBelow, deleteEmptyParagraphAndMoveBlockUp } from '@atlaskit/editor-common/utils';
|
|
7
6
|
import * as blockTypes from '../types';
|
|
8
7
|
import { cleanUpAtTheStartOfDocument, deleteAndMoveCursor, deleteBlockContent, insertBlockTypesWithAnalytics } from '../commands';
|
|
9
8
|
import { isNodeAWrappingBlockNode } from '../utils';
|
|
10
|
-
var
|
|
9
|
+
var backspaceCommand = chainCommands(cleanUpAtTheStartOfDocument, deleteBlockContent(isNodeAWrappingBlockNode), deleteAndMoveCursor);
|
|
11
10
|
var del = chainCommands(deleteEmptyParagraphAndMoveBlockUp(isNodeAWrappingBlockNode), deleteBlockContent(isNodeAWrappingBlockNode), deleteAndMoveCursor);
|
|
12
11
|
export default function keymapPlugin(editorAnalyticsApi, schema, _featureFlags) {
|
|
13
12
|
var list = {};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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);
|
|
22
21
|
if (schema.nodes[blockTypes.BLOCK_QUOTE.nodeName]) {
|
|
23
|
-
|
|
22
|
+
bindKeymapWithCommand(findShortcutByKeymap(toggleBlockQuote), insertBlockTypesWithAnalytics(blockTypes.BLOCK_QUOTE.name, INPUT_METHOD.KEYBOARD, editorAnalyticsApi), list);
|
|
24
23
|
}
|
|
25
24
|
return keymap(list);
|
|
26
25
|
}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { keymap } from '@atlaskit/editor-prosemirror/keymap';
|
|
2
2
|
import { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
-
import
|
|
3
|
+
import { bindKeymapWithCommand, moveDown, enter, moveUp, shiftTab, tab, moveLeft } from '@atlaskit/editor-common/keymaps';
|
|
4
4
|
import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
5
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 = {};
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
9
|
+
bindKeymapWithCommand(moveDown.common, createNewParagraphBelowCaption, list);
|
|
10
|
+
bindKeymapWithCommand(enter.common, createNewParagraphBelowCaption, list);
|
|
11
|
+
bindKeymapWithCommand(moveDown.common, getOutOfCaption, list);
|
|
12
|
+
bindKeymapWithCommand(enter.common, getOutOfCaption, list);
|
|
13
|
+
bindKeymapWithCommand(moveUp.common, selectParentMediaSingle, list);
|
|
14
|
+
bindKeymapWithCommand(shiftTab.common, selectParentMediaSingle, list);
|
|
15
|
+
bindKeymapWithCommand(tab.common, getOutOfCaption, list);
|
|
16
|
+
bindKeymapWithCommand(moveLeft.common, gapCursorSelectLeftParentMediaSingle, list);
|
|
17
17
|
return keymap(list);
|
|
18
18
|
}
|
|
19
19
|
var createNewParagraphBelowCaption = function createNewParagraphBelowCaption(state, dispatch) {
|
|
@@ -4,8 +4,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import { keymap } from '@atlaskit/editor-prosemirror/keymap';
|
|
6
6
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
7
|
-
import
|
|
8
|
-
import { openHelp, tooltip } from '../../keymaps';
|
|
7
|
+
import { bindKeymapWithCommand, openHelp, tooltip } from '@atlaskit/editor-common/keymaps';
|
|
9
8
|
import WithPluginState from '../../ui/WithPluginState';
|
|
10
9
|
import { HelpDialogLoader } from './ui/HelpDialogLoader';
|
|
11
10
|
import { pluginKey as quickInsertPluginKey } from '../quick-insert';
|
|
@@ -116,7 +115,7 @@ var helpDialog = function helpDialog() {
|
|
|
116
115
|
};
|
|
117
116
|
var keymapPlugin = function keymapPlugin(editorAnalyticsAPI) {
|
|
118
117
|
var list = {};
|
|
119
|
-
|
|
118
|
+
bindKeymapWithCommand(openHelp.common, function (state, dispatch) {
|
|
120
119
|
var tr = state.tr;
|
|
121
120
|
var isVisible = tr.getMeta(pluginKey);
|
|
122
121
|
if (!isVisible) {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { keymap } from '@atlaskit/editor-prosemirror/keymap';
|
|
2
|
-
import
|
|
2
|
+
import { bindKeymapWithCommand, addAltText, escape } from '@atlaskit/editor-common/keymaps';
|
|
3
3
|
import { openMediaAltTextMenu, closeMediaAltTextMenu } from './commands';
|
|
4
4
|
export default function keymapPlugin(schema, editorAnalyticsAPI) {
|
|
5
5
|
var list = {};
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
bindKeymapWithCommand(addAltText.common, openMediaAltTextMenu(editorAnalyticsAPI), list);
|
|
7
|
+
bindKeymapWithCommand(escape.common, closeMediaAltTextMenu, list);
|
|
8
8
|
return keymap(list);
|
|
9
9
|
}
|
|
@@ -20,7 +20,7 @@ import { messages } from '../messages';
|
|
|
20
20
|
import { injectIntl } from 'react-intl-next';
|
|
21
21
|
import { FloatingToolbarButton as Button } from '@atlaskit/editor-common/ui';
|
|
22
22
|
import { PanelTextInput } from '@atlaskit/editor-common/ui';
|
|
23
|
-
import
|
|
23
|
+
import { escape } from '@atlaskit/editor-common/keymaps';
|
|
24
24
|
import { ToolTipContent } from '../../../../../keymaps';
|
|
25
25
|
import { closeMediaAltTextMenu, updateAltText } from '../commands';
|
|
26
26
|
import { withAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
@@ -133,7 +133,7 @@ export var AltTextEditComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
133
133
|
var backButtonMessage = formatMessage(messages.back);
|
|
134
134
|
var backButtonMessageComponent = jsx(ToolTipContent, {
|
|
135
135
|
description: backButtonMessage,
|
|
136
|
-
keymap:
|
|
136
|
+
keymap: escape,
|
|
137
137
|
shortcutOverride: "Esc"
|
|
138
138
|
});
|
|
139
139
|
var errorsList = (this.state.validationErrors || []).map(function (error, index) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { keymap } from '@atlaskit/editor-prosemirror/keymap';
|
|
2
2
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
-
import
|
|
3
|
+
import { bindKeymapWithCommand, undo, enter, tab, moveLeft, moveRight, moveDown, insertNewLine } from '@atlaskit/editor-common/keymaps';
|
|
4
4
|
import { stateKey } from '../pm-plugins/plugin-key';
|
|
5
5
|
import { getMediaFeatureFlag } from '@atlaskit/media-common';
|
|
6
6
|
import { GapCursorSelection, Side } from '@atlaskit/editor-common/selection';
|
|
@@ -9,15 +9,15 @@ export function keymapPlugin(options, editorAnalyticsAPI) {
|
|
|
9
9
|
var list = {};
|
|
10
10
|
var _ref = options || {},
|
|
11
11
|
featureFlags = _ref.featureFlags;
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
bindKeymapWithCommand(undo.common, ignoreLinksInSteps, list);
|
|
13
|
+
bindKeymapWithCommand(enter.common, splitMediaGroup, list);
|
|
14
14
|
if (getMediaFeatureFlag('captions', featureFlags)) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
bindKeymapWithCommand(moveDown.common, insertAndSelectCaption(editorAnalyticsAPI), list);
|
|
16
|
+
bindKeymapWithCommand(tab.common, insertAndSelectCaption(editorAnalyticsAPI), list);
|
|
17
|
+
bindKeymapWithCommand(moveLeft.common, arrowLeftFromMediaSingle(options === null || options === void 0 ? void 0 : options.editorSelectionAPI), list);
|
|
18
|
+
bindKeymapWithCommand(moveRight.common, arrowRightFromMediaSingle(options === null || options === void 0 ? void 0 : options.editorSelectionAPI), list);
|
|
19
19
|
}
|
|
20
|
-
|
|
20
|
+
bindKeymapWithCommand(insertNewLine.common, splitMediaGroup, list);
|
|
21
21
|
return keymap(list);
|
|
22
22
|
}
|
|
23
23
|
var ignoreLinksInSteps = function ignoreLinksInSteps(state) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { keymap } from '@atlaskit/editor-prosemirror/keymap';
|
|
2
|
-
import
|
|
2
|
+
import { bindKeymapWithCommand, addLink } from '@atlaskit/editor-common/keymaps';
|
|
3
3
|
import { showLinkingToolbarWithMediaTypeCheck } from '../../commands/linking';
|
|
4
4
|
export default function keymapPlugin(schema) {
|
|
5
5
|
var list = {};
|
|
6
|
-
|
|
6
|
+
bindKeymapWithCommand(addLink.common, showLinkingToolbarWithMediaTypeCheck, list);
|
|
7
7
|
return keymap(list);
|
|
8
8
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { keymap } from '@atlaskit/editor-prosemirror/keymap';
|
|
2
|
-
import
|
|
2
|
+
import { bindKeymapWithCommand, enter, tab } from '../../keymaps';
|
|
3
3
|
import { mayGetStatusAtSelection } from './utils';
|
|
4
4
|
export function keymapPlugin() {
|
|
5
5
|
var list = {};
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
bindKeymapWithCommand(enter.common, consumeKeyEvent, list);
|
|
7
|
+
bindKeymapWithCommand(tab.common, consumeKeyEvent, list);
|
|
8
8
|
return keymap(list);
|
|
9
9
|
}
|
|
10
10
|
|