@atlaskit/editor-core 180.1.0 → 181.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 +43 -0
- package/dist/cjs/actions/index.js +25 -10
- package/dist/cjs/analytics-api/attach-payload-into-transaction.js +1 -1
- package/dist/cjs/create-editor/ReactEditorView.js +0 -5
- package/dist/cjs/create-editor/ReactEditorViewInternal.js +73 -103
- package/dist/cjs/create-editor/create-plugins-list.js +30 -3
- package/dist/cjs/create-editor/preset-utils.js +27 -0
- package/dist/cjs/editor-next/editor-internal.js +2 -2
- package/dist/cjs/editor-next/editor-migration-component.js +18 -2
- package/dist/cjs/editor-next/hooks/useProviderFactory.js +4 -3
- package/dist/cjs/editor-next/index.js +13 -9
- package/dist/cjs/editor-next/utils/getProvidersFromEditorProps.js +41 -0
- package/dist/cjs/editor-next/utils/handleProviders.js +17 -22
- package/dist/cjs/editor.js +20 -13
- package/dist/cjs/keymaps/consts.js +1 -16
- package/dist/cjs/labs/next/presets/cxhtml.js +56 -55
- package/dist/cjs/labs/next/presets/default.js +15 -42
- package/dist/cjs/labs/next/presets/mobile.js +76 -89
- package/dist/cjs/labs/next/presets/universal.js +330 -257
- package/dist/cjs/labs/next/presets/useUniversalPreset.js +36 -0
- package/dist/cjs/plugins/analytics/plugin.js +6 -0
- package/dist/cjs/plugins/annotation/utils.js +2 -36
- package/dist/cjs/plugins/base/pm-plugins/react-nodeview.js +2 -7
- package/dist/cjs/plugins/block-type/pm-plugins/input-rule.js +0 -10
- package/dist/cjs/plugins/caption/index.js +0 -7
- package/dist/cjs/plugins/card/nodeviews/blockCard.js +9 -4
- package/dist/cjs/plugins/card/nodeviews/inlineCard.js +6 -2
- package/dist/cjs/plugins/card/pm-plugins/main.js +6 -3
- package/dist/cjs/plugins/card/pm-plugins/util/resolve.js +4 -0
- package/dist/cjs/plugins/code-block/pm-plugins/main-state.js +2 -14
- package/dist/cjs/plugins/collab-edit/provider/index.js +1 -8
- package/dist/cjs/plugins/collab-edit/provider/types.js +1 -12
- package/dist/cjs/plugins/context-panel/index.js +1 -6
- package/dist/cjs/plugins/data-consumer/index.js +0 -8
- package/dist/cjs/plugins/date/utils/internal.js +0 -4
- package/dist/cjs/plugins/extension/commands.js +1 -8
- package/dist/cjs/plugins/extension/ui/Extension/Extension/index.js +9 -2
- package/dist/cjs/plugins/extension/ui/Extension/Extension/styles.js +2 -2
- package/dist/cjs/plugins/extension/ui/Extension/Lozenge.js +1 -0
- package/dist/cjs/plugins/feedback-dialog/index.js +1 -4
- package/dist/cjs/plugins/floating-toolbar/ui/Button.js +7 -3
- package/dist/cjs/plugins/floating-toolbar/ui/Dropdown.js +10 -5
- package/dist/cjs/plugins/floating-toolbar/ui/EmojiPickerButton.js +2 -9
- package/dist/cjs/plugins/floating-toolbar/ui/ExtensionsPlaceholder.js +1 -0
- package/dist/cjs/plugins/floating-toolbar/ui/Toolbar.js +24 -8
- package/dist/cjs/plugins/floating-toolbar/utils.js +0 -12
- package/dist/cjs/plugins/fragment/index.js +0 -8
- package/dist/cjs/plugins/help-dialog/commands.js +2 -6
- package/dist/cjs/plugins/image-upload/pm-plugins/main.js +50 -12
- package/dist/cjs/plugins/layout/styles.js +10 -1
- package/dist/cjs/plugins/list/utils/find.js +0 -28
- package/dist/cjs/plugins/list/utils/indentation.js +1 -25
- package/dist/cjs/plugins/list/utils/node.js +0 -5
- package/dist/cjs/plugins/list/utils/selection.js +2 -15
- package/dist/cjs/plugins/media/utils/media-common.js +1 -20
- package/dist/cjs/plugins/mentions/nodeviews/mention.js +100 -16
- package/dist/cjs/plugins/mentions/type-ahead/index.js +1 -18
- package/dist/cjs/plugins/mentions/ui/InviteItem/index.js +1 -3
- package/dist/cjs/plugins/mobile-dimensions/index.js +1 -4
- package/dist/cjs/plugins/paste/index.js +1 -2
- package/dist/cjs/plugins/paste/pm-plugins/analytics.js +123 -87
- package/dist/cjs/plugins/paste/util/index.js +0 -46
- package/dist/cjs/plugins/quick-insert/assets/index.js +1 -27
- package/dist/cjs/plugins/selection/gap-cursor/actions.js +49 -44
- package/dist/cjs/plugins/status/utils.js +1 -15
- package/dist/cjs/plugins/text-color/pm-plugins/main.js +0 -1
- package/dist/cjs/plugins/text-color/ui/ToolbarTextColor/index.js +7 -5
- package/dist/cjs/plugins/text-formatting/pm-plugins/smart-input-rule.js +8 -2
- package/dist/cjs/plugins/text-formatting/utils.js +1 -26
- package/dist/cjs/plugins/type-ahead/constants.js +1 -7
- package/dist/cjs/plugins/type-ahead/pm-plugins/decorations.js +2 -35
- package/dist/cjs/plugins/type-ahead/utils.js +3 -22
- package/dist/cjs/test-utils.js +4 -12
- package/dist/cjs/ui/Appearance/Comment/Toolbar.js +43 -8
- package/dist/cjs/ui/ColorPalette/index.js +18 -0
- package/dist/cjs/ui/ColorPickerButton/index.js +6 -2
- package/dist/cjs/ui/ConfigPanel/Fields/Expand.js +1 -0
- package/dist/cjs/ui/ConfigPanel/utils.js +4 -17
- package/dist/cjs/ui/ContentStyles/index.js +1 -1
- package/dist/cjs/ui/ElementBrowser/ModalElementBrowser.js +1 -1
- package/dist/cjs/ui/ElementBrowser/constants.js +1 -3
- package/dist/cjs/ui/Resizer/utils.js +1 -3
- package/dist/cjs/ui/styles.js +3 -7
- package/dist/cjs/utils/get-editor-plugins.js +1 -3
- package/dist/cjs/utils/index.js +9 -269
- package/dist/cjs/utils/input-rules.js +1 -15
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/actions/index.js +23 -9
- package/dist/es2019/analytics-api/attach-payload-into-transaction.js +1 -1
- package/dist/es2019/create-editor/ReactEditorView.js +0 -5
- package/dist/es2019/create-editor/ReactEditorViewInternal.js +67 -82
- package/dist/es2019/create-editor/create-plugins-list.js +25 -3
- package/dist/es2019/create-editor/preset-utils.js +15 -0
- package/dist/es2019/editor-next/editor-internal.js +2 -2
- package/dist/es2019/editor-next/editor-migration-component.js +19 -2
- package/dist/es2019/editor-next/hooks/useProviderFactory.js +4 -3
- package/dist/es2019/editor-next/index.js +13 -7
- package/dist/es2019/editor-next/utils/getProvidersFromEditorProps.js +36 -0
- package/dist/es2019/editor-next/utils/handleProviders.js +18 -24
- package/dist/es2019/editor.js +20 -11
- package/dist/es2019/keymaps/consts.js +7 -11
- package/dist/es2019/labs/next/presets/cxhtml.js +56 -53
- package/dist/es2019/labs/next/presets/default.js +18 -38
- package/dist/es2019/labs/next/presets/mobile.js +88 -88
- package/dist/es2019/labs/next/presets/universal.js +338 -265
- package/dist/es2019/labs/next/presets/useUniversalPreset.js +25 -0
- package/dist/es2019/plugins/analytics/plugin.js +7 -0
- package/dist/es2019/plugins/annotation/utils.js +2 -30
- package/dist/es2019/plugins/base/pm-plugins/react-nodeview.js +1 -3
- package/dist/es2019/plugins/block-type/pm-plugins/input-rule.js +3 -9
- package/dist/es2019/plugins/caption/index.js +0 -2
- package/dist/es2019/plugins/card/nodeviews/blockCard.js +8 -4
- package/dist/es2019/plugins/card/nodeviews/inlineCard.js +6 -2
- package/dist/es2019/plugins/card/pm-plugins/main.js +6 -3
- package/dist/es2019/plugins/card/pm-plugins/util/resolve.js +4 -0
- package/dist/es2019/plugins/code-block/pm-plugins/main-state.js +1 -9
- package/dist/es2019/plugins/collab-edit/provider/index.js +1 -1
- package/dist/es2019/plugins/collab-edit/provider/types.js +1 -10
- package/dist/es2019/plugins/context-panel/index.js +0 -3
- package/dist/es2019/plugins/data-consumer/index.js +0 -7
- package/dist/es2019/plugins/date/utils/internal.js +0 -3
- package/dist/es2019/plugins/extension/commands.js +0 -6
- package/dist/es2019/plugins/extension/ui/Extension/Extension/index.js +12 -2
- package/dist/es2019/plugins/extension/ui/Extension/Extension/styles.js +3 -0
- package/dist/es2019/plugins/extension/ui/Extension/Lozenge.js +1 -0
- package/dist/es2019/plugins/feedback-dialog/index.js +0 -2
- package/dist/es2019/plugins/floating-toolbar/ui/Button.js +7 -3
- package/dist/es2019/plugins/floating-toolbar/ui/Dropdown.js +10 -5
- package/dist/es2019/plugins/floating-toolbar/ui/EmojiPickerButton.js +1 -11
- package/dist/es2019/plugins/floating-toolbar/ui/ExtensionsPlaceholder.js +1 -0
- package/dist/es2019/plugins/floating-toolbar/ui/Toolbar.js +21 -4
- package/dist/es2019/plugins/floating-toolbar/utils.js +0 -10
- package/dist/es2019/plugins/fragment/index.js +0 -7
- package/dist/es2019/plugins/help-dialog/commands.js +1 -2
- package/dist/es2019/plugins/image-upload/pm-plugins/main.js +47 -5
- package/dist/es2019/plugins/layout/styles.js +12 -4
- package/dist/es2019/plugins/list/utils/find.js +0 -27
- package/dist/es2019/plugins/list/utils/indentation.js +0 -23
- package/dist/es2019/plugins/list/utils/node.js +1 -4
- package/dist/es2019/plugins/list/utils/selection.js +2 -15
- package/dist/es2019/plugins/media/utils/media-common.js +1 -19
- package/dist/es2019/plugins/mentions/nodeviews/mention.js +64 -16
- package/dist/es2019/plugins/mentions/type-ahead/index.js +1 -14
- package/dist/es2019/plugins/mentions/ui/InviteItem/index.js +1 -2
- package/dist/es2019/plugins/mobile-dimensions/index.js +0 -3
- package/dist/es2019/plugins/paste/index.js +1 -2
- package/dist/es2019/plugins/paste/pm-plugins/analytics.js +126 -94
- package/dist/es2019/plugins/paste/util/index.js +5 -45
- package/dist/es2019/plugins/quick-insert/assets/index.js +0 -8
- package/dist/es2019/plugins/selection/gap-cursor/actions.js +56 -56
- package/dist/es2019/plugins/status/utils.js +1 -11
- package/dist/es2019/plugins/text-color/pm-plugins/main.js +1 -1
- package/dist/es2019/plugins/text-color/ui/ToolbarTextColor/index.js +7 -5
- package/dist/es2019/plugins/text-formatting/pm-plugins/smart-input-rule.js +8 -2
- package/dist/es2019/plugins/text-formatting/utils.js +0 -19
- package/dist/es2019/plugins/type-ahead/constants.js +0 -5
- package/dist/es2019/plugins/type-ahead/pm-plugins/decorations.js +0 -35
- package/dist/es2019/plugins/type-ahead/utils.js +0 -23
- package/dist/es2019/test-utils.js +4 -7
- package/dist/es2019/ui/Appearance/Comment/Toolbar.js +40 -6
- package/dist/es2019/ui/ColorPalette/index.js +2 -1
- package/dist/es2019/ui/ColorPickerButton/index.js +6 -2
- package/dist/es2019/ui/ConfigPanel/Fields/Expand.js +1 -0
- package/dist/es2019/ui/ConfigPanel/utils.js +0 -6
- package/dist/es2019/ui/ContentStyles/index.js +1 -1
- package/dist/es2019/ui/ElementBrowser/ModalElementBrowser.js +1 -1
- package/dist/es2019/ui/ElementBrowser/constants.js +0 -1
- package/dist/es2019/ui/Resizer/utils.js +0 -1
- package/dist/es2019/ui/styles.js +0 -6
- package/dist/es2019/utils/get-editor-plugins.js +1 -3
- package/dist/es2019/utils/index.js +13 -199
- package/dist/es2019/utils/input-rules.js +0 -14
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/actions/index.js +23 -9
- package/dist/esm/analytics-api/attach-payload-into-transaction.js +1 -1
- package/dist/esm/create-editor/ReactEditorView.js +0 -5
- package/dist/esm/create-editor/ReactEditorViewInternal.js +73 -102
- package/dist/esm/create-editor/create-plugins-list.js +29 -3
- package/dist/esm/create-editor/preset-utils.js +21 -0
- package/dist/esm/editor-next/editor-internal.js +2 -2
- package/dist/esm/editor-next/editor-migration-component.js +18 -2
- package/dist/esm/editor-next/hooks/useProviderFactory.js +4 -3
- package/dist/esm/editor-next/index.js +13 -9
- package/dist/esm/editor-next/utils/getProvidersFromEditorProps.js +35 -0
- package/dist/esm/editor-next/utils/handleProviders.js +17 -22
- package/dist/esm/editor.js +20 -13
- package/dist/esm/keymaps/consts.js +7 -11
- package/dist/esm/labs/next/presets/cxhtml.js +56 -55
- package/dist/esm/labs/next/presets/default.js +18 -41
- package/dist/esm/labs/next/presets/mobile.js +88 -90
- package/dist/esm/labs/next/presets/universal.js +330 -257
- package/dist/esm/labs/next/presets/useUniversalPreset.js +29 -0
- package/dist/esm/plugins/analytics/plugin.js +6 -0
- package/dist/esm/plugins/annotation/utils.js +2 -32
- package/dist/esm/plugins/base/pm-plugins/react-nodeview.js +1 -5
- package/dist/esm/plugins/block-type/pm-plugins/input-rule.js +3 -9
- package/dist/esm/plugins/caption/index.js +0 -2
- package/dist/esm/plugins/card/nodeviews/blockCard.js +9 -4
- package/dist/esm/plugins/card/nodeviews/inlineCard.js +6 -2
- package/dist/esm/plugins/card/pm-plugins/main.js +6 -3
- package/dist/esm/plugins/card/pm-plugins/util/resolve.js +4 -0
- package/dist/esm/plugins/code-block/pm-plugins/main-state.js +0 -10
- package/dist/esm/plugins/collab-edit/provider/index.js +1 -1
- package/dist/esm/plugins/collab-edit/provider/types.js +1 -10
- package/dist/esm/plugins/context-panel/index.js +0 -3
- package/dist/esm/plugins/data-consumer/index.js +0 -7
- package/dist/esm/plugins/date/utils/internal.js +0 -3
- package/dist/esm/plugins/extension/commands.js +0 -6
- package/dist/esm/plugins/extension/ui/Extension/Extension/index.js +9 -2
- package/dist/esm/plugins/extension/ui/Extension/Extension/styles.js +2 -2
- package/dist/esm/plugins/extension/ui/Extension/Lozenge.js +1 -0
- package/dist/esm/plugins/feedback-dialog/index.js +0 -2
- package/dist/esm/plugins/floating-toolbar/ui/Button.js +7 -3
- package/dist/esm/plugins/floating-toolbar/ui/Dropdown.js +10 -5
- package/dist/esm/plugins/floating-toolbar/ui/EmojiPickerButton.js +2 -9
- package/dist/esm/plugins/floating-toolbar/ui/ExtensionsPlaceholder.js +1 -0
- package/dist/esm/plugins/floating-toolbar/ui/Toolbar.js +24 -8
- package/dist/esm/plugins/floating-toolbar/utils.js +0 -10
- package/dist/esm/plugins/fragment/index.js +0 -7
- package/dist/esm/plugins/help-dialog/commands.js +0 -3
- package/dist/esm/plugins/image-upload/pm-plugins/main.js +51 -12
- package/dist/esm/plugins/layout/styles.js +11 -2
- package/dist/esm/plugins/list/utils/find.js +0 -27
- package/dist/esm/plugins/list/utils/indentation.js +0 -23
- package/dist/esm/plugins/list/utils/node.js +1 -4
- package/dist/esm/plugins/list/utils/selection.js +2 -12
- package/dist/esm/plugins/media/utils/media-common.js +1 -17
- package/dist/esm/plugins/mentions/nodeviews/mention.js +97 -16
- package/dist/esm/plugins/mentions/type-ahead/index.js +1 -18
- package/dist/esm/plugins/mentions/ui/InviteItem/index.js +1 -2
- package/dist/esm/plugins/mobile-dimensions/index.js +0 -3
- package/dist/esm/plugins/paste/index.js +1 -2
- package/dist/esm/plugins/paste/pm-plugins/analytics.js +122 -86
- package/dist/esm/plugins/paste/util/index.js +5 -45
- package/dist/esm/plugins/quick-insert/assets/index.js +0 -20
- package/dist/esm/plugins/selection/gap-cursor/actions.js +52 -45
- package/dist/esm/plugins/status/utils.js +1 -13
- package/dist/esm/plugins/text-color/pm-plugins/main.js +1 -1
- package/dist/esm/plugins/text-color/ui/ToolbarTextColor/index.js +7 -5
- package/dist/esm/plugins/text-formatting/pm-plugins/smart-input-rule.js +8 -2
- package/dist/esm/plugins/text-formatting/utils.js +0 -21
- package/dist/esm/plugins/type-ahead/constants.js +0 -5
- package/dist/esm/plugins/type-ahead/pm-plugins/decorations.js +0 -31
- package/dist/esm/plugins/type-ahead/utils.js +2 -20
- package/dist/esm/test-utils.js +4 -7
- package/dist/esm/ui/Appearance/Comment/Toolbar.js +41 -6
- package/dist/esm/ui/ColorPalette/index.js +2 -1
- package/dist/esm/ui/ColorPickerButton/index.js +6 -2
- package/dist/esm/ui/ConfigPanel/Fields/Expand.js +1 -0
- package/dist/esm/ui/ConfigPanel/utils.js +3 -14
- package/dist/esm/ui/ContentStyles/index.js +1 -1
- package/dist/esm/ui/ElementBrowser/ModalElementBrowser.js +1 -1
- package/dist/esm/ui/ElementBrowser/constants.js +0 -1
- package/dist/esm/ui/Resizer/utils.js +0 -1
- package/dist/esm/ui/styles.js +2 -5
- package/dist/esm/utils/get-editor-plugins.js +1 -3
- package/dist/esm/utils/index.js +13 -196
- package/dist/esm/utils/input-rules.js +0 -13
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/actions/index.d.ts +4 -4
- package/dist/types/create-editor/ReactEditorView.d.ts +0 -3
- package/dist/types/create-editor/ReactEditorViewInternal.d.ts +9 -7
- package/dist/types/create-editor/ReactEditorViewNext.d.ts +3 -4
- package/dist/types/create-editor/create-plugins-list.d.ts +3 -5
- package/dist/types/create-editor/preset-utils.d.ts +2 -0
- package/dist/types/editor-next/editor-internal.d.ts +9 -9
- package/dist/types/editor-next/hooks/useMeasureEditorMountTime.d.ts +2 -2
- package/dist/types/editor-next/hooks/useProviderFactory.d.ts +2 -2
- package/dist/types/editor-next/index.d.ts +6 -6
- package/dist/types/editor-next/utils/deprecationWarnings.d.ts +2 -2
- package/dist/types/editor-next/utils/editorPropTypes.d.ts +1 -1
- package/dist/types/editor-next/utils/getProvidersFromEditorProps.d.ts +9 -0
- package/dist/types/editor-next/utils/handleProviders.d.ts +2 -2
- package/dist/types/editor-next/utils/onEditorCreated.d.ts +2 -2
- package/dist/types/editor-next/utils/sendDurationAnalytics.d.ts +1 -1
- package/dist/types/editor.d.ts +7 -4
- package/dist/types/keymaps/consts.d.ts +0 -11
- package/dist/types/labs/next/presets/cxhtml.d.ts +33 -1
- package/dist/types/labs/next/presets/default.d.ts +67 -10
- package/dist/types/labs/next/presets/mobile.d.ts +33 -1
- package/dist/types/labs/next/presets/universal.d.ts +5 -13
- package/dist/types/labs/next/presets/useUniversalPreset.d.ts +7 -0
- package/dist/types/nodeviews/context-adapter.d.ts +0 -1
- package/dist/types/nodeviews/index.d.ts +0 -1
- package/dist/types/plugins/alignment/pm-plugins/types.d.ts +0 -11
- package/dist/types/plugins/annotation/utils.d.ts +0 -17
- package/dist/types/plugins/base/pm-plugins/react-nodeview.d.ts +2 -3
- package/dist/types/plugins/block-type/pm-plugins/input-rule.d.ts +2 -6
- package/dist/types/plugins/caption/index.d.ts +0 -2
- package/dist/types/plugins/card/nodeviews/blockCard.d.ts +2 -10
- package/dist/types/plugins/card/nodeviews/genericCard.d.ts +1 -0
- package/dist/types/plugins/card/nodeviews/inlineCard.d.ts +1 -1
- package/dist/types/plugins/code-block/actions.d.ts +0 -4
- package/dist/types/plugins/code-block/pm-plugins/main-state.d.ts +0 -3
- package/dist/types/plugins/collab-edit/provider/index.d.ts +1 -2
- package/dist/types/plugins/collab-edit/provider/types.d.ts +1 -36
- package/dist/types/plugins/context-panel/index.d.ts +2 -3
- package/dist/types/plugins/data-consumer/index.d.ts +0 -2
- package/dist/types/plugins/date/utils/internal.d.ts +0 -1
- package/dist/types/plugins/extension/commands.d.ts +0 -1
- package/dist/types/plugins/extension/nodeviews/extension.d.ts +0 -5
- package/dist/types/plugins/feedback-dialog/index.d.ts +0 -2
- package/dist/types/plugins/floating-toolbar/ui/Button.d.ts +3 -1
- package/dist/types/plugins/floating-toolbar/ui/Dropdown.d.ts +1 -0
- package/dist/types/plugins/floating-toolbar/utils.d.ts +0 -2
- package/dist/types/plugins/fragment/index.d.ts +0 -2
- package/dist/types/plugins/help-dialog/commands.d.ts +0 -1
- package/dist/types/plugins/history/actions.d.ts +1 -2
- package/dist/types/plugins/layout/styles.d.ts +2 -1
- package/dist/types/plugins/list/utils/find.d.ts +0 -1
- package/dist/types/plugins/list/utils/indentation.d.ts +0 -1
- package/dist/types/plugins/list/utils/node.d.ts +0 -2
- package/dist/types/plugins/list/utils/selection.d.ts +0 -3
- package/dist/types/plugins/media/utils/media-common.d.ts +0 -5
- package/dist/types/plugins/mentions/types.d.ts +1 -2
- package/dist/types/plugins/mentions/ui/InviteItem/index.d.ts +2 -3
- package/dist/types/plugins/mentions/ui/InviteItem/styles.d.ts +0 -6
- package/dist/types/plugins/mentions/ui/ToolbarMention/index.d.ts +1 -4
- package/dist/types/plugins/mobile-dimensions/index.d.ts +0 -1
- package/dist/types/plugins/paste/index.d.ts +0 -1
- package/dist/types/plugins/paste/pm-plugins/analytics.d.ts +6 -3
- package/dist/types/plugins/paste/util/index.d.ts +0 -6
- package/dist/types/plugins/quick-insert/assets/index.d.ts +0 -2
- package/dist/types/plugins/status/utils.d.ts +0 -3
- package/dist/types/plugins/tasks-and-decisions/pm-plugins/main.d.ts +0 -6
- package/dist/types/plugins/text-color/pm-plugins/main.d.ts +2 -12
- package/dist/types/plugins/text-formatting/pm-plugins/clear-formatting.d.ts +0 -1
- package/dist/types/plugins/text-formatting/utils.d.ts +0 -4
- package/dist/types/plugins/type-ahead/constants.d.ts +0 -4
- package/dist/types/plugins/type-ahead/pm-plugins/decorations.d.ts +0 -10
- package/dist/types/plugins/type-ahead/utils.d.ts +1 -2
- package/dist/types/test-utils.d.ts +4 -5
- package/dist/types/types/editor-appearance-component.d.ts +2 -2
- package/dist/types/types/editor-props.d.ts +55 -42
- package/dist/types/ui/Appearance/Chromeless.d.ts +0 -5
- package/dist/types/ui/Appearance/Comment/Comment.d.ts +0 -7
- package/dist/types/ui/Appearance/Comment/Toolbar.d.ts +3 -2
- package/dist/types/ui/Appearance/FullPage/MainToolbar.d.ts +0 -4
- package/dist/types/ui/Appearance/FullPage/StyledComponents.d.ts +3 -3
- package/dist/types/ui/AppearanceComponents/Mobile.d.ts +2 -5
- package/dist/types/ui/ColorPalette/Palettes/index.d.ts +1 -1
- package/dist/types/ui/ColorPalette/Palettes/type.d.ts +1 -1
- package/dist/types/ui/ColorPalette/index.d.ts +2 -1
- package/dist/types/ui/ColorPickerButton/index.d.ts +4 -2
- package/dist/types/ui/ConfigPanel/types.d.ts +0 -3
- package/dist/types/ui/ConfigPanel/utils.d.ts +2 -3
- package/dist/types/ui/ContentStyles/index.d.ts +2 -2
- package/dist/types/ui/ElementBrowser/ModalElementBrowser.d.ts +0 -3
- package/dist/types/ui/ElementBrowser/constants.d.ts +0 -1
- package/dist/types/ui/ElementBrowser/types.d.ts +0 -5
- package/dist/types/ui/Resizer/utils.d.ts +0 -1
- package/dist/types/ui/styles.d.ts +0 -1
- package/dist/types/utils/index.d.ts +6 -65
- package/dist/types/utils/input-rules.d.ts +1 -2
- package/dist/types/utils/table.d.ts +0 -1
- package/package.json +23 -24
- package/report.api.md +155 -146
- package/dist/cjs/labs/next/presets/preset.js +0 -101
- package/dist/cjs/plugins/analytics/types/type-ahead.js +0 -5
- package/dist/cjs/plugins/collab-edit/provider/channel.js +0 -313
- package/dist/cjs/plugins/collab-edit/provider/logger.js +0 -17
- package/dist/cjs/plugins/collab-edit/provider/mock-users.js +0 -19
- package/dist/cjs/plugins/data-consumer/plugin-key.js +0 -9
- package/dist/cjs/plugins/media/toolbar/toolbar-messages.js +0 -15
- package/dist/cjs/profiler/render-count.js +0 -60
- package/dist/cjs/ui/ColorPalette/Color/index.js +0 -9
- package/dist/cjs/ui/ConfigPanel/FieldDescription.js +0 -19
- package/dist/cjs/ui/WithPluginState/types.js +0 -5
- package/dist/es2019/labs/next/presets/preset.js +0 -68
- package/dist/es2019/plugins/analytics/types/type-ahead.js +0 -1
- package/dist/es2019/plugins/collab-edit/provider/channel.js +0 -179
- package/dist/es2019/plugins/collab-edit/provider/logger.js +0 -8
- package/dist/es2019/plugins/collab-edit/provider/mock-users.js +0 -12
- package/dist/es2019/plugins/data-consumer/plugin-key.js +0 -2
- package/dist/es2019/plugins/media/toolbar/toolbar-messages.js +0 -8
- package/dist/es2019/profiler/render-count.js +0 -53
- package/dist/es2019/ui/ColorPalette/Color/index.js +0 -2
- package/dist/es2019/ui/ConfigPanel/FieldDescription.js +0 -12
- package/dist/es2019/ui/WithPluginState/types.js +0 -1
- package/dist/esm/labs/next/presets/preset.js +0 -93
- package/dist/esm/plugins/analytics/types/type-ahead.js +0 -1
- package/dist/esm/plugins/collab-edit/provider/channel.js +0 -305
- package/dist/esm/plugins/collab-edit/provider/logger.js +0 -10
- package/dist/esm/plugins/collab-edit/provider/mock-users.js +0 -12
- package/dist/esm/plugins/data-consumer/plugin-key.js +0 -2
- package/dist/esm/plugins/media/toolbar/toolbar-messages.js +0 -8
- package/dist/esm/profiler/render-count.js +0 -49
- package/dist/esm/ui/ColorPalette/Color/index.js +0 -2
- package/dist/esm/ui/ConfigPanel/FieldDescription.js +0 -11
- package/dist/esm/ui/WithPluginState/types.js +0 -1
- package/dist/types/labs/next/presets/preset.d.ts +0 -46
- package/dist/types/plugins/analytics/types/type-ahead.d.ts +0 -1
- package/dist/types/plugins/collab-edit/provider/channel.d.ts +0 -48
- package/dist/types/plugins/collab-edit/provider/logger.d.ts +0 -1
- package/dist/types/plugins/collab-edit/provider/mock-users.d.ts +0 -6
- package/dist/types/plugins/data-consumer/plugin-key.d.ts +0 -2
- package/dist/types/plugins/media/toolbar/toolbar-messages.d.ts +0 -7
- package/dist/types/profiler/render-count.d.ts +0 -14
- package/dist/types/ui/ColorPalette/Color/index.d.ts +0 -2
- package/dist/types/ui/ConfigPanel/FieldDescription.d.ts +0 -6
- package/dist/types/ui/WithPluginState/types.d.ts +0 -10
|
@@ -29,8 +29,7 @@ import { EVENT_NAME_DISPATCH_TRANSACTION, EVENT_NAME_STATE_APPLY, EVENT_NAME_UPD
|
|
|
29
29
|
import { PROSEMIRROR_RENDERED_NORMAL_SEVERITY_THRESHOLD, PROSEMIRROR_RENDERED_DEGRADED_SEVERITY_THRESHOLD, DEFAULT_SAMPLING_RATE_VALID_TRANSACTIONS } from './consts';
|
|
30
30
|
import { getContextIdentifier } from '../plugins/base/pm-plugins/context-identifier';
|
|
31
31
|
import ReactEditorViewContext from './ReactEditorViewContext';
|
|
32
|
-
import {
|
|
33
|
-
import { createEditorAnalyticsAPI } from '../analytics-api/api';
|
|
32
|
+
import { EditorPluginInjectionAPI } from '@atlaskit/editor-common/preset';
|
|
34
33
|
function handleEditorFocus(view) {
|
|
35
34
|
if (view.hasFocus()) {
|
|
36
35
|
return;
|
|
@@ -39,18 +38,6 @@ function handleEditorFocus(view) {
|
|
|
39
38
|
view.focus();
|
|
40
39
|
}, 0);
|
|
41
40
|
}
|
|
42
|
-
const EMPTY = [];
|
|
43
|
-
export function shouldReconfigureState(props, nextProps) {
|
|
44
|
-
var _props$dangerouslyApp, _props$dangerouslyApp2, _nextProps$dangerousl, _nextProps$dangerousl2;
|
|
45
|
-
const prevPlugins = (_props$dangerouslyApp = (_props$dangerouslyApp2 = props.dangerouslyAppendPlugins) === null || _props$dangerouslyApp2 === void 0 ? void 0 : _props$dangerouslyApp2.__plugins) !== null && _props$dangerouslyApp !== void 0 ? _props$dangerouslyApp : EMPTY;
|
|
46
|
-
const nextPlugins = (_nextProps$dangerousl = (_nextProps$dangerousl2 = nextProps.dangerouslyAppendPlugins) === null || _nextProps$dangerousl2 === void 0 ? void 0 : _nextProps$dangerousl2.__plugins) !== null && _nextProps$dangerousl !== void 0 ? _nextProps$dangerousl : EMPTY;
|
|
47
|
-
if (nextPlugins.length !== prevPlugins.length || prevPlugins.some(p => nextPlugins.some(n => n.name === p.name && n !== p))) {
|
|
48
|
-
return true;
|
|
49
|
-
}
|
|
50
|
-
const mobileProperties = props.appearance === 'mobile' ? ['featureFlags', 'quickInsert'] : [];
|
|
51
|
-
const properties = ['appearance', 'persistScrollGutter', 'allowUndoRedoButtons', 'placeholder', 'sanitizePrivateContent', ...mobileProperties];
|
|
52
|
-
return properties.reduce((acc, curr) => acc || props[curr] !== nextProps[curr], false);
|
|
53
|
-
}
|
|
54
41
|
export class ReactEditorView extends React.Component {
|
|
55
42
|
// ProseMirror is instantiated prior to the initial React render cycle,
|
|
56
43
|
// so we allow transactions by default, to avoid discarding the initial one.
|
|
@@ -67,8 +54,8 @@ export class ReactEditorView extends React.Component {
|
|
|
67
54
|
countNodes() {
|
|
68
55
|
return countNodes(this.editorState);
|
|
69
56
|
}
|
|
70
|
-
constructor(
|
|
71
|
-
super(
|
|
57
|
+
constructor(props, context) {
|
|
58
|
+
super(props, context);
|
|
72
59
|
_defineProperty(this, "editorRef", /*#__PURE__*/React.createRef());
|
|
73
60
|
_defineProperty(this, "canDispatchTransactions", true);
|
|
74
61
|
_defineProperty(this, "onPluginObservation", (report, editorState) => {
|
|
@@ -82,6 +69,10 @@ export class ReactEditorView extends React.Component {
|
|
|
82
69
|
}
|
|
83
70
|
});
|
|
84
71
|
});
|
|
72
|
+
_defineProperty(this, "getEditorState", () => {
|
|
73
|
+
var _this$view;
|
|
74
|
+
return (_this$view = this.view) === null || _this$view === void 0 ? void 0 : _this$view.state;
|
|
75
|
+
});
|
|
85
76
|
_defineProperty(this, "formatFullWidthAppearance", appearance => {
|
|
86
77
|
if (appearance === 'full-width') {
|
|
87
78
|
return FULL_WIDTH_MODE.FULL_WIDTH;
|
|
@@ -130,45 +121,6 @@ export class ReactEditorView extends React.Component {
|
|
|
130
121
|
sel.removeAllRanges();
|
|
131
122
|
}
|
|
132
123
|
});
|
|
133
|
-
_defineProperty(this, "reconfigureState", props => {
|
|
134
|
-
if (!this.view) {
|
|
135
|
-
return;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
// We cannot currently guarentee when all the portals will have re-rendered during a reconfigure
|
|
139
|
-
// so we blur here to stop ProseMirror from trying to apply selection to detached nodes or
|
|
140
|
-
// nodes that haven't been re-rendered to the document yet.
|
|
141
|
-
this.blur();
|
|
142
|
-
const editorPlugins = this.getPlugins(props.editorProps, this.props.editorProps, this.props.createAnalyticsEvent);
|
|
143
|
-
this.config = processPluginsList(editorPlugins);
|
|
144
|
-
const state = this.editorState;
|
|
145
|
-
const plugins = createPMPlugins({
|
|
146
|
-
schema: state.schema,
|
|
147
|
-
dispatch: this.dispatch,
|
|
148
|
-
errorReporter: this.errorReporter,
|
|
149
|
-
editorConfig: this.config,
|
|
150
|
-
eventDispatcher: this.eventDispatcher,
|
|
151
|
-
providerFactory: props.providerFactory,
|
|
152
|
-
portalProviderAPI: props.portalProviderAPI,
|
|
153
|
-
reactContext: () => this.context,
|
|
154
|
-
dispatchAnalyticsEvent: this.dispatchAnalyticsEvent,
|
|
155
|
-
performanceTracking: props.editorProps.performanceTracking,
|
|
156
|
-
transactionTracker: this.transactionTracker,
|
|
157
|
-
featureFlags: createFeatureFlagsFromProps(props.editorProps),
|
|
158
|
-
getIntl: () => this.props.intl
|
|
159
|
-
});
|
|
160
|
-
const newState = state.reconfigure({
|
|
161
|
-
plugins: plugins
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
// need to update the state first so when the view builds the nodeviews it is
|
|
165
|
-
// using the latest plugins
|
|
166
|
-
this.view.updateState(newState);
|
|
167
|
-
return this.view.update({
|
|
168
|
-
...this.view.props,
|
|
169
|
-
state: newState
|
|
170
|
-
});
|
|
171
|
-
});
|
|
172
124
|
_defineProperty(this, "handleAnalyticsEvent", payload => {
|
|
173
125
|
if (!this.props.allowAnalyticsGASV3) {
|
|
174
126
|
return;
|
|
@@ -199,7 +151,7 @@ export class ReactEditorView extends React.Component {
|
|
|
199
151
|
return this.editorState;
|
|
200
152
|
}
|
|
201
153
|
} else {
|
|
202
|
-
this.config = processPluginsList(this.getPlugins(options.props.
|
|
154
|
+
this.config = processPluginsList(this.getPlugins(options.props.preset));
|
|
203
155
|
schema = createSchema(this.config);
|
|
204
156
|
}
|
|
205
157
|
const {
|
|
@@ -319,6 +271,10 @@ export class ReactEditorView extends React.Component {
|
|
|
319
271
|
var _this$experienceStore3;
|
|
320
272
|
(_this$experienceStore3 = this.experienceStore) === null || _this$experienceStore3 === void 0 ? void 0 : _this$experienceStore3.mark(EditorExperience.interaction, 'viewUpdateState', startTime + duration);
|
|
321
273
|
});
|
|
274
|
+
this.pluginInjectionAPI.onEditorViewUpdated({
|
|
275
|
+
newEditorState: editorState,
|
|
276
|
+
oldEditorState
|
|
277
|
+
});
|
|
322
278
|
startMeasure(EVENT_NAME_VIEW_STATE_UPDATED);
|
|
323
279
|
this.onEditorViewStateUpdated({
|
|
324
280
|
originalTransaction: transaction,
|
|
@@ -441,6 +397,10 @@ export class ReactEditorView extends React.Component {
|
|
|
441
397
|
this.view = new EditorView({
|
|
442
398
|
mount: node
|
|
443
399
|
}, this.getDirectEditorProps());
|
|
400
|
+
this.pluginInjectionAPI.onEditorViewUpdated({
|
|
401
|
+
newEditorState: this.view.state,
|
|
402
|
+
oldEditorState: undefined
|
|
403
|
+
});
|
|
444
404
|
});
|
|
445
405
|
_defineProperty(this, "handleEditorViewRef", node => {
|
|
446
406
|
if (!this.view && node) {
|
|
@@ -523,9 +483,12 @@ export class ReactEditorView extends React.Component {
|
|
|
523
483
|
"aria-label": this.props.intl.formatMessage(editorMessages.editorAssistiveLabel),
|
|
524
484
|
role: "textbox"
|
|
525
485
|
}));
|
|
486
|
+
this.pluginInjectionAPI = new EditorPluginInjectionAPI({
|
|
487
|
+
getEditorState: this.getEditorState
|
|
488
|
+
});
|
|
526
489
|
this.eventDispatcher = new EventDispatcher();
|
|
527
490
|
this.dispatch = createDispatch(this.eventDispatcher);
|
|
528
|
-
this.errorReporter = createErrorReporter(
|
|
491
|
+
this.errorReporter = createErrorReporter(props.editorProps.errorReporterHandler);
|
|
529
492
|
this.transactionTracker = new TransactionTracker();
|
|
530
493
|
this.pluginPerformanceObserver = new PluginPerformanceObserver(report => this.onPluginObservation(report, this.editorState)).withPlugins(() => this.getPluginNames()).withNodeCounts(() => this.countNodes()).withOptions(() => this.transactionTracking).withTransactionTracker(() => this.transactionTracker);
|
|
531
494
|
this.validTransactionCount = 0;
|
|
@@ -543,11 +506,11 @@ export class ReactEditorView extends React.Component {
|
|
|
543
506
|
this.eventDispatcher.on(analyticsEventKey, this.handleAnalyticsEvent);
|
|
544
507
|
this.eventDispatcher.on('resetEditorState', this.resetEditorState);
|
|
545
508
|
this.editorState = this.createEditorState({
|
|
546
|
-
props
|
|
509
|
+
props,
|
|
547
510
|
context,
|
|
548
|
-
doc:
|
|
511
|
+
doc: props.editorProps.defaultValue,
|
|
549
512
|
// ED-4759: Don't set selection at end for full-page editor - should be at start.
|
|
550
|
-
selectionAtStart: isFullPage(
|
|
513
|
+
selectionAtStart: isFullPage(props.editorProps.appearance)
|
|
551
514
|
});
|
|
552
515
|
this.dispatchAnalyticsEvent({
|
|
553
516
|
action: ACTION.STARTED,
|
|
@@ -582,7 +545,7 @@ export class ReactEditorView extends React.Component {
|
|
|
582
545
|
const {
|
|
583
546
|
appearance: nextAppearance
|
|
584
547
|
} = nextProps.editorProps;
|
|
585
|
-
if (
|
|
548
|
+
if (this.props.preset !== nextProps.preset) {
|
|
586
549
|
this.reconfigureState(nextProps);
|
|
587
550
|
}
|
|
588
551
|
if (nextAppearance !== appearance) {
|
|
@@ -602,6 +565,45 @@ export class ReactEditorView extends React.Component {
|
|
|
602
565
|
this.pluginPerformanceObserver.disconnect();
|
|
603
566
|
}
|
|
604
567
|
}
|
|
568
|
+
reconfigureState(props) {
|
|
569
|
+
if (!this.view) {
|
|
570
|
+
return;
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
// We cannot currently guarentee when all the portals will have re-rendered during a reconfigure
|
|
574
|
+
// so we blur here to stop ProseMirror from trying to apply selection to detached nodes or
|
|
575
|
+
// nodes that haven't been re-rendered to the document yet.
|
|
576
|
+
this.blur();
|
|
577
|
+
const editorPlugins = this.getPlugins(props.preset);
|
|
578
|
+
this.config = processPluginsList(editorPlugins);
|
|
579
|
+
const state = this.editorState;
|
|
580
|
+
const plugins = createPMPlugins({
|
|
581
|
+
schema: state.schema,
|
|
582
|
+
dispatch: this.dispatch,
|
|
583
|
+
errorReporter: this.errorReporter,
|
|
584
|
+
editorConfig: this.config,
|
|
585
|
+
eventDispatcher: this.eventDispatcher,
|
|
586
|
+
providerFactory: props.providerFactory,
|
|
587
|
+
portalProviderAPI: props.portalProviderAPI,
|
|
588
|
+
reactContext: () => this.context,
|
|
589
|
+
dispatchAnalyticsEvent: this.dispatchAnalyticsEvent,
|
|
590
|
+
performanceTracking: props.editorProps.performanceTracking,
|
|
591
|
+
transactionTracker: this.transactionTracker,
|
|
592
|
+
featureFlags: createFeatureFlagsFromProps(props.editorProps),
|
|
593
|
+
getIntl: () => this.props.intl
|
|
594
|
+
});
|
|
595
|
+
const newState = state.reconfigure({
|
|
596
|
+
plugins: plugins
|
|
597
|
+
});
|
|
598
|
+
|
|
599
|
+
// need to update the state first so when the view builds the nodeviews it is
|
|
600
|
+
// using the latest plugins
|
|
601
|
+
this.view.updateState(newState);
|
|
602
|
+
return this.view.update({
|
|
603
|
+
...this.view.props,
|
|
604
|
+
state: newState
|
|
605
|
+
});
|
|
606
|
+
}
|
|
605
607
|
componentDidMount() {
|
|
606
608
|
// Transaction dispatching is already enabled by default prior to
|
|
607
609
|
// mounting, but we reset it here, just in case the editor view
|
|
@@ -644,28 +646,11 @@ export class ReactEditorView extends React.Component {
|
|
|
644
646
|
}
|
|
645
647
|
|
|
646
648
|
// Helper to allow tests to inject plugins directly
|
|
647
|
-
getPlugins(
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
getEditorView: () => this.view,
|
|
651
|
-
getEditorPlugins: () => this.editorPlugins
|
|
652
|
-
});
|
|
653
|
-
const editorAnalyticsAPI = createEditorAnalyticsAPI({
|
|
654
|
-
getEditorView: () => this.view,
|
|
655
|
-
getCreateUIAnalyticsEvent: () => createAnalyticsEvent
|
|
649
|
+
getPlugins(preset) {
|
|
650
|
+
const plugins = preset.build({
|
|
651
|
+
pluginInjectionAPI: this.pluginInjectionAPI
|
|
656
652
|
});
|
|
657
|
-
|
|
658
|
-
props: editorProps,
|
|
659
|
-
prevAppearance: prevEditorProps === null || prevEditorProps === void 0 ? void 0 : prevEditorProps.appearance,
|
|
660
|
-
createAnalyticsEvent,
|
|
661
|
-
insertNodeAPI,
|
|
662
|
-
editorAnalyticsAPI
|
|
663
|
-
};
|
|
664
|
-
if (this.props.getEditorPlugins === undefined) {
|
|
665
|
-
// eslint-disable-next-line no-console
|
|
666
|
-
console.error('getEditorPlugins is undefined in ReactEditorViewInternal - no editor plugins will be added.');
|
|
667
|
-
}
|
|
668
|
-
this.editorPlugins = (_this$props$getEditor = (_this$props$getEditor2 = (_this$props = this.props).getEditorPlugins) === null || _this$props$getEditor2 === void 0 ? void 0 : _this$props$getEditor2.call(_this$props, getPluginsProps)) !== null && _this$props$getEditor !== void 0 ? _this$props$getEditor : [];
|
|
653
|
+
this.editorPlugins = plugins;
|
|
669
654
|
return this.editorPlugins;
|
|
670
655
|
}
|
|
671
656
|
render() {
|
|
@@ -100,13 +100,35 @@ export function getDefaultPresetOptionsFromEditorProps(props, createAnalyticsEve
|
|
|
100
100
|
* Note: The order that presets are added determines
|
|
101
101
|
* their placement in the editor toolbar
|
|
102
102
|
*/
|
|
103
|
-
export default function createPluginsList(props, prevProps, createAnalyticsEvent
|
|
104
|
-
const preset = createUniversalPreset(props.appearance, getDefaultPresetOptionsFromEditorProps(props, createAnalyticsEvent), createFeatureFlagsFromProps(props), prevProps === null || prevProps === void 0 ? void 0 : prevProps.appearance, createAnalyticsEvent
|
|
103
|
+
export default function createPluginsList(props, prevProps, createAnalyticsEvent) {
|
|
104
|
+
const preset = createUniversalPreset(props.appearance, getDefaultPresetOptionsFromEditorProps(props, createAnalyticsEvent), createFeatureFlagsFromProps(props), prevProps === null || prevProps === void 0 ? void 0 : prevProps.appearance, createAnalyticsEvent);
|
|
105
105
|
const excludes = new Set();
|
|
106
106
|
if (!isCodeBlockAllowed({
|
|
107
107
|
allowBlockType: props.allowBlockType
|
|
108
108
|
})) {
|
|
109
109
|
excludes.add('codeBlock');
|
|
110
110
|
}
|
|
111
|
-
return preset.
|
|
111
|
+
return preset.build({
|
|
112
|
+
excludePlugins: excludes
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
function withDangerouslyAppendPlugins(preset) {
|
|
116
|
+
function createEditorNextPluginsFromDangerouslyAppended(plugins) {
|
|
117
|
+
return plugins ? plugins.map(plugin => () => plugin) : [];
|
|
118
|
+
}
|
|
119
|
+
return editorPluginsToAppend => {
|
|
120
|
+
if (!editorPluginsToAppend || editorPluginsToAppend.length === 0) {
|
|
121
|
+
return preset;
|
|
122
|
+
}
|
|
123
|
+
const nextEditorPluginsToAppend = createEditorNextPluginsFromDangerouslyAppended(editorPluginsToAppend);
|
|
124
|
+
const presetWithAppendedPlugins = nextEditorPluginsToAppend.reduce((acc, plugin) => {
|
|
125
|
+
return acc.add(plugin);
|
|
126
|
+
}, preset);
|
|
127
|
+
return presetWithAppendedPlugins;
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
export function createPreset(props, prevProps, createAnalyticsEvent) {
|
|
131
|
+
var _props$dangerouslyApp;
|
|
132
|
+
const preset = createUniversalPreset(props.appearance, getDefaultPresetOptionsFromEditorProps(props, createAnalyticsEvent), createFeatureFlagsFromProps(props), prevProps === null || prevProps === void 0 ? void 0 : prevProps.appearance, createAnalyticsEvent);
|
|
133
|
+
return withDangerouslyAppendPlugins(preset)((_props$dangerouslyApp = props.dangerouslyAppendPlugins) === null || _props$dangerouslyApp === void 0 ? void 0 : _props$dangerouslyApp.__plugins);
|
|
112
134
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const EMPTY = [];
|
|
2
|
+
export function shouldRecreatePreset(props, nextProps) {
|
|
3
|
+
var _props$dangerouslyApp, _props$dangerouslyApp2, _nextProps$dangerousl, _nextProps$dangerousl2;
|
|
4
|
+
const prevPlugins = (_props$dangerouslyApp = (_props$dangerouslyApp2 = props.dangerouslyAppendPlugins) === null || _props$dangerouslyApp2 === void 0 ? void 0 : _props$dangerouslyApp2.__plugins) !== null && _props$dangerouslyApp !== void 0 ? _props$dangerouslyApp : EMPTY;
|
|
5
|
+
const nextPlugins = (_nextProps$dangerousl = (_nextProps$dangerousl2 = nextProps.dangerouslyAppendPlugins) === null || _nextProps$dangerousl2 === void 0 ? void 0 : _nextProps$dangerousl2.__plugins) !== null && _nextProps$dangerousl !== void 0 ? _nextProps$dangerousl : EMPTY;
|
|
6
|
+
if (nextPlugins.length !== prevPlugins.length || prevPlugins.some(p => nextPlugins.some(n => n.name === p.name && n !== p))) {
|
|
7
|
+
return true;
|
|
8
|
+
}
|
|
9
|
+
return shouldReconfigureState(props, nextProps);
|
|
10
|
+
}
|
|
11
|
+
function shouldReconfigureState(props, nextProps) {
|
|
12
|
+
const mobileProperties = props.appearance === 'mobile' ? ['quickInsert', 'featureFlags'] : [];
|
|
13
|
+
const properties = ['appearance', 'persistScrollGutter', 'allowUndoRedoButtons', 'placeholder', 'sanitizePrivateContent', ...mobileProperties];
|
|
14
|
+
return properties.reduce((acc, curr) => acc || props[curr] !== nextProps[curr], false);
|
|
15
|
+
}
|
|
@@ -48,7 +48,7 @@ export function EditorInternalWithoutHooks({
|
|
|
48
48
|
providerFactory,
|
|
49
49
|
onEditorCreated,
|
|
50
50
|
onEditorDestroyed,
|
|
51
|
-
|
|
51
|
+
preset
|
|
52
52
|
}) {
|
|
53
53
|
var _props$performanceTra, _props$performanceTra2;
|
|
54
54
|
const Component = getUiComponent(props.appearance);
|
|
@@ -90,7 +90,7 @@ export function EditorInternalWithoutHooks({
|
|
|
90
90
|
onEditorDestroyed: onEditorDestroyed,
|
|
91
91
|
allowAnalyticsGASV3: props.allowAnalyticsGASV3,
|
|
92
92
|
disabled: props.disabled,
|
|
93
|
-
|
|
93
|
+
preset: preset,
|
|
94
94
|
render: ({
|
|
95
95
|
editor,
|
|
96
96
|
view,
|
|
@@ -1,10 +1,27 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
1
2
|
import React from 'react';
|
|
3
|
+
import { createFeatureFlagsFromProps } from '../create-editor/feature-flags-from-props';
|
|
2
4
|
import Editor from '../editor';
|
|
3
5
|
import EditorNext from './index';
|
|
4
|
-
import
|
|
6
|
+
import useUniversalPreset from '../labs/next/presets/useUniversalPreset';
|
|
7
|
+
const EditorNextWrapper = ({
|
|
8
|
+
props
|
|
9
|
+
}) => {
|
|
10
|
+
const preset = useUniversalPreset({
|
|
11
|
+
props
|
|
12
|
+
});
|
|
13
|
+
return /*#__PURE__*/React.createElement(EditorNext, _extends({
|
|
14
|
+
preset: preset
|
|
15
|
+
}, props));
|
|
16
|
+
};
|
|
5
17
|
export default class EditorMigrationComponent extends React.Component {
|
|
6
18
|
render() {
|
|
7
19
|
const featureFlags = createFeatureFlagsFromProps(this.props);
|
|
8
|
-
|
|
20
|
+
if (!featureFlags.useEditorNext) {
|
|
21
|
+
return /*#__PURE__*/React.createElement(Editor, this.props);
|
|
22
|
+
}
|
|
23
|
+
return /*#__PURE__*/React.createElement(EditorNextWrapper, {
|
|
24
|
+
props: this.props
|
|
25
|
+
});
|
|
9
26
|
}
|
|
10
27
|
}
|
|
@@ -4,6 +4,7 @@ import { usePreviousState } from '@atlaskit/editor-common/hooks';
|
|
|
4
4
|
import prepareQuickInsertProvider from '../../utils/prepare-quick-insert-provider';
|
|
5
5
|
import prepareExtensionProvider from '../../utils/prepare-extension-provider';
|
|
6
6
|
import handleProviders from '../utils/handleProviders';
|
|
7
|
+
import getProvidersFromEditorProps from '../utils/getProvidersFromEditorProps';
|
|
7
8
|
function createNewState(editorActions, quickInsert, extensionProviders, createAnalyticsEvent) {
|
|
8
9
|
const extensionProvider = prepareExtensionProvider(() => editorActions)(extensionProviders);
|
|
9
10
|
const quickInsertProvider = prepareQuickInsertProvider(editorActions, extensionProvider, quickInsert, createAnalyticsEvent);
|
|
@@ -42,11 +43,11 @@ export default function useProviderFactory(props, editorActions, createAnalytics
|
|
|
42
43
|
quickInsert && quickInsert !== (prevProps === null || prevProps === void 0 ? void 0 : prevProps.quickInsert)) {
|
|
43
44
|
const newState = createNewState(editorActions, quickInsert, extensionProviders, createAnalyticsEvent);
|
|
44
45
|
setProviderState(newState);
|
|
45
|
-
handleProviders(providerFactory.current, props, newState.extensionProvider, newState.quickInsertProvider);
|
|
46
|
+
handleProviders(providerFactory.current, getProvidersFromEditorProps(props), newState.extensionProvider, newState.quickInsertProvider);
|
|
46
47
|
return;
|
|
47
48
|
}
|
|
48
|
-
handleProviders(providerFactory.current, props, providerState.extensionProvider, providerState.quickInsertProvider);
|
|
49
|
-
}, [props, prevProps, createAnalyticsEvent, editorActions, providerState.extensionProvider, providerState.quickInsertProvider, extensionProviders, quickInsert]);
|
|
49
|
+
handleProviders(providerFactory.current, getProvidersFromEditorProps(props), providerState.extensionProvider, providerState.quickInsertProvider);
|
|
50
|
+
}, [props, prevProps === null || prevProps === void 0 ? void 0 : prevProps.quickInsert, prevProps === null || prevProps === void 0 ? void 0 : prevProps.extensionProviders, createAnalyticsEvent, editorActions, providerState.extensionProvider, providerState.quickInsertProvider, extensionProviders, quickInsert]);
|
|
50
51
|
|
|
51
52
|
// componentWillUnmount equivalent
|
|
52
53
|
useEffect(() => {
|
|
@@ -16,7 +16,7 @@ import { defaultProps, propTypes } from './utils/editorPropTypes';
|
|
|
16
16
|
import trackEditorActions from './utils/trackEditorActions';
|
|
17
17
|
import onEditorCreated from './utils/onEditorCreated';
|
|
18
18
|
import deprecationWarnings from './utils/deprecationWarnings';
|
|
19
|
-
import
|
|
19
|
+
import { basePlugin } from '../plugins';
|
|
20
20
|
export default class EditorNext extends React.Component {
|
|
21
21
|
/**
|
|
22
22
|
* WARNING: Code should be shared between Editor + EditorNext
|
|
@@ -39,7 +39,6 @@ export default class EditorNext extends React.Component {
|
|
|
39
39
|
this.onEditorCreated = this.onEditorCreated.bind(this);
|
|
40
40
|
this.onEditorDestroyed = this.onEditorDestroyed.bind(this);
|
|
41
41
|
this.getExperienceStore = this.getExperienceStore.bind(this);
|
|
42
|
-
this.getEditorPlugins = this.getEditorPlugins.bind(this);
|
|
43
42
|
trackEditorActions(this.editorActions, props.performanceTracking, value => this.handleAnalyticsEvent(value));
|
|
44
43
|
}
|
|
45
44
|
onEditorCreated(instance) {
|
|
@@ -70,7 +69,7 @@ export default class EditorNext extends React.Component {
|
|
|
70
69
|
props: this.props,
|
|
71
70
|
handleAnalyticsEvent: this.handleAnalyticsEvent,
|
|
72
71
|
createAnalyticsEvent: this.createAnalyticsEvent,
|
|
73
|
-
|
|
72
|
+
preset: this.props.preset,
|
|
74
73
|
handleSave: this.handleSave,
|
|
75
74
|
editorActions: this.editorActions,
|
|
76
75
|
getExperienceStore: this.getExperienceStore,
|
|
@@ -79,12 +78,19 @@ export default class EditorNext extends React.Component {
|
|
|
79
78
|
})
|
|
80
79
|
}));
|
|
81
80
|
}
|
|
82
|
-
getEditorPlugins(props) {
|
|
83
|
-
return getEditorPlugins(props);
|
|
84
|
-
}
|
|
85
81
|
}
|
|
86
82
|
_defineProperty(EditorNext, "defaultProps", defaultProps);
|
|
87
83
|
_defineProperty(EditorNext, "contextTypes", {
|
|
88
84
|
editorActions: PropTypes.object
|
|
89
85
|
});
|
|
90
|
-
_defineProperty(EditorNext, "propTypes",
|
|
86
|
+
_defineProperty(EditorNext, "propTypes", {
|
|
87
|
+
...propTypes('minHeight only supports editor appearance chromeless and comment for EditorNext'),
|
|
88
|
+
preset: ({
|
|
89
|
+
preset
|
|
90
|
+
}) => {
|
|
91
|
+
if (!preset.has(basePlugin)) {
|
|
92
|
+
return new Error('Presets must contain the base plugin');
|
|
93
|
+
}
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export default function getProvidersFromEditorProps({
|
|
2
|
+
linking,
|
|
3
|
+
smartLinks,
|
|
4
|
+
UNSAFE_cards,
|
|
5
|
+
autoformattingProvider,
|
|
6
|
+
media,
|
|
7
|
+
emojiProvider,
|
|
8
|
+
mentionProvider,
|
|
9
|
+
legacyImageUploadProvider,
|
|
10
|
+
taskDecisionProvider,
|
|
11
|
+
contextIdentifierProvider,
|
|
12
|
+
searchProvider,
|
|
13
|
+
macroProvider,
|
|
14
|
+
activityProvider,
|
|
15
|
+
collabEdit,
|
|
16
|
+
collabEditProvider,
|
|
17
|
+
presenceProvider
|
|
18
|
+
}) {
|
|
19
|
+
var _linking$smartLinks;
|
|
20
|
+
const cardProvider = (linking === null || linking === void 0 ? void 0 : (_linking$smartLinks = linking.smartLinks) === null || _linking$smartLinks === void 0 ? void 0 : _linking$smartLinks.provider) || smartLinks && smartLinks.provider || UNSAFE_cards && UNSAFE_cards.provider;
|
|
21
|
+
return {
|
|
22
|
+
mediaProvider: media === null || media === void 0 ? void 0 : media.provider,
|
|
23
|
+
emojiProvider: emojiProvider,
|
|
24
|
+
mentionProvider: mentionProvider,
|
|
25
|
+
autoformattingProvider: autoformattingProvider,
|
|
26
|
+
cardProvider: cardProvider,
|
|
27
|
+
activityProvider: activityProvider,
|
|
28
|
+
imageUploadProvider: legacyImageUploadProvider,
|
|
29
|
+
taskDecisionProvider: taskDecisionProvider,
|
|
30
|
+
contextIdentifierProvider: contextIdentifierProvider,
|
|
31
|
+
searchProvider: searchProvider,
|
|
32
|
+
presenceProvider: presenceProvider,
|
|
33
|
+
macroProvider: macroProvider,
|
|
34
|
+
collabEditProvider: collabEdit && collabEdit.provider ? collabEdit.provider : collabEditProvider
|
|
35
|
+
};
|
|
36
|
+
}
|
|
@@ -7,38 +7,32 @@
|
|
|
7
7
|
* @param extensionProvider
|
|
8
8
|
* @param quickInsertProvider
|
|
9
9
|
*/
|
|
10
|
-
export default function handleProviders(providerFactory,
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
searchProvider,
|
|
26
|
-
UNSAFE_cards,
|
|
27
|
-
smartLinks,
|
|
28
|
-
linking
|
|
29
|
-
} = props;
|
|
10
|
+
export default function handleProviders(providerFactory, {
|
|
11
|
+
emojiProvider,
|
|
12
|
+
mentionProvider,
|
|
13
|
+
taskDecisionProvider,
|
|
14
|
+
contextIdentifierProvider,
|
|
15
|
+
collabEditProvider,
|
|
16
|
+
activityProvider,
|
|
17
|
+
presenceProvider,
|
|
18
|
+
macroProvider,
|
|
19
|
+
imageUploadProvider,
|
|
20
|
+
mediaProvider,
|
|
21
|
+
autoformattingProvider,
|
|
22
|
+
searchProvider,
|
|
23
|
+
cardProvider
|
|
24
|
+
}, extensionProvider, quickInsertProvider) {
|
|
30
25
|
providerFactory.setProvider('emojiProvider', emojiProvider);
|
|
31
26
|
providerFactory.setProvider('mentionProvider', mentionProvider);
|
|
32
27
|
providerFactory.setProvider('taskDecisionProvider', taskDecisionProvider);
|
|
33
28
|
providerFactory.setProvider('contextIdentifierProvider', contextIdentifierProvider);
|
|
34
|
-
providerFactory.setProvider('mediaProvider',
|
|
35
|
-
providerFactory.setProvider('imageUploadProvider',
|
|
36
|
-
providerFactory.setProvider('collabEditProvider',
|
|
29
|
+
providerFactory.setProvider('mediaProvider', mediaProvider);
|
|
30
|
+
providerFactory.setProvider('imageUploadProvider', imageUploadProvider);
|
|
31
|
+
providerFactory.setProvider('collabEditProvider', collabEditProvider);
|
|
37
32
|
providerFactory.setProvider('activityProvider', activityProvider);
|
|
38
33
|
providerFactory.setProvider('searchProvider', searchProvider);
|
|
39
34
|
providerFactory.setProvider('presenceProvider', presenceProvider);
|
|
40
35
|
providerFactory.setProvider('macroProvider', macroProvider);
|
|
41
|
-
const cardProvider = (linking === null || linking === void 0 ? void 0 : (_linking$smartLinks = linking.smartLinks) === null || _linking$smartLinks === void 0 ? void 0 : _linking$smartLinks.provider) || smartLinks && smartLinks.provider || UNSAFE_cards && UNSAFE_cards.provider;
|
|
42
36
|
if (cardProvider) {
|
|
43
37
|
providerFactory.setProvider('cardProvider', cardProvider);
|
|
44
38
|
}
|
package/dist/es2019/editor.js
CHANGED
|
@@ -19,12 +19,14 @@ import { fireAnalyticsEvent } from '@atlaskit/editor-common/analytics';
|
|
|
19
19
|
import prepareQuickInsertProvider from './utils/prepare-quick-insert-provider';
|
|
20
20
|
import prepareExtensionProvider from './utils/prepare-extension-provider';
|
|
21
21
|
import handleProviders from './editor-next/utils/handleProviders';
|
|
22
|
+
import getProvidersFromEditorProps from './editor-next/utils/getProvidersFromEditorProps';
|
|
22
23
|
import { startMeasure, clearMeasure, stopMeasure, measureTTI } from '@atlaskit/editor-common/utils';
|
|
23
24
|
import measurements from './utils/performance/measure-enum';
|
|
24
25
|
import editorMeasureTTICallback from './editor-next/utils/editorMeasureTTICallback';
|
|
25
26
|
import { ACTION } from '@atlaskit/editor-common/analytics';
|
|
26
27
|
import sendDurationAnalytics from './editor-next/utils/sendDurationAnalytics';
|
|
27
|
-
import
|
|
28
|
+
import { createPreset } from './create-editor/create-plugins-list';
|
|
29
|
+
import { shouldRecreatePreset } from './create-editor/preset-utils';
|
|
28
30
|
export default class Editor extends React.Component {
|
|
29
31
|
/**
|
|
30
32
|
* WARNING: Code should be shared between Editor + EditorNext
|
|
@@ -52,7 +54,6 @@ export default class Editor extends React.Component {
|
|
|
52
54
|
this.startTime = performance.now();
|
|
53
55
|
this.onEditorCreated = this.onEditorCreated.bind(this);
|
|
54
56
|
this.onEditorDestroyed = this.onEditorDestroyed.bind(this);
|
|
55
|
-
this.getEditorPlugins = this.getEditorPlugins.bind(this);
|
|
56
57
|
this.getExperienceStore = this.getExperienceStore.bind(this);
|
|
57
58
|
this.trackEditorActions(this.editorActions, props);
|
|
58
59
|
|
|
@@ -74,9 +75,11 @@ export default class Editor extends React.Component {
|
|
|
74
75
|
*/
|
|
75
76
|
const _extensionProvider = this.prepareExtensionProvider(props.extensionProviders);
|
|
76
77
|
const quickInsertProvider = this.prepareQuickInsertProvider(_extensionProvider, props.quickInsert);
|
|
78
|
+
const preset = createPreset(props, undefined, this.createAnalyticsEvent);
|
|
77
79
|
this.state = {
|
|
78
80
|
extensionProvider: _extensionProvider,
|
|
79
|
-
quickInsertProvider
|
|
81
|
+
quickInsertProvider,
|
|
82
|
+
preset
|
|
80
83
|
};
|
|
81
84
|
}
|
|
82
85
|
|
|
@@ -87,7 +90,7 @@ export default class Editor extends React.Component {
|
|
|
87
90
|
*/
|
|
88
91
|
componentDidMount() {
|
|
89
92
|
stopMeasure(measurements.EDITOR_MOUNTED, sendDurationAnalytics(ACTION.EDITOR_MOUNTED, this.props, this.getExperienceStore, this.createAnalyticsEvent));
|
|
90
|
-
handleProviders(this.providerFactory, this.props, this.state.extensionProvider, this.state.quickInsertProvider);
|
|
93
|
+
handleProviders(this.providerFactory, getProvidersFromEditorProps(this.props), this.state.extensionProvider, this.state.quickInsertProvider);
|
|
91
94
|
}
|
|
92
95
|
|
|
93
96
|
/**
|
|
@@ -95,6 +98,8 @@ export default class Editor extends React.Component {
|
|
|
95
98
|
* `useProviderFactory` (editor-next/hooks/useProviderFactory.ts)
|
|
96
99
|
*/
|
|
97
100
|
componentDidUpdate(prevProps) {
|
|
101
|
+
const needsANewPreset = shouldRecreatePreset(prevProps, this.props);
|
|
102
|
+
const preset = needsANewPreset ? createPreset(this.props, prevProps, this.createAnalyticsEvent) : this.state.preset;
|
|
98
103
|
const {
|
|
99
104
|
extensionProviders,
|
|
100
105
|
quickInsert
|
|
@@ -108,11 +113,18 @@ export default class Editor extends React.Component {
|
|
|
108
113
|
const quickInsertProvider = this.prepareQuickInsertProvider(extensionProvider, quickInsert);
|
|
109
114
|
this.setState({
|
|
110
115
|
extensionProvider,
|
|
111
|
-
quickInsertProvider
|
|
112
|
-
|
|
116
|
+
quickInsertProvider,
|
|
117
|
+
preset
|
|
118
|
+
}, () => handleProviders(this.providerFactory, getProvidersFromEditorProps(this.props), this.state.extensionProvider, this.state.quickInsertProvider));
|
|
113
119
|
return;
|
|
114
120
|
}
|
|
115
|
-
|
|
121
|
+
if (needsANewPreset) {
|
|
122
|
+
this.setState({
|
|
123
|
+
preset
|
|
124
|
+
});
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
handleProviders(this.providerFactory, getProvidersFromEditorProps(this.props), this.state.extensionProvider, this.state.quickInsertProvider);
|
|
116
128
|
}
|
|
117
129
|
|
|
118
130
|
/**
|
|
@@ -213,7 +225,7 @@ export default class Editor extends React.Component {
|
|
|
213
225
|
props: this.props,
|
|
214
226
|
handleAnalyticsEvent: this.handleAnalyticsEvent,
|
|
215
227
|
createAnalyticsEvent: this.createAnalyticsEvent,
|
|
216
|
-
|
|
228
|
+
preset: this.state.preset,
|
|
217
229
|
handleSave: this.handleSave,
|
|
218
230
|
editorActions: this.editorActions,
|
|
219
231
|
providerFactory: this.providerFactory,
|
|
@@ -222,9 +234,6 @@ export default class Editor extends React.Component {
|
|
|
222
234
|
})
|
|
223
235
|
}));
|
|
224
236
|
}
|
|
225
|
-
getEditorPlugins(props) {
|
|
226
|
-
return getEditorPlugins(props);
|
|
227
|
-
}
|
|
228
237
|
}
|
|
229
238
|
_defineProperty(Editor, "defaultProps", defaultProps);
|
|
230
239
|
_defineProperty(Editor, "contextTypes", {
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export const KEY_3 = 51;
|
|
9
|
-
export const KEY_4 = 52;
|
|
10
|
-
export const KEY_5 = 53;
|
|
11
|
-
export const KEY_6 = 54;
|
|
1
|
+
const KEY_0 = 48;
|
|
2
|
+
const KEY_1 = 49;
|
|
3
|
+
const KEY_2 = 50;
|
|
4
|
+
const KEY_3 = 51;
|
|
5
|
+
const KEY_4 = 52;
|
|
6
|
+
const KEY_5 = 53;
|
|
7
|
+
const KEY_6 = 54;
|
|
12
8
|
export const HEADING_KEYS = [KEY_0, KEY_1, KEY_2, KEY_3, KEY_4, KEY_5, KEY_6];
|