@atlaskit/editor-core 161.0.0 → 162.0.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 +44 -0
- package/dist/cjs/actions/index.js +76 -48
- package/dist/cjs/extensibility.js +2 -2
- package/dist/cjs/labs/next/full-page.js +1 -1
- package/dist/cjs/plugins/block-type/styles.js +5 -2
- package/dist/cjs/plugins/block-type/ui/ToolbarBlockType/index.js +13 -11
- package/dist/cjs/plugins/block-type/ui/ToolbarBlockType/styled.js +11 -7
- package/dist/cjs/plugins/card/messages.js +4 -4
- package/dist/cjs/plugins/card/ui/LinkToolbarAppearance.js +29 -11
- package/dist/cjs/plugins/card/ui/LinkToolbarButtonGroup.js +66 -7
- package/dist/cjs/plugins/card/ui/LinkToolbarIconDropdown.js +166 -7
- package/dist/cjs/plugins/card/ui/ResizableEmbedCard.js +9 -6
- package/dist/cjs/plugins/card/ui/assets/card.js +1 -1
- package/dist/cjs/plugins/card/ui/assets/embed.js +1 -1
- package/dist/cjs/plugins/card/ui/assets/inline.js +1 -1
- package/dist/cjs/plugins/card/ui/assets/url.js +1 -1
- package/dist/cjs/plugins/card/ui/link-toolbar-button-group-options.js +60 -0
- package/dist/cjs/plugins/card/ui/link-toolbar-icon-dropdown-options.js +66 -0
- package/dist/cjs/plugins/card/ui/styled.js +5 -13
- package/dist/cjs/plugins/card/ui/types.js +5 -0
- package/dist/cjs/plugins/clipboard/pm-plugins/main.js +99 -3
- package/dist/cjs/plugins/code-block/styles.js +45 -38
- package/dist/cjs/plugins/extension/plugin-factory.js +4 -1
- package/dist/cjs/plugins/extension/pm-plugins/main.js +34 -11
- package/dist/cjs/plugins/extension/utils.js +57 -12
- package/dist/cjs/plugins/find-replace/ui/Find.js +12 -12
- package/dist/cjs/plugins/find-replace/ui/FindReplace.js +5 -5
- package/dist/cjs/plugins/find-replace/ui/Replace.js +5 -5
- package/dist/cjs/plugins/find-replace/ui/styles.js +12 -15
- package/dist/cjs/plugins/layout/styles.js +2 -2
- package/dist/cjs/plugins/list/actions/wrap-and-join-lists.js +180 -0
- package/dist/cjs/plugins/list/commands/index.js +35 -38
- package/dist/cjs/plugins/list/utils/replace-content.js +31 -0
- package/dist/cjs/plugins/media/nodeviews/mediaNodeUpdater.js +3 -3
- package/dist/cjs/plugins/media/styles.js +2 -2
- package/dist/cjs/plugins/media/utils/media-single.js +15 -2
- package/dist/cjs/plugins/paste/handlers.js +19 -5
- package/dist/cjs/plugins/paste/pm-plugins/analytics.js +1 -1
- package/dist/cjs/plugins/placeholder-text/index.js +45 -1
- package/dist/cjs/plugins/placeholder-text/placeholder-text-nodeview.js +66 -22
- package/dist/cjs/plugins/placeholder-text/selection-utils.js +19 -0
- package/dist/cjs/plugins/placeholder-text/styles.js +3 -1
- package/dist/cjs/plugins/table/commands/index.js +0 -6
- package/dist/cjs/plugins/table/commands/insert.js +1 -1
- package/dist/cjs/plugins/table/commands/misc.js +5 -18
- package/dist/cjs/plugins/table/commands-with-analytics.js +1 -1
- package/dist/cjs/plugins/table/handlers.js +6 -2
- package/dist/cjs/plugins/table/index.js +7 -13
- package/dist/cjs/plugins/table/nodeviews/TableComponent.js +2 -2
- package/dist/cjs/plugins/table/nodeviews/table.js +7 -38
- package/dist/cjs/plugins/table/pm-plugins/decorations/plugin.js +2 -2
- package/dist/cjs/plugins/table/pm-plugins/main.js +3 -1
- package/dist/cjs/plugins/table/pm-plugins/plugin-factory.js +4 -7
- package/dist/cjs/plugins/table/pm-plugins/plugin-key.js +11 -0
- package/dist/cjs/plugins/table/pm-plugins/safari-delayed-dom-selection-syncing-workaround.js +2 -0
- package/dist/cjs/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +3 -3
- package/dist/cjs/plugins/table/reducer.js +0 -7
- package/dist/cjs/plugins/table/toolbar.js +5 -15
- package/dist/cjs/plugins/table/transforms/metadata.js +2 -2
- package/dist/cjs/plugins/table/ui/FloatingContextualMenu/index.js +3 -1
- package/dist/cjs/plugins/table/ui/FloatingInsertButton/index.js +1 -1
- package/dist/cjs/plugins/table/ui/LayoutButton/index.js +1 -2
- package/dist/cjs/plugins/table/ui/common-styles.css.js +17 -8
- package/dist/cjs/plugins/table/ui/ui-styles.css.js +39 -25
- package/dist/cjs/plugins/table/utils/nodes.js +15 -15
- package/dist/cjs/plugins/tasks-and-decisions/commands.js +15 -1
- package/dist/cjs/plugins/text-formatting/styles.js +5 -2
- package/dist/cjs/plugins/text-formatting/ui/Toolbar/index.js +71 -1
- package/dist/cjs/plugins/text-formatting/ui/Toolbar/toolbar-messages.js +30 -0
- package/dist/cjs/plugins/text-formatting/utils.js +30 -2
- package/dist/cjs/plugins/type-ahead/api.js +32 -1
- package/dist/cjs/plugins/type-ahead/transforms/open-typeahead-at-cursor.js +20 -5
- package/dist/cjs/plugins/type-ahead/utils.js +22 -4
- package/dist/cjs/ui/Appearance/Comment/Comment.js +1 -1
- package/dist/cjs/ui/Appearance/FullPage/StyledComponents.js +1 -1
- package/dist/cjs/ui/ContentStyles/index.js +32 -9
- package/dist/cjs/utils/index.js +1 -8
- package/dist/cjs/utils/insert.js +1 -9
- package/dist/cjs/utils/selection.js +2 -9
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/actions/index.js +20 -23
- package/dist/es2019/extensibility.js +1 -1
- package/dist/es2019/labs/next/full-page.js +2 -2
- package/dist/es2019/plugins/block-type/styles.js +3 -3
- package/dist/es2019/plugins/block-type/ui/ToolbarBlockType/index.js +15 -12
- package/dist/es2019/plugins/block-type/ui/ToolbarBlockType/styled.js +19 -14
- package/dist/es2019/plugins/card/messages.js +4 -4
- package/dist/es2019/plugins/card/ui/LinkToolbarAppearance.js +21 -9
- package/dist/es2019/plugins/card/ui/LinkToolbarButtonGroup.js +54 -3
- package/dist/es2019/plugins/card/ui/LinkToolbarIconDropdown.js +145 -3
- package/dist/es2019/plugins/card/ui/ResizableEmbedCard.js +10 -6
- package/dist/es2019/plugins/card/ui/assets/card.js +1 -1
- package/dist/es2019/plugins/card/ui/assets/embed.js +1 -1
- package/dist/es2019/plugins/card/ui/assets/inline.js +1 -1
- package/dist/es2019/plugins/card/ui/assets/url.js +1 -1
- package/dist/es2019/plugins/card/ui/link-toolbar-button-group-options.js +45 -0
- package/dist/es2019/plugins/card/ui/link-toolbar-icon-dropdown-options.js +51 -0
- package/dist/es2019/plugins/card/ui/styled.js +2 -2
- package/dist/es2019/plugins/card/ui/types.js +1 -0
- package/dist/es2019/plugins/clipboard/pm-plugins/main.js +91 -9
- package/dist/es2019/plugins/code-block/styles.js +14 -14
- package/dist/es2019/plugins/extension/plugin-factory.js +3 -1
- package/dist/es2019/plugins/extension/pm-plugins/main.js +38 -12
- package/dist/es2019/plugins/extension/utils.js +37 -2
- package/dist/es2019/plugins/find-replace/ui/Find.js +1 -1
- package/dist/es2019/plugins/find-replace/ui/FindReplace.js +1 -1
- package/dist/es2019/plugins/find-replace/ui/Replace.js +1 -1
- package/dist/es2019/plugins/find-replace/ui/styles.js +14 -9
- package/dist/es2019/plugins/layout/styles.js +5 -1
- package/dist/es2019/plugins/list/actions/wrap-and-join-lists.js +163 -0
- package/dist/es2019/plugins/list/commands/index.js +29 -28
- package/dist/es2019/plugins/list/utils/replace-content.js +22 -0
- package/dist/es2019/plugins/media/nodeviews/mediaNodeUpdater.js +3 -3
- package/dist/es2019/plugins/media/styles.js +1 -1
- package/dist/es2019/plugins/media/utils/media-single.js +14 -1
- package/dist/es2019/plugins/paste/handlers.js +19 -5
- package/dist/es2019/plugins/paste/pm-plugins/analytics.js +2 -2
- package/dist/es2019/plugins/placeholder-text/index.js +46 -1
- package/dist/es2019/plugins/placeholder-text/placeholder-text-nodeview.js +66 -20
- package/dist/es2019/plugins/placeholder-text/selection-utils.js +9 -0
- package/dist/es2019/plugins/placeholder-text/styles.js +22 -0
- package/dist/es2019/plugins/table/commands/index.js +1 -1
- package/dist/es2019/plugins/table/commands/insert.js +1 -1
- package/dist/es2019/plugins/table/commands/misc.js +5 -11
- package/dist/es2019/plugins/table/commands-with-analytics.js +1 -1
- package/dist/es2019/plugins/table/handlers.js +6 -2
- package/dist/es2019/plugins/table/index.js +4 -8
- package/dist/es2019/plugins/table/nodeviews/TableComponent.js +2 -2
- package/dist/es2019/plugins/table/nodeviews/table.js +2 -16
- package/dist/es2019/plugins/table/pm-plugins/decorations/plugin.js +1 -1
- package/dist/es2019/plugins/table/pm-plugins/main.js +2 -1
- package/dist/es2019/plugins/table/pm-plugins/plugin-factory.js +1 -2
- package/dist/es2019/plugins/table/pm-plugins/plugin-key.js +2 -0
- package/dist/es2019/plugins/table/pm-plugins/safari-delayed-dom-selection-syncing-workaround.js +2 -0
- package/dist/es2019/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +1 -1
- package/dist/es2019/plugins/table/reducer.js +0 -9
- package/dist/es2019/plugins/table/toolbar.js +1 -4
- package/dist/es2019/plugins/table/transforms/metadata.js +1 -1
- package/dist/es2019/plugins/table/ui/FloatingContextualMenu/index.js +2 -1
- package/dist/es2019/plugins/table/ui/FloatingInsertButton/index.js +1 -1
- package/dist/es2019/plugins/table/ui/LayoutButton/index.js +1 -2
- package/dist/es2019/plugins/table/ui/common-styles.css.js +51 -26
- package/dist/es2019/plugins/table/ui/ui-styles.css.js +57 -56
- package/dist/es2019/plugins/table/utils/nodes.js +11 -11
- package/dist/es2019/plugins/tasks-and-decisions/commands.js +13 -1
- package/dist/es2019/plugins/text-formatting/styles.js +3 -3
- package/dist/es2019/plugins/text-formatting/ui/Toolbar/index.js +61 -2
- package/dist/es2019/plugins/text-formatting/ui/Toolbar/toolbar-messages.js +30 -0
- package/dist/es2019/plugins/text-formatting/utils.js +13 -1
- package/dist/es2019/plugins/type-ahead/api.js +31 -2
- package/dist/es2019/plugins/type-ahead/transforms/open-typeahead-at-cursor.js +17 -5
- package/dist/es2019/plugins/type-ahead/utils.js +15 -0
- package/dist/es2019/ui/Appearance/Comment/Comment.js +2 -2
- package/dist/es2019/ui/Appearance/FullPage/StyledComponents.js +2 -2
- package/dist/es2019/ui/ContentStyles/index.js +45 -23
- package/dist/es2019/utils/index.js +1 -1
- package/dist/es2019/utils/insert.js +2 -10
- package/dist/es2019/utils/selection.js +1 -6
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/actions/index.js +76 -48
- package/dist/esm/extensibility.js +1 -1
- package/dist/esm/labs/next/full-page.js +2 -2
- package/dist/esm/plugins/block-type/styles.js +4 -2
- package/dist/esm/plugins/block-type/ui/ToolbarBlockType/index.js +14 -12
- package/dist/esm/plugins/block-type/ui/ToolbarBlockType/styled.js +9 -5
- package/dist/esm/plugins/card/messages.js +4 -4
- package/dist/esm/plugins/card/ui/LinkToolbarAppearance.js +25 -9
- package/dist/esm/plugins/card/ui/LinkToolbarButtonGroup.js +57 -5
- package/dist/esm/plugins/card/ui/LinkToolbarIconDropdown.js +154 -5
- package/dist/esm/plugins/card/ui/ResizableEmbedCard.js +9 -6
- package/dist/esm/plugins/card/ui/assets/card.js +1 -1
- package/dist/esm/plugins/card/ui/assets/embed.js +1 -1
- package/dist/esm/plugins/card/ui/assets/inline.js +1 -1
- package/dist/esm/plugins/card/ui/assets/url.js +1 -1
- package/dist/esm/plugins/card/ui/link-toolbar-button-group-options.js +45 -0
- package/dist/esm/plugins/card/ui/link-toolbar-icon-dropdown-options.js +51 -0
- package/dist/esm/plugins/card/ui/styled.js +2 -2
- package/dist/esm/plugins/card/ui/types.js +1 -0
- package/dist/esm/plugins/clipboard/pm-plugins/main.js +91 -2
- package/dist/esm/plugins/code-block/styles.js +42 -38
- package/dist/esm/plugins/extension/plugin-factory.js +3 -1
- package/dist/esm/plugins/extension/pm-plugins/main.js +34 -11
- package/dist/esm/plugins/extension/utils.js +51 -9
- package/dist/esm/plugins/find-replace/ui/Find.js +1 -1
- package/dist/esm/plugins/find-replace/ui/FindReplace.js +1 -1
- package/dist/esm/plugins/find-replace/ui/Replace.js +1 -1
- package/dist/esm/plugins/find-replace/ui/styles.js +6 -10
- package/dist/esm/plugins/layout/styles.js +2 -2
- package/dist/esm/plugins/list/actions/wrap-and-join-lists.js +168 -0
- package/dist/esm/plugins/list/commands/index.js +33 -34
- package/dist/esm/plugins/list/utils/replace-content.js +21 -0
- package/dist/esm/plugins/media/nodeviews/mediaNodeUpdater.js +3 -3
- package/dist/esm/plugins/media/styles.js +1 -1
- package/dist/esm/plugins/media/utils/media-single.js +12 -1
- package/dist/esm/plugins/paste/handlers.js +19 -5
- package/dist/esm/plugins/paste/pm-plugins/analytics.js +2 -2
- package/dist/esm/plugins/placeholder-text/index.js +44 -1
- package/dist/esm/plugins/placeholder-text/placeholder-text-nodeview.js +67 -20
- package/dist/esm/plugins/placeholder-text/selection-utils.js +9 -0
- package/dist/esm/plugins/placeholder-text/styles.js +2 -1
- package/dist/esm/plugins/table/commands/index.js +1 -1
- package/dist/esm/plugins/table/commands/insert.js +1 -1
- package/dist/esm/plugins/table/commands/misc.js +5 -15
- package/dist/esm/plugins/table/commands-with-analytics.js +1 -1
- package/dist/esm/plugins/table/handlers.js +6 -2
- package/dist/esm/plugins/table/index.js +6 -11
- package/dist/esm/plugins/table/nodeviews/TableComponent.js +2 -2
- package/dist/esm/plugins/table/nodeviews/table.js +6 -37
- package/dist/esm/plugins/table/pm-plugins/decorations/plugin.js +1 -1
- package/dist/esm/plugins/table/pm-plugins/main.js +2 -1
- package/dist/esm/plugins/table/pm-plugins/plugin-factory.js +1 -2
- package/dist/esm/plugins/table/pm-plugins/plugin-key.js +2 -0
- package/dist/esm/plugins/table/pm-plugins/safari-delayed-dom-selection-syncing-workaround.js +2 -0
- package/dist/esm/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +1 -1
- package/dist/esm/plugins/table/reducer.js +0 -7
- package/dist/esm/plugins/table/toolbar.js +1 -10
- package/dist/esm/plugins/table/transforms/metadata.js +1 -1
- package/dist/esm/plugins/table/ui/FloatingContextualMenu/index.js +2 -1
- package/dist/esm/plugins/table/ui/FloatingInsertButton/index.js +1 -1
- package/dist/esm/plugins/table/ui/LayoutButton/index.js +1 -2
- package/dist/esm/plugins/table/ui/common-styles.css.js +10 -6
- package/dist/esm/plugins/table/ui/ui-styles.css.js +20 -11
- package/dist/esm/plugins/table/utils/nodes.js +14 -14
- package/dist/esm/plugins/tasks-and-decisions/commands.js +13 -1
- package/dist/esm/plugins/text-formatting/styles.js +4 -2
- package/dist/esm/plugins/text-formatting/ui/Toolbar/index.js +69 -2
- package/dist/esm/plugins/text-formatting/ui/Toolbar/toolbar-messages.js +30 -0
- package/dist/esm/plugins/text-formatting/utils.js +18 -0
- package/dist/esm/plugins/type-ahead/api.js +30 -2
- package/dist/esm/plugins/type-ahead/transforms/open-typeahead-at-cursor.js +16 -4
- package/dist/esm/plugins/type-ahead/utils.js +17 -3
- package/dist/esm/ui/Appearance/Comment/Comment.js +2 -2
- package/dist/esm/ui/Appearance/FullPage/StyledComponents.js +2 -2
- package/dist/esm/ui/ContentStyles/index.js +27 -9
- package/dist/esm/utils/index.js +1 -1
- package/dist/esm/utils/insert.js +2 -10
- package/dist/esm/utils/selection.js +1 -6
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/actions/index.d.ts +2 -2
- package/dist/types/extensibility.d.ts +1 -1
- package/dist/types/plugins/analytics/types/list-events.d.ts +0 -1
- package/dist/types/plugins/block-type/styles.d.ts +2 -1
- package/dist/types/plugins/block-type/ui/ToolbarBlockType/index.d.ts +1 -0
- package/dist/types/plugins/block-type/ui/ToolbarBlockType/styled.d.ts +2 -7
- package/dist/types/plugins/card/messages.d.ts +2 -2
- package/dist/types/plugins/card/ui/LinkToolbarButtonGroup.d.ts +18 -2
- package/dist/types/plugins/card/ui/LinkToolbarIconDropdown.d.ts +23 -3
- package/dist/types/plugins/card/ui/ResizableEmbedCard.d.ts +3 -1
- package/dist/types/plugins/card/ui/link-toolbar-button-group-options.d.ts +5 -0
- package/dist/types/plugins/card/ui/link-toolbar-icon-dropdown-options.d.ts +5 -0
- package/dist/types/plugins/card/ui/styled.d.ts +2 -3
- package/dist/types/plugins/card/ui/types.d.ts +12 -0
- package/dist/types/plugins/clipboard/pm-plugins/main.d.ts +10 -1
- package/dist/types/plugins/code-block/styles.d.ts +3 -2
- package/dist/types/plugins/extension/pm-plugins/main.d.ts +2 -1
- package/dist/types/plugins/extension/types.d.ts +1 -0
- package/dist/types/plugins/extension/utils.d.ts +3 -1
- package/dist/types/plugins/find-replace/ui/FindReplace.d.ts +2 -1
- package/dist/types/plugins/find-replace/ui/styles.d.ts +5 -5
- package/dist/types/plugins/layout/styles.d.ts +1 -1
- package/dist/types/plugins/list/actions/wrap-and-join-lists.d.ts +25 -0
- package/dist/types/plugins/list/commands/index.d.ts +0 -1
- package/dist/types/plugins/list/utils/replace-content.d.ts +8 -0
- package/dist/types/plugins/media/nodeviews/mediaNodeUpdater.d.ts +2 -2
- package/dist/types/plugins/media/styles.d.ts +1 -1
- package/dist/types/plugins/media/utils/media-single.d.ts +1 -0
- package/dist/types/plugins/panel/styles.d.ts +1 -1
- package/dist/types/plugins/paste/handlers.d.ts +1 -1
- package/dist/types/plugins/placeholder-text/placeholder-text-nodeview.d.ts +3 -2
- package/dist/types/plugins/placeholder-text/selection-utils.d.ts +2 -0
- package/dist/types/plugins/rule/styles.d.ts +1 -1
- package/dist/types/plugins/table/commands/index.d.ts +1 -1
- package/dist/types/plugins/table/commands/misc.d.ts +0 -1
- package/dist/types/plugins/table/nodeviews/table.d.ts +0 -1
- package/dist/types/plugins/table/pm-plugins/plugin-factory.d.ts +1 -4
- package/dist/types/plugins/table/pm-plugins/plugin-key.d.ts +3 -0
- package/dist/types/plugins/table/types.d.ts +1 -8
- package/dist/types/plugins/table/ui/LayoutButton/index.d.ts +0 -1
- package/dist/types/plugins/table/ui/common-styles.css.d.ts +6 -3
- package/dist/types/plugins/table/ui/ui-styles.css.d.ts +15 -14
- package/dist/types/plugins/table/utils/nodes.d.ts +6 -6
- package/dist/types/plugins/text-formatting/pm-plugins/smart-input-rule.d.ts +1 -1
- package/dist/types/plugins/text-formatting/styles.d.ts +2 -1
- package/dist/types/plugins/text-formatting/ui/Toolbar/toolbar-messages.d.ts +30 -0
- package/dist/types/plugins/text-formatting/utils.d.ts +4 -0
- package/dist/types/plugins/type-ahead/api.d.ts +11 -1
- package/dist/types/plugins/type-ahead/transforms/open-typeahead-at-cursor.d.ts +1 -0
- package/dist/types/plugins/type-ahead/utils.d.ts +4 -0
- package/dist/types/ui/ContentStyles/index.d.ts +1 -0
- package/dist/types/utils/index.d.ts +1 -1
- package/dist/types/utils/selection.d.ts +0 -1
- package/package.json +28 -26
|
@@ -3,17 +3,99 @@ import { TextSelection } from 'prosemirror-state';
|
|
|
3
3
|
import { clipboardPluginKey } from '../plugin-key';
|
|
4
4
|
import { getNodeSelectionAnalyticsPayload, getAllSelectionAnalyticsPayload, getRangeSelectionAnalyticsPayload, getCellSelectionAnalyticsPayload } from '../../selection/utils';
|
|
5
5
|
import { EVENT_TYPE, ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID } from '../../analytics/types/enums';
|
|
6
|
+
import { DOMSerializer } from 'prosemirror-model';
|
|
7
|
+
import { findParentNodeOfType } from 'prosemirror-utils';
|
|
8
|
+
import { Fragment } from 'prosemirror-model';
|
|
6
9
|
export const createPlugin = ({
|
|
7
|
-
dispatchAnalyticsEvent
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
dispatchAnalyticsEvent,
|
|
11
|
+
schema
|
|
12
|
+
}) => {
|
|
13
|
+
let editorView;
|
|
14
|
+
|
|
15
|
+
const getEditorView = () => editorView;
|
|
16
|
+
|
|
17
|
+
return new SafePlugin({
|
|
18
|
+
key: clipboardPluginKey,
|
|
19
|
+
view: view => {
|
|
20
|
+
editorView = view;
|
|
21
|
+
return {
|
|
22
|
+
update: view => {
|
|
23
|
+
editorView = view;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
},
|
|
27
|
+
props: {
|
|
28
|
+
handleDOMEvents: {
|
|
29
|
+
cut: view => sendClipboardAnalytics(view, dispatchAnalyticsEvent, ACTION.CUT),
|
|
30
|
+
copy: view => sendClipboardAnalytics(view, dispatchAnalyticsEvent, ACTION.COPIED)
|
|
31
|
+
},
|
|
32
|
+
clipboardSerializer: createClipboardSerializer(schema, getEditorView)
|
|
14
33
|
}
|
|
15
|
-
}
|
|
16
|
-
}
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Overrides Prosemirror's default clipboardSerializer, in order to fix table row copy/paste bug raised in ED-13003.
|
|
38
|
+
* This allows us to store the original table’s attributes on the new table that the row is wrapped with when it is being copied.
|
|
39
|
+
* e.g. keeping the layout on a row that is copied.
|
|
40
|
+
* We store the default serializer in order to call it after we handle the table row case.
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
export const createClipboardSerializer = (schema, getEditorView) => {
|
|
44
|
+
const oldSerializer = DOMSerializer.fromSchema(schema);
|
|
45
|
+
const newSerializer = new DOMSerializer(oldSerializer.nodes, oldSerializer.marks);
|
|
46
|
+
const originalSerializeFragment = newSerializer.serializeFragment.bind(newSerializer);
|
|
47
|
+
|
|
48
|
+
newSerializer.serializeFragment = (content, options = {}, target) => {
|
|
49
|
+
var _content$firstChild;
|
|
50
|
+
|
|
51
|
+
const editorView = getEditorView();
|
|
52
|
+
const selection = editorView.state.selection; // We do not need to handle when a user copies a tableRow + other content.
|
|
53
|
+
// In that scenario it already wraps the Row with correct Table and attributes.
|
|
54
|
+
|
|
55
|
+
if (!options.tableWrapperExists) {
|
|
56
|
+
let i = 0;
|
|
57
|
+
|
|
58
|
+
while (i < content.childCount) {
|
|
59
|
+
var _content$maybeChild;
|
|
60
|
+
|
|
61
|
+
if (((_content$maybeChild = content.maybeChild(i)) === null || _content$maybeChild === void 0 ? void 0 : _content$maybeChild.type.name) === 'table') {
|
|
62
|
+
options.tableWrapperExists = true;
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
i++;
|
|
67
|
+
}
|
|
68
|
+
} // When the content being copied includes a tableRow that is not already wrapped with a table,
|
|
69
|
+
// We will wrap it with one ourselves, while preserving the parent table's attributes.
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
if (((_content$firstChild = content.firstChild) === null || _content$firstChild === void 0 ? void 0 : _content$firstChild.type.name) === 'tableRow' && !options.tableWrapperExists) {
|
|
73
|
+
// We only want 1 table wrapping the rows.
|
|
74
|
+
// tableWrapperExist is a custom prop added solely for the purposes of this recursive algorithm.
|
|
75
|
+
// The function is recursively called for each node in the tree captured in the fragment.
|
|
76
|
+
// For recursive logic see the bind call above and the prosemirror-model (https://github.com/ProseMirror/prosemirror-model/blob/master/src/to_dom.js#L44
|
|
77
|
+
// and https://github.com/ProseMirror/prosemirror-model/blob/master/src/to_dom.js#L87)
|
|
78
|
+
options.tableWrapperExists = true;
|
|
79
|
+
const parentTable = findParentNodeOfType(schema.nodes.table)(selection);
|
|
80
|
+
const attributes = parentTable === null || parentTable === void 0 ? void 0 : parentTable.node.attrs;
|
|
81
|
+
const newTable = schema.nodes.table;
|
|
82
|
+
const newTableNode = newTable.createChecked({ ...attributes
|
|
83
|
+
}, content);
|
|
84
|
+
const newContent = Fragment.from(newTableNode); // Pass updated content into original ProseMirror serializeFragment function.
|
|
85
|
+
// Currently incorrectly typed in @Types. See this GitHub thread: https://github.com/DefinitelyTyped/DefinitelyTyped/pull/57668
|
|
86
|
+
//@ts-ignore
|
|
87
|
+
|
|
88
|
+
return originalSerializeFragment(newContent, options, target);
|
|
89
|
+
} // If we're not copying any rows, just run default serializeFragment function.
|
|
90
|
+
// Currently incorrectly typed in @Types. See this GitHub thread: https://github.com/DefinitelyTyped/DefinitelyTyped/pull/57668
|
|
91
|
+
//@ts-ignore
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
return originalSerializeFragment(content, options, target);
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
return newSerializer;
|
|
98
|
+
};
|
|
17
99
|
export const sendClipboardAnalytics = (view, dispatchAnalyticsEvent, action) => {
|
|
18
100
|
const clipboardAnalyticsPayload = getAnalyticsPayload(view.state, action);
|
|
19
101
|
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import { css } from '
|
|
1
|
+
import { css } from '@emotion/react';
|
|
2
2
|
import { themed } from '@atlaskit/theme/components';
|
|
3
3
|
import { borderRadius, fontSize, gridSize } from '@atlaskit/theme/constants';
|
|
4
4
|
import * as colors from '@atlaskit/theme/colors';
|
|
5
5
|
import { blockNodesVerticalMargin, akEditorTableCellMinWidth, akEditorDeleteBackground, akEditorDeleteBorder, akEditorSelectedBorderSize, akEditorDeleteIconColor, SelectionStyle, getSelectionStyles, akEditorCodeFontFamily, akEditorSelectedNodeClassName, overflowShadow, relativeFontSizeToBase16 } from '@atlaskit/editor-shared-styles';
|
|
6
6
|
import { codeBlockClassNames } from './ui/class-names';
|
|
7
|
-
export const highlightingCodeBlockStyles = css`
|
|
7
|
+
export const highlightingCodeBlockStyles = props => css`
|
|
8
8
|
.ProseMirror .code-block {
|
|
9
9
|
position: relative;
|
|
10
10
|
background-image: ${overflowShadow({
|
|
11
11
|
background: themed({
|
|
12
12
|
light: colors.N20,
|
|
13
13
|
dark: colors.DN50
|
|
14
|
-
}),
|
|
14
|
+
})(props),
|
|
15
15
|
width: '8px'
|
|
16
16
|
})};
|
|
17
17
|
background-repeat: no-repeat;
|
|
18
18
|
background-color: ${themed({
|
|
19
19
|
light: colors.N20,
|
|
20
20
|
dark: colors.DN50
|
|
21
|
-
})};
|
|
21
|
+
})(props)};
|
|
22
22
|
--ds--code--bg-color: transparent;
|
|
23
23
|
background-attachment: local, scroll, scroll;
|
|
24
24
|
background-size: 8px 100%, 8px 100%, 8px 100%;
|
|
@@ -39,12 +39,12 @@ export const highlightingCodeBlockStyles = css`
|
|
|
39
39
|
background-color: ${themed({
|
|
40
40
|
light: colors.N30,
|
|
41
41
|
dark: colors.DN20
|
|
42
|
-
})};
|
|
42
|
+
})(props)};
|
|
43
43
|
padding: ${gridSize()}px;
|
|
44
44
|
color: ${themed({
|
|
45
45
|
light: colors.N90,
|
|
46
46
|
dark: colors.DN90
|
|
47
|
-
})};
|
|
47
|
+
})(props)};
|
|
48
48
|
|
|
49
49
|
span {
|
|
50
50
|
display: block;
|
|
@@ -60,7 +60,7 @@ export const highlightingCodeBlockStyles = css`
|
|
|
60
60
|
color: ${themed({
|
|
61
61
|
light: colors.N400,
|
|
62
62
|
dark: colors.DN400
|
|
63
|
-
})};
|
|
63
|
+
})(props)};
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
66
|
}
|
|
@@ -114,7 +114,7 @@ export const highlightingCodeBlockStyles = css`
|
|
|
114
114
|
caret-color: ${themed({
|
|
115
115
|
light: colors.N800,
|
|
116
116
|
dark: colors.DN500
|
|
117
|
-
})};
|
|
117
|
+
})(props)};
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
120
|
}
|
|
@@ -154,14 +154,14 @@ export const highlightingCodeBlockStyles = css`
|
|
|
154
154
|
}
|
|
155
155
|
}
|
|
156
156
|
`;
|
|
157
|
-
export const codeBlockStyles = css`
|
|
157
|
+
export const codeBlockStyles = props => css`
|
|
158
158
|
.ProseMirror .code-block {
|
|
159
159
|
position: relative;
|
|
160
160
|
background-image: ${overflowShadow({
|
|
161
161
|
background: themed({
|
|
162
162
|
light: colors.N20,
|
|
163
163
|
dark: colors.DN50
|
|
164
|
-
}),
|
|
164
|
+
})(props),
|
|
165
165
|
width: '8px'
|
|
166
166
|
})};
|
|
167
167
|
--ds--code--bg-color: transparent;
|
|
@@ -169,7 +169,7 @@ export const codeBlockStyles = css`
|
|
|
169
169
|
background-color: ${themed({
|
|
170
170
|
light: colors.N20,
|
|
171
171
|
dark: colors.DN50
|
|
172
|
-
})};
|
|
172
|
+
})(props)};
|
|
173
173
|
background-attachment: local, scroll, scroll;
|
|
174
174
|
background-size: 8px 100%, 8px 100%, 8px 100%;
|
|
175
175
|
background-position: 100% 0, 100% 0, 0 0;
|
|
@@ -189,7 +189,7 @@ export const codeBlockStyles = css`
|
|
|
189
189
|
background-color: ${themed({
|
|
190
190
|
light: colors.N30,
|
|
191
191
|
dark: colors.DN20
|
|
192
|
-
})};
|
|
192
|
+
})(props)};
|
|
193
193
|
padding: ${gridSize()}px;
|
|
194
194
|
|
|
195
195
|
span {
|
|
@@ -206,7 +206,7 @@ export const codeBlockStyles = css`
|
|
|
206
206
|
color: ${themed({
|
|
207
207
|
light: colors.N400,
|
|
208
208
|
dark: colors.DN400
|
|
209
|
-
})};
|
|
209
|
+
})(props)};
|
|
210
210
|
}
|
|
211
211
|
}
|
|
212
212
|
}
|
|
@@ -225,7 +225,7 @@ export const codeBlockStyles = css`
|
|
|
225
225
|
color: ${themed({
|
|
226
226
|
light: colors.N800,
|
|
227
227
|
dark: colors.DN800
|
|
228
|
-
})};
|
|
228
|
+
})(props)};
|
|
229
229
|
border-radius: ${borderRadius()}px;
|
|
230
230
|
margin: ${gridSize()}px;
|
|
231
231
|
white-space: pre;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { pluginFactory } from '../../utils/plugin-state-factory';
|
|
2
2
|
import reducer from './reducer';
|
|
3
3
|
import { pluginKey } from './plugin-key';
|
|
4
|
+
import { onSelectionChanged } from './utils';
|
|
4
5
|
const factory = pluginFactory(pluginKey, reducer, {
|
|
5
6
|
mapping(tr, state) {
|
|
6
7
|
const {
|
|
@@ -21,8 +22,9 @@ const factory = pluginFactory(pluginKey, reducer, {
|
|
|
21
22
|
return { ...state,
|
|
22
23
|
positions
|
|
23
24
|
};
|
|
24
|
-
}
|
|
25
|
+
},
|
|
25
26
|
|
|
27
|
+
onSelectionChanged: onSelectionChanged
|
|
26
28
|
});
|
|
27
29
|
export const createPluginState = factory.createPluginState;
|
|
28
30
|
export const createCommand = factory.createCommand;
|
|
@@ -97,6 +97,7 @@ export const createContextIdentifierProviderHandler = view => async (name, provi
|
|
|
97
97
|
|
|
98
98
|
const createPlugin = (dispatch, providerFactory, extensionHandlers, portalProviderAPI, eventDispatcher, useLongPressSelection = false, options = {}) => {
|
|
99
99
|
const state = createPluginState(dispatch, {
|
|
100
|
+
shouldRefreshEditButton: false,
|
|
100
101
|
showEditButton: false,
|
|
101
102
|
showContextPanel: false
|
|
102
103
|
});
|
|
@@ -121,27 +122,48 @@ const createPlugin = (dispatch, providerFactory, extensionHandlers, portalProvid
|
|
|
121
122
|
element,
|
|
122
123
|
localId,
|
|
123
124
|
extensionProvider,
|
|
124
|
-
showContextPanel
|
|
125
|
-
|
|
125
|
+
showContextPanel,
|
|
126
|
+
shouldRefreshEditButton
|
|
127
|
+
} = getPluginState(state);
|
|
126
128
|
|
|
127
|
-
|
|
129
|
+
if (!shouldRefreshEditButton) {
|
|
130
|
+
return false;
|
|
131
|
+
} // This fetches the selected extension node, either by keyboard selection or click for all types of extensions
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
const selectedExtension = getSelectedExtension(state, true); // If our selection isn't on an extension node, clear some state and hide the config panel
|
|
128
135
|
|
|
129
136
|
if (!selectedExtension) {
|
|
130
137
|
if (showContextPanel) {
|
|
131
138
|
clearEditingContext(state, dispatch);
|
|
132
139
|
}
|
|
133
140
|
|
|
141
|
+
updateState({
|
|
142
|
+
shouldRefreshEditButton: false,
|
|
143
|
+
localId: undefined,
|
|
144
|
+
element: undefined,
|
|
145
|
+
showEditButton: false,
|
|
146
|
+
updateExtension: undefined
|
|
147
|
+
})(state, dispatch);
|
|
134
148
|
return;
|
|
135
|
-
}
|
|
149
|
+
} // By this point we're certain we've selected an extension node.
|
|
150
|
+
// But we need to determine if the selection has changed to another
|
|
151
|
+
// extension node or remained on the same node.
|
|
152
|
+
|
|
136
153
|
|
|
137
154
|
const {
|
|
138
155
|
node
|
|
139
156
|
} = selectedExtension;
|
|
140
157
|
const newElement = getSelectedDomElement(state.schema, domAtPos, selectedExtension); // New node is selection
|
|
141
158
|
|
|
142
|
-
|
|
159
|
+
const hasSelectedNodeChanged = node.attrs.localId ? localId !== node.attrs.localId : // This is the current assumption and it's wrong but we are keeping it
|
|
143
160
|
// as fallback in case we need to turn off `allowLocalIdGeneration`
|
|
144
|
-
element !== newElement
|
|
161
|
+
element !== newElement;
|
|
162
|
+
const nextState = {
|
|
163
|
+
shouldRefreshEditButton: false
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
if (hasSelectedNodeChanged) {
|
|
145
167
|
if (showContextPanel) {
|
|
146
168
|
clearEditingContext(state, dispatch);
|
|
147
169
|
}
|
|
@@ -154,20 +176,20 @@ const createPlugin = (dispatch, providerFactory, extensionHandlers, portalProvid
|
|
|
154
176
|
const showEditButton = shouldShowEditButton(extensionHandler, extensionProvider);
|
|
155
177
|
const updateExtension = getUpdateExtensionPromise(view, extensionHandler, extensionProvider).catch(() => {// do nothing;
|
|
156
178
|
});
|
|
157
|
-
|
|
179
|
+
Object.assign(nextState, {
|
|
158
180
|
localId: node.attrs.localId,
|
|
159
|
-
showContextPanel: false,
|
|
160
181
|
element: newElement,
|
|
161
182
|
showEditButton,
|
|
162
183
|
updateExtension
|
|
163
|
-
})
|
|
184
|
+
});
|
|
164
185
|
} // New DOM element doesn't necessarily mean it's a new Node
|
|
165
186
|
else if (element !== newElement) {
|
|
166
|
-
|
|
187
|
+
Object.assign(nextState, {
|
|
167
188
|
element: newElement
|
|
168
|
-
})
|
|
189
|
+
});
|
|
169
190
|
}
|
|
170
191
|
|
|
192
|
+
updateState(nextState)(state, dispatch);
|
|
171
193
|
return true;
|
|
172
194
|
},
|
|
173
195
|
destroy: () => {
|
|
@@ -183,7 +205,11 @@ const createPlugin = (dispatch, providerFactory, extensionHandlers, portalProvid
|
|
|
183
205
|
bodiedExtension: ExtensionNodeView(portalProviderAPI, eventDispatcher, providerFactory, extensionHandlers, extensionNodeViewOptions),
|
|
184
206
|
inlineExtension: ExtensionNodeView(portalProviderAPI, eventDispatcher, providerFactory, extensionHandlers, extensionNodeViewOptions)
|
|
185
207
|
},
|
|
186
|
-
handleClickOn: createSelectionClickHandler(['extension', 'bodiedExtension'], target =>
|
|
208
|
+
handleClickOn: createSelectionClickHandler(['extension', 'bodiedExtension'], target => {
|
|
209
|
+
// Clicked on anything around the extension content
|
|
210
|
+
// or specifically on the content border of a bodied extension
|
|
211
|
+
return !target.closest('.extension-content') || target.classList.contains('extension-content');
|
|
212
|
+
}, {
|
|
187
213
|
useLongPressSelection
|
|
188
214
|
})
|
|
189
215
|
}
|
|
@@ -1,15 +1,25 @@
|
|
|
1
1
|
import { findParentNodeOfType, findSelectedNodeOfType, findDomRefAtPos } from 'prosemirror-utils';
|
|
2
2
|
import { closestElement } from '../../utils/dom';
|
|
3
3
|
import { findNodePosByLocalIds } from '../../utils/nodes-by-localIds';
|
|
4
|
+
|
|
5
|
+
const getSelectedExtensionByTransaction = (transaction, searchParent = true) => {
|
|
6
|
+
return _getSelectedExtension(transaction.doc.type.schema, transaction.selection, searchParent);
|
|
7
|
+
};
|
|
8
|
+
|
|
4
9
|
export const getSelectedExtension = (state, searchParent = false) => {
|
|
10
|
+
return _getSelectedExtension(state.schema, state.selection, searchParent);
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const _getSelectedExtension = (schema, selection, searchParent) => {
|
|
5
14
|
const {
|
|
6
15
|
inlineExtension,
|
|
7
16
|
extension,
|
|
8
17
|
bodiedExtension
|
|
9
|
-
} =
|
|
18
|
+
} = schema.nodes;
|
|
10
19
|
const nodeTypes = [extension, bodiedExtension, inlineExtension];
|
|
11
|
-
return findSelectedNodeOfType(nodeTypes)(
|
|
20
|
+
return findSelectedNodeOfType(nodeTypes)(selection) || searchParent && findParentNodeOfType(nodeTypes)(selection) || undefined;
|
|
12
21
|
};
|
|
22
|
+
|
|
13
23
|
export const findExtensionWithLocalId = (state, localId) => {
|
|
14
24
|
const selectedExtension = getSelectedExtension(state, true);
|
|
15
25
|
|
|
@@ -62,4 +72,29 @@ export const getNodeTypesReferenced = (ids, state) => {
|
|
|
62
72
|
export const findNodePosWithLocalId = (state, localId) => {
|
|
63
73
|
const nodes = findNodePosByLocalIds(state, [localId]);
|
|
64
74
|
return nodes.length >= 1 ? nodes[0] : undefined;
|
|
75
|
+
};
|
|
76
|
+
export const onSelectionChanged = (tr, state) => {
|
|
77
|
+
const selectedExtension = getSelectedExtensionByTransaction(tr, true);
|
|
78
|
+
const hasUnselectedExtension = !!state.element && !selectedExtension;
|
|
79
|
+
/*
|
|
80
|
+
* We use this to indicate to our plugin that the selection has changed.
|
|
81
|
+
*
|
|
82
|
+
* - ignore if shouldRefreshEditButton already set
|
|
83
|
+
* - restrict to scenarios when an extension is
|
|
84
|
+
* - a) actually selected
|
|
85
|
+
* - b) or un-selected (not accounting for selection extensionA -> extensionB)
|
|
86
|
+
*
|
|
87
|
+
* The rest of the logic will be handled in Extension main plugin view update().
|
|
88
|
+
*
|
|
89
|
+
* Known issue: typing inside of a bodiedExtension will trigger state changes each keystroke
|
|
90
|
+
* as the toolbar always being open while it is focused.
|
|
91
|
+
*/
|
|
92
|
+
|
|
93
|
+
if (!state.shouldRefreshEditButton && (selectedExtension || hasUnselectedExtension)) {
|
|
94
|
+
return { ...state,
|
|
95
|
+
shouldRefreshEditButton: true
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return state;
|
|
65
100
|
};
|
|
@@ -2,7 +2,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
2
2
|
|
|
3
3
|
/** @jsx jsx */
|
|
4
4
|
import React from 'react';
|
|
5
|
-
import { jsx } from '@emotion/
|
|
5
|
+
import { jsx } from '@emotion/react';
|
|
6
6
|
import { defineMessages, injectIntl } from 'react-intl-next';
|
|
7
7
|
import EditorCloseIcon from '@atlaskit/icon/glyph/editor/close';
|
|
8
8
|
import ChevronDownIcon from '@atlaskit/icon/glyph/hipchat/chevron-down';
|
|
@@ -2,7 +2,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
2
2
|
|
|
3
3
|
/** @jsx jsx */
|
|
4
4
|
import React from 'react';
|
|
5
|
-
import { jsx } from '@emotion/
|
|
5
|
+
import { jsx } from '@emotion/react';
|
|
6
6
|
import Find from './Find';
|
|
7
7
|
import Replace from './Replace';
|
|
8
8
|
import { ruleStyles, wrapperStyles } from './styles';
|
|
@@ -2,7 +2,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
2
2
|
|
|
3
3
|
/** @jsx jsx */
|
|
4
4
|
import React from 'react';
|
|
5
|
-
import { jsx } from '@emotion/
|
|
5
|
+
import { jsx } from '@emotion/react';
|
|
6
6
|
import Button from '@atlaskit/button/standard-button';
|
|
7
7
|
import { defineMessages, injectIntl } from 'react-intl-next';
|
|
8
8
|
import Textfield from '@atlaskit/textfield';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
|
-
import { css } from '@emotion/
|
|
2
|
+
import { css } from '@emotion/react';
|
|
3
3
|
import { N60, N30A } from '@atlaskit/theme/colors';
|
|
4
4
|
import { relativeFontSizeToBase16 } from '@atlaskit/editor-shared-styles';
|
|
5
5
|
export const replaceSectionButtonStyles = css({
|
|
@@ -20,15 +20,20 @@ export const wrapperStyles = css({
|
|
|
20
20
|
margin: '0px 4px'
|
|
21
21
|
}
|
|
22
22
|
});
|
|
23
|
-
export const sectionWrapperStyles = css
|
|
24
|
-
display:
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
display:
|
|
28
|
-
height:
|
|
29
|
-
flex:
|
|
23
|
+
export const sectionWrapperStyles = css`
|
|
24
|
+
display: flex;
|
|
25
|
+
|
|
26
|
+
& > * {
|
|
27
|
+
display: inline-flex;
|
|
28
|
+
height: 32px;
|
|
29
|
+
flex: 0 0 auto;
|
|
30
30
|
}
|
|
31
|
-
|
|
31
|
+
|
|
32
|
+
& > [data-ds--text-field--container] {
|
|
33
|
+
display: flex;
|
|
34
|
+
flex: 1 1 auto;
|
|
35
|
+
}
|
|
36
|
+
`;
|
|
32
37
|
export const countStyles = css({
|
|
33
38
|
color: `${N60}`,
|
|
34
39
|
fontSize: `${relativeFontSizeToBase16(12)}`,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { css } from '
|
|
1
|
+
import { css } from '@emotion/react';
|
|
2
2
|
import { gridSize } from '@atlaskit/theme/constants';
|
|
3
3
|
import { N40A, N50A } from '@atlaskit/theme/colors';
|
|
4
4
|
import { columnLayoutSharedStyle } from '@atlaskit/editor-common/styles';
|
|
@@ -36,6 +36,10 @@ export const layoutStyles = css`
|
|
|
36
36
|
margin-top: 0;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
.rich-media-item {
|
|
40
|
+
margin-top: 0;
|
|
41
|
+
}
|
|
42
|
+
|
|
39
43
|
> .mediaSingleView-content-wrap:first-child .rich-media-item {
|
|
40
44
|
margin-top: 0;
|
|
41
45
|
}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { Fragment, Slice, NodeRange } from 'prosemirror-model';
|
|
2
|
+
import { ReplaceAroundStep, findWrapping, canSplit, canJoin } from 'prosemirror-transform';
|
|
3
|
+
/**
|
|
4
|
+
* Wraps the selection in a list with the given type. If this results in
|
|
5
|
+
* two adjacent lists of the same type, those will be joined together.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export function wrapInListAndJoin(nodeType, tr) {
|
|
9
|
+
wrapInList(nodeType)(tr);
|
|
10
|
+
autoJoin(tr, (before, after) => before.type === after.type && before.type === nodeType);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Wraps the selection in a list with the given type and attributes.
|
|
14
|
+
*
|
|
15
|
+
* Adapted from https://github.com/ProseMirror/prosemirror-schema-list/blob/master/src/schema-list.js#L64-L89
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
export function wrapInList(listType, attrs) {
|
|
19
|
+
return function (tr) {
|
|
20
|
+
const {
|
|
21
|
+
$from,
|
|
22
|
+
$to
|
|
23
|
+
} = tr.selection;
|
|
24
|
+
let range = $from.blockRange($to);
|
|
25
|
+
let doJoin = false;
|
|
26
|
+
let outerRange = range;
|
|
27
|
+
|
|
28
|
+
if (!range) {
|
|
29
|
+
return false;
|
|
30
|
+
} // This is at the top of an existing list item
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
if (range.depth >= 2 && // @ts-ignore - missing type for compatibleContent
|
|
34
|
+
$from.node(range.depth - 1).type.compatibleContent(listType) && range.startIndex === 0) {
|
|
35
|
+
// Don't do anything if this is the top of the list
|
|
36
|
+
if ($from.index(range.depth - 1) === 0) {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
let $insert = tr.doc.resolve(range.start - 2);
|
|
41
|
+
outerRange = new NodeRange($insert, $insert, range.depth);
|
|
42
|
+
|
|
43
|
+
if (range.endIndex < range.parent.childCount) {
|
|
44
|
+
range = new NodeRange($from, tr.doc.resolve($to.end(range.depth)), range.depth);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
doJoin = true;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
let wrap = findWrapping(outerRange, listType, attrs, range);
|
|
51
|
+
|
|
52
|
+
if (!wrap) {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
tr = doWrapInList(tr, range, wrap, doJoin, listType);
|
|
57
|
+
return true;
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Internal function used by wrapInList
|
|
62
|
+
*
|
|
63
|
+
* Adapted from https://github.com/ProseMirror/prosemirror-schema-list/blob/master/src/schema-list.js#L91-L112
|
|
64
|
+
*/
|
|
65
|
+
|
|
66
|
+
function doWrapInList(tr, range, wrappers, joinBefore, listType) {
|
|
67
|
+
let content = Fragment.empty;
|
|
68
|
+
|
|
69
|
+
for (let i = wrappers.length - 1; i >= 0; i--) {
|
|
70
|
+
content = Fragment.from(wrappers[i].type.create(wrappers[i].attrs, content));
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
tr.step(new ReplaceAroundStep(range.start - (joinBefore ? 2 : 0), range.end, range.start, range.end, new Slice(content, 0, 0), wrappers.length, true));
|
|
74
|
+
let found = 0;
|
|
75
|
+
|
|
76
|
+
for (let i = 0; i < wrappers.length; i++) {
|
|
77
|
+
if (wrappers[i].type === listType) {
|
|
78
|
+
found = i + 1;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const splitDepth = wrappers.length - found;
|
|
83
|
+
let splitPos = range.start + wrappers.length - (joinBefore ? 2 : 0);
|
|
84
|
+
const parent = range.parent;
|
|
85
|
+
|
|
86
|
+
for (let i = range.startIndex, e = range.endIndex, first = true; i < e; i++, first = false) {
|
|
87
|
+
if (!first && canSplit(tr.doc, splitPos, splitDepth)) {
|
|
88
|
+
tr.split(splitPos, splitDepth);
|
|
89
|
+
splitPos += 2 * splitDepth;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
splitPos += parent.child(i).nodeSize;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return tr;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Checks whether two adjacent nodes can be joined. If so, the document
|
|
99
|
+
* will be updated to join those nodes. If not, the original transaction
|
|
100
|
+
* remains untouched.
|
|
101
|
+
*
|
|
102
|
+
* Nodes are considered joinable if the `isJoinable` predicate returns true.
|
|
103
|
+
*
|
|
104
|
+
* Adapted from https://github.com/ProseMirror/prosemirror-commands/blob/master/src/commands.js#L597-L610
|
|
105
|
+
*/
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
export function autoJoin(tr, isJoinable) {
|
|
109
|
+
if (!tr.isGeneric) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const ranges = [];
|
|
114
|
+
|
|
115
|
+
for (let i = 0; i < tr.mapping.maps.length; i++) {
|
|
116
|
+
const map = tr.mapping.maps[i];
|
|
117
|
+
|
|
118
|
+
for (let j = 0; j < ranges.length; j++) {
|
|
119
|
+
ranges[j] = map.map(ranges[j]);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
map.forEach((_s, _e, from, to) => ranges.push(from, to));
|
|
123
|
+
} // Figure out which joinable points exist inside those ranges,
|
|
124
|
+
// by checking all node boundaries in their parent nodes.
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
const joinable = [];
|
|
128
|
+
|
|
129
|
+
for (let i = 0; i < ranges.length; i += 2) {
|
|
130
|
+
const from = ranges[i];
|
|
131
|
+
const to = ranges[i + 1];
|
|
132
|
+
const $from = tr.doc.resolve(from);
|
|
133
|
+
const depth = $from.sharedDepth(to);
|
|
134
|
+
const parent = $from.node(depth);
|
|
135
|
+
|
|
136
|
+
for (let index = $from.indexAfter(depth), pos = $from.after(depth + 1); pos <= to; ++index) {
|
|
137
|
+
const after = parent.maybeChild(index);
|
|
138
|
+
|
|
139
|
+
if (!after) {
|
|
140
|
+
break;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
if (index && joinable.indexOf(pos) === -1) {
|
|
144
|
+
const before = parent.child(index - 1);
|
|
145
|
+
|
|
146
|
+
if (before.type === after.type && isJoinable(before, after)) {
|
|
147
|
+
joinable.push(pos);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
pos += after.nodeSize;
|
|
152
|
+
}
|
|
153
|
+
} // Join the joinable points
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
joinable.sort((a, b) => a - b);
|
|
157
|
+
|
|
158
|
+
for (let i = joinable.length - 1; i >= 0; i--) {
|
|
159
|
+
if (canJoin(tr.doc, joinable[i])) {
|
|
160
|
+
tr.join(joinable[i]);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|