@atlaskit/editor-core 185.1.6 → 185.2.2
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 +13 -0
- package/dist/cjs/actions/index.js +2 -2
- package/dist/cjs/create-editor/ReactEditorViewInternal.js +1 -2
- package/dist/cjs/index.js +0 -6
- package/dist/cjs/labs/next/internal/hooks/use-editor/create-editor.js +1 -1
- package/dist/cjs/messages.js +6 -56
- package/dist/cjs/nodeviews/getInlineNodeViewProducer.styles.js +2 -2
- package/dist/cjs/plugins/base/pm-plugins/scroll-gutter.js +1 -1
- package/dist/cjs/plugins/card/nodeviews/blockCard.js +2 -2
- package/dist/cjs/plugins/card/nodeviews/embedCard.js +4 -4
- package/dist/cjs/plugins/card/pm-plugins/doc.js +9 -11
- package/dist/cjs/plugins/card/pm-plugins/keymap.js +3 -6
- package/dist/cjs/plugins/card/pm-plugins/main.js +2 -2
- package/dist/cjs/plugins/card/toolbar.js +12 -15
- package/dist/cjs/plugins/card/ui/EditLinkToolbar.js +4 -6
- package/dist/cjs/plugins/card/ui/ResizableEmbedCard.js +7 -10
- package/dist/cjs/plugins/card/utils.js +3 -4
- package/dist/cjs/plugins/clear-marks-on-change-to-empty-document/index.js +1 -1
- package/dist/cjs/plugins/custom-autoformat/doc.js +1 -1
- package/dist/cjs/plugins/date/pm-plugins/main.js +2 -2
- package/dist/cjs/plugins/emoji/index.js +2 -2
- package/dist/cjs/plugins/floating-toolbar/index.js +1 -1
- package/dist/cjs/plugins/hyperlink/Toolbar.js +8 -8
- package/dist/cjs/plugins/hyperlink/commands.js +2 -3
- package/dist/cjs/plugins/hyperlink/ui/HyperlinkAddToolbar/index.js +2 -2
- package/dist/cjs/plugins/layout/actions.js +1 -1
- package/dist/cjs/plugins/media/nodeviews/mediaSingle.js +2 -3
- package/dist/cjs/plugins/media/pm-plugins/alt-text/ui/AltTextEdit.js +1 -2
- package/dist/cjs/plugins/media/toolbar/index.js +9 -8
- package/dist/cjs/plugins/media/toolbar/linking-toolbar-appearance.js +4 -3
- package/dist/cjs/plugins/media/toolbar/linking.js +3 -3
- package/dist/cjs/plugins/media/ui/MediaLinkingToolbar.js +1 -1
- package/dist/cjs/plugins/media/ui/ResizableMediaSingle/index.js +6 -8
- package/dist/cjs/plugins/media/utils/media-files.js +8 -7
- package/dist/cjs/plugins/mentions/pm-plugins/main.js +2 -2
- package/dist/cjs/plugins/placeholder/index.js +2 -3
- package/dist/cjs/plugins/status/plugin.js +2 -2
- package/dist/cjs/plugins/unsupported-content/index.js +3 -3
- package/dist/cjs/ui/Appearance/Chromeless.js +4 -2
- package/dist/cjs/ui/Appearance/Comment/Comment.js +4 -2
- package/dist/cjs/ui/Appearance/FullPage/FullPage.js +2 -1
- package/dist/cjs/ui/Appearance/FullPage/FullPageContentArea.js +2 -1
- package/dist/cjs/ui/Appearance/Mobile.js +4 -2
- package/dist/cjs/ui/AppearanceComponents/Mobile.js +6 -3
- package/dist/cjs/ui/ContentStyles/index.js +5 -3
- package/dist/cjs/ui/LinkSearch/ToolbarComponents.js +4 -11
- package/dist/cjs/utils/document.js +7 -249
- package/dist/cjs/utils/index.js +1 -23
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/actions/index.js +2 -1
- package/dist/es2019/create-editor/ReactEditorViewInternal.js +1 -1
- package/dist/es2019/index.js +1 -1
- package/dist/es2019/labs/next/internal/hooks/use-editor/create-editor.js +1 -1
- package/dist/es2019/messages.js +2 -54
- package/dist/es2019/nodeviews/getInlineNodeViewProducer.styles.js +1 -1
- package/dist/es2019/plugins/base/pm-plugins/scroll-gutter.js +1 -1
- package/dist/es2019/plugins/card/nodeviews/blockCard.js +1 -1
- package/dist/es2019/plugins/card/nodeviews/embedCard.js +1 -1
- package/dist/es2019/plugins/card/pm-plugins/doc.js +2 -3
- package/dist/es2019/plugins/card/pm-plugins/keymap.js +3 -3
- package/dist/es2019/plugins/card/pm-plugins/main.js +1 -1
- package/dist/es2019/plugins/card/toolbar.js +7 -9
- package/dist/es2019/plugins/card/ui/EditLinkToolbar.js +3 -4
- package/dist/es2019/plugins/card/ui/ResizableEmbedCard.js +1 -4
- package/dist/es2019/plugins/card/utils.js +1 -2
- package/dist/es2019/plugins/clear-marks-on-change-to-empty-document/index.js +1 -1
- package/dist/es2019/plugins/custom-autoformat/doc.js +1 -1
- package/dist/es2019/plugins/date/pm-plugins/main.js +1 -1
- package/dist/es2019/plugins/emoji/index.js +1 -1
- package/dist/es2019/plugins/floating-toolbar/index.js +1 -1
- package/dist/es2019/plugins/hyperlink/Toolbar.js +3 -3
- package/dist/es2019/plugins/hyperlink/commands.js +1 -2
- package/dist/es2019/plugins/hyperlink/ui/HyperlinkAddToolbar/index.js +1 -1
- package/dist/es2019/plugins/layout/actions.js +1 -1
- package/dist/es2019/plugins/media/nodeviews/mediaSingle.js +1 -1
- package/dist/es2019/plugins/media/pm-plugins/alt-text/ui/AltTextEdit.js +1 -1
- package/dist/es2019/plugins/media/toolbar/index.js +9 -8
- package/dist/es2019/plugins/media/toolbar/linking-toolbar-appearance.js +2 -1
- package/dist/es2019/plugins/media/toolbar/linking.js +1 -1
- package/dist/es2019/plugins/media/ui/MediaLinkingToolbar.js +1 -1
- package/dist/es2019/plugins/media/ui/ResizableMediaSingle/index.js +2 -4
- package/dist/es2019/plugins/media/utils/media-files.js +4 -3
- package/dist/es2019/plugins/mentions/pm-plugins/main.js +1 -1
- package/dist/es2019/plugins/placeholder/index.js +1 -1
- package/dist/es2019/plugins/status/plugin.js +1 -1
- package/dist/es2019/plugins/unsupported-content/index.js +1 -1
- package/dist/es2019/ui/Appearance/Chromeless.js +4 -2
- package/dist/es2019/ui/Appearance/Comment/Comment.js +4 -2
- package/dist/es2019/ui/Appearance/FullPage/FullPage.js +2 -1
- package/dist/es2019/ui/Appearance/FullPage/FullPageContentArea.js +2 -1
- package/dist/es2019/ui/Appearance/Mobile.js +4 -2
- package/dist/es2019/ui/AppearanceComponents/Mobile.js +6 -3
- package/dist/es2019/ui/ContentStyles/index.js +5 -3
- package/dist/es2019/ui/LinkSearch/ToolbarComponents.js +1 -4
- package/dist/es2019/utils/document.js +3 -244
- package/dist/es2019/utils/index.js +1 -4
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/actions/index.js +2 -1
- package/dist/esm/create-editor/ReactEditorViewInternal.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/labs/next/internal/hooks/use-editor/create-editor.js +1 -1
- package/dist/esm/messages.js +2 -54
- package/dist/esm/nodeviews/getInlineNodeViewProducer.styles.js +1 -1
- package/dist/esm/plugins/base/pm-plugins/scroll-gutter.js +1 -1
- package/dist/esm/plugins/card/nodeviews/blockCard.js +1 -1
- package/dist/esm/plugins/card/nodeviews/embedCard.js +1 -1
- package/dist/esm/plugins/card/pm-plugins/doc.js +2 -3
- package/dist/esm/plugins/card/pm-plugins/keymap.js +3 -3
- package/dist/esm/plugins/card/pm-plugins/main.js +1 -1
- package/dist/esm/plugins/card/toolbar.js +7 -9
- package/dist/esm/plugins/card/ui/EditLinkToolbar.js +3 -4
- package/dist/esm/plugins/card/ui/ResizableEmbedCard.js +1 -4
- package/dist/esm/plugins/card/utils.js +1 -2
- package/dist/esm/plugins/clear-marks-on-change-to-empty-document/index.js +1 -1
- package/dist/esm/plugins/custom-autoformat/doc.js +1 -1
- package/dist/esm/plugins/date/pm-plugins/main.js +1 -1
- package/dist/esm/plugins/emoji/index.js +1 -1
- package/dist/esm/plugins/floating-toolbar/index.js +1 -1
- package/dist/esm/plugins/hyperlink/Toolbar.js +3 -3
- package/dist/esm/plugins/hyperlink/commands.js +1 -2
- package/dist/esm/plugins/hyperlink/ui/HyperlinkAddToolbar/index.js +1 -1
- package/dist/esm/plugins/layout/actions.js +1 -1
- package/dist/esm/plugins/media/nodeviews/mediaSingle.js +1 -1
- package/dist/esm/plugins/media/pm-plugins/alt-text/ui/AltTextEdit.js +1 -1
- package/dist/esm/plugins/media/toolbar/index.js +9 -8
- package/dist/esm/plugins/media/toolbar/linking-toolbar-appearance.js +2 -1
- package/dist/esm/plugins/media/toolbar/linking.js +1 -1
- package/dist/esm/plugins/media/ui/MediaLinkingToolbar.js +1 -1
- package/dist/esm/plugins/media/ui/ResizableMediaSingle/index.js +2 -4
- package/dist/esm/plugins/media/utils/media-files.js +4 -3
- package/dist/esm/plugins/mentions/pm-plugins/main.js +1 -1
- package/dist/esm/plugins/placeholder/index.js +1 -1
- package/dist/esm/plugins/status/plugin.js +1 -1
- package/dist/esm/plugins/unsupported-content/index.js +1 -1
- package/dist/esm/ui/Appearance/Chromeless.js +4 -2
- package/dist/esm/ui/Appearance/Comment/Comment.js +4 -2
- package/dist/esm/ui/Appearance/FullPage/FullPage.js +2 -1
- package/dist/esm/ui/Appearance/FullPage/FullPageContentArea.js +2 -1
- package/dist/esm/ui/Appearance/Mobile.js +4 -2
- package/dist/esm/ui/AppearanceComponents/Mobile.js +6 -3
- package/dist/esm/ui/ContentStyles/index.js +5 -3
- package/dist/esm/ui/LinkSearch/ToolbarComponents.js +1 -4
- package/dist/esm/utils/document.js +6 -240
- package/dist/esm/utils/index.js +1 -4
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/index.d.ts +1 -2
- package/dist/types/labs/next/presets/cxhtml.d.ts +3 -3
- package/dist/types/labs/next/presets/default.d.ts +1 -1
- package/dist/types/labs/next/presets/mobile.d.ts +3 -3
- package/dist/types/messages.d.ts +2 -53
- package/dist/types/plugins/card/nodeviews/blockCard.d.ts +1 -1
- package/dist/types/plugins/card/nodeviews/genericCard.d.ts +3 -3
- package/dist/types/plugins/card/nodeviews/inlineCard.d.ts +1 -1
- package/dist/types/plugins/card/toolbar.d.ts +1 -1
- package/dist/types/plugins/card/types.d.ts +1 -1
- package/dist/types/plugins/card/ui/EditLinkToolbar.d.ts +1 -1
- package/dist/types/plugins/card/ui/ResizableEmbedCard.d.ts +1 -1
- package/dist/types/plugins/date/nodeviews/date.d.ts +1 -1
- package/dist/types/plugins/emoji/nodeviews/emoji.d.ts +1 -1
- package/dist/types/plugins/floating-toolbar/ui/Toolbar.d.ts +1 -1
- package/dist/types/plugins/hyperlink/Toolbar.d.ts +1 -1
- package/dist/types/plugins/hyperlink/commands.d.ts +2 -3
- package/dist/types/plugins/hyperlink/index.d.ts +1 -1
- package/dist/types/plugins/hyperlink/ui/HyperlinkAddToolbar/HyperlinkAddToolbar.d.ts +1 -1
- package/dist/types/plugins/hyperlink/ui/HyperlinkAddToolbar/index.d.ts +1 -1
- package/dist/types/plugins/media/ui/ResizableMediaSingle/types.d.ts +0 -15
- package/dist/types/plugins/media/utils/media-files.d.ts +1 -1
- package/dist/types/plugins/mentions/nodeviews/mention.d.ts +1 -1
- package/dist/types/plugins/status/nodeviews/status.d.ts +1 -1
- package/dist/types/plugins/unsupported-content/unsupported-inline-node-view.d.ts +1 -1
- package/dist/types/types/editor-props.d.ts +1 -1
- package/dist/types/ui/Appearance/FullPage/FullPageContentArea.d.ts +2 -0
- package/dist/types/ui/Appearance/FullPage/StyledComponents.d.ts +5 -364
- package/dist/types/ui/Appearance/Mobile.d.ts +1 -1
- package/dist/types/ui/AppearanceComponents/Mobile.d.ts +2 -0
- package/dist/types/ui/ContentStyles/index.d.ts +3 -3
- package/dist/types/ui/LinkSearch/ToolbarComponents.d.ts +0 -4
- package/dist/types/utils/document.d.ts +0 -12
- package/dist/types/utils/index.d.ts +1 -2
- package/dist/types-ts4.5/index.d.ts +1 -2
- package/dist/types-ts4.5/labs/next/presets/cxhtml.d.ts +3 -3
- package/dist/types-ts4.5/labs/next/presets/default.d.ts +1 -1
- package/dist/types-ts4.5/labs/next/presets/mobile.d.ts +3 -3
- package/dist/types-ts4.5/messages.d.ts +2 -53
- package/dist/types-ts4.5/plugins/card/nodeviews/blockCard.d.ts +1 -1
- package/dist/types-ts4.5/plugins/card/nodeviews/genericCard.d.ts +3 -3
- package/dist/types-ts4.5/plugins/card/nodeviews/inlineCard.d.ts +1 -1
- package/dist/types-ts4.5/plugins/card/toolbar.d.ts +1 -1
- package/dist/types-ts4.5/plugins/card/types.d.ts +1 -1
- package/dist/types-ts4.5/plugins/card/ui/EditLinkToolbar.d.ts +1 -1
- package/dist/types-ts4.5/plugins/card/ui/ResizableEmbedCard.d.ts +1 -1
- package/dist/types-ts4.5/plugins/date/nodeviews/date.d.ts +1 -1
- package/dist/types-ts4.5/plugins/emoji/nodeviews/emoji.d.ts +1 -1
- package/dist/types-ts4.5/plugins/floating-toolbar/ui/Toolbar.d.ts +1 -1
- package/dist/types-ts4.5/plugins/hyperlink/Toolbar.d.ts +1 -1
- package/dist/types-ts4.5/plugins/hyperlink/commands.d.ts +2 -3
- package/dist/types-ts4.5/plugins/hyperlink/index.d.ts +1 -1
- package/dist/types-ts4.5/plugins/hyperlink/ui/HyperlinkAddToolbar/HyperlinkAddToolbar.d.ts +1 -1
- package/dist/types-ts4.5/plugins/hyperlink/ui/HyperlinkAddToolbar/index.d.ts +1 -1
- package/dist/types-ts4.5/plugins/media/ui/ResizableMediaSingle/types.d.ts +0 -15
- package/dist/types-ts4.5/plugins/media/utils/media-files.d.ts +1 -1
- package/dist/types-ts4.5/plugins/mentions/nodeviews/mention.d.ts +1 -1
- package/dist/types-ts4.5/plugins/status/nodeviews/status.d.ts +1 -1
- package/dist/types-ts4.5/plugins/unsupported-content/unsupported-inline-node-view.d.ts +1 -1
- package/dist/types-ts4.5/types/editor-props.d.ts +1 -1
- package/dist/types-ts4.5/ui/Appearance/FullPage/FullPageContentArea.d.ts +2 -0
- package/dist/types-ts4.5/ui/Appearance/FullPage/StyledComponents.d.ts +5 -364
- package/dist/types-ts4.5/ui/Appearance/Mobile.d.ts +1 -1
- package/dist/types-ts4.5/ui/AppearanceComponents/Mobile.d.ts +2 -0
- package/dist/types-ts4.5/ui/ContentStyles/index.d.ts +3 -3
- package/dist/types-ts4.5/ui/LinkSearch/ToolbarComponents.d.ts +0 -4
- package/dist/types-ts4.5/utils/document.d.ts +0 -12
- package/dist/types-ts4.5/utils/index.d.ts +1 -2
- package/package.json +9 -10
- package/report.api.md +9 -34
- package/tmp/api-report-tmp.d.ts +7 -33
- package/dist/cjs/nodeviews/getInlineNodeViewProducer.js +0 -227
- package/dist/cjs/plugins/hyperlink/types.js +0 -5
- package/dist/cjs/ui/MediaAndEmbedsToolbar/index.js +0 -152
- package/dist/cjs/ui/Resizer/index.js +0 -210
- package/dist/cjs/ui/Resizer/styled.js +0 -15
- package/dist/cjs/ui/Resizer/types.js +0 -5
- package/dist/cjs/ui/Resizer/utils.js +0 -21
- package/dist/cjs/utils/filter/privacy-filter.js +0 -55
- package/dist/cjs/utils/linking-utils.js +0 -84
- package/dist/cjs/utils/rich-media-utils.js +0 -130
- package/dist/es2019/nodeviews/getInlineNodeViewProducer.js +0 -221
- package/dist/es2019/plugins/hyperlink/types.js +0 -1
- package/dist/es2019/ui/MediaAndEmbedsToolbar/index.js +0 -159
- package/dist/es2019/ui/Resizer/index.js +0 -191
- package/dist/es2019/ui/Resizer/styled.js +0 -15
- package/dist/es2019/ui/Resizer/types.js +0 -1
- package/dist/es2019/ui/Resizer/utils.js +0 -12
- package/dist/es2019/utils/filter/privacy-filter.js +0 -47
- package/dist/es2019/utils/linking-utils.js +0 -74
- package/dist/es2019/utils/rich-media-utils.js +0 -108
- package/dist/esm/nodeviews/getInlineNodeViewProducer.js +0 -217
- package/dist/esm/plugins/hyperlink/types.js +0 -1
- package/dist/esm/ui/MediaAndEmbedsToolbar/index.js +0 -144
- package/dist/esm/ui/Resizer/index.js +0 -203
- package/dist/esm/ui/Resizer/styled.js +0 -7
- package/dist/esm/ui/Resizer/types.js +0 -1
- package/dist/esm/ui/Resizer/utils.js +0 -12
- package/dist/esm/utils/filter/privacy-filter.js +0 -48
- package/dist/esm/utils/linking-utils.js +0 -74
- package/dist/esm/utils/rich-media-utils.js +0 -117
- package/dist/types/nodeviews/getInlineNodeViewProducer.d.ts +0 -24
- package/dist/types/plugins/hyperlink/types.d.ts +0 -35
- package/dist/types/ui/MediaAndEmbedsToolbar/index.d.ts +0 -9
- package/dist/types/ui/Resizer/index.d.ts +0 -41
- package/dist/types/ui/Resizer/styled.d.ts +0 -2
- package/dist/types/ui/Resizer/types.d.ts +0 -26
- package/dist/types/ui/Resizer/utils.d.ts +0 -6
- package/dist/types/utils/filter/privacy-filter.d.ts +0 -9
- package/dist/types/utils/linking-utils.d.ts +0 -14
- package/dist/types/utils/rich-media-utils.d.ts +0 -8
- package/dist/types-ts4.5/nodeviews/getInlineNodeViewProducer.d.ts +0 -24
- package/dist/types-ts4.5/plugins/hyperlink/types.d.ts +0 -35
- package/dist/types-ts4.5/ui/MediaAndEmbedsToolbar/index.d.ts +0 -9
- package/dist/types-ts4.5/ui/Resizer/index.d.ts +0 -41
- package/dist/types-ts4.5/ui/Resizer/styled.d.ts +0 -2
- package/dist/types-ts4.5/ui/Resizer/types.d.ts +0 -26
- package/dist/types-ts4.5/ui/Resizer/utils.d.ts +0 -6
- package/dist/types-ts4.5/utils/filter/privacy-filter.d.ts +0 -9
- package/dist/types-ts4.5/utils/linking-utils.d.ts +0 -14
- package/dist/types-ts4.5/utils/rich-media-utils.d.ts +0 -8
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { ACTION, ACTION_SUBJECT, EVENT_TYPE, ACTION_SUBJECT_ID, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
2
|
-
export const buildEditLinkPayload = type => {
|
|
3
|
-
return {
|
|
4
|
-
action: ACTION.CLICKED,
|
|
5
|
-
actionSubject: type === ACTION_SUBJECT_ID.HYPERLINK ? ACTION_SUBJECT.HYPERLINK : ACTION_SUBJECT.SMART_LINK,
|
|
6
|
-
actionSubjectId: ACTION_SUBJECT_ID.EDIT_LINK,
|
|
7
|
-
attributes: type !== ACTION_SUBJECT_ID.HYPERLINK ? {
|
|
8
|
-
display: type
|
|
9
|
-
} : {},
|
|
10
|
-
eventType: EVENT_TYPE.UI
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
const mapLinkTypeToCardAppearance = type => {
|
|
14
|
-
switch (type) {
|
|
15
|
-
case ACTION_SUBJECT_ID.CARD_INLINE:
|
|
16
|
-
{
|
|
17
|
-
return 'inline';
|
|
18
|
-
}
|
|
19
|
-
case ACTION_SUBJECT_ID.CARD_BLOCK:
|
|
20
|
-
{
|
|
21
|
-
return 'block';
|
|
22
|
-
}
|
|
23
|
-
case ACTION_SUBJECT_ID.EMBEDS:
|
|
24
|
-
{
|
|
25
|
-
return 'embed';
|
|
26
|
-
}
|
|
27
|
-
default:
|
|
28
|
-
{
|
|
29
|
-
return 'url';
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
export const buildVisitedLinkPayload = type => {
|
|
34
|
-
return type === ACTION_SUBJECT_ID.HYPERLINK ? {
|
|
35
|
-
action: ACTION.VISITED,
|
|
36
|
-
actionSubject: ACTION_SUBJECT.HYPERLINK,
|
|
37
|
-
actionSubjectId: undefined,
|
|
38
|
-
attributes: {
|
|
39
|
-
inputMethod: INPUT_METHOD.TOOLBAR
|
|
40
|
-
},
|
|
41
|
-
eventType: EVENT_TYPE.TRACK
|
|
42
|
-
} : {
|
|
43
|
-
action: ACTION.VISITED,
|
|
44
|
-
actionSubject: ACTION_SUBJECT.SMART_LINK,
|
|
45
|
-
actionSubjectId: type,
|
|
46
|
-
attributes: {
|
|
47
|
-
inputMethod: INPUT_METHOD.TOOLBAR
|
|
48
|
-
},
|
|
49
|
-
eventType: EVENT_TYPE.TRACK
|
|
50
|
-
};
|
|
51
|
-
};
|
|
52
|
-
export const buildOpenedSettingsPayload = type => {
|
|
53
|
-
return {
|
|
54
|
-
action: ACTION.CLICKED,
|
|
55
|
-
actionSubject: ACTION_SUBJECT.BUTTON,
|
|
56
|
-
actionSubjectId: ACTION_SUBJECT_ID.GOTO_SMART_LINK_SETTINGS,
|
|
57
|
-
attributes: {
|
|
58
|
-
inputMethod: INPUT_METHOD.TOOLBAR,
|
|
59
|
-
display: mapLinkTypeToCardAppearance(type)
|
|
60
|
-
},
|
|
61
|
-
eventType: EVENT_TYPE.UI
|
|
62
|
-
};
|
|
63
|
-
};
|
|
64
|
-
export const unlinkPayload = type => {
|
|
65
|
-
return {
|
|
66
|
-
action: ACTION.UNLINK,
|
|
67
|
-
actionSubject: type === ACTION_SUBJECT_ID.HYPERLINK ? ACTION_SUBJECT.HYPERLINK : ACTION_SUBJECT.SMART_LINK,
|
|
68
|
-
actionSubjectId: type === ACTION_SUBJECT_ID.HYPERLINK ? undefined : type,
|
|
69
|
-
attributes: {
|
|
70
|
-
inputMethod: INPUT_METHOD.TOOLBAR
|
|
71
|
-
},
|
|
72
|
-
eventType: EVENT_TYPE.TRACK
|
|
73
|
-
};
|
|
74
|
-
};
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import { wrappedLayouts, shouldAddDefaultWrappedWidth, calcPxFromColumns } from '@atlaskit/editor-common/ui';
|
|
2
|
-
import { findParentNodeOfTypeClosestToPos } from 'prosemirror-utils';
|
|
3
|
-
import { akEditorBreakoutPadding } from '@atlaskit/editor-shared-styles';
|
|
4
|
-
export const nonWrappedLayouts = ['center', 'wide', 'full-width'];
|
|
5
|
-
export const floatingLayouts = ['wrap-left', 'wrap-right'];
|
|
6
|
-
export const isRichMediaInsideOfBlockNode = (view, pos) => {
|
|
7
|
-
if (typeof pos !== 'number' || isNaN(pos) || !view) {
|
|
8
|
-
return false;
|
|
9
|
-
}
|
|
10
|
-
const $pos = view.state.doc.resolve(pos);
|
|
11
|
-
const {
|
|
12
|
-
expand,
|
|
13
|
-
nestedExpand,
|
|
14
|
-
layoutColumn
|
|
15
|
-
} = view.state.schema.nodes;
|
|
16
|
-
return !!findParentNodeOfTypeClosestToPos($pos, [expand, nestedExpand, layoutColumn]);
|
|
17
|
-
};
|
|
18
|
-
export const alignAttributes = (layout, oldAttrs, gridSize = 12, originalWidth, lineLength) => {
|
|
19
|
-
let width = oldAttrs.width;
|
|
20
|
-
const oldLayout = oldAttrs.layout;
|
|
21
|
-
const oldLayoutIsNonWrapped = nonWrappedLayouts.indexOf(oldLayout) > -1;
|
|
22
|
-
const newLayoutIsNonWrapped = nonWrappedLayouts.indexOf(layout) > -1;
|
|
23
|
-
const newLayoutIsWrapped = wrappedLayouts.indexOf(layout) > -1;
|
|
24
|
-
const oldLayoutIsWrapped = wrappedLayouts.indexOf(oldLayout) > -1;
|
|
25
|
-
if (oldLayoutIsNonWrapped && shouldAddDefaultWrappedWidth(layout, originalWidth, lineLength)) {
|
|
26
|
-
// 'full-width' or 'wide' or 'center' -> 'wrap-left' or 'wrap-right' or 'align-end' or 'align-start'
|
|
27
|
-
if (!width || width >= 100 || oldLayout !== 'center' // == 'full-width' or 'wide'
|
|
28
|
-
) {
|
|
29
|
-
width = 50;
|
|
30
|
-
}
|
|
31
|
-
} else if (layout !== oldLayout && ['full-width', 'wide'].indexOf(oldLayout) > -1) {
|
|
32
|
-
// 'full-width' -> 'center' or 'wide'
|
|
33
|
-
// 'wide' -> 'center' or 'full-width'
|
|
34
|
-
// unset width
|
|
35
|
-
width = undefined;
|
|
36
|
-
} else if (width) {
|
|
37
|
-
const cols = Math.round(width / 100 * gridSize);
|
|
38
|
-
let targetCols = cols;
|
|
39
|
-
if (oldLayoutIsWrapped && newLayoutIsNonWrapped) {
|
|
40
|
-
// wrap -> center needs to align to even grid
|
|
41
|
-
targetCols = Math.floor(targetCols / 2) * 2;
|
|
42
|
-
width = undefined;
|
|
43
|
-
} else if (oldLayoutIsNonWrapped && newLayoutIsWrapped) {
|
|
44
|
-
// Can be here only if
|
|
45
|
-
// 'full-width' or 'wide' or 'center' -> 'wrap-left' or 'wrap-right' or 'align-end' or 'align-start'
|
|
46
|
-
// AND
|
|
47
|
-
// !originalWidth || !lineLength || small image
|
|
48
|
-
// AND
|
|
49
|
-
// width defined!
|
|
50
|
-
|
|
51
|
-
// cannot resize to full column width, and cannot resize to 1 column
|
|
52
|
-
if (cols <= 1) {
|
|
53
|
-
targetCols = 2;
|
|
54
|
-
} else if (cols >= gridSize) {
|
|
55
|
-
targetCols = 10;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
if (targetCols !== cols) {
|
|
59
|
-
width = targetCols / gridSize * 100;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
return {
|
|
63
|
-
...oldAttrs,
|
|
64
|
-
layout,
|
|
65
|
-
width
|
|
66
|
-
};
|
|
67
|
-
};
|
|
68
|
-
export function calculateSnapPoints({
|
|
69
|
-
$pos,
|
|
70
|
-
akEditorWideLayoutWidth,
|
|
71
|
-
allowBreakoutSnapPoints,
|
|
72
|
-
containerWidth,
|
|
73
|
-
gridSize,
|
|
74
|
-
gridWidth,
|
|
75
|
-
insideInlineLike,
|
|
76
|
-
insideLayout,
|
|
77
|
-
isVideoFile,
|
|
78
|
-
lineLength,
|
|
79
|
-
offsetLeft,
|
|
80
|
-
wrappedLayout
|
|
81
|
-
}) {
|
|
82
|
-
const snapTargets = [];
|
|
83
|
-
for (let i = 0; i < gridWidth; i++) {
|
|
84
|
-
const pxFromColumns = calcPxFromColumns(i, lineLength, gridWidth);
|
|
85
|
-
snapTargets.push(insideLayout ? pxFromColumns : pxFromColumns - offsetLeft);
|
|
86
|
-
}
|
|
87
|
-
// full width
|
|
88
|
-
snapTargets.push(lineLength - offsetLeft);
|
|
89
|
-
const columns = wrappedLayout || insideInlineLike ? 1 : 2;
|
|
90
|
-
const minimumWidth = calcPxFromColumns(columns, lineLength, gridSize);
|
|
91
|
-
let snapPoints = snapTargets.filter(width => width >= minimumWidth);
|
|
92
|
-
if (!$pos) {
|
|
93
|
-
return snapPoints;
|
|
94
|
-
}
|
|
95
|
-
snapPoints = isVideoFile ? snapPoints.filter(width => width > 320) : snapPoints;
|
|
96
|
-
const isTopLevel = $pos.parent.type.name === 'doc';
|
|
97
|
-
if (isTopLevel && allowBreakoutSnapPoints) {
|
|
98
|
-
snapPoints.push(akEditorWideLayoutWidth);
|
|
99
|
-
const fullWidthPoint = containerWidth - akEditorBreakoutPadding;
|
|
100
|
-
if (fullWidthPoint > akEditorWideLayoutWidth) {
|
|
101
|
-
snapPoints.push(fullWidthPoint);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
// EDM-1107: Ensure new snapPoints are sorted with existing points
|
|
106
|
-
snapPoints = snapPoints.sort((a, b) => a - b);
|
|
107
|
-
return snapPoints;
|
|
108
|
-
}
|
|
@@ -1,217 +0,0 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
/** @jsx jsx */
|
|
3
|
-
import { jsx } from '@emotion/react';
|
|
4
|
-
import React from 'react';
|
|
5
|
-
import { ZERO_WIDTH_SPACE } from '@atlaskit/editor-common/utils';
|
|
6
|
-
import { ACTION_SUBJECT, ACTION_SUBJECT_ID } from '../plugins/analytics';
|
|
7
|
-
import { analyticsEventKey } from '../plugins/analytics/consts';
|
|
8
|
-
import { ErrorBoundary } from '../ui/ErrorBoundary';
|
|
9
|
-
import { getPerformanceOptions, startMeasureReactNodeViewRendered, stopMeasureReactNodeViewRendered } from './getPerformanceOptions';
|
|
10
|
-
export var inlineNodeViewClassname = 'inlineNodeView';
|
|
11
|
-
function createNodeView(_ref) {
|
|
12
|
-
var nodeViewParams = _ref.nodeViewParams,
|
|
13
|
-
pmPluginFactoryParams = _ref.pmPluginFactoryParams,
|
|
14
|
-
Component = _ref.Component,
|
|
15
|
-
extraComponentProps = _ref.extraComponentProps;
|
|
16
|
-
// We set a variable for the current node which is
|
|
17
|
-
// used for comparisions when doing updates, before being
|
|
18
|
-
// overwritten to the updated node.
|
|
19
|
-
var currentNode = nodeViewParams.node;
|
|
20
|
-
|
|
21
|
-
// First we setup the dom element which will be rendered and "tracked" by prosemirror
|
|
22
|
-
// and also used as a "editor portal" (not react portal) target by the editor
|
|
23
|
-
// portal provider api, for rendering the Component passed.
|
|
24
|
-
|
|
25
|
-
var domRef = document.createElement('span');
|
|
26
|
-
domRef.contentEditable = 'false';
|
|
27
|
-
setDomAttrs(nodeViewParams.node, domRef);
|
|
28
|
-
|
|
29
|
-
// @see ED-3790
|
|
30
|
-
// something gets messed up during mutation processing inside of a
|
|
31
|
-
// nodeView if DOM structure has nested plain "div"s, it doesn't see the
|
|
32
|
-
// difference between them and it kills the nodeView
|
|
33
|
-
domRef.classList.add("".concat(nodeViewParams.node.type.name, "View-content-wrap"), "".concat(inlineNodeViewClassname));
|
|
34
|
-
|
|
35
|
-
// This util is shared for tracking rendering, and the ErrorBoundary that
|
|
36
|
-
// is setup to wrap the Component when rendering
|
|
37
|
-
// NOTE: This is not a prosemirror dispatch
|
|
38
|
-
function dispatchAnalyticsEvent(payload) {
|
|
39
|
-
pmPluginFactoryParams.eventDispatcher.emit(analyticsEventKey, {
|
|
40
|
-
payload: payload
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// This is called to render the Component into domRef which is inside the
|
|
45
|
-
// prosemirror View.
|
|
46
|
-
// Internally it uses the unstable_renderSubtreeIntoContainer api to render,
|
|
47
|
-
// to the passed dom element (domRef) which means it is automatically
|
|
48
|
-
// "cleaned up" when you do a "re render".
|
|
49
|
-
function renderComponent() {
|
|
50
|
-
pmPluginFactoryParams.portalProviderAPI.render(getPortalChildren({
|
|
51
|
-
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
52
|
-
currentNode: currentNode,
|
|
53
|
-
nodeViewParams: nodeViewParams,
|
|
54
|
-
Component: Component,
|
|
55
|
-
extraComponentProps: extraComponentProps
|
|
56
|
-
}), domRef, false,
|
|
57
|
-
// node views should be rendered with intl context
|
|
58
|
-
true);
|
|
59
|
-
}
|
|
60
|
-
var _getPerformanceOption = getPerformanceOptions(nodeViewParams.view),
|
|
61
|
-
samplingRate = _getPerformanceOption.samplingRate,
|
|
62
|
-
slowThreshold = _getPerformanceOption.slowThreshold,
|
|
63
|
-
trackingEnabled = _getPerformanceOption.trackingEnabled;
|
|
64
|
-
trackingEnabled && startMeasureReactNodeViewRendered({
|
|
65
|
-
nodeTypeName: currentNode.type.name
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
// We render the component while creating the node view
|
|
69
|
-
renderComponent();
|
|
70
|
-
trackingEnabled && stopMeasureReactNodeViewRendered({
|
|
71
|
-
nodeTypeName: currentNode.type.name,
|
|
72
|
-
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
73
|
-
editorState: nodeViewParams.view.state,
|
|
74
|
-
samplingRate: samplingRate,
|
|
75
|
-
slowThreshold: slowThreshold
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
// https://prosemirror.net/docs/ref/#view.NodeView
|
|
79
|
-
var nodeView = {
|
|
80
|
-
get dom() {
|
|
81
|
-
return domRef;
|
|
82
|
-
},
|
|
83
|
-
update: function update(nextNode, _decorations) {
|
|
84
|
-
// Let ProseMirror handle the update if node types are different.
|
|
85
|
-
// This prevents an issue where it was not possible to select the
|
|
86
|
-
// inline node view then replace it by entering text - the node
|
|
87
|
-
// view contents would be deleted but the node view itself would
|
|
88
|
-
// stay in the view and become uneditable.
|
|
89
|
-
if (currentNode.type !== nextNode.type) {
|
|
90
|
-
return false;
|
|
91
|
-
}
|
|
92
|
-
// On updates, we only set the new attributes if the type, attributes, and marks
|
|
93
|
-
// have changed on the node.
|
|
94
|
-
|
|
95
|
-
// NOTE: this could mean attrs changes aren't reflected in the dom,
|
|
96
|
-
// when an attribute key which was previously present is no longer
|
|
97
|
-
// present.
|
|
98
|
-
// ie.
|
|
99
|
-
// -> Original attributes { text: "hello world", color: "red" }
|
|
100
|
-
// -> Updated attributes { color: "blue" }
|
|
101
|
-
// in this case, the dom text attribute will not be cleared.
|
|
102
|
-
//
|
|
103
|
-
// This may not be an issue with any of our current node schemas.
|
|
104
|
-
if (!currentNode.sameMarkup(nextNode)) {
|
|
105
|
-
setDomAttrs(nextNode, domRef);
|
|
106
|
-
}
|
|
107
|
-
currentNode = nextNode;
|
|
108
|
-
renderComponent();
|
|
109
|
-
return true;
|
|
110
|
-
},
|
|
111
|
-
destroy: function destroy() {
|
|
112
|
-
// When prosemirror destroys the node view, we need to clean up
|
|
113
|
-
// what we have previously rendered using the editor portal
|
|
114
|
-
// provider api.
|
|
115
|
-
pmPluginFactoryParams.portalProviderAPI.remove(domRef);
|
|
116
|
-
// @ts-expect-error Expect an error as domRef is expected to be
|
|
117
|
-
// of HTMLSpanElement type however once the node view has
|
|
118
|
-
// been destroyed no other consumers should still be using it.
|
|
119
|
-
domRef = undefined;
|
|
120
|
-
}
|
|
121
|
-
};
|
|
122
|
-
return nodeView;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* Copies the attributes from a ProseMirror Node to a DOM node.
|
|
127
|
-
* @param node The Prosemirror Node from which to source the attributes
|
|
128
|
-
*/
|
|
129
|
-
function setDomAttrs(node, element) {
|
|
130
|
-
Object.keys(node.attrs || {}).forEach(function (attr) {
|
|
131
|
-
element.setAttribute(attr, node.attrs[attr]);
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
function getPortalChildren(_ref2) {
|
|
135
|
-
var dispatchAnalyticsEvent = _ref2.dispatchAnalyticsEvent,
|
|
136
|
-
currentNode = _ref2.currentNode,
|
|
137
|
-
nodeViewParams = _ref2.nodeViewParams,
|
|
138
|
-
Component = _ref2.Component,
|
|
139
|
-
extraComponentProps = _ref2.extraComponentProps;
|
|
140
|
-
return function portalChildren() {
|
|
141
|
-
var _currentNode$type$nam, _currentNode$type;
|
|
142
|
-
// All inline nodes use `display: inline` to allow for multi-line
|
|
143
|
-
// wrapping. This does produce an issue in Chrome where it is not
|
|
144
|
-
// possible to click select the position after the node,
|
|
145
|
-
// see: https://product-fabric.atlassian.net/browse/ED-12003
|
|
146
|
-
// however this is only a problem for node views that use
|
|
147
|
-
// `display: inline-block` somewhere within the Component.
|
|
148
|
-
// Looking at the below structure, spans with className
|
|
149
|
-
// `inlineNodeViewAddZeroWidthSpace` have pseudo elements that
|
|
150
|
-
// add a zero width space which fixes the problem.
|
|
151
|
-
// Without the additional zero width space before the Component,
|
|
152
|
-
// it is not possible to use the keyboard to range select in Safari.
|
|
153
|
-
//
|
|
154
|
-
// Zero width spaces on either side of the Component also prevent
|
|
155
|
-
// the cursor from appearing inside the node view on all browsers.
|
|
156
|
-
//
|
|
157
|
-
// Note:
|
|
158
|
-
// In future it is worth considering prohibiting the use of `display: inline-block`
|
|
159
|
-
// within inline node view Components however would require a sizable
|
|
160
|
-
// refactor. A test suite to catch any instances of this is ideal however
|
|
161
|
-
// the refactor required is currently out of scope for https://product-fabric.atlassian.net/browse/ED-14176
|
|
162
|
-
|
|
163
|
-
return jsx(ErrorBoundary, {
|
|
164
|
-
component: ACTION_SUBJECT.REACT_NODE_VIEW,
|
|
165
|
-
componentId: (_currentNode$type$nam = currentNode === null || currentNode === void 0 ? void 0 : (_currentNode$type = currentNode.type) === null || _currentNode$type === void 0 ? void 0 : _currentNode$type.name) !== null && _currentNode$type$nam !== void 0 ? _currentNode$type$nam : ACTION_SUBJECT_ID.UNKNOWN_NODE,
|
|
166
|
-
dispatchAnalyticsEvent: dispatchAnalyticsEvent
|
|
167
|
-
}, jsx("span", {
|
|
168
|
-
"aria-hidden": "true",
|
|
169
|
-
className: "zeroWidthSpaceContainer"
|
|
170
|
-
}, jsx("span", {
|
|
171
|
-
className: "".concat(inlineNodeViewClassname, "AddZeroWidthSpace")
|
|
172
|
-
}), ZERO_WIDTH_SPACE), jsx(Component, _extends({
|
|
173
|
-
view: nodeViewParams.view,
|
|
174
|
-
getPos: nodeViewParams.getPos,
|
|
175
|
-
node: currentNode
|
|
176
|
-
}, extraComponentProps)), jsx("span", {
|
|
177
|
-
"aria-hidden": "true",
|
|
178
|
-
className: "".concat(inlineNodeViewClassname, "AddZeroWidthSpace")
|
|
179
|
-
}));
|
|
180
|
-
};
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
// https://prosemirror.net/docs/ref/#view.EditorProps.nodeViews
|
|
184
|
-
// The prosemirror EditorProps has a nodeViews key which has the rough shape:
|
|
185
|
-
// type nodeViews: {
|
|
186
|
-
// [nodeViewName: string]: (node, editorView, getPos, decorations, innerDecorations) => NodeView
|
|
187
|
-
// }
|
|
188
|
-
// So the value of the keys on the nodeViews object, are a function which should return a NodeView.
|
|
189
|
-
// The following type NodeViewProducer, refers to these functions which return a NodeView.
|
|
190
|
-
//
|
|
191
|
-
// So the above type could also be described as
|
|
192
|
-
// type NodeViewProducer = (node, editorView, getPos, decorations, innerDecorations) => NodeView
|
|
193
|
-
// nodeViews: {
|
|
194
|
-
// [nodeViewName: string]: NodeViewProducer
|
|
195
|
-
// }
|
|
196
|
-
// This return of this function is intended to be the value of a key
|
|
197
|
-
// in a ProseMirror nodeViews object.
|
|
198
|
-
export function getInlineNodeViewProducer(_ref3) {
|
|
199
|
-
var pmPluginFactoryParams = _ref3.pmPluginFactoryParams,
|
|
200
|
-
Component = _ref3.Component,
|
|
201
|
-
extraComponentProps = _ref3.extraComponentProps;
|
|
202
|
-
function nodeViewProducer() {
|
|
203
|
-
var nodeView = createNodeView({
|
|
204
|
-
nodeViewParams: {
|
|
205
|
-
node: arguments.length <= 0 ? undefined : arguments[0],
|
|
206
|
-
view: arguments.length <= 1 ? undefined : arguments[1],
|
|
207
|
-
getPos: arguments.length <= 2 ? undefined : arguments[2],
|
|
208
|
-
decorations: arguments.length <= 3 ? undefined : arguments[3]
|
|
209
|
-
},
|
|
210
|
-
pmPluginFactoryParams: pmPluginFactoryParams,
|
|
211
|
-
Component: Component,
|
|
212
|
-
extraComponentProps: extraComponentProps
|
|
213
|
-
});
|
|
214
|
-
return nodeView;
|
|
215
|
-
}
|
|
216
|
-
return nodeViewProducer;
|
|
217
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
-
import { NodeSelection } from 'prosemirror-state';
|
|
3
|
-
import { hasParentNodeOfType } from 'prosemirror-utils';
|
|
4
|
-
import commonMessages from '../../messages';
|
|
5
|
-
import WrapLeftIcon from '@atlaskit/icon/glyph/editor/media-wrap-left';
|
|
6
|
-
import WrapRightIcon from '@atlaskit/icon/glyph/editor/media-wrap-right';
|
|
7
|
-
import WideIcon from '@atlaskit/icon/glyph/editor/media-wide';
|
|
8
|
-
import FullWidthIcon from '@atlaskit/icon/glyph/editor/media-full-width';
|
|
9
|
-
import EditorAlignImageLeft from '@atlaskit/icon/glyph/editor/align-image-left';
|
|
10
|
-
import EditorAlignImageRight from '@atlaskit/icon/glyph/editor/align-image-right';
|
|
11
|
-
import EditorAlignImageCenter from '@atlaskit/icon/glyph/editor/align-image-center';
|
|
12
|
-
import { alignAttributes } from '../../utils/rich-media-utils';
|
|
13
|
-
import { DEFAULT_EMBED_CARD_WIDTH } from '@atlaskit/editor-shared-styles';
|
|
14
|
-
import { addAnalytics } from '../../plugins/analytics/utils';
|
|
15
|
-
import { ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, ACTION } from '../../plugins/analytics';
|
|
16
|
-
import { toolbarMessages } from './toolbar-messages';
|
|
17
|
-
import { insideTable, isInLayoutColumn } from '../../utils';
|
|
18
|
-
var alignmentIcons = [{
|
|
19
|
-
id: 'editor.media.alignLeft',
|
|
20
|
-
value: 'align-start',
|
|
21
|
-
icon: EditorAlignImageLeft
|
|
22
|
-
}, {
|
|
23
|
-
id: 'editor.media.alignCenter',
|
|
24
|
-
value: 'center',
|
|
25
|
-
icon: EditorAlignImageCenter
|
|
26
|
-
}, {
|
|
27
|
-
id: 'editor.media.alignRight',
|
|
28
|
-
value: 'align-end',
|
|
29
|
-
icon: EditorAlignImageRight
|
|
30
|
-
}];
|
|
31
|
-
var wrappingIcons = [{
|
|
32
|
-
id: 'editor.media.wrapLeft',
|
|
33
|
-
value: 'wrap-left',
|
|
34
|
-
icon: WrapLeftIcon
|
|
35
|
-
}, {
|
|
36
|
-
id: 'editor.media.wrapRight',
|
|
37
|
-
value: 'wrap-right',
|
|
38
|
-
icon: WrapRightIcon
|
|
39
|
-
}];
|
|
40
|
-
var breakoutIcons = [{
|
|
41
|
-
value: 'wide',
|
|
42
|
-
icon: WideIcon
|
|
43
|
-
}, {
|
|
44
|
-
value: 'full-width',
|
|
45
|
-
icon: FullWidthIcon
|
|
46
|
-
}];
|
|
47
|
-
var layoutToMessages = {
|
|
48
|
-
'wrap-left': toolbarMessages.wrapLeft,
|
|
49
|
-
center: commonMessages.alignImageCenter,
|
|
50
|
-
'wrap-right': toolbarMessages.wrapRight,
|
|
51
|
-
wide: commonMessages.layoutWide,
|
|
52
|
-
'full-width': commonMessages.layoutFullWidth,
|
|
53
|
-
'align-end': commonMessages.alignImageRight,
|
|
54
|
-
'align-start': commonMessages.alignImageLeft
|
|
55
|
-
};
|
|
56
|
-
var getNodeWidth = function getNodeWidth(node, schema) {
|
|
57
|
-
var embedCard = schema.nodes.embedCard;
|
|
58
|
-
if (node.type === embedCard) {
|
|
59
|
-
return node.attrs.originalWidth || DEFAULT_EMBED_CARD_WIDTH;
|
|
60
|
-
}
|
|
61
|
-
return node.firstChild && node.firstChild.attrs.width || node.attrs.width;
|
|
62
|
-
};
|
|
63
|
-
var makeAlign = function makeAlign(layout, nodeType, widthPluginDependencyApi) {
|
|
64
|
-
return function (state, dispatch) {
|
|
65
|
-
var _ref = state.selection,
|
|
66
|
-
node = _ref.node;
|
|
67
|
-
var previousLayoutType = node.attrs.layout;
|
|
68
|
-
var mediaSingle = state.schema.nodes.mediaSingle;
|
|
69
|
-
if (!dispatch) {
|
|
70
|
-
return false;
|
|
71
|
-
}
|
|
72
|
-
var widthPluginState = widthPluginDependencyApi === null || widthPluginDependencyApi === void 0 ? void 0 : widthPluginDependencyApi.sharedState.currentState();
|
|
73
|
-
if (!node || node.type !== nodeType || !widthPluginState) {
|
|
74
|
-
return false;
|
|
75
|
-
}
|
|
76
|
-
var nodeWidth = getNodeWidth(node, state.schema);
|
|
77
|
-
var newAttrs = alignAttributes(layout, node.attrs, undefined, nodeWidth, widthPluginState.lineLength);
|
|
78
|
-
var tr = state.tr.setNodeMarkup(state.selection.from, undefined, newAttrs);
|
|
79
|
-
tr.setMeta('scrollIntoView', false);
|
|
80
|
-
// when image captions are enabled, the wrong node gets selected after
|
|
81
|
-
// setNodeMarkup is called
|
|
82
|
-
tr.setSelection(NodeSelection.create(tr.doc, state.selection.from));
|
|
83
|
-
var paragraph = tr.doc.type.schema.nodes.paragraph;
|
|
84
|
-
|
|
85
|
-
// see https://product-fabric.atlassian.net/browse/ED-15518 insert a new paragraph when an embedded card is wrapped left or right
|
|
86
|
-
if (layout.startsWith('wrap') && paragraph && !tr.doc.nodeAt(state.selection.to) && (insideTable(state) || isInLayoutColumn(state))) {
|
|
87
|
-
tr.insert(state.selection.to, paragraph.createAndFill());
|
|
88
|
-
}
|
|
89
|
-
dispatch(addAnalytics(state, tr, {
|
|
90
|
-
eventType: EVENT_TYPE.TRACK,
|
|
91
|
-
action: ACTION.SELECTED,
|
|
92
|
-
actionSubject: ACTION_SUBJECT[node.type === mediaSingle ? 'MEDIA_SINGLE' : 'EMBEDS'],
|
|
93
|
-
actionSubjectId: ACTION_SUBJECT_ID.RICH_MEDIA_LAYOUT,
|
|
94
|
-
attributes: {
|
|
95
|
-
previousLayoutType: previousLayoutType,
|
|
96
|
-
currentLayoutType: layout
|
|
97
|
-
}
|
|
98
|
-
}));
|
|
99
|
-
return true;
|
|
100
|
-
};
|
|
101
|
-
};
|
|
102
|
-
var mapIconsToToolbarItem = function mapIconsToToolbarItem(icons, layout, intl, nodeType, widthPluginDependencyApi) {
|
|
103
|
-
return icons.map(function (toolbarItem) {
|
|
104
|
-
var id = toolbarItem.id,
|
|
105
|
-
value = toolbarItem.value;
|
|
106
|
-
return {
|
|
107
|
-
id: id,
|
|
108
|
-
type: 'button',
|
|
109
|
-
icon: toolbarItem.icon,
|
|
110
|
-
title: intl.formatMessage(layoutToMessages[value]),
|
|
111
|
-
selected: layout === value,
|
|
112
|
-
onClick: makeAlign(value, nodeType, widthPluginDependencyApi)
|
|
113
|
-
};
|
|
114
|
-
});
|
|
115
|
-
};
|
|
116
|
-
var shouldHideLayoutToolbar = function shouldHideLayoutToolbar(selection, _ref2, allowResizingInTables) {
|
|
117
|
-
var nodes = _ref2.nodes;
|
|
118
|
-
return hasParentNodeOfType([nodes.bodiedExtension, nodes.listItem, nodes.expand, nodes.nestedExpand].concat(_toConsumableArray(allowResizingInTables ? [] : [nodes.table])).filter(Boolean))(selection);
|
|
119
|
-
};
|
|
120
|
-
var buildLayoutButtons = function buildLayoutButtons(state, intl, nodeType, widthPluginDependencyApi, allowResizing, allowResizingInTables) {
|
|
121
|
-
var allowWrapping = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : true;
|
|
122
|
-
var allowAlignment = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : true;
|
|
123
|
-
var selection = state.selection;
|
|
124
|
-
if (!(selection instanceof NodeSelection) || !selection.node || !nodeType || shouldHideLayoutToolbar(selection, state.schema, allowResizingInTables)) {
|
|
125
|
-
return [];
|
|
126
|
-
}
|
|
127
|
-
var layout = selection.node.attrs.layout;
|
|
128
|
-
var alignmentToolbarItems = allowAlignment ? mapIconsToToolbarItem(alignmentIcons, layout, intl, nodeType, widthPluginDependencyApi) : [];
|
|
129
|
-
var wrappingToolbarItems = allowWrapping ? mapIconsToToolbarItem(wrappingIcons, layout, intl, nodeType, widthPluginDependencyApi) : [];
|
|
130
|
-
var breakOutToolbarItems = !allowResizing ? mapIconsToToolbarItem(breakoutIcons, layout, intl, nodeType, widthPluginDependencyApi) : [];
|
|
131
|
-
var items = [].concat(_toConsumableArray(alignmentToolbarItems), _toConsumableArray(getSeparatorBetweenAlignmentAndWrapping(allowAlignment, allowWrapping)), _toConsumableArray(wrappingToolbarItems), _toConsumableArray(getSeparatorBeforeBreakoutItems(allowAlignment, allowWrapping, allowResizing)), _toConsumableArray(breakOutToolbarItems));
|
|
132
|
-
return items;
|
|
133
|
-
};
|
|
134
|
-
var getSeparatorBetweenAlignmentAndWrapping = function getSeparatorBetweenAlignmentAndWrapping(allowAlignment, allowWrapping) {
|
|
135
|
-
return allowAlignment && allowWrapping ? [{
|
|
136
|
-
type: 'separator'
|
|
137
|
-
}] : [];
|
|
138
|
-
};
|
|
139
|
-
var getSeparatorBeforeBreakoutItems = function getSeparatorBeforeBreakoutItems(allowAlignment, allowWrapping, allowResizing) {
|
|
140
|
-
return !allowResizing && (allowAlignment || allowWrapping) ? [{
|
|
141
|
-
type: 'separator'
|
|
142
|
-
}] : [];
|
|
143
|
-
};
|
|
144
|
-
export default buildLayoutButtons;
|