@atlaskit/renderer 81.1.0 → 82.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +44 -0
- package/dist/cjs/react/index.js +33 -8
- package/dist/cjs/react/marks/code.js +26 -4
- package/dist/cjs/react/nodes/codeBlock.js +17 -3
- package/dist/cjs/react/nodes/heading-anchor.js +1 -2
- package/dist/cjs/react/nodes/heading.js +3 -5
- package/dist/cjs/react/nodes/index.js +15 -1
- package/dist/cjs/react/nodes/mediaInline.js +104 -0
- package/dist/cjs/react/nodes/panel.js +1 -1
- package/dist/cjs/react/nodes/text-wrapper.js +5 -6
- package/dist/cjs/ui/Renderer/index.js +1 -1
- package/dist/cjs/ui/Renderer/style.js +5 -5
- package/dist/cjs/ui/annotations/draft/component.js +6 -6
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/react/index.js +30 -5
- package/dist/es2019/react/marks/code.js +15 -3
- package/dist/es2019/react/nodes/codeBlock.js +13 -3
- package/dist/es2019/react/nodes/heading-anchor.js +1 -2
- package/dist/es2019/react/nodes/heading.js +3 -5
- package/dist/es2019/react/nodes/index.js +8 -1
- package/dist/es2019/react/nodes/mediaInline.js +53 -0
- package/dist/es2019/react/nodes/panel.js +1 -1
- package/dist/es2019/react/nodes/text-wrapper.js +7 -6
- package/dist/es2019/ui/Renderer/index.js +1 -1
- package/dist/es2019/ui/Renderer/style.js +47 -81
- package/dist/es2019/ui/annotations/draft/component.js +6 -6
- package/dist/es2019/version.json +1 -1
- package/dist/esm/react/index.js +32 -8
- package/dist/esm/react/marks/code.js +15 -3
- package/dist/esm/react/nodes/codeBlock.js +13 -3
- package/dist/esm/react/nodes/heading-anchor.js +1 -2
- package/dist/esm/react/nodes/heading.js +3 -5
- package/dist/esm/react/nodes/index.js +14 -1
- package/dist/esm/react/nodes/mediaInline.js +80 -0
- package/dist/esm/react/nodes/panel.js +1 -1
- package/dist/esm/react/nodes/text-wrapper.js +7 -6
- package/dist/esm/ui/Renderer/index.js +1 -1
- package/dist/esm/ui/Renderer/style.js +5 -6
- package/dist/esm/ui/annotations/draft/component.js +6 -6
- package/dist/esm/version.json +1 -1
- package/dist/types/react/index.d.ts +1 -0
- package/dist/types/react/marks/code.d.ts +15 -1
- package/dist/types/react/nodes/codeBlock.d.ts +4 -3
- package/dist/types/react/nodes/index.d.ts +8 -7
- package/dist/types/react/nodes/mediaInline.d.ts +17 -0
- package/dist/types/react/nodes/text-wrapper.d.ts +2 -3
- package/dist/types/renderer-context.d.ts +3 -1
- package/dist/types/ui/ExtensionRenderer.d.ts +1 -1
- package/dist/types/ui/annotations/draft/component.d.ts +1 -1
- package/package.json +13 -13
|
@@ -10,6 +10,7 @@ import { getMarksByOrder, isSameMark, calcTableColumnWidths } from '@atlaskit/ed
|
|
|
10
10
|
import { getText } from '../utils';
|
|
11
11
|
import { findChildrenByType } from 'prosemirror-utils';
|
|
12
12
|
import { insideBreakoutLayout } from './renderer-node';
|
|
13
|
+
import { isCodeMark } from './marks/code';
|
|
13
14
|
|
|
14
15
|
function mergeMarks(marksAndNodes) {
|
|
15
16
|
return marksAndNodes.reduce((acc, markOrNode) => {
|
|
@@ -128,13 +129,23 @@ export default class ReactSerializer {
|
|
|
128
129
|
} = mark.attrs;
|
|
129
130
|
const extraProps = {
|
|
130
131
|
isInline: node === null || node === void 0 ? void 0 : node.isInline
|
|
131
|
-
};
|
|
132
|
+
}; // currently the only mark which has custom props is the code mark
|
|
133
|
+
|
|
134
|
+
const markSpecificProps = isCodeMark(mark) ? {
|
|
135
|
+
// The appearance being mobile indicates we are in an renderer being
|
|
136
|
+
// rendered by mobile bridge in a web view.
|
|
137
|
+
// The tooltip is likely to have unexpected behaviour there, with being cut
|
|
138
|
+
// off, so we disable it. This is also to keep the behaviour consistent with
|
|
139
|
+
// the rendering in the mobile Native Renderer.
|
|
140
|
+
codeBidiWarningTooltipEnabled: this.appearance !== 'mobile'
|
|
141
|
+
} : {};
|
|
132
142
|
const props = {
|
|
133
143
|
eventHandlers: this.eventHandlers,
|
|
134
144
|
fireAnalyticsEvent: this.fireAnalyticsEvent,
|
|
135
145
|
markKey: key,
|
|
136
146
|
...otherAttrs,
|
|
137
147
|
...extraProps,
|
|
148
|
+
...markSpecificProps,
|
|
138
149
|
dataAttributes: {
|
|
139
150
|
'data-renderer-mark': true
|
|
140
151
|
}
|
|
@@ -192,6 +203,9 @@ export default class ReactSerializer {
|
|
|
192
203
|
case 'mediaGroup':
|
|
193
204
|
return this.getMediaGroupProps(node);
|
|
194
205
|
|
|
206
|
+
case 'mediaInline':
|
|
207
|
+
return this.getMediaInlineProps(node);
|
|
208
|
+
|
|
195
209
|
case 'mediaSingle':
|
|
196
210
|
return this.getMediaSingleProps(node, path);
|
|
197
211
|
|
|
@@ -296,9 +310,8 @@ export default class ReactSerializer {
|
|
|
296
310
|
return /*#__PURE__*/React.createElement(TextWrapperComponent, {
|
|
297
311
|
key: textKey,
|
|
298
312
|
startPos: startPos + parentDepth,
|
|
299
|
-
endPos: endPos + parentDepth
|
|
300
|
-
|
|
301
|
-
});
|
|
313
|
+
endPos: endPos + parentDepth
|
|
314
|
+
}, mark.text);
|
|
302
315
|
}
|
|
303
316
|
|
|
304
317
|
return mark.text || '';
|
|
@@ -410,6 +423,11 @@ export default class ReactSerializer {
|
|
|
410
423
|
};
|
|
411
424
|
}
|
|
412
425
|
|
|
426
|
+
getMediaInlineProps(node) {
|
|
427
|
+
return { ...this.getProps(node)
|
|
428
|
+
};
|
|
429
|
+
}
|
|
430
|
+
|
|
413
431
|
getTaskItemProps(node, path = []) {
|
|
414
432
|
return { ...this.getProps(node, path),
|
|
415
433
|
disabled: this.disableActions
|
|
@@ -430,8 +448,15 @@ export default class ReactSerializer {
|
|
|
430
448
|
}
|
|
431
449
|
|
|
432
450
|
getCodeBlockProps(node) {
|
|
451
|
+
// The appearance being mobile indicates we are in an renderer being
|
|
452
|
+
// rendered by mobile bridge in a web view.
|
|
453
|
+
// The tooltip is likely to have unexpected behaviour there, with being cut
|
|
454
|
+
// off, so we disable it. This is also to keep the behaviour consistent with
|
|
455
|
+
// the rendering in the mobile Native Renderer.
|
|
456
|
+
const codeBidiWarningTooltipEnabled = this.appearance !== 'mobile';
|
|
433
457
|
return { ...this.getProps(node),
|
|
434
|
-
text: node.textContent
|
|
458
|
+
text: node.textContent,
|
|
459
|
+
codeBidiWarningTooltipEnabled
|
|
435
460
|
};
|
|
436
461
|
}
|
|
437
462
|
|
|
@@ -1,8 +1,20 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import React from 'react';
|
|
3
|
+
import { injectIntl } from 'react-intl';
|
|
3
4
|
import AkCode from '@atlaskit/code/inline';
|
|
4
|
-
|
|
5
|
+
import { codeBidiWarningMessages } from '@atlaskit/editor-common/messages';
|
|
6
|
+
import { useFeatureFlags } from '../../use-feature-flags';
|
|
7
|
+
export const isCodeMark = mark => {
|
|
8
|
+
return mark && mark.type && mark.type.name === 'code';
|
|
9
|
+
};
|
|
10
|
+
export function CodeWithIntl(props) {
|
|
11
|
+
const featureFlags = useFeatureFlags();
|
|
12
|
+
const codeBidiWarningLabel = props.intl.formatMessage(codeBidiWarningMessages.label);
|
|
5
13
|
return /*#__PURE__*/React.createElement(AkCode, _extends({
|
|
6
|
-
className: "code"
|
|
14
|
+
className: "code",
|
|
15
|
+
codeBidiWarnings: featureFlags === null || featureFlags === void 0 ? void 0 : featureFlags.codeBidiWarnings,
|
|
16
|
+
codeBidiWarningLabel: codeBidiWarningLabel,
|
|
17
|
+
codeBidiWarningTooltipEnabled: props.codeBidiWarningTooltipEnabled
|
|
7
18
|
}, props.dataAttributes), props.children);
|
|
8
|
-
}
|
|
19
|
+
}
|
|
20
|
+
export default injectIntl(CodeWithIntl);
|
|
@@ -1,18 +1,24 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { injectIntl } from 'react-intl';
|
|
2
3
|
import styled from 'styled-components';
|
|
3
4
|
import { CodeBlock as AkCodeBlock } from '@atlaskit/code';
|
|
4
5
|
import { overflowShadow, relativeFontSizeToBase16 } from '@atlaskit/editor-shared-styles';
|
|
5
6
|
import { N20, DN50 } from '@atlaskit/theme/colors';
|
|
6
7
|
import { themed } from '@atlaskit/theme/components';
|
|
7
8
|
import { fontSize, gridSize } from '@atlaskit/theme/constants';
|
|
9
|
+
import { codeBidiWarningMessages } from '@atlaskit/editor-common/messages';
|
|
10
|
+
import { useFeatureFlags } from '../../use-feature-flags';
|
|
8
11
|
import CopyButton from './codeBlockCopyButton';
|
|
9
12
|
|
|
10
13
|
function CodeBlock(props) {
|
|
11
14
|
const {
|
|
12
15
|
text,
|
|
13
16
|
language,
|
|
14
|
-
allowCopyToClipboard = false
|
|
17
|
+
allowCopyToClipboard = false,
|
|
18
|
+
codeBidiWarningTooltipEnabled
|
|
15
19
|
} = props;
|
|
20
|
+
const featureFlags = useFeatureFlags();
|
|
21
|
+
const codeBidiWarningLabel = props.intl.formatMessage(codeBidiWarningMessages.label);
|
|
16
22
|
const className = ['code-block', props.className].join(' ');
|
|
17
23
|
return /*#__PURE__*/React.createElement("div", {
|
|
18
24
|
className: className
|
|
@@ -20,11 +26,15 @@ function CodeBlock(props) {
|
|
|
20
26
|
content: text
|
|
21
27
|
}) : null, /*#__PURE__*/React.createElement(AkCodeBlock, {
|
|
22
28
|
language: language,
|
|
23
|
-
text: text
|
|
29
|
+
text: text,
|
|
30
|
+
codeBidiWarnings: featureFlags === null || featureFlags === void 0 ? void 0 : featureFlags.codeBidiWarnings,
|
|
31
|
+
codeBidiWarningLabel: codeBidiWarningLabel,
|
|
32
|
+
codeBidiWarningTooltipEnabled: codeBidiWarningTooltipEnabled
|
|
24
33
|
}));
|
|
25
34
|
}
|
|
26
35
|
|
|
27
|
-
|
|
36
|
+
const IntlCodeBlock = injectIntl(CodeBlock);
|
|
37
|
+
export default styled(IntlCodeBlock)`
|
|
28
38
|
tab-size: 4;
|
|
29
39
|
[data-ds--code--code-block] {
|
|
30
40
|
font-size: ${relativeFontSizeToBase16(fontSize())};
|
|
@@ -66,8 +66,7 @@ class HeadingAnchor extends React.PureComponent {
|
|
|
66
66
|
_defineProperty(this, "renderAnchorButton", () => {
|
|
67
67
|
return /*#__PURE__*/React.createElement(CopyAnchorButton, {
|
|
68
68
|
onMouseLeave: this.resetMessage,
|
|
69
|
-
onClick: this.copyToClipboard
|
|
70
|
-
"aria-label": this.state.tooltipMessage
|
|
69
|
+
onClick: this.copyToClipboard
|
|
71
70
|
}, /*#__PURE__*/React.createElement(LinkIcon, {
|
|
72
71
|
label: "copy",
|
|
73
72
|
size: this.props.level > 3 ? 'small' : 'medium',
|
|
@@ -39,11 +39,9 @@ function Heading(props) {
|
|
|
39
39
|
const showAnchorLink = !!props.showAnchorLink;
|
|
40
40
|
const isRightAligned = hasRightAlignmentMark(marks);
|
|
41
41
|
const enableNestedHeaderLinks = allowHeadingAnchorLinks && allowHeadingAnchorLinks.allowNestedHeaderLinks;
|
|
42
|
-
return /*#__PURE__*/React.createElement(
|
|
43
|
-
className: `heading-wrapper ${HX}`
|
|
44
|
-
}, /*#__PURE__*/React.createElement(HX, _extends({
|
|
42
|
+
return /*#__PURE__*/React.createElement(HX, _extends({
|
|
45
43
|
id: headingId
|
|
46
|
-
}, dataAttributes), /*#__PURE__*/React.createElement(React.Fragment, null, showAnchorLink && isRightAligned ? WrapChildTextInSpan(props.children) : props.children
|
|
44
|
+
}, dataAttributes), /*#__PURE__*/React.createElement(React.Fragment, null, showAnchorLink && isRightAligned ? WrapChildTextInSpan(props.children) : props.children, showAnchorLink && /*#__PURE__*/React.createElement(CopyTextConsumer, null, ({
|
|
47
45
|
copyTextToClipboard
|
|
48
46
|
}) => {
|
|
49
47
|
return headingId && /*#__PURE__*/React.createElement(AnalyticsContext.Consumer, null, ({
|
|
@@ -61,7 +59,7 @@ function Heading(props) {
|
|
|
61
59
|
return copyTextToClipboard(getCurrentUrlWithHash(headingId));
|
|
62
60
|
}
|
|
63
61
|
}));
|
|
64
|
-
}));
|
|
62
|
+
})));
|
|
65
63
|
}
|
|
66
64
|
|
|
67
65
|
export default Heading;
|
|
@@ -85,6 +85,12 @@ const MediaGroup = Loadable({
|
|
|
85
85
|
'./mediaGroup').then(mod => mod.default),
|
|
86
86
|
loading: () => null
|
|
87
87
|
});
|
|
88
|
+
const MediaInline = Loadable({
|
|
89
|
+
loader: () => import(
|
|
90
|
+
/* webpackChunkName: "@atlaskit-internal_renderer-node_MediaInline" */
|
|
91
|
+
'./mediaInline').then(mod => mod.default),
|
|
92
|
+
loading: () => null
|
|
93
|
+
});
|
|
88
94
|
const Mention = Loadable({
|
|
89
95
|
loader: () => import(
|
|
90
96
|
/* webpackChunkName: "@atlaskit-internal_renderer-node_Mention" */
|
|
@@ -119,6 +125,7 @@ export const nodeToReact = {
|
|
|
119
125
|
listItem: ListItem,
|
|
120
126
|
media: Media,
|
|
121
127
|
mediaGroup: MediaGroup,
|
|
128
|
+
mediaInline: MediaInline,
|
|
122
129
|
mediaSingle: MediaSingle,
|
|
123
130
|
mention: Mention,
|
|
124
131
|
orderedList: OrderedList,
|
|
@@ -278,4 +285,4 @@ const isEmojiBlock = pnode => {
|
|
|
278
285
|
return emojiCount > 0;
|
|
279
286
|
};
|
|
280
287
|
|
|
281
|
-
export { Blockquote, BodiedExtension, BulletList, BlockCard, Caption, CodeBlock, Date, DecisionItem, DecisionList, Doc, DocWithSelectAllTrap, Emoji, Extension, Expand, HardBreak, Heading, ListItem, InlineCard, InlineExtension, LayoutSection, LayoutColumn, Media, MediaGroup, MediaSingle, Mention, OrderedList, Panel, Paragraph, Placeholder, Rule, Status, TaskItem, TaskList, Table, TableCell, TableRow, UnknownBlock, EmbedCard };
|
|
288
|
+
export { Blockquote, BodiedExtension, BulletList, BlockCard, Caption, CodeBlock, Date, DecisionItem, DecisionList, Doc, DocWithSelectAllTrap, Emoji, Extension, Expand, HardBreak, Heading, ListItem, InlineCard, InlineExtension, LayoutSection, LayoutColumn, Media, MediaGroup, MediaInline, MediaSingle, Mention, OrderedList, Panel, Paragraph, Placeholder, Rule, Status, TaskItem, TaskList, Table, TableCell, TableRow, UnknownBlock, EmbedCard };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import { MediaInlineCard } from '@atlaskit/media-card';
|
|
3
|
+
import { WithProviders } from '@atlaskit/editor-common';
|
|
4
|
+
export const RenderMediaInline = props => {
|
|
5
|
+
const {
|
|
6
|
+
mediaProvider
|
|
7
|
+
} = props;
|
|
8
|
+
const [viewMediaClientConfigState, setViewMediaClientConfigState] = useState({});
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
updateViewMediaClientConfigState(mediaProvider);
|
|
11
|
+
}, [mediaProvider]);
|
|
12
|
+
|
|
13
|
+
const updateViewMediaClientConfigState = async mediaProvider => {
|
|
14
|
+
if (mediaProvider) {
|
|
15
|
+
const mediaClientConfig = await mediaProvider;
|
|
16
|
+
setViewMediaClientConfigState(mediaClientConfig.viewMediaClientConfig);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
return /*#__PURE__*/React.createElement(MediaInlineCard, {
|
|
21
|
+
identifier: props.identifier,
|
|
22
|
+
shouldOpenMediaViewer: true,
|
|
23
|
+
mediaClientConfig: viewMediaClientConfigState
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const MediaInline = props => {
|
|
28
|
+
const {
|
|
29
|
+
collection,
|
|
30
|
+
id,
|
|
31
|
+
providers
|
|
32
|
+
} = props;
|
|
33
|
+
const identifier = {
|
|
34
|
+
id,
|
|
35
|
+
mediaItemType: 'file',
|
|
36
|
+
collectionName: collection
|
|
37
|
+
};
|
|
38
|
+
return /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement(WithProviders, {
|
|
39
|
+
providers: ['mediaProvider'],
|
|
40
|
+
providerFactory: providers,
|
|
41
|
+
renderNode: providers => {
|
|
42
|
+
const {
|
|
43
|
+
mediaProvider
|
|
44
|
+
} = providers;
|
|
45
|
+
return /*#__PURE__*/React.createElement(RenderMediaInline, {
|
|
46
|
+
identifier: identifier,
|
|
47
|
+
mediaProvider: mediaProvider
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}));
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export default MediaInline;
|
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { TextWithAnnotationDraft } from '../../ui/annotations';
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
const TextWrapper = props => {
|
|
4
5
|
const {
|
|
5
6
|
startPos,
|
|
6
7
|
endPos
|
|
7
8
|
} = props;
|
|
8
9
|
const {
|
|
9
|
-
|
|
10
|
+
children
|
|
10
11
|
} = props;
|
|
11
12
|
|
|
12
|
-
if (!
|
|
13
|
+
if (!children) {
|
|
13
14
|
return null;
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
return /*#__PURE__*/React.createElement(TextWithAnnotationDraft, {
|
|
17
|
-
text: text,
|
|
18
18
|
startPos: startPos,
|
|
19
19
|
endPos: endPos
|
|
20
|
-
});
|
|
21
|
-
}
|
|
20
|
+
}, children);
|
|
21
|
+
};
|
|
22
|
+
|
|
22
23
|
export default TextWrapper;
|
|
@@ -147,7 +147,7 @@ export class Renderer extends PureComponent {
|
|
|
147
147
|
const nextMedia = nextProps.media || {};
|
|
148
148
|
const media = this.props.media || {};
|
|
149
149
|
|
|
150
|
-
if (nextProps.portal !== this.props.portal || nextProps.appearance !== this.props.appearance || nextProps.stickyHeaders !== this.props.stickyHeaders || nextProps.disableActions !== this.props.disableActions || nextProps.allowHeadingAnchorLinks !== this.props.allowHeadingAnchorLinks || nextMedia.allowLinking !== media.allowLinking) {
|
|
150
|
+
if (nextProps.portal !== this.props.portal || nextProps.appearance !== this.props.appearance || nextProps.stickyHeaders !== this.props.stickyHeaders || nextProps.disableActions !== this.props.disableActions || nextProps.UNSAFE_allowCustomPanels !== this.props.UNSAFE_allowCustomPanels || nextProps.allowHeadingAnchorLinks !== this.props.allowHeadingAnchorLinks || nextMedia.allowLinking !== media.allowLinking) {
|
|
151
151
|
this.serializer = new ReactSerializer(this.deriveSerializerProps(nextProps));
|
|
152
152
|
}
|
|
153
153
|
}
|
|
@@ -7,7 +7,6 @@ import { tableSharedStyle, columnLayoutSharedStyle, blockquoteSharedStyles, head
|
|
|
7
7
|
import { editorFontSize, blockNodesVerticalMargin, akEditorTableToolbar, akEditorTableToolbarDark, akEditorTableBorder, akEditorTableBorderDark, akEditorTableNumberColumnWidth, gridMediumMaxWidth, akEditorFullWidthLayoutWidth, akEditorStickyHeaderZIndex, relativeFontSizeToBase16 } from '@atlaskit/editor-shared-styles';
|
|
8
8
|
import { RendererCssClassName } from '../../consts';
|
|
9
9
|
import { HeadingAnchorWrapperClassName } from '../../react/nodes/heading-anchor';
|
|
10
|
-
import { h100, h300, h400, h500, h600, h700 } from '@atlaskit/theme/typography';
|
|
11
10
|
export const FullPagePadding = 32;
|
|
12
11
|
|
|
13
12
|
const getLineHeight = fontCode => headingSizesImport[fontCode].lineHeight / headingSizesImport[fontCode].size;
|
|
@@ -38,10 +37,12 @@ const headingAnchorStyle = headingTag => css`
|
|
|
38
37
|
* The copy link button doesn't reserve space in the DOM so that
|
|
39
38
|
* the text alignment isn't impacted by the button/icon's space.
|
|
40
39
|
*/
|
|
41
|
-
|
|
42
|
-
& + .${HeadingAnchorWrapperClassName} {
|
|
40
|
+
.${HeadingAnchorWrapperClassName} {
|
|
43
41
|
position: absolute;
|
|
42
|
+
height: ${headingSizes[headingTag].lineHeight}em;
|
|
43
|
+
|
|
44
44
|
margin-left: 6px;
|
|
45
|
+
|
|
45
46
|
button {
|
|
46
47
|
padding-left: 0;
|
|
47
48
|
padding-right: 0;
|
|
@@ -58,16 +59,18 @@ const headingAnchorStyle = headingTag => css`
|
|
|
58
59
|
* @see https://caniuse.com/mdn-css_at-rules_media_hover
|
|
59
60
|
*/
|
|
60
61
|
@media (hover: hover) and (pointer: fine) {
|
|
61
|
-
|
|
62
|
+
.${HeadingAnchorWrapperClassName} {
|
|
62
63
|
> button {
|
|
63
64
|
opacity: 0;
|
|
64
65
|
transform: translate(-8px, 0px);
|
|
65
66
|
transition: opacity 0.2s ease 0s, transform 0.2s ease 0s;
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
&:hover {
|
|
71
|
+
.${HeadingAnchorWrapperClassName} > button {
|
|
72
|
+
opacity: 1;
|
|
73
|
+
transform: none !important;
|
|
71
74
|
}
|
|
72
75
|
}
|
|
73
76
|
}
|
|
@@ -93,39 +96,41 @@ const alignedHeadingAnchorStyle = ({
|
|
|
93
96
|
* container edge.
|
|
94
97
|
*/
|
|
95
98
|
.fabric-editor-block-mark:not([data-align='center'])[data-align] {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
99
|
+
> {
|
|
100
|
+
h1, h2, h3, h4, h5, h6 {
|
|
101
|
+
// Using right to left text to achieve the inverse effect
|
|
102
|
+
// of where the copy link button icon sits for left/center
|
|
103
|
+
// alignment.
|
|
104
|
+
// Although this is unorthodox it's the only approach which
|
|
105
|
+
// allows the button to sit flush against the left edge of
|
|
106
|
+
// bottom line of text.
|
|
107
|
+
direction: rtl;
|
|
108
|
+
|
|
109
|
+
// By default RTL will negatively impact the layout of special
|
|
110
|
+
// characters within the heading text, and potentially other
|
|
111
|
+
// nested inline nodes. To prevent this we insert pseudo elements
|
|
112
|
+
// containing HTML entities to retain LTR for all heading content
|
|
113
|
+
// except for the copy link button.
|
|
114
|
+
> *:not(.${HeadingAnchorWrapperClassName}):not(br) {
|
|
115
|
+
::before {
|
|
116
|
+
// Open LTR: https://www.fileformat.info/info/unicode/char/202a/index.htm
|
|
117
|
+
content: '\u202A';
|
|
118
|
+
}
|
|
119
|
+
::after {
|
|
120
|
+
// Close LTR: https://www.fileformat.info/info/unicode/char/202c/index.htm
|
|
121
|
+
content: '\u202C';
|
|
122
|
+
}
|
|
118
123
|
}
|
|
119
124
|
}
|
|
120
125
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
}
|
|
126
|
+
.${HeadingAnchorWrapperClassName} {
|
|
127
|
+
margin: 0 6px 0 0;
|
|
128
|
+
}
|
|
125
129
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
130
|
+
@media (hover: hover) and (pointer: fine) {
|
|
131
|
+
.${HeadingAnchorWrapperClassName} > button {
|
|
132
|
+
transform: translate(8px, 0px);
|
|
133
|
+
}
|
|
129
134
|
}
|
|
130
135
|
}
|
|
131
136
|
}
|
|
@@ -160,8 +165,10 @@ const tableSortableColumnStyle = ({
|
|
|
160
165
|
.${HeadingAnchorWrapperClassName} {
|
|
161
166
|
position: unset;
|
|
162
167
|
}
|
|
163
|
-
|
|
164
|
-
|
|
168
|
+
> {
|
|
169
|
+
h1, h2, h3, h4, h5, h6 {
|
|
170
|
+
margin-right: 30px;
|
|
171
|
+
}
|
|
165
172
|
}
|
|
166
173
|
`;
|
|
167
174
|
}
|
|
@@ -272,47 +279,6 @@ export const Wrapper = styled.div`
|
|
|
272
279
|
${fullPageStyles}
|
|
273
280
|
${fullWidthStyles}
|
|
274
281
|
|
|
275
|
-
div.heading-wrapper{
|
|
276
|
-
position: relative;
|
|
277
|
-
h1, h2, h3, h4, h5, h6{
|
|
278
|
-
margin-top: 0;
|
|
279
|
-
font-size: inherit;
|
|
280
|
-
}
|
|
281
|
-
&.h1 {
|
|
282
|
-
${h700};
|
|
283
|
-
margin-top: 1.667em;
|
|
284
|
-
}
|
|
285
|
-
&.h2 {
|
|
286
|
-
${h600};
|
|
287
|
-
margin-top: 1.8em;
|
|
288
|
-
}
|
|
289
|
-
&.h3 {
|
|
290
|
-
${h500};
|
|
291
|
-
margin-top: 2em;
|
|
292
|
-
}
|
|
293
|
-
&.h4 {
|
|
294
|
-
${h400};
|
|
295
|
-
margin-top: 1.357em;
|
|
296
|
-
}
|
|
297
|
-
&.h5 {
|
|
298
|
-
${h300};
|
|
299
|
-
margin-top: 1.667em;
|
|
300
|
-
}
|
|
301
|
-
&.h6 {
|
|
302
|
-
${h100};
|
|
303
|
-
margin-top: 1.455em;
|
|
304
|
-
}
|
|
305
|
-
/* show copy button on heading wrapper hover */
|
|
306
|
-
@media (hover: hover) and (pointer: fine) {
|
|
307
|
-
&:hover {
|
|
308
|
-
.${HeadingAnchorWrapperClassName} > button{
|
|
309
|
-
opacity: 1;
|
|
310
|
-
transform: none !important;
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
|
|
316
282
|
& h1 {
|
|
317
283
|
${headingAnchorStyle('h1')}
|
|
318
284
|
}
|
|
@@ -59,7 +59,7 @@ export const applyAnnotationOnText = ({
|
|
|
59
59
|
export const TextWithAnnotationDraft = ({
|
|
60
60
|
startPos,
|
|
61
61
|
endPos,
|
|
62
|
-
|
|
62
|
+
children
|
|
63
63
|
}) => {
|
|
64
64
|
const textPosition = React.useMemo(() => ({
|
|
65
65
|
start: startPos,
|
|
@@ -75,21 +75,21 @@ export const TextWithAnnotationDraft = ({
|
|
|
75
75
|
}, [nextDraftPosition, textPosition]);
|
|
76
76
|
|
|
77
77
|
if (shouldApplyAnnotationAt === false || !nextDraftPosition) {
|
|
78
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null,
|
|
78
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, children);
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
if (shouldApplyAnnotationAt === InsertDraftPosition.AROUND_TEXT) {
|
|
82
82
|
return /*#__PURE__*/React.createElement(AnnotationDraft, {
|
|
83
83
|
key: 0,
|
|
84
84
|
draftPosition: nextDraftPosition
|
|
85
|
-
},
|
|
85
|
+
}, children);
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
const offsets = calcTextSplitOffset(nextDraftPosition, textPosition,
|
|
89
|
-
const texts = splitText(
|
|
88
|
+
const offsets = calcTextSplitOffset(nextDraftPosition, textPosition, children);
|
|
89
|
+
const texts = splitText(children, offsets);
|
|
90
90
|
|
|
91
91
|
if (!texts) {
|
|
92
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null,
|
|
92
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, children);
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
const components = applyAnnotationOnText({
|
package/dist/es2019/version.json
CHANGED
package/dist/esm/react/index.js
CHANGED
|
@@ -19,6 +19,7 @@ import { getMarksByOrder, isSameMark, calcTableColumnWidths } from '@atlaskit/ed
|
|
|
19
19
|
import { getText } from '../utils';
|
|
20
20
|
import { findChildrenByType } from 'prosemirror-utils';
|
|
21
21
|
import { insideBreakoutLayout } from './renderer-node';
|
|
22
|
+
import { isCodeMark } from './marks/code';
|
|
22
23
|
|
|
23
24
|
function mergeMarks(marksAndNodes) {
|
|
24
25
|
return marksAndNodes.reduce(function (acc, markOrNode) {
|
|
@@ -144,13 +145,22 @@ var ReactSerializer = /*#__PURE__*/function () {
|
|
|
144
145
|
|
|
145
146
|
var extraProps = {
|
|
146
147
|
isInline: node === null || node === void 0 ? void 0 : node.isInline
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
var
|
|
148
|
+
}; // currently the only mark which has custom props is the code mark
|
|
149
|
+
|
|
150
|
+
var markSpecificProps = isCodeMark(mark) ? {
|
|
151
|
+
// The appearance being mobile indicates we are in an renderer being
|
|
152
|
+
// rendered by mobile bridge in a web view.
|
|
153
|
+
// The tooltip is likely to have unexpected behaviour there, with being cut
|
|
154
|
+
// off, so we disable it. This is also to keep the behaviour consistent with
|
|
155
|
+
// the rendering in the mobile Native Renderer.
|
|
156
|
+
codeBidiWarningTooltipEnabled: _this.appearance !== 'mobile'
|
|
157
|
+
} : {};
|
|
158
|
+
|
|
159
|
+
var props = _objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
150
160
|
eventHandlers: _this.eventHandlers,
|
|
151
161
|
fireAnalyticsEvent: _this.fireAnalyticsEvent,
|
|
152
162
|
markKey: key
|
|
153
|
-
}, otherAttrs), extraProps), {}, {
|
|
163
|
+
}, otherAttrs), extraProps), markSpecificProps), {}, {
|
|
154
164
|
dataAttributes: {
|
|
155
165
|
'data-renderer-mark': true
|
|
156
166
|
}
|
|
@@ -212,6 +222,9 @@ var ReactSerializer = /*#__PURE__*/function () {
|
|
|
212
222
|
case 'mediaGroup':
|
|
213
223
|
return this.getMediaGroupProps(node);
|
|
214
224
|
|
|
225
|
+
case 'mediaInline':
|
|
226
|
+
return this.getMediaInlineProps(node);
|
|
227
|
+
|
|
215
228
|
case 'mediaSingle':
|
|
216
229
|
return this.getMediaSingleProps(node, path);
|
|
217
230
|
|
|
@@ -331,9 +344,8 @@ var ReactSerializer = /*#__PURE__*/function () {
|
|
|
331
344
|
return /*#__PURE__*/React.createElement(TextWrapperComponent, {
|
|
332
345
|
key: textKey,
|
|
333
346
|
startPos: startPos + parentDepth,
|
|
334
|
-
endPos: endPos + parentDepth
|
|
335
|
-
|
|
336
|
-
});
|
|
347
|
+
endPos: endPos + parentDepth
|
|
348
|
+
}, mark.text);
|
|
337
349
|
}
|
|
338
350
|
|
|
339
351
|
return mark.text || '';
|
|
@@ -470,6 +482,11 @@ var ReactSerializer = /*#__PURE__*/function () {
|
|
|
470
482
|
enableDownloadButton: (_this$media = this.media) === null || _this$media === void 0 ? void 0 : _this$media.enableDownloadButton
|
|
471
483
|
});
|
|
472
484
|
}
|
|
485
|
+
}, {
|
|
486
|
+
key: "getMediaInlineProps",
|
|
487
|
+
value: function getMediaInlineProps(node) {
|
|
488
|
+
return _objectSpread({}, this.getProps(node));
|
|
489
|
+
}
|
|
473
490
|
}, {
|
|
474
491
|
key: "getTaskItemProps",
|
|
475
492
|
value: function getTaskItemProps(node) {
|
|
@@ -496,8 +513,15 @@ var ReactSerializer = /*#__PURE__*/function () {
|
|
|
496
513
|
}, {
|
|
497
514
|
key: "getCodeBlockProps",
|
|
498
515
|
value: function getCodeBlockProps(node) {
|
|
516
|
+
// The appearance being mobile indicates we are in an renderer being
|
|
517
|
+
// rendered by mobile bridge in a web view.
|
|
518
|
+
// The tooltip is likely to have unexpected behaviour there, with being cut
|
|
519
|
+
// off, so we disable it. This is also to keep the behaviour consistent with
|
|
520
|
+
// the rendering in the mobile Native Renderer.
|
|
521
|
+
var codeBidiWarningTooltipEnabled = this.appearance !== 'mobile';
|
|
499
522
|
return _objectSpread(_objectSpread({}, this.getProps(node)), {}, {
|
|
500
|
-
text: node.textContent
|
|
523
|
+
text: node.textContent,
|
|
524
|
+
codeBidiWarningTooltipEnabled: codeBidiWarningTooltipEnabled
|
|
501
525
|
});
|
|
502
526
|
}
|
|
503
527
|
}, {
|
|
@@ -1,8 +1,20 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import React from 'react';
|
|
3
|
+
import { injectIntl } from 'react-intl';
|
|
3
4
|
import AkCode from '@atlaskit/code/inline';
|
|
4
|
-
|
|
5
|
+
import { codeBidiWarningMessages } from '@atlaskit/editor-common/messages';
|
|
6
|
+
import { useFeatureFlags } from '../../use-feature-flags';
|
|
7
|
+
export var isCodeMark = function isCodeMark(mark) {
|
|
8
|
+
return mark && mark.type && mark.type.name === 'code';
|
|
9
|
+
};
|
|
10
|
+
export function CodeWithIntl(props) {
|
|
11
|
+
var featureFlags = useFeatureFlags();
|
|
12
|
+
var codeBidiWarningLabel = props.intl.formatMessage(codeBidiWarningMessages.label);
|
|
5
13
|
return /*#__PURE__*/React.createElement(AkCode, _extends({
|
|
6
|
-
className: "code"
|
|
14
|
+
className: "code",
|
|
15
|
+
codeBidiWarnings: featureFlags === null || featureFlags === void 0 ? void 0 : featureFlags.codeBidiWarnings,
|
|
16
|
+
codeBidiWarningLabel: codeBidiWarningLabel,
|
|
17
|
+
codeBidiWarningTooltipEnabled: props.codeBidiWarningTooltipEnabled
|
|
7
18
|
}, props.dataAttributes), props.children);
|
|
8
|
-
}
|
|
19
|
+
}
|
|
20
|
+
export default injectIntl(CodeWithIntl);
|