@atlaskit/renderer 94.0.0 → 96.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 +48 -0
- package/dist/cjs/react/index.js +0 -2
- package/dist/cjs/react/marks/link.js +3 -1
- package/dist/cjs/react/nodes/codeBlock.js +5 -0
- package/dist/cjs/react/nodes/codeBlockCopyButton.js +3 -1
- package/dist/cjs/react/nodes/embedCard.js +2 -5
- package/dist/cjs/react/nodes/heading-anchor.js +4 -2
- package/dist/cjs/react/nodes/inlineCard.js +5 -1
- package/dist/cjs/react/nodes/mediaInline.js +41 -4
- package/dist/cjs/react/nodes/mediaSingle/index.js +3 -7
- package/dist/cjs/react/nodes/table/colgroup.js +6 -12
- package/dist/cjs/react/nodes/table/sticky.js +21 -21
- package/dist/cjs/react/nodes/table/table.js +1 -3
- package/dist/cjs/react/nodes/table.js +20 -9
- package/dist/cjs/react/nodes/tableCell.js +5 -3
- package/dist/cjs/render-document.js +142 -55
- package/dist/cjs/ui/MediaCard.js +2 -2
- package/dist/cjs/ui/Renderer/breakout-ssr.js +6 -8
- package/dist/cjs/ui/Renderer/index.js +22 -34
- package/dist/cjs/ui/Renderer/style.js +30 -28
- package/dist/cjs/ui/Renderer/truncated-wrapper.js +6 -3
- package/dist/cjs/ui/SortingIcon.js +6 -2
- package/dist/cjs/ui/annotations/draft/component.js +1 -1
- package/dist/cjs/ui/annotations/element/mark.js +1 -1
- package/dist/cjs/ui/annotations/hooks/use-events.js +4 -2
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/react/index.js +0 -2
- package/dist/es2019/react/marks/link.js +8 -3
- package/dist/es2019/react/nodes/codeBlock.js +5 -0
- package/dist/es2019/react/nodes/codeBlockCopyButton.js +7 -6
- package/dist/es2019/react/nodes/embedCard.js +4 -7
- package/dist/es2019/react/nodes/heading-anchor.js +3 -2
- package/dist/es2019/react/nodes/inlineCard.js +4 -1
- package/dist/es2019/react/nodes/mediaInline.js +36 -4
- package/dist/es2019/react/nodes/mediaSingle/index.js +5 -9
- package/dist/es2019/react/nodes/table/colgroup.js +2 -8
- package/dist/es2019/react/nodes/table/sticky.js +30 -28
- package/dist/es2019/react/nodes/table/table.js +1 -3
- package/dist/es2019/react/nodes/table.js +18 -9
- package/dist/es2019/react/nodes/tableCell.js +4 -1
- package/dist/es2019/render-document.js +117 -56
- package/dist/es2019/ui/MediaCard.js +1 -1
- package/dist/es2019/ui/Renderer/breakout-ssr.js +6 -8
- package/dist/es2019/ui/Renderer/index.js +6 -19
- package/dist/es2019/ui/Renderer/style.js +50 -32
- package/dist/es2019/ui/Renderer/truncated-wrapper.js +5 -3
- package/dist/es2019/ui/SortingIcon.js +7 -5
- package/dist/es2019/ui/annotations/draft/component.js +1 -1
- package/dist/es2019/ui/annotations/element/mark.js +1 -1
- package/dist/es2019/ui/annotations/hooks/use-events.js +2 -2
- package/dist/es2019/version.json +1 -1
- package/dist/esm/react/index.js +0 -2
- package/dist/esm/react/marks/link.js +3 -2
- package/dist/esm/react/nodes/codeBlock.js +5 -0
- package/dist/esm/react/nodes/codeBlockCopyButton.js +2 -1
- package/dist/esm/react/nodes/embedCard.js +4 -7
- package/dist/esm/react/nodes/heading-anchor.js +3 -2
- package/dist/esm/react/nodes/inlineCard.js +4 -1
- package/dist/esm/react/nodes/mediaInline.js +36 -4
- package/dist/esm/react/nodes/mediaSingle/index.js +5 -9
- package/dist/esm/react/nodes/table/colgroup.js +6 -12
- package/dist/esm/react/nodes/table/sticky.js +20 -22
- package/dist/esm/react/nodes/table/table.js +1 -3
- package/dist/esm/react/nodes/table.js +20 -9
- package/dist/esm/react/nodes/tableCell.js +5 -3
- package/dist/esm/render-document.js +137 -55
- package/dist/esm/ui/MediaCard.js +1 -1
- package/dist/esm/ui/Renderer/breakout-ssr.js +6 -8
- package/dist/esm/ui/Renderer/index.js +21 -33
- package/dist/esm/ui/Renderer/style.js +30 -28
- package/dist/esm/ui/Renderer/truncated-wrapper.js +5 -3
- package/dist/esm/ui/SortingIcon.js +5 -3
- package/dist/esm/ui/annotations/draft/component.js +1 -1
- package/dist/esm/ui/annotations/element/mark.js +1 -1
- package/dist/esm/ui/annotations/hooks/use-events.js +4 -2
- package/dist/esm/version.json +1 -1
- package/dist/types/react/index.d.ts +0 -2
- package/dist/types/react/nodes/embedCard.d.ts +0 -1
- package/dist/types/react/nodes/extension.d.ts +6 -0
- package/dist/types/react/nodes/index.d.ts +1 -2
- package/dist/types/react/nodes/media.d.ts +0 -1
- package/dist/types/react/nodes/mediaInline.d.ts +6 -3
- package/dist/types/react/nodes/mediaSingle/index.d.ts +0 -1
- package/dist/types/react/nodes/table/sticky.d.ts +1 -2
- package/dist/types/react/nodes/table/table.d.ts +1 -1
- package/dist/types/react/nodes/table/types.d.ts +0 -1
- package/dist/types/react/types.d.ts +0 -1
- package/dist/types/render-document.d.ts +1 -1
- package/dist/types/renderer-context.d.ts +1 -0
- package/dist/types/ui/MediaCard.d.ts +1 -1
- package/dist/types/ui/Renderer/breakout-ssr.d.ts +2 -4
- package/dist/types/ui/renderer-props.d.ts +1 -0
- package/package.json +27 -20
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import memoizeOne from 'memoize-one';
|
|
1
2
|
import { defaultSchema } from '@atlaskit/adf-schema/schema-default';
|
|
2
3
|
import { getValidDocument } from '@atlaskit/editor-common/validator';
|
|
3
4
|
import { validateADFEntity, findAndTrackUnsupportedContentNodes } from '@atlaskit/editor-common/utils';
|
|
4
5
|
import { ACTION, ACTION_SUBJECT, EVENT_TYPE } from './analytics/enums';
|
|
5
6
|
import { PLATFORM } from './analytics/events';
|
|
6
7
|
import { trackUnsupportedContentLevels } from './analytics/unsupported-content';
|
|
7
|
-
import { transformMediaLinkMarks } from '@atlaskit/adf-utils';
|
|
8
|
+
import { transformMediaLinkMarks } from '@atlaskit/adf-utils/transforms';
|
|
8
9
|
const SUPPORTS_HIRES_TIMER_API = !!(window.performance && performance.now);
|
|
9
10
|
|
|
10
11
|
const withStopwatch = cb => {
|
|
@@ -18,6 +19,116 @@ const withStopwatch = cb => {
|
|
|
18
19
|
};
|
|
19
20
|
};
|
|
20
21
|
|
|
22
|
+
const _validation = (doc, schema, adfStage, useSpecBasedValidator, dispatchAnalyticsEvent) => {
|
|
23
|
+
let result;
|
|
24
|
+
|
|
25
|
+
if (useSpecBasedValidator) {
|
|
26
|
+
// link mark on mediaSingle is deprecated, need to move link mark to child media node
|
|
27
|
+
// https://product-fabric.atlassian.net/browse/ED-14043
|
|
28
|
+
const {
|
|
29
|
+
transformedAdf,
|
|
30
|
+
isTransformed
|
|
31
|
+
} = transformMediaLinkMarks(doc);
|
|
32
|
+
|
|
33
|
+
if (isTransformed && dispatchAnalyticsEvent) {
|
|
34
|
+
dispatchAnalyticsEvent({
|
|
35
|
+
action: ACTION.MEDIA_LINK_TRANSFORMED,
|
|
36
|
+
actionSubject: ACTION_SUBJECT.RENDERER,
|
|
37
|
+
eventType: EVENT_TYPE.OPERATIONAL
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
result = validateADFEntity(schema, transformedAdf || doc, dispatchAnalyticsEvent);
|
|
42
|
+
} else {
|
|
43
|
+
result = getValidDocument(doc, schema, adfStage);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (!result) {
|
|
47
|
+
return result;
|
|
48
|
+
} // ProseMirror always require a child under doc
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
if (result.type === 'doc' && useSpecBasedValidator) {
|
|
52
|
+
if (Array.isArray(result.content) && result.content.length === 0) {
|
|
53
|
+
result.content.push({
|
|
54
|
+
type: 'paragraph',
|
|
55
|
+
content: []
|
|
56
|
+
});
|
|
57
|
+
} // Just making sure doc is always valid
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
if (!result.version) {
|
|
61
|
+
result.version = 1;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return result;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const memoValidation = memoizeOne(_validation, (newArgs, lastArgs) => {
|
|
69
|
+
const [newDoc, newSchema, newADFStage, newUseSpecValidator] = newArgs;
|
|
70
|
+
const [oldDoc, oldSchema, oldADFStage, oldUseSpecValidator] = lastArgs; // we're ignoring changes to dispatchAnalyticsEvent in this check
|
|
71
|
+
|
|
72
|
+
const result = areDocsEqual(newDoc, oldDoc) && newSchema === oldSchema && newADFStage === oldADFStage && newUseSpecValidator === oldUseSpecValidator;
|
|
73
|
+
return result;
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
const areDocsEqual = (docA, docB) => {
|
|
77
|
+
if (docA === docB) {
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (typeof docA === 'string' && typeof docB === 'string') {
|
|
82
|
+
return docA === docB;
|
|
83
|
+
} // PMNode
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
if (docA.type && docA.toJSON && docB.type && docB.toJSON) {
|
|
87
|
+
return JSON.stringify(docA.toJSON()) === JSON.stringify(docB.toJSON());
|
|
88
|
+
} // Object
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
return JSON.stringify(docA) === JSON.stringify(docB);
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
const _serializeFragment = (serializer, doc) => {
|
|
95
|
+
return serializer.serializeFragment(doc.content);
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
const memoSerializeFragment = memoizeOne(_serializeFragment, (newArgs, lastArgs) => {
|
|
99
|
+
const [newSerializer, newDoc] = newArgs;
|
|
100
|
+
const [oldSerializer, oldDoc] = lastArgs;
|
|
101
|
+
return newSerializer === oldSerializer && areDocsEqual(newDoc, oldDoc);
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
const _createNodeAndCheck = (schema, doc, dispatchAnalyticsEvent) => {
|
|
105
|
+
const pmNode = schema.nodeFromJSON(doc);
|
|
106
|
+
|
|
107
|
+
try {
|
|
108
|
+
pmNode.check();
|
|
109
|
+
} catch (err) {
|
|
110
|
+
if (dispatchAnalyticsEvent) {
|
|
111
|
+
dispatchAnalyticsEvent({
|
|
112
|
+
action: ACTION.INVALID_PROSEMIRROR_DOCUMENT,
|
|
113
|
+
actionSubject: ACTION_SUBJECT.RENDERER,
|
|
114
|
+
attributes: {
|
|
115
|
+
platform: PLATFORM.WEB,
|
|
116
|
+
error: err === null || err === void 0 ? void 0 : err.toString()
|
|
117
|
+
},
|
|
118
|
+
eventType: EVENT_TYPE.OPERATIONAL
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return pmNode;
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
const memoCreateNodeAndCheck = memoizeOne(_createNodeAndCheck, (newArgs, lastArgs) => {
|
|
127
|
+
// ignore dispatchAnalyticsEvent
|
|
128
|
+
const [newSchema, newDoc] = newArgs;
|
|
129
|
+
const [oldSchema, oldDoc] = lastArgs;
|
|
130
|
+
return newSchema === oldSchema && areDocsEqual(newDoc, oldDoc);
|
|
131
|
+
});
|
|
21
132
|
export const renderDocument = (doc, serializer, schema = defaultSchema, adfStage = 'final', useSpecBasedValidator = false, rendererId = 'noid', dispatchAnalyticsEvent, unsupportedContentLevelsTracking, appearance) => {
|
|
22
133
|
const stat = {
|
|
23
134
|
sanitizeTime: 0
|
|
@@ -26,26 +137,7 @@ export const renderDocument = (doc, serializer, schema = defaultSchema, adfStage
|
|
|
26
137
|
output: validDoc,
|
|
27
138
|
time: sanitizeTime
|
|
28
139
|
} = withStopwatch(() => {
|
|
29
|
-
|
|
30
|
-
// link mark on mediaSingle is deprecated, need to move link mark to child media node
|
|
31
|
-
// https://product-fabric.atlassian.net/browse/ED-14043
|
|
32
|
-
const {
|
|
33
|
-
transformedAdf,
|
|
34
|
-
isTransformed
|
|
35
|
-
} = transformMediaLinkMarks(doc);
|
|
36
|
-
|
|
37
|
-
if (isTransformed && dispatchAnalyticsEvent) {
|
|
38
|
-
dispatchAnalyticsEvent({
|
|
39
|
-
action: ACTION.MEDIA_LINK_TRANSFORMED,
|
|
40
|
-
actionSubject: ACTION_SUBJECT.RENDERER,
|
|
41
|
-
eventType: EVENT_TYPE.OPERATIONAL
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
return validateADFEntity(schema, transformedAdf || doc, dispatchAnalyticsEvent);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
return getValidDocument(doc, schema, adfStage);
|
|
140
|
+
return memoValidation(doc, schema, adfStage, useSpecBasedValidator, dispatchAnalyticsEvent);
|
|
49
141
|
}); // save sanitize time to stats
|
|
50
142
|
|
|
51
143
|
stat.sanitizeTime = sanitizeTime;
|
|
@@ -55,53 +147,22 @@ export const renderDocument = (doc, serializer, schema = defaultSchema, adfStage
|
|
|
55
147
|
stat,
|
|
56
148
|
result: null
|
|
57
149
|
};
|
|
58
|
-
} // ProseMirror always require a child under doc
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
if (validDoc.type === 'doc' && useSpecBasedValidator) {
|
|
62
|
-
if (Array.isArray(validDoc.content) && validDoc.content.length === 0) {
|
|
63
|
-
validDoc.content.push({
|
|
64
|
-
type: 'paragraph',
|
|
65
|
-
content: []
|
|
66
|
-
});
|
|
67
|
-
} // Just making sure doc is always valid
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
if (!validDoc.version) {
|
|
71
|
-
validDoc.version = 1;
|
|
72
|
-
}
|
|
73
150
|
}
|
|
74
151
|
|
|
75
152
|
const {
|
|
76
153
|
output: node,
|
|
77
154
|
time: buildTreeTime
|
|
78
155
|
} = withStopwatch(() => {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
try {
|
|
82
|
-
pmNode.check();
|
|
83
|
-
} catch (err) {
|
|
84
|
-
if (dispatchAnalyticsEvent) {
|
|
85
|
-
dispatchAnalyticsEvent({
|
|
86
|
-
action: ACTION.INVALID_PROSEMIRROR_DOCUMENT,
|
|
87
|
-
actionSubject: ACTION_SUBJECT.RENDERER,
|
|
88
|
-
attributes: {
|
|
89
|
-
platform: PLATFORM.WEB,
|
|
90
|
-
error: err === null || err === void 0 ? void 0 : err.toString()
|
|
91
|
-
},
|
|
92
|
-
eventType: EVENT_TYPE.OPERATIONAL
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
return pmNode;
|
|
156
|
+
return memoCreateNodeAndCheck(schema, validDoc, dispatchAnalyticsEvent);
|
|
98
157
|
}); // save build tree time to stats
|
|
99
158
|
|
|
100
159
|
stat.buildTreeTime = buildTreeTime;
|
|
101
160
|
const {
|
|
102
161
|
output: result,
|
|
103
162
|
time: serializeTime
|
|
104
|
-
} = withStopwatch(() =>
|
|
163
|
+
} = withStopwatch(() => {
|
|
164
|
+
return memoSerializeFragment(serializer, node);
|
|
165
|
+
}); // save serialize tree time to stats
|
|
105
166
|
|
|
106
167
|
stat.serializeTime = serializeTime;
|
|
107
168
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import React, { Component } from 'react';
|
|
3
|
-
import { filter } from '@atlaskit/adf-utils';
|
|
3
|
+
import { filter } from '@atlaskit/adf-utils/traverse';
|
|
4
4
|
import { Card, CardLoading, CardError } from '@atlaskit/media-card';
|
|
5
5
|
import { getMediaClient } from '@atlaskit/media-client';
|
|
6
6
|
import { withImageLoader } from '@atlaskit/editor-common/utils';
|
|
@@ -7,9 +7,7 @@ import { breakoutConsts } from '@atlaskit/editor-common/utils';
|
|
|
7
7
|
* More info: https://product-fabric.atlassian.net/wiki/spaces/E/pages/1216218119/Renderer+SSR+for+Breakout+Nodes
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
export function BreakoutSSRInlineScript({
|
|
11
|
-
allowDynamicTextSizing
|
|
12
|
-
}) {
|
|
10
|
+
export function BreakoutSSRInlineScript() {
|
|
13
11
|
/**
|
|
14
12
|
* Should only inline this script while SSR,
|
|
15
13
|
* not needed on the client side.
|
|
@@ -19,7 +17,7 @@ export function BreakoutSSRInlineScript({
|
|
|
19
17
|
}
|
|
20
18
|
|
|
21
19
|
const id = Math.floor(Math.random() * (9999999999 - 9999 + 1)) + 9999;
|
|
22
|
-
const context = createBreakoutInlineScript(id
|
|
20
|
+
const context = createBreakoutInlineScript(id);
|
|
23
21
|
return /*#__PURE__*/React.createElement("script", {
|
|
24
22
|
"data-breakout-script-id": id,
|
|
25
23
|
dangerouslySetInnerHTML: {
|
|
@@ -27,11 +25,11 @@ export function BreakoutSSRInlineScript({
|
|
|
27
25
|
}
|
|
28
26
|
});
|
|
29
27
|
}
|
|
30
|
-
export function createBreakoutInlineScript(id
|
|
28
|
+
export function createBreakoutInlineScript(id) {
|
|
31
29
|
return `
|
|
32
30
|
(function(window){
|
|
33
31
|
${breakoutInlineScriptContext};
|
|
34
|
-
(${applyBreakoutAfterSSR.toString()})("${id}",
|
|
32
|
+
(${applyBreakoutAfterSSR.toString()})("${id}", breakoutConsts);
|
|
35
33
|
})(window);
|
|
36
34
|
`;
|
|
37
35
|
}
|
|
@@ -44,7 +42,7 @@ export const breakoutInlineScriptContext = `
|
|
|
44
42
|
breakoutConsts.calcWideWidth = ${breakoutConsts.calcWideWidth.toString()};
|
|
45
43
|
`;
|
|
46
44
|
|
|
47
|
-
function applyBreakoutAfterSSR(id,
|
|
45
|
+
function applyBreakoutAfterSSR(id, breakoutConsts) {
|
|
48
46
|
const MEDIA_NODE_TYPE = 'mediaSingle';
|
|
49
47
|
const WIDE_LAYOUT_MODES = ['full-width', 'wide'];
|
|
50
48
|
|
|
@@ -98,7 +96,7 @@ function applyBreakoutAfterSSR(id, allowDynamicTextSizing, breakoutConsts) {
|
|
|
98
96
|
// https://bitbucket.org/atlassian/atlassian-frontend/src/77938aee0c140d02ff99b98a03849be1236865b4/packages/editor/renderer/src/react/nodes/table.tsx#table.tsx-235:245
|
|
99
97
|
|
|
100
98
|
if (node.classList.contains('pm-table-container')) {
|
|
101
|
-
const lineLength = breakoutConsts.calcLineLength(
|
|
99
|
+
const lineLength = breakoutConsts.calcLineLength();
|
|
102
100
|
const left = lineLength / 2 - parseInt(width) / 2;
|
|
103
101
|
|
|
104
102
|
if (left < 0) {
|
|
@@ -6,7 +6,7 @@ import React, { Fragment, useContext, useLayoutEffect, useRef } from 'react';
|
|
|
6
6
|
import { jsx } from '@emotion/react';
|
|
7
7
|
import { PureComponent } from 'react';
|
|
8
8
|
import { getSchemaBasedOnStage } from '@atlaskit/adf-schema/schema-default';
|
|
9
|
-
import { reduce } from '@atlaskit/adf-utils';
|
|
9
|
+
import { reduce } from '@atlaskit/adf-utils/traverse';
|
|
10
10
|
import { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
|
|
11
11
|
import { UnsupportedBlock, BaseTheme, WidthProvider, WithCreateAnalyticsEvent, IntlErrorBoundary } from '@atlaskit/editor-common/ui';
|
|
12
12
|
import { getAnalyticsAppearance, getAnalyticsEventSeverity, getResponseEndTime, startMeasure, stopMeasure, shouldForceTracking, measureTTI } from '@atlaskit/editor-common/utils';
|
|
@@ -61,18 +61,13 @@ export class Renderer extends PureComponent {
|
|
|
61
61
|
}
|
|
62
62
|
});
|
|
63
63
|
|
|
64
|
-
_defineProperty(this, "getSchema", () => {
|
|
65
|
-
const {
|
|
66
|
-
schema,
|
|
67
|
-
adfStage
|
|
68
|
-
} = this.props;
|
|
69
|
-
|
|
64
|
+
_defineProperty(this, "getSchema", memoizeOne((schema, adfStage) => {
|
|
70
65
|
if (schema) {
|
|
71
66
|
return schema;
|
|
72
67
|
}
|
|
73
68
|
|
|
74
69
|
return getSchemaBasedOnStage(adfStage);
|
|
75
|
-
});
|
|
70
|
+
}));
|
|
76
71
|
|
|
77
72
|
_defineProperty(this, "onMouseDownEditView", () => {
|
|
78
73
|
// When the user is deselecting text on the screen by clicking, if they are clicking outside
|
|
@@ -197,7 +192,6 @@ export class Renderer extends PureComponent {
|
|
|
197
192
|
appearance: props.appearance,
|
|
198
193
|
disableHeadingIDs: props.disableHeadingIDs,
|
|
199
194
|
disableActions: props.disableActions,
|
|
200
|
-
allowDynamicTextSizing: props.allowDynamicTextSizing,
|
|
201
195
|
allowHeadingAnchorLinks: props.allowHeadingAnchorLinks,
|
|
202
196
|
allowColumnSorting: props.allowColumnSorting,
|
|
203
197
|
fireAnalyticsEvent: this.fireAnalyticsEvent,
|
|
@@ -223,7 +217,6 @@ export class Renderer extends PureComponent {
|
|
|
223
217
|
onError,
|
|
224
218
|
appearance,
|
|
225
219
|
adfStage,
|
|
226
|
-
allowDynamicTextSizing,
|
|
227
220
|
truncated,
|
|
228
221
|
maxHeight,
|
|
229
222
|
fadeOutHeight,
|
|
@@ -283,7 +276,7 @@ export class Renderer extends PureComponent {
|
|
|
283
276
|
try {
|
|
284
277
|
var _this$featureFlags, _this$featureFlags$fe, _this$featureFlags$fe2;
|
|
285
278
|
|
|
286
|
-
const schema = this.getSchema();
|
|
279
|
+
const schema = this.getSchema(this.props.schema, this.props.adfStage);
|
|
287
280
|
const {
|
|
288
281
|
result,
|
|
289
282
|
stat,
|
|
@@ -304,7 +297,6 @@ export class Renderer extends PureComponent {
|
|
|
304
297
|
}
|
|
305
298
|
}, jsx(SmartCardStorageProvider, null, jsx(RendererWrapper, {
|
|
306
299
|
appearance: appearance,
|
|
307
|
-
dynamicTextSizing: !!allowDynamicTextSizing,
|
|
308
300
|
allowNestedHeaderLinks: allowNestedHeaderLinks,
|
|
309
301
|
allowColumnSorting: allowColumnSorting,
|
|
310
302
|
allowCopyToClipboard: allowCopyToClipboard,
|
|
@@ -313,9 +305,7 @@ export class Renderer extends PureComponent {
|
|
|
313
305
|
innerRef: this.editorRef,
|
|
314
306
|
onClick: handleWrapperOnClick,
|
|
315
307
|
onMouseDown: this.onMouseDownEditView
|
|
316
|
-
}, enableSsrInlineScripts ? jsx(BreakoutSSRInlineScript, {
|
|
317
|
-
allowDynamicTextSizing: !!allowDynamicTextSizing
|
|
318
|
-
}) : null, jsx(RendererActionsInternalUpdater, {
|
|
308
|
+
}, enableSsrInlineScripts ? jsx(BreakoutSSRInlineScript, null) : null, jsx(RendererActionsInternalUpdater, {
|
|
319
309
|
doc: pmDoc,
|
|
320
310
|
schema: schema,
|
|
321
311
|
onAnalyticsEvent: this.fireAnalyticsEvent
|
|
@@ -340,7 +330,6 @@ export class Renderer extends PureComponent {
|
|
|
340
330
|
|
|
341
331
|
return jsx(RendererWrapper, {
|
|
342
332
|
appearance: appearance,
|
|
343
|
-
dynamicTextSizing: !!allowDynamicTextSizing,
|
|
344
333
|
allowCopyToClipboard: allowCopyToClipboard,
|
|
345
334
|
allowPlaceholderText: allowPlaceholderText,
|
|
346
335
|
allowColumnSorting: allowColumnSorting,
|
|
@@ -391,7 +380,6 @@ const RendererWithAnalytics = /*#__PURE__*/React.memo(props => jsx(FabricEditorA
|
|
|
391
380
|
const RendererWrapper = /*#__PURE__*/React.memo(props => {
|
|
392
381
|
const {
|
|
393
382
|
allowColumnSorting,
|
|
394
|
-
dynamicTextSizing,
|
|
395
383
|
allowNestedHeaderLinks,
|
|
396
384
|
innerRef,
|
|
397
385
|
appearance,
|
|
@@ -402,8 +390,7 @@ const RendererWrapper = /*#__PURE__*/React.memo(props => {
|
|
|
402
390
|
return jsx(WidthProvider, {
|
|
403
391
|
className: "ak-renderer-wrapper"
|
|
404
392
|
}, jsx(BaseTheme, {
|
|
405
|
-
|
|
406
|
-
baseFontSize: !dynamicTextSizing && appearance && appearance !== 'comment' ? akEditorFullPageDefaultFontSize : undefined
|
|
393
|
+
baseFontSize: appearance && appearance !== 'comment' ? akEditorFullPageDefaultFontSize : undefined
|
|
407
394
|
}, jsx("div", {
|
|
408
395
|
ref: innerRef,
|
|
409
396
|
onClick: onClick,
|
|
@@ -3,11 +3,13 @@ import { themed } from '@atlaskit/theme/components';
|
|
|
3
3
|
import { gridSize, fontFamily, fontSize, borderRadius } from '@atlaskit/theme/constants';
|
|
4
4
|
import * as colors from '@atlaskit/theme/colors';
|
|
5
5
|
import { headingSizes as headingSizesImport } from '@atlaskit/theme/typography';
|
|
6
|
+
import { token } from '@atlaskit/tokens';
|
|
6
7
|
import { tableSharedStyle, columnLayoutSharedStyle, blockquoteSharedStyles, headingsSharedStyles, ruleSharedStyles, whitespaceSharedStyles, paragraphSharedStyles, listsSharedStyles, indentationSharedStyles, blockMarksSharedStyles, mediaSingleSharedStyle, TableSharedCssClassName, tableMarginTop, codeMarkSharedStyles, shadowSharedStyle, dateSharedStyle, richMediaClassName, tasksAndDecisionsStyles, smartCardSharedStyles, tableCellPadding, textColorStyles } from '@atlaskit/editor-common/styles';
|
|
7
8
|
import { shadowClassNames } from '@atlaskit/editor-common/ui';
|
|
8
9
|
import { editorFontSize, blockNodesVerticalMargin, akEditorTableToolbar, akEditorTableToolbarDark, akEditorTableBorder, akEditorTableBorderDark, akEditorTableNumberColumnWidth, gridMediumMaxWidth, akEditorFullWidthLayoutWidth, akEditorStickyHeaderZIndex, relativeFontSizeToBase16 } from '@atlaskit/editor-shared-styles';
|
|
9
10
|
import { RendererCssClassName } from '../../consts';
|
|
10
11
|
import { HeadingAnchorWrapperClassName } from '../../react/nodes/heading-anchor';
|
|
12
|
+
import { shadowObserverClassNames } from '@atlaskit/editor-common/ui';
|
|
11
13
|
export const FullPagePadding = 32;
|
|
12
14
|
|
|
13
15
|
const getLineHeight = fontCode => headingSizesImport[fontCode].lineHeight / headingSizesImport[fontCode].size;
|
|
@@ -200,11 +202,11 @@ const tableSortableColumnStyle = ({
|
|
|
200
202
|
margin-top: 0;
|
|
201
203
|
}
|
|
202
204
|
|
|
203
|
-
> .ProseMirror-gapcursor.-right:first-
|
|
205
|
+
> .ProseMirror-gapcursor.-right:first-of-type + * {
|
|
204
206
|
margin-top: 0;
|
|
205
207
|
}
|
|
206
208
|
|
|
207
|
-
> .ProseMirror-gapcursor:first-
|
|
209
|
+
> .ProseMirror-gapcursor:first-of-type + span + * {
|
|
208
210
|
margin-top: 0;
|
|
209
211
|
}
|
|
210
212
|
|
|
@@ -213,7 +215,7 @@ const tableSortableColumnStyle = ({
|
|
|
213
215
|
outline: unset;
|
|
214
216
|
}
|
|
215
217
|
&:focus-visible {
|
|
216
|
-
border-color: ${colors.B300};
|
|
218
|
+
border-color: ${token('color.border.focused', colors.B300)};
|
|
217
219
|
}
|
|
218
220
|
}
|
|
219
221
|
|
|
@@ -288,8 +290,8 @@ export const rendererStyles = wrapperProps => theme => {
|
|
|
288
290
|
font-size: ${editorFontSize(themeProps)}px;
|
|
289
291
|
line-height: 1.5rem;
|
|
290
292
|
color: ${themed({
|
|
291
|
-
light: colors.N800,
|
|
292
|
-
dark: '#B8C7E0'
|
|
293
|
+
light: token('color.text', colors.N800),
|
|
294
|
+
dark: token('color.text', '#B8C7E0')
|
|
293
295
|
})(themeProps)};
|
|
294
296
|
|
|
295
297
|
.${RendererCssClassName.DOCUMENT}::after {
|
|
@@ -331,13 +333,17 @@ export const rendererStyles = wrapperProps => theme => {
|
|
|
331
333
|
}
|
|
332
334
|
|
|
333
335
|
& span.akActionMark {
|
|
334
|
-
color: ${colors.B400};
|
|
336
|
+
color: ${token('color.link', colors.B400)};
|
|
335
337
|
text-decoration: none;
|
|
336
338
|
|
|
337
339
|
&:hover {
|
|
338
|
-
color: ${colors.B300};
|
|
340
|
+
color: ${token('color.link', colors.B300)};
|
|
339
341
|
text-decoration: underline;
|
|
340
342
|
}
|
|
343
|
+
|
|
344
|
+
&:active {
|
|
345
|
+
color: ${token('color.link.pressed', colors.B500)};
|
|
346
|
+
}
|
|
341
347
|
}
|
|
342
348
|
|
|
343
349
|
& span.akActionMark {
|
|
@@ -373,13 +379,13 @@ export const rendererStyles = wrapperProps => theme => {
|
|
|
373
379
|
|
|
374
380
|
& span.date-node {
|
|
375
381
|
background: ${themed({
|
|
376
|
-
light: colors.N30A,
|
|
377
|
-
dark: colors.DN70
|
|
382
|
+
light: token('color.background.neutral', colors.N30A),
|
|
383
|
+
dark: token('color.background.neutral', colors.DN70)
|
|
378
384
|
})(themeProps)};
|
|
379
385
|
border-radius: ${borderRadius()}px;
|
|
380
386
|
color: ${themed({
|
|
381
|
-
light: colors.N800,
|
|
382
|
-
dark: colors.DN600
|
|
387
|
+
light: token('color.text', colors.N800),
|
|
388
|
+
dark: token('color.text', colors.DN600)
|
|
383
389
|
})(themeProps)};
|
|
384
390
|
padding: 2px 4px;
|
|
385
391
|
margin: 0 1px;
|
|
@@ -387,8 +393,8 @@ export const rendererStyles = wrapperProps => theme => {
|
|
|
387
393
|
}
|
|
388
394
|
|
|
389
395
|
& span.date-node-highlighted {
|
|
390
|
-
background: ${colors.R50};
|
|
391
|
-
color: ${colors.R500};
|
|
396
|
+
background: ${token('color.background.danger', colors.R50)};
|
|
397
|
+
color: ${token('color.text.danger', colors.R500)};
|
|
392
398
|
}
|
|
393
399
|
|
|
394
400
|
& .renderer-image {
|
|
@@ -464,6 +470,11 @@ export const rendererStyles = wrapperProps => theme => {
|
|
|
464
470
|
.${TableSharedCssClassName.TABLE_NODE_WRAPPER} {
|
|
465
471
|
overflow-x: auto;
|
|
466
472
|
}
|
|
473
|
+
|
|
474
|
+
.${shadowObserverClassNames.SHADOW_CONTAINER}
|
|
475
|
+
.${TableSharedCssClassName.TABLE_NODE_WRAPPER} {
|
|
476
|
+
display: flex;
|
|
477
|
+
}
|
|
467
478
|
}
|
|
468
479
|
|
|
469
480
|
${tableSharedStyle(themeProps)}
|
|
@@ -481,6 +492,13 @@ export const rendererStyles = wrapperProps => theme => {
|
|
|
481
492
|
z-index: ${akEditorStickyHeaderZIndex};
|
|
482
493
|
}
|
|
483
494
|
|
|
495
|
+
&
|
|
496
|
+
.${shadowObserverClassNames.SENTINEL_LEFT},
|
|
497
|
+
&
|
|
498
|
+
.${shadowObserverClassNames.SENTINEL_RIGHT} {
|
|
499
|
+
height: calc(100% - ${tableMarginTop}px);
|
|
500
|
+
}
|
|
501
|
+
|
|
484
502
|
/**
|
|
485
503
|
* A hack for making all the <th /> heights equal in case some have shorter
|
|
486
504
|
* content than others.
|
|
@@ -494,7 +512,7 @@ export const rendererStyles = wrapperProps => theme => {
|
|
|
494
512
|
margin-right: 0;
|
|
495
513
|
}
|
|
496
514
|
|
|
497
|
-
table tr:first-
|
|
515
|
+
table tr:first-of-type {
|
|
498
516
|
height: 100%;
|
|
499
517
|
|
|
500
518
|
td,
|
|
@@ -506,19 +524,19 @@ export const rendererStyles = wrapperProps => theme => {
|
|
|
506
524
|
table[data-number-column='true'] {
|
|
507
525
|
.${RendererCssClassName.NUMBER_COLUMN} {
|
|
508
526
|
background-color: ${themed({
|
|
509
|
-
light: akEditorTableToolbar,
|
|
510
|
-
dark: akEditorTableToolbarDark
|
|
527
|
+
light: token('color.background.neutral', akEditorTableToolbar),
|
|
528
|
+
dark: token('color.background.neutral', akEditorTableToolbarDark)
|
|
511
529
|
})(themeProps)};
|
|
512
530
|
border-right: 1px solid
|
|
513
531
|
${themed({
|
|
514
|
-
light: akEditorTableBorder,
|
|
515
|
-
dark: akEditorTableBorderDark
|
|
532
|
+
light: token('color.border', akEditorTableBorder),
|
|
533
|
+
dark: token('color.border', akEditorTableBorderDark)
|
|
516
534
|
})(themeProps)};
|
|
517
535
|
width: ${akEditorTableNumberColumnWidth}px;
|
|
518
536
|
text-align: center;
|
|
519
537
|
color: ${themed({
|
|
520
|
-
light: colors.N200,
|
|
521
|
-
dark: colors.DN400
|
|
538
|
+
light: token('color.text.subtlest', colors.N200),
|
|
539
|
+
dark: token('color.text.subtlest', colors.DN400)
|
|
522
540
|
})(themeProps)};
|
|
523
541
|
font-size: ${relativeFontSizeToBase16(fontSize())};
|
|
524
542
|
}
|
|
@@ -537,13 +555,13 @@ export const rendererStyles = wrapperProps => theme => {
|
|
|
537
555
|
|
|
538
556
|
border-right: 1px solid
|
|
539
557
|
${themed({
|
|
540
|
-
light: akEditorTableBorder,
|
|
541
|
-
dark: akEditorTableBorderDark
|
|
558
|
+
light: token('color.border', akEditorTableBorder),
|
|
559
|
+
dark: token('color.border', akEditorTableBorderDark)
|
|
542
560
|
})(themeProps)};
|
|
543
561
|
border-bottom: 1px solid
|
|
544
562
|
${themed({
|
|
545
|
-
light: akEditorTableBorder,
|
|
546
|
-
dark: akEditorTableBorderDark
|
|
563
|
+
light: token('color.border', akEditorTableBorder),
|
|
564
|
+
dark: token('color.border', akEditorTableBorderDark)
|
|
547
565
|
})(themeProps)};
|
|
548
566
|
|
|
549
567
|
/* this is to compensate for the table border */
|
|
@@ -569,20 +587,20 @@ export const rendererStyles = wrapperProps => theme => {
|
|
|
569
587
|
.sticky td {
|
|
570
588
|
box-shadow: 0px 1px
|
|
571
589
|
${themed({
|
|
572
|
-
light: akEditorTableBorder,
|
|
573
|
-
dark: akEditorTableBorderDark
|
|
590
|
+
light: token('color.border', akEditorTableBorder),
|
|
591
|
+
dark: token('color.border', akEditorTableBorderDark)
|
|
574
592
|
})(themeProps)},
|
|
575
593
|
0px -0.5px ${themed({
|
|
576
|
-
light: akEditorTableBorder,
|
|
577
|
-
dark: akEditorTableBorderDark
|
|
594
|
+
light: token('color.border', akEditorTableBorder),
|
|
595
|
+
dark: token('color.border', akEditorTableBorderDark)
|
|
578
596
|
})(themeProps)},
|
|
579
597
|
inset -1px 0px ${themed({
|
|
580
|
-
light: akEditorTableToolbar,
|
|
581
|
-
dark: akEditorTableToolbarDark
|
|
598
|
+
light: token('color.border', akEditorTableToolbar),
|
|
599
|
+
dark: token('color.border', akEditorTableToolbarDark)
|
|
582
600
|
})(themeProps)},
|
|
583
601
|
0px -1px ${themed({
|
|
584
|
-
light: akEditorTableToolbar,
|
|
585
|
-
dark: akEditorTableToolbarDark
|
|
602
|
+
light: token('color.border', akEditorTableToolbar),
|
|
603
|
+
dark: token('color.border', akEditorTableToolbarDark)
|
|
586
604
|
})(themeProps)};
|
|
587
605
|
}
|
|
588
606
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
2
|
import { css, jsx } from '@emotion/react';
|
|
3
3
|
import { Component } from 'react';
|
|
4
|
+
import { token } from '@atlaskit/tokens';
|
|
4
5
|
|
|
5
6
|
const fadeOutStyles = (maxHeight, top, backgroundColor) => css`
|
|
6
7
|
position: relative;
|
|
@@ -14,7 +15,7 @@ const fadeOutStyles = (maxHeight, top, backgroundColor) => css`
|
|
|
14
15
|
left: 0;
|
|
15
16
|
right: 0;
|
|
16
17
|
background-image: linear-gradient(
|
|
17
|
-
rgba(255, 255, 255, 0),
|
|
18
|
+
${token('color.background.neutral.subtle', 'rgba(255, 255, 255, 0)')},
|
|
18
19
|
${backgroundColor}
|
|
19
20
|
);
|
|
20
21
|
}
|
|
@@ -37,13 +38,14 @@ const FadeOut = props => {
|
|
|
37
38
|
export class TruncatedWrapper extends Component {
|
|
38
39
|
constructor(props) {
|
|
39
40
|
super(props);
|
|
40
|
-
}
|
|
41
|
+
} // TODO: Quality ticket as elevation.surface will be issue when sits top of modal. https://product-fabric.atlassian.net/browse/DSP-4123
|
|
42
|
+
|
|
41
43
|
|
|
42
44
|
render() {
|
|
43
45
|
const {
|
|
44
46
|
height = 95,
|
|
45
47
|
fadeHeight = 24,
|
|
46
|
-
backgroundColor = 'white',
|
|
48
|
+
backgroundColor = token('elevation.surface', 'white'),
|
|
47
49
|
children
|
|
48
50
|
} = this.props;
|
|
49
51
|
return jsx(FadeOut, {
|
|
@@ -5,13 +5,15 @@ import { gridSize } from '@atlaskit/theme/constants';
|
|
|
5
5
|
import { N20, N30 } from '@atlaskit/theme/colors';
|
|
6
6
|
import { SortOrder } from '@atlaskit/editor-common/types';
|
|
7
7
|
import { sortingIconMessages } from '../messages';
|
|
8
|
-
import { injectIntl } from 'react-intl-next';
|
|
8
|
+
import { injectIntl } from 'react-intl-next';
|
|
9
|
+
import { token } from '@atlaskit/tokens'; // We use data url here because of this issue:
|
|
9
10
|
// https://product-fabric.atlassian.net/browse/ED-8001
|
|
10
11
|
// Remove this workaround if Firefox has fixed: https://bugzilla.mozilla.org/show_bug.cgi?id=1664350
|
|
12
|
+
// TODO: Quality ticket: https://product-fabric.atlassian.net/browse/DSP-4136
|
|
11
13
|
|
|
12
14
|
export const TableSortIconDataUrl = `data:image/svg+xml;utf8,${encodeURIComponent(`<svg xmlns="http://www.w3.org/2000/svg"><g fill="none" fill-rule="evenodd"><path d="M-8-6h24v24H-8z"></path><path d="M3 8.509V1c0-.552.449-1 1-1 .552 0 1 .448 1 1V8.51l1.217-1.206a1.05 1.05 0 011.477 0 1.03 1.03 0 01.004 1.463l-.003.002-2.956 2.93a1.053 1.053 0 01-1.478 0L.305 8.767a1.03 1.03 0 01.001-1.464 1.05 1.05 0 011.477 0L3 8.508z" fill="#42526E"></path></g></svg>`)}`;
|
|
13
15
|
const TABLE_SORTING_ICON_CLASS = 'table-sorting-icon';
|
|
14
|
-
export let StatusClassNames;
|
|
16
|
+
export let StatusClassNames; // TODO: get design to check border
|
|
15
17
|
|
|
16
18
|
(function (StatusClassNames) {
|
|
17
19
|
StatusClassNames["ASC"] = "sorting-icon-svg__asc";
|
|
@@ -28,14 +30,14 @@ const wrapperStyles = css`
|
|
|
28
30
|
margin: 6px;
|
|
29
31
|
right: 0;
|
|
30
32
|
top: 0;
|
|
31
|
-
border: 2px solid #fff;
|
|
33
|
+
border: 2px solid ${token('color.border.inverse', '#fff')};
|
|
32
34
|
border-radius: ${gridSize() / 2}px;
|
|
33
|
-
background-color: ${N20};
|
|
35
|
+
background-color: ${token('color.background.neutral.subtle', N20)};
|
|
34
36
|
justify-content: center;
|
|
35
37
|
align-items: center;
|
|
36
38
|
|
|
37
39
|
&:hover {
|
|
38
|
-
background-color: ${N30};
|
|
40
|
+
background-color: ${token('color.background.neutral.subtle.hovered', N30)};
|
|
39
41
|
}
|
|
40
42
|
|
|
41
43
|
&.${StatusClassNames.SORTING_NOT_ALLOWED} {
|
|
@@ -13,7 +13,7 @@ import { AnnotationSharedCSSByState } from '@atlaskit/editor-common/styles';
|
|
|
13
13
|
const markStyles = props => css`
|
|
14
14
|
color: inherit;
|
|
15
15
|
background-color: unset;
|
|
16
|
-
-webkit-tap-highlight-color:
|
|
16
|
+
-webkit-tap-highlight-color: transparent;
|
|
17
17
|
|
|
18
18
|
${AnnotationSharedCSSByState(props).focus};
|
|
19
19
|
`;
|
|
@@ -9,7 +9,7 @@ import { AnnotationMarkStates } from '@atlaskit/adf-schema';
|
|
|
9
9
|
const markStyles = props => css`
|
|
10
10
|
color: inherit;
|
|
11
11
|
background-color: unset;
|
|
12
|
-
-webkit-tap-highlight-color:
|
|
12
|
+
-webkit-tap-highlight-color: transparent;
|
|
13
13
|
|
|
14
14
|
&[data-mark-annotation-state='${AnnotationMarkStates.ACTIVE}'] {
|
|
15
15
|
${AnnotationSharedCSSByState({
|