@atlaskit/editor-common 74.5.2 → 74.6.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 +6 -0
- package/dist/cjs/analytics/index.js +26 -1
- package/dist/cjs/analytics/linking-utils.js +84 -0
- package/dist/cjs/card/MediaAndEmbedsToolbar/index.js +156 -0
- package/dist/cjs/card/index.js +9 -1
- package/dist/cjs/messages/index.js +14 -0
- package/dist/cjs/messages/link-toolbar.js +60 -0
- package/dist/cjs/messages/media-and-embed-toolbar.js +20 -0
- package/dist/cjs/monitoring/error.js +1 -1
- package/dist/cjs/react-node-view/getInlineNodeViewProducer.js +225 -0
- package/dist/cjs/react-node-view/index.js +13 -0
- package/dist/cjs/{ui/Resizer/index.js → resizer/Resizer.js} +1 -1
- package/dist/cjs/{resizer.js → resizer/index.js} +1 -1
- package/dist/cjs/resizer/utils.js +21 -0
- package/dist/cjs/types/hyperlink.js +5 -0
- package/dist/cjs/types/resizable-media-single.js +5 -0
- package/dist/cjs/ui/DropList/index.js +1 -1
- package/dist/cjs/ui/LinkSearch/const.js +14 -0
- package/dist/cjs/ui/ResizerLegacy/index.js +210 -0
- package/dist/cjs/ui/ResizerLegacy/styled.js +15 -0
- package/dist/cjs/ui/ResizerLegacy/types.js +5 -0
- package/dist/cjs/ui/ResizerLegacy/utils.js +21 -0
- package/dist/cjs/ui/index.js +58 -0
- package/dist/cjs/utils/document.js +258 -0
- package/dist/cjs/utils/editor-core-utils.js +7 -2
- package/dist/cjs/utils/filter/privacy-filter.js +55 -0
- package/dist/cjs/utils/index.js +75 -0
- package/dist/cjs/utils/rich-media-utils.js +131 -0
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/analytics/index.js +2 -1
- package/dist/es2019/analytics/linking-utils.js +74 -0
- package/dist/es2019/card/MediaAndEmbedsToolbar/index.js +161 -0
- package/dist/es2019/card/index.js +2 -1
- package/dist/es2019/messages/index.js +2 -0
- package/dist/es2019/messages/link-toolbar.js +53 -0
- package/dist/es2019/messages/media-and-embed-toolbar.js +13 -0
- package/dist/es2019/monitoring/error.js +1 -1
- package/dist/es2019/react-node-view/getInlineNodeViewProducer.js +219 -0
- package/dist/es2019/react-node-view/index.js +1 -0
- package/dist/es2019/{ui/Resizer/index.js → resizer/Resizer.js} +1 -1
- package/dist/es2019/resizer/index.js +1 -0
- package/dist/es2019/resizer/utils.js +12 -0
- package/dist/es2019/types/resizable-media-single.js +1 -0
- package/dist/es2019/ui/DropList/index.js +1 -1
- package/dist/es2019/ui/LinkSearch/const.js +4 -0
- package/dist/es2019/ui/ResizerLegacy/index.js +191 -0
- package/dist/es2019/ui/ResizerLegacy/styled.js +15 -0
- package/dist/es2019/ui/ResizerLegacy/types.js +1 -0
- package/dist/es2019/ui/ResizerLegacy/utils.js +12 -0
- package/dist/es2019/ui/index.js +5 -1
- package/dist/es2019/utils/document.js +253 -0
- package/dist/es2019/utils/editor-core-utils.js +4 -0
- package/dist/es2019/utils/filter/privacy-filter.js +47 -0
- package/dist/es2019/utils/index.js +5 -2
- package/dist/es2019/utils/rich-media-utils.js +109 -0
- package/dist/es2019/version.json +1 -1
- package/dist/esm/analytics/index.js +2 -1
- package/dist/esm/analytics/linking-utils.js +74 -0
- package/dist/esm/card/MediaAndEmbedsToolbar/index.js +146 -0
- package/dist/esm/card/index.js +2 -1
- package/dist/esm/messages/index.js +2 -0
- package/dist/esm/messages/link-toolbar.js +53 -0
- package/dist/esm/messages/media-and-embed-toolbar.js +13 -0
- package/dist/esm/monitoring/error.js +1 -1
- package/dist/esm/react-node-view/getInlineNodeViewProducer.js +215 -0
- package/dist/esm/react-node-view/index.js +1 -0
- package/dist/esm/{ui/Resizer/index.js → resizer/Resizer.js} +1 -1
- package/dist/esm/resizer/index.js +1 -0
- package/dist/esm/resizer/types.js +1 -0
- package/dist/esm/resizer/utils.js +12 -0
- package/dist/esm/types/hyperlink.js +1 -0
- package/dist/esm/types/resizable-media-single.js +1 -0
- package/dist/esm/ui/DropList/index.js +1 -1
- package/dist/esm/ui/LinkSearch/const.js +4 -0
- package/dist/esm/ui/ResizerLegacy/index.js +203 -0
- package/dist/esm/ui/ResizerLegacy/styled.js +7 -0
- package/dist/esm/ui/ResizerLegacy/types.js +1 -0
- package/dist/esm/ui/ResizerLegacy/utils.js +12 -0
- package/dist/esm/ui/index.js +5 -1
- package/dist/esm/utils/document.js +246 -0
- package/dist/esm/utils/editor-core-utils.js +4 -0
- package/dist/esm/utils/filter/privacy-filter.js +48 -0
- package/dist/esm/utils/index.js +5 -2
- package/dist/esm/utils/rich-media-utils.js +118 -0
- package/dist/esm/version.json +1 -1
- package/dist/types/analytics/index.d.ts +2 -0
- package/dist/types/analytics/linking-utils.d.ts +14 -0
- package/dist/types/card/MediaAndEmbedsToolbar/index.d.ts +11 -0
- package/dist/types/card/index.d.ts +1 -0
- package/dist/types/messages/index.d.ts +2 -0
- package/dist/types/messages/link-toolbar.d.ts +52 -0
- package/dist/types/messages/media-and-embed-toolbar.d.ts +12 -0
- package/dist/types/react-node-view/getInlineNodeViewProducer.d.ts +25 -0
- package/dist/types/react-node-view/index.d.ts +3 -0
- package/dist/types/resizer/index.d.ts +2 -0
- package/dist/types/resizer/utils.d.ts +6 -0
- package/dist/types/types/hyperlink.d.ts +35 -0
- package/dist/types/types/index.d.ts +2 -0
- package/dist/types/types/resizable-media-single.d.ts +15 -0
- package/dist/types/ui/DropList/index.d.ts +1 -1
- package/dist/types/ui/LinkSearch/const.d.ts +4 -0
- package/dist/types/ui/ResizerLegacy/index.d.ts +40 -0
- package/dist/types/ui/ResizerLegacy/styled.d.ts +2 -0
- package/dist/types/ui/ResizerLegacy/types.d.ts +26 -0
- package/dist/types/ui/ResizerLegacy/utils.d.ts +6 -0
- package/dist/types/ui/index.d.ts +6 -0
- package/dist/types/utils/document.d.ts +19 -0
- package/dist/types/utils/editor-core-utils.d.ts +1 -0
- package/dist/types/utils/filter/privacy-filter.d.ts +9 -0
- package/dist/types/utils/index.d.ts +4 -1
- package/dist/types/utils/rich-media-utils.d.ts +8 -0
- package/dist/types-ts4.5/analytics/index.d.ts +2 -0
- package/dist/types-ts4.5/analytics/linking-utils.d.ts +14 -0
- package/dist/types-ts4.5/card/MediaAndEmbedsToolbar/index.d.ts +11 -0
- package/dist/types-ts4.5/card/index.d.ts +1 -0
- package/dist/types-ts4.5/messages/index.d.ts +2 -0
- package/dist/types-ts4.5/messages/link-toolbar.d.ts +52 -0
- package/dist/types-ts4.5/messages/media-and-embed-toolbar.d.ts +12 -0
- package/dist/types-ts4.5/react-node-view/getInlineNodeViewProducer.d.ts +25 -0
- package/dist/types-ts4.5/react-node-view/index.d.ts +3 -0
- package/dist/types-ts4.5/resizer/index.d.ts +2 -0
- package/dist/types-ts4.5/resizer/utils.d.ts +6 -0
- package/dist/types-ts4.5/types/hyperlink.d.ts +35 -0
- package/dist/types-ts4.5/types/index.d.ts +2 -0
- package/dist/types-ts4.5/types/resizable-media-single.d.ts +15 -0
- package/dist/types-ts4.5/ui/DropList/index.d.ts +1 -1
- package/dist/types-ts4.5/ui/LinkSearch/const.d.ts +4 -0
- package/dist/types-ts4.5/ui/ResizerLegacy/index.d.ts +40 -0
- package/dist/types-ts4.5/ui/ResizerLegacy/styled.d.ts +2 -0
- package/dist/types-ts4.5/ui/ResizerLegacy/types.d.ts +26 -0
- package/dist/types-ts4.5/ui/ResizerLegacy/utils.d.ts +6 -0
- package/dist/types-ts4.5/ui/index.d.ts +6 -0
- package/dist/types-ts4.5/utils/document.d.ts +19 -0
- package/dist/types-ts4.5/utils/editor-core-utils.d.ts +1 -0
- package/dist/types-ts4.5/utils/filter/privacy-filter.d.ts +9 -0
- package/dist/types-ts4.5/utils/index.d.ts +4 -1
- package/dist/types-ts4.5/utils/rich-media-utils.d.ts +8 -0
- package/package.json +7 -6
- package/resizer/package.json +5 -5
- package/dist/cjs/ui/Resizer/utils.js +0 -8
- package/dist/es2019/resizer.js +0 -1
- package/dist/es2019/ui/Resizer/utils.js +0 -1
- package/dist/esm/resizer.js +0 -1
- package/dist/esm/ui/Resizer/utils.js +0 -1
- package/dist/types/resizer.d.ts +0 -2
- package/dist/types/ui/Resizer/utils.d.ts +0 -1
- package/dist/types-ts4.5/resizer.d.ts +0 -2
- package/dist/types-ts4.5/ui/Resizer/utils.d.ts +0 -1
- /package/dist/cjs/{ui/Resizer → resizer}/types.js +0 -0
- /package/dist/es2019/{ui/Resizer → resizer}/types.js +0 -0
- /package/dist/{esm/ui/Resizer/types.js → es2019/types/hyperlink.js} +0 -0
- /package/dist/types/{ui/Resizer/index.d.ts → resizer/Resizer.d.ts} +0 -0
- /package/dist/types/{ui/Resizer → resizer}/types.d.ts +0 -0
- /package/dist/types-ts4.5/{ui/Resizer/index.d.ts → resizer/Resizer.d.ts} +0 -0
- /package/dist/types-ts4.5/{ui/Resizer → resizer}/types.d.ts +0 -0
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.bracketTyped = bracketTyped;
|
|
7
|
+
exports.getStepRange = void 0;
|
|
8
|
+
exports.hasDocAsParent = hasDocAsParent;
|
|
9
|
+
exports.isEmptyDocument = isEmptyDocument;
|
|
10
|
+
exports.nodesBetweenChanged = nodesBetweenChanged;
|
|
11
|
+
exports.processRawValue = processRawValue;
|
|
12
|
+
var _prosemirrorModel = require("prosemirror-model");
|
|
13
|
+
var _transforms = require("@atlaskit/adf-utils/transforms");
|
|
14
|
+
var _analytics = require("../analytics");
|
|
15
|
+
var _editorCoreUtils = require("./editor-core-utils");
|
|
16
|
+
var _privacyFilter = require("./filter/privacy-filter");
|
|
17
|
+
var _trackUnsupportedContent = require("./track-unsupported-content");
|
|
18
|
+
var _validateUsingSpec = require("./validate-using-spec");
|
|
19
|
+
var getStepRange = function getStepRange(transaction) {
|
|
20
|
+
var from = -1;
|
|
21
|
+
var to = -1;
|
|
22
|
+
transaction.mapping.maps.forEach(function (stepMap, index) {
|
|
23
|
+
stepMap.forEach(function (oldStart, oldEnd) {
|
|
24
|
+
var newStart = transaction.mapping.slice(index).map(oldStart, -1);
|
|
25
|
+
var newEnd = transaction.mapping.slice(index).map(oldEnd);
|
|
26
|
+
from = newStart < from || from === -1 ? newStart : from;
|
|
27
|
+
to = newEnd > to || to === -1 ? newEnd : to;
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
if (from !== -1) {
|
|
31
|
+
return {
|
|
32
|
+
from: from,
|
|
33
|
+
to: to
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
return null;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
// Checks to see if the parent node is the document, ie not contained within another entity
|
|
40
|
+
exports.getStepRange = getStepRange;
|
|
41
|
+
function hasDocAsParent($anchor) {
|
|
42
|
+
return $anchor.depth === 1;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Checks if a node looks like an empty document
|
|
47
|
+
*/
|
|
48
|
+
function isEmptyDocument(node) {
|
|
49
|
+
var nodeChild = node.content.firstChild;
|
|
50
|
+
if (node.childCount !== 1 || !nodeChild) {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
return (0, _editorCoreUtils.isEmptyParagraph)(nodeChild);
|
|
54
|
+
}
|
|
55
|
+
function bracketTyped(state) {
|
|
56
|
+
var selection = state.selection;
|
|
57
|
+
var _ref = selection,
|
|
58
|
+
$cursor = _ref.$cursor,
|
|
59
|
+
$anchor = _ref.$anchor;
|
|
60
|
+
if (!$cursor) {
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
var node = $cursor.nodeBefore;
|
|
64
|
+
if (!node) {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
if (node.type.name === 'text' && node.text === '{') {
|
|
68
|
+
var paragraphNode = $anchor.node();
|
|
69
|
+
return paragraphNode.marks.length === 0 && hasDocAsParent($anchor);
|
|
70
|
+
}
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
function nodesBetweenChanged(tr, f, startPos) {
|
|
74
|
+
var stepRange = getStepRange(tr);
|
|
75
|
+
if (!stepRange) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
tr.doc.nodesBetween(stepRange.from, stepRange.to, f, startPos);
|
|
79
|
+
}
|
|
80
|
+
function processRawValue(schema, value, providerFactory, sanitizePrivateContent, contentTransformer, dispatchAnalyticsEvent) {
|
|
81
|
+
if (!value) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
var node;
|
|
85
|
+
if (typeof value === 'string') {
|
|
86
|
+
try {
|
|
87
|
+
if (contentTransformer) {
|
|
88
|
+
var doc = contentTransformer.parse(value);
|
|
89
|
+
node = doc.toJSON();
|
|
90
|
+
} else {
|
|
91
|
+
node = JSON.parse(value);
|
|
92
|
+
}
|
|
93
|
+
} catch (e) {
|
|
94
|
+
// eslint-disable-next-line no-console
|
|
95
|
+
console.error("Error processing value: ".concat(value, " isn't a valid JSON"));
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
} else {
|
|
99
|
+
node = value;
|
|
100
|
+
}
|
|
101
|
+
if (Array.isArray(node)) {
|
|
102
|
+
// eslint-disable-next-line no-console
|
|
103
|
+
console.error("Error processing value: ".concat(node, " is an array, but it must be an object."));
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
try {
|
|
107
|
+
// ProseMirror always require a child under doc
|
|
108
|
+
if (node.type === 'doc') {
|
|
109
|
+
if (Array.isArray(node.content) && node.content.length === 0) {
|
|
110
|
+
node.content.push({
|
|
111
|
+
type: 'paragraph',
|
|
112
|
+
content: []
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
// Just making sure doc is always valid
|
|
116
|
+
if (!node.version) {
|
|
117
|
+
node.version = 1;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
if (contentTransformer) {
|
|
121
|
+
return _prosemirrorModel.Node.fromJSON(schema, node);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// link mark on mediaSingle is deprecated, need to move link mark to child media node
|
|
125
|
+
// https://product-fabric.atlassian.net/browse/ED-14043
|
|
126
|
+
var _transformMediaLinkMa = (0, _transforms.transformMediaLinkMarks)(node),
|
|
127
|
+
transformedAdf = _transformMediaLinkMa.transformedAdf,
|
|
128
|
+
isTransformed = _transformMediaLinkMa.isTransformed;
|
|
129
|
+
if (isTransformed && dispatchAnalyticsEvent) {
|
|
130
|
+
dispatchAnalyticsEvent({
|
|
131
|
+
action: _analytics.ACTION.MEDIA_LINK_TRANSFORMED,
|
|
132
|
+
actionSubject: _analytics.ACTION_SUBJECT.EDITOR,
|
|
133
|
+
eventType: _analytics.EVENT_TYPE.OPERATIONAL
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// See: HOT-97965 https://product-fabric.atlassian.net/browse/ED-14400
|
|
138
|
+
// We declared in code mark spec that links and marks should not co-exist on
|
|
139
|
+
// text nodes. This util strips code marks from bad text nodes and preserves links.
|
|
140
|
+
// Otherwise, prosemirror will try to repair the invalid document by stripping links
|
|
141
|
+
// and preserving code marks during content changes.
|
|
142
|
+
var _transformTextLinkCod = (0, _transforms.transformTextLinkCodeMarks)(transformedAdf);
|
|
143
|
+
transformedAdf = _transformTextLinkCod.transformedAdf;
|
|
144
|
+
isTransformed = _transformTextLinkCod.isTransformed;
|
|
145
|
+
if (isTransformed && dispatchAnalyticsEvent) {
|
|
146
|
+
dispatchAnalyticsEvent({
|
|
147
|
+
action: _analytics.ACTION.TEXT_LINK_MARK_TRANSFORMED,
|
|
148
|
+
actionSubject: _analytics.ACTION_SUBJECT.EDITOR,
|
|
149
|
+
eventType: _analytics.EVENT_TYPE.OPERATIONAL
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
var discardedMarks = [];
|
|
153
|
+
var _transformDedupeMarks = (0, _transforms.transformDedupeMarks)(transformedAdf);
|
|
154
|
+
transformedAdf = _transformDedupeMarks.transformedAdf;
|
|
155
|
+
isTransformed = _transformDedupeMarks.isTransformed;
|
|
156
|
+
discardedMarks = _transformDedupeMarks.discardedMarks;
|
|
157
|
+
if (isTransformed && dispatchAnalyticsEvent) {
|
|
158
|
+
dispatchAnalyticsEvent({
|
|
159
|
+
action: _analytics.ACTION.DEDUPE_MARKS_TRANSFORMED_V2,
|
|
160
|
+
actionSubject: _analytics.ACTION_SUBJECT.EDITOR,
|
|
161
|
+
eventType: _analytics.EVENT_TYPE.OPERATIONAL,
|
|
162
|
+
attributes: {
|
|
163
|
+
/** UGC WARNING
|
|
164
|
+
*
|
|
165
|
+
* DO NOT include the `mark` attributes inside, we map here to only
|
|
166
|
+
* extract the mark type as that is the only non-UGC safe information
|
|
167
|
+
* that we can add to event-attributes
|
|
168
|
+
*
|
|
169
|
+
*/
|
|
170
|
+
discardedMarkTypes: discardedMarks.map(function (mark) {
|
|
171
|
+
return mark.type;
|
|
172
|
+
})
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
var _transformNodesMissin = (0, _transforms.transformNodesMissingContent)(transformedAdf);
|
|
177
|
+
transformedAdf = _transformNodesMissin.transformedAdf;
|
|
178
|
+
isTransformed = _transformNodesMissin.isTransformed;
|
|
179
|
+
if (isTransformed && dispatchAnalyticsEvent) {
|
|
180
|
+
dispatchAnalyticsEvent({
|
|
181
|
+
action: _analytics.ACTION.NODES_MISSING_CONTENT_TRANSFORMED,
|
|
182
|
+
actionSubject: _analytics.ACTION_SUBJECT.EDITOR,
|
|
183
|
+
eventType: _analytics.EVENT_TYPE.OPERATIONAL
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
var _transformIndentation = (0, _transforms.transformIndentationMarks)(transformedAdf);
|
|
187
|
+
transformedAdf = _transformIndentation.transformedAdf;
|
|
188
|
+
isTransformed = _transformIndentation.isTransformed;
|
|
189
|
+
if (isTransformed && dispatchAnalyticsEvent) {
|
|
190
|
+
dispatchAnalyticsEvent({
|
|
191
|
+
action: _analytics.ACTION.INDENTATION_MARKS_TRANSFORMED,
|
|
192
|
+
actionSubject: _analytics.ACTION_SUBJECT.EDITOR,
|
|
193
|
+
eventType: _analytics.EVENT_TYPE.OPERATIONAL
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
var _transformInvalidMedi = (0, _transforms.transformInvalidMediaContent)(transformedAdf);
|
|
197
|
+
transformedAdf = _transformInvalidMedi.transformedAdf;
|
|
198
|
+
isTransformed = _transformInvalidMedi.isTransformed;
|
|
199
|
+
if (isTransformed && dispatchAnalyticsEvent) {
|
|
200
|
+
dispatchAnalyticsEvent({
|
|
201
|
+
action: _analytics.ACTION.INVALID_MEDIA_CONTENT_TRANSFORMED,
|
|
202
|
+
actionSubject: _analytics.ACTION_SUBJECT.EDITOR,
|
|
203
|
+
eventType: _analytics.EVENT_TYPE.OPERATIONAL
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
var entity = (0, _validateUsingSpec.validateADFEntity)(schema, transformedAdf || node, dispatchAnalyticsEvent);
|
|
207
|
+
var newEntity = maySanitizePrivateContent(entity, providerFactory, sanitizePrivateContent);
|
|
208
|
+
var parsedDoc = _prosemirrorModel.Node.fromJSON(schema, newEntity);
|
|
209
|
+
|
|
210
|
+
// throws an error if the document is invalid
|
|
211
|
+
try {
|
|
212
|
+
parsedDoc.check();
|
|
213
|
+
} catch (err) {
|
|
214
|
+
if (dispatchAnalyticsEvent) {
|
|
215
|
+
dispatchAnalyticsEvent({
|
|
216
|
+
action: _analytics.ACTION.INVALID_PROSEMIRROR_DOCUMENT,
|
|
217
|
+
actionSubject: _analytics.ACTION_SUBJECT.EDITOR,
|
|
218
|
+
eventType: _analytics.EVENT_TYPE.OPERATIONAL,
|
|
219
|
+
attributes: {
|
|
220
|
+
errorStack: err instanceof Error ? err.stack : String(err)
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
throw err;
|
|
225
|
+
}
|
|
226
|
+
if (dispatchAnalyticsEvent) {
|
|
227
|
+
(0, _trackUnsupportedContent.findAndTrackUnsupportedContentNodes)(parsedDoc, schema, dispatchAnalyticsEvent);
|
|
228
|
+
}
|
|
229
|
+
return parsedDoc;
|
|
230
|
+
} catch (e) {
|
|
231
|
+
if (dispatchAnalyticsEvent) {
|
|
232
|
+
dispatchAnalyticsEvent({
|
|
233
|
+
action: _analytics.ACTION.DOCUMENT_PROCESSING_ERROR,
|
|
234
|
+
actionSubject: _analytics.ACTION_SUBJECT.EDITOR,
|
|
235
|
+
eventType: _analytics.EVENT_TYPE.OPERATIONAL,
|
|
236
|
+
nonPrivacySafeAttributes: {
|
|
237
|
+
errorStack: e instanceof Error ? e.stack : String(e)
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
// eslint-disable-next-line no-console
|
|
243
|
+
console.error("Error processing document:\n".concat(e instanceof Error ? e.message : String(e), "\n\n"), JSON.stringify(node));
|
|
244
|
+
if (isProseMirrorSchemaCheckError(e)) {
|
|
245
|
+
throw e;
|
|
246
|
+
}
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
function isProseMirrorSchemaCheckError(error) {
|
|
251
|
+
return error instanceof RangeError && (!!error.message.match(/^Invalid collection of marks for node/) || !!error.message.match(/^Invalid content for node/));
|
|
252
|
+
}
|
|
253
|
+
var maySanitizePrivateContent = function maySanitizePrivateContent(entity, providerFactory, sanitizePrivateContent) {
|
|
254
|
+
if (sanitizePrivateContent && providerFactory) {
|
|
255
|
+
return (0, _privacyFilter.sanitizeNodeForPrivacy)(entity, providerFactory);
|
|
256
|
+
}
|
|
257
|
+
return entity;
|
|
258
|
+
};
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.isElementInTableCell = exports.extractSliceFromStep = void 0;
|
|
7
7
|
exports.isEmptyParagraph = isEmptyParagraph;
|
|
8
|
-
exports.isValidPosition = exports.isTextSelection = exports.isLastItemMediaGroup = void 0;
|
|
8
|
+
exports.isValidPosition = exports.isTextSelection = exports.isLastItemMediaGroup = exports.isInLayoutColumn = void 0;
|
|
9
9
|
exports.nonNullable = nonNullable;
|
|
10
10
|
exports.setNodeSelection = void 0;
|
|
11
11
|
exports.setTextSelection = setTextSelection;
|
|
@@ -13,6 +13,7 @@ exports.stepAddsOneOf = stepAddsOneOf;
|
|
|
13
13
|
exports.stepHasSlice = void 0;
|
|
14
14
|
var _prosemirrorState = require("prosemirror-state");
|
|
15
15
|
var _prosemirrorTransform = require("prosemirror-transform");
|
|
16
|
+
var _prosemirrorUtils = require("prosemirror-utils");
|
|
16
17
|
var _dom = require("./dom");
|
|
17
18
|
/**
|
|
18
19
|
* Checks if node is an empty paragraph.
|
|
@@ -95,4 +96,8 @@ var isValidPosition = function isValidPosition(pos, state) {
|
|
|
95
96
|
}
|
|
96
97
|
return false;
|
|
97
98
|
};
|
|
98
|
-
exports.isValidPosition = isValidPosition;
|
|
99
|
+
exports.isValidPosition = isValidPosition;
|
|
100
|
+
var isInLayoutColumn = function isInLayoutColumn(state) {
|
|
101
|
+
return (0, _prosemirrorUtils.hasParentNodeOfType)(state.schema.nodes.layoutSection)(state.selection);
|
|
102
|
+
};
|
|
103
|
+
exports.isInLayoutColumn = isInLayoutColumn;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.sanitizeNodeForPrivacy = sanitizeNodeForPrivacy;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
+
var _traverse = require("@atlaskit/adf-utils/traverse");
|
|
10
|
+
var _resource = require("@atlaskit/mention/resource");
|
|
11
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
12
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
13
|
+
/**
|
|
14
|
+
* Sanitises a document where some content should not be in the document (e.g. mention names).
|
|
15
|
+
*
|
|
16
|
+
* It is expected that these names we be resolved separately (e.g. when rendering
|
|
17
|
+
* a node view).
|
|
18
|
+
*/
|
|
19
|
+
function sanitizeNodeForPrivacy(json, providerFactory) {
|
|
20
|
+
var mentionNames = new Map();
|
|
21
|
+
var hasCacheableMentions = false;
|
|
22
|
+
var sanitizedJSON = (0, _traverse.traverse)(json, {
|
|
23
|
+
mention: function mention(node) {
|
|
24
|
+
if (node.attrs && node.attrs.text) {
|
|
25
|
+
hasCacheableMentions = true;
|
|
26
|
+
// Remove @ prefix
|
|
27
|
+
var text = node.attrs.text;
|
|
28
|
+
var name = text.startsWith('@') ? text.slice(1) : text;
|
|
29
|
+
mentionNames.set(node.attrs.id, name);
|
|
30
|
+
}
|
|
31
|
+
return _objectSpread(_objectSpread({}, node), {}, {
|
|
32
|
+
attrs: _objectSpread(_objectSpread({}, node.attrs), {}, {
|
|
33
|
+
text: ''
|
|
34
|
+
})
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
if (hasCacheableMentions && providerFactory) {
|
|
39
|
+
var handler = function handler(_name, providerPromise) {
|
|
40
|
+
if (providerPromise) {
|
|
41
|
+
providerPromise.then(function (provider) {
|
|
42
|
+
if ((0, _resource.isResolvingMentionProvider)(provider)) {
|
|
43
|
+
mentionNames.forEach(function (name, id) {
|
|
44
|
+
provider.cacheMentionName(id, name);
|
|
45
|
+
});
|
|
46
|
+
mentionNames.clear();
|
|
47
|
+
providerFactory.unsubscribe('mentionProvider', handler);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
providerFactory.subscribe('mentionProvider', handler);
|
|
53
|
+
}
|
|
54
|
+
return sanitizedJSON;
|
|
55
|
+
}
|
package/dist/cjs/utils/index.js
CHANGED
|
@@ -94,12 +94,24 @@ Object.defineProperty(exports, "absoluteBreakoutWidth", {
|
|
|
94
94
|
return _breakout.absoluteBreakoutWidth;
|
|
95
95
|
}
|
|
96
96
|
});
|
|
97
|
+
Object.defineProperty(exports, "alignAttributes", {
|
|
98
|
+
enumerable: true,
|
|
99
|
+
get: function get() {
|
|
100
|
+
return _richMediaUtils.alignAttributes;
|
|
101
|
+
}
|
|
102
|
+
});
|
|
97
103
|
Object.defineProperty(exports, "analyticsEventKey", {
|
|
98
104
|
enumerable: true,
|
|
99
105
|
get: function get() {
|
|
100
106
|
return _analytics.analyticsEventKey;
|
|
101
107
|
}
|
|
102
108
|
});
|
|
109
|
+
Object.defineProperty(exports, "bracketTyped", {
|
|
110
|
+
enumerable: true,
|
|
111
|
+
get: function get() {
|
|
112
|
+
return _document.bracketTyped;
|
|
113
|
+
}
|
|
114
|
+
});
|
|
103
115
|
Object.defineProperty(exports, "breakoutConsts", {
|
|
104
116
|
enumerable: true,
|
|
105
117
|
get: function get() {
|
|
@@ -142,6 +154,12 @@ Object.defineProperty(exports, "calculateBreakoutStyles", {
|
|
|
142
154
|
return _breakout.calculateBreakoutStyles;
|
|
143
155
|
}
|
|
144
156
|
});
|
|
157
|
+
Object.defineProperty(exports, "calculateSnapPoints", {
|
|
158
|
+
enumerable: true,
|
|
159
|
+
get: function get() {
|
|
160
|
+
return _richMediaUtils.calculateSnapPoints;
|
|
161
|
+
}
|
|
162
|
+
});
|
|
145
163
|
Object.defineProperty(exports, "canApplyAnnotationOnRange", {
|
|
146
164
|
enumerable: true,
|
|
147
165
|
get: function get() {
|
|
@@ -220,6 +238,12 @@ Object.defineProperty(exports, "flatmap", {
|
|
|
220
238
|
return _slice.flatmap;
|
|
221
239
|
}
|
|
222
240
|
});
|
|
241
|
+
Object.defineProperty(exports, "floatingLayouts", {
|
|
242
|
+
enumerable: true,
|
|
243
|
+
get: function get() {
|
|
244
|
+
return _richMediaUtils.floatingLayouts;
|
|
245
|
+
}
|
|
246
|
+
});
|
|
223
247
|
Object.defineProperty(exports, "getAnalyticsAppearance", {
|
|
224
248
|
enumerable: true,
|
|
225
249
|
get: function get() {
|
|
@@ -334,6 +358,12 @@ Object.defineProperty(exports, "getShallowPropsDifference", {
|
|
|
334
358
|
return _compareProps.getShallowPropsDifference;
|
|
335
359
|
}
|
|
336
360
|
});
|
|
361
|
+
Object.defineProperty(exports, "getStepRange", {
|
|
362
|
+
enumerable: true,
|
|
363
|
+
get: function get() {
|
|
364
|
+
return _document.getStepRange;
|
|
365
|
+
}
|
|
366
|
+
});
|
|
337
367
|
Object.defineProperty(exports, "getTTISeverity", {
|
|
338
368
|
enumerable: true,
|
|
339
369
|
get: function get() {
|
|
@@ -352,6 +382,12 @@ Object.defineProperty(exports, "gridTypeForLayout", {
|
|
|
352
382
|
return _grid.gridTypeForLayout;
|
|
353
383
|
}
|
|
354
384
|
});
|
|
385
|
+
Object.defineProperty(exports, "hasDocAsParent", {
|
|
386
|
+
enumerable: true,
|
|
387
|
+
get: function get() {
|
|
388
|
+
return _document.hasDocAsParent;
|
|
389
|
+
}
|
|
390
|
+
});
|
|
355
391
|
Object.defineProperty(exports, "hasMergedCell", {
|
|
356
392
|
enumerable: true,
|
|
357
393
|
get: function get() {
|
|
@@ -370,6 +406,12 @@ Object.defineProperty(exports, "isElementInTableCell", {
|
|
|
370
406
|
return _editorCoreUtils.isElementInTableCell;
|
|
371
407
|
}
|
|
372
408
|
});
|
|
409
|
+
Object.defineProperty(exports, "isEmptyDocument", {
|
|
410
|
+
enumerable: true,
|
|
411
|
+
get: function get() {
|
|
412
|
+
return _document.isEmptyDocument;
|
|
413
|
+
}
|
|
414
|
+
});
|
|
373
415
|
Object.defineProperty(exports, "isEmptyParagraph", {
|
|
374
416
|
enumerable: true,
|
|
375
417
|
get: function get() {
|
|
@@ -382,6 +424,12 @@ Object.defineProperty(exports, "isFromCurrentDomain", {
|
|
|
382
424
|
return _hyperlink.isFromCurrentDomain;
|
|
383
425
|
}
|
|
384
426
|
});
|
|
427
|
+
Object.defineProperty(exports, "isInLayoutColumn", {
|
|
428
|
+
enumerable: true,
|
|
429
|
+
get: function get() {
|
|
430
|
+
return _editorCoreUtils.isInLayoutColumn;
|
|
431
|
+
}
|
|
432
|
+
});
|
|
385
433
|
Object.defineProperty(exports, "isLastItemMediaGroup", {
|
|
386
434
|
enumerable: true,
|
|
387
435
|
get: function get() {
|
|
@@ -472,6 +520,12 @@ Object.defineProperty(exports, "isReferencedSource", {
|
|
|
472
520
|
return _referentiality.isReferencedSource;
|
|
473
521
|
}
|
|
474
522
|
});
|
|
523
|
+
Object.defineProperty(exports, "isRichMediaInsideOfBlockNode", {
|
|
524
|
+
enumerable: true,
|
|
525
|
+
get: function get() {
|
|
526
|
+
return _richMediaUtils.isRichMediaInsideOfBlockNode;
|
|
527
|
+
}
|
|
528
|
+
});
|
|
475
529
|
Object.defineProperty(exports, "isSupportedInParent", {
|
|
476
530
|
enumerable: true,
|
|
477
531
|
get: function get() {
|
|
@@ -556,6 +610,12 @@ Object.defineProperty(exports, "measureTTI", {
|
|
|
556
610
|
return _measureTti.measureTTI;
|
|
557
611
|
}
|
|
558
612
|
});
|
|
613
|
+
Object.defineProperty(exports, "nodesBetweenChanged", {
|
|
614
|
+
enumerable: true,
|
|
615
|
+
get: function get() {
|
|
616
|
+
return _document.nodesBetweenChanged;
|
|
617
|
+
}
|
|
618
|
+
});
|
|
559
619
|
Object.defineProperty(exports, "nonNullable", {
|
|
560
620
|
enumerable: true,
|
|
561
621
|
get: function get() {
|
|
@@ -581,6 +641,12 @@ Object.defineProperty(exports, "pluginFactory", {
|
|
|
581
641
|
}
|
|
582
642
|
});
|
|
583
643
|
exports.pmHistoryPluginKey = void 0;
|
|
644
|
+
Object.defineProperty(exports, "processRawValue", {
|
|
645
|
+
enumerable: true,
|
|
646
|
+
get: function get() {
|
|
647
|
+
return _document.processRawValue;
|
|
648
|
+
}
|
|
649
|
+
});
|
|
584
650
|
Object.defineProperty(exports, "removeConnectedNodes", {
|
|
585
651
|
enumerable: true,
|
|
586
652
|
get: function get() {
|
|
@@ -599,6 +665,12 @@ Object.defineProperty(exports, "resolveOrder", {
|
|
|
599
665
|
return _list.resolveOrder;
|
|
600
666
|
}
|
|
601
667
|
});
|
|
668
|
+
Object.defineProperty(exports, "sanitizeNodeForPrivacy", {
|
|
669
|
+
enumerable: true,
|
|
670
|
+
get: function get() {
|
|
671
|
+
return _privacyFilter.sanitizeNodeForPrivacy;
|
|
672
|
+
}
|
|
673
|
+
});
|
|
602
674
|
Object.defineProperty(exports, "setNodeSelection", {
|
|
603
675
|
enumerable: true,
|
|
604
676
|
get: function get() {
|
|
@@ -776,6 +848,9 @@ var _referentiality = require("./referentiality");
|
|
|
776
848
|
var _list = require("./list");
|
|
777
849
|
var _hyperlink = require("./hyperlink");
|
|
778
850
|
var _grid = require("./grid");
|
|
851
|
+
var _document = require("./document");
|
|
852
|
+
var _richMediaUtils = require("./rich-media-utils");
|
|
853
|
+
var _privacyFilter = require("./filter/privacy-filter");
|
|
779
854
|
// prosemirror-history does not export its plugin key
|
|
780
855
|
var pmHistoryPluginKey = 'history$';
|
|
781
856
|
exports.pmHistoryPluginKey = pmHistoryPluginKey;
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.alignAttributes = void 0;
|
|
8
|
+
exports.calculateSnapPoints = calculateSnapPoints;
|
|
9
|
+
exports.nonWrappedLayouts = exports.isRichMediaInsideOfBlockNode = exports.floatingLayouts = void 0;
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
var _prosemirrorUtils = require("prosemirror-utils");
|
|
12
|
+
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
13
|
+
var _MediaSingle = require("../ui/MediaSingle");
|
|
14
|
+
var _grid = require("../ui/MediaSingle/grid");
|
|
15
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
16
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
17
|
+
var nonWrappedLayouts = ['center', 'wide', 'full-width'];
|
|
18
|
+
exports.nonWrappedLayouts = nonWrappedLayouts;
|
|
19
|
+
var floatingLayouts = ['wrap-left', 'wrap-right'];
|
|
20
|
+
exports.floatingLayouts = floatingLayouts;
|
|
21
|
+
var isRichMediaInsideOfBlockNode = function isRichMediaInsideOfBlockNode(view, pos) {
|
|
22
|
+
if (typeof pos !== 'number' || isNaN(pos) || !view) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
var $pos = view.state.doc.resolve(pos);
|
|
26
|
+
var _view$state$schema$no = view.state.schema.nodes,
|
|
27
|
+
expand = _view$state$schema$no.expand,
|
|
28
|
+
nestedExpand = _view$state$schema$no.nestedExpand,
|
|
29
|
+
layoutColumn = _view$state$schema$no.layoutColumn;
|
|
30
|
+
return !!(0, _prosemirrorUtils.findParentNodeOfTypeClosestToPos)($pos, [expand, nestedExpand, layoutColumn]);
|
|
31
|
+
};
|
|
32
|
+
exports.isRichMediaInsideOfBlockNode = isRichMediaInsideOfBlockNode;
|
|
33
|
+
var alignAttributes = function alignAttributes(layout, oldAttrs) {
|
|
34
|
+
var gridSize = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 12;
|
|
35
|
+
var originalWidth = arguments.length > 3 ? arguments[3] : undefined;
|
|
36
|
+
var lineLength = arguments.length > 4 ? arguments[4] : undefined;
|
|
37
|
+
var width = oldAttrs.width;
|
|
38
|
+
var oldLayout = oldAttrs.layout;
|
|
39
|
+
var oldLayoutIsNonWrapped = nonWrappedLayouts.indexOf(oldLayout) > -1;
|
|
40
|
+
var newLayoutIsNonWrapped = nonWrappedLayouts.indexOf(layout) > -1;
|
|
41
|
+
var newLayoutIsWrapped = _grid.wrappedLayouts.indexOf(layout) > -1;
|
|
42
|
+
var oldLayoutIsWrapped = _grid.wrappedLayouts.indexOf(oldLayout) > -1;
|
|
43
|
+
if (oldLayoutIsNonWrapped && (0, _MediaSingle.shouldAddDefaultWrappedWidth)(layout, originalWidth, lineLength)) {
|
|
44
|
+
// 'full-width' or 'wide' or 'center' -> 'wrap-left' or 'wrap-right' or 'align-end' or 'align-start'
|
|
45
|
+
if (!width || width >= 100 || oldLayout !== 'center' // == 'full-width' or 'wide'
|
|
46
|
+
) {
|
|
47
|
+
width = 50;
|
|
48
|
+
}
|
|
49
|
+
} else if (layout !== oldLayout && ['full-width', 'wide'].indexOf(oldLayout) > -1) {
|
|
50
|
+
// 'full-width' -> 'center' or 'wide'
|
|
51
|
+
// 'wide' -> 'center' or 'full-width'
|
|
52
|
+
// unset width
|
|
53
|
+
width = undefined;
|
|
54
|
+
} else if (width) {
|
|
55
|
+
var cols = Math.round(width / 100 * gridSize);
|
|
56
|
+
var targetCols = cols;
|
|
57
|
+
if (oldLayoutIsWrapped && newLayoutIsNonWrapped) {
|
|
58
|
+
// wrap -> center needs to align to even grid
|
|
59
|
+
targetCols = Math.floor(targetCols / 2) * 2;
|
|
60
|
+
width = undefined;
|
|
61
|
+
} else if (oldLayoutIsNonWrapped && newLayoutIsWrapped) {
|
|
62
|
+
// Can be here only if
|
|
63
|
+
// 'full-width' or 'wide' or 'center' -> 'wrap-left' or 'wrap-right' or 'align-end' or 'align-start'
|
|
64
|
+
// AND
|
|
65
|
+
// !originalWidth || !lineLength || small image
|
|
66
|
+
// AND
|
|
67
|
+
// width defined!
|
|
68
|
+
|
|
69
|
+
// cannot resize to full column width, and cannot resize to 1 column
|
|
70
|
+
if (cols <= 1) {
|
|
71
|
+
targetCols = 2;
|
|
72
|
+
} else if (cols >= gridSize) {
|
|
73
|
+
targetCols = 10;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
if (targetCols !== cols) {
|
|
77
|
+
width = targetCols / gridSize * 100;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return _objectSpread(_objectSpread({}, oldAttrs), {}, {
|
|
81
|
+
layout: layout,
|
|
82
|
+
width: width
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
exports.alignAttributes = alignAttributes;
|
|
86
|
+
function calculateSnapPoints(_ref) {
|
|
87
|
+
var $pos = _ref.$pos,
|
|
88
|
+
akEditorWideLayoutWidth = _ref.akEditorWideLayoutWidth,
|
|
89
|
+
allowBreakoutSnapPoints = _ref.allowBreakoutSnapPoints,
|
|
90
|
+
containerWidth = _ref.containerWidth,
|
|
91
|
+
gridSize = _ref.gridSize,
|
|
92
|
+
gridWidth = _ref.gridWidth,
|
|
93
|
+
insideInlineLike = _ref.insideInlineLike,
|
|
94
|
+
insideLayout = _ref.insideLayout,
|
|
95
|
+
isVideoFile = _ref.isVideoFile,
|
|
96
|
+
lineLength = _ref.lineLength,
|
|
97
|
+
offsetLeft = _ref.offsetLeft,
|
|
98
|
+
wrappedLayout = _ref.wrappedLayout;
|
|
99
|
+
var snapTargets = [];
|
|
100
|
+
for (var i = 0; i < gridWidth; i++) {
|
|
101
|
+
var pxFromColumns = (0, _grid.calcPxFromColumns)(i, lineLength, gridWidth);
|
|
102
|
+
snapTargets.push(insideLayout ? pxFromColumns : pxFromColumns - offsetLeft);
|
|
103
|
+
}
|
|
104
|
+
// full width
|
|
105
|
+
snapTargets.push(lineLength - offsetLeft);
|
|
106
|
+
var columns = wrappedLayout || insideInlineLike ? 1 : 2;
|
|
107
|
+
var minimumWidth = (0, _grid.calcPxFromColumns)(columns, lineLength, gridSize);
|
|
108
|
+
var snapPoints = snapTargets.filter(function (width) {
|
|
109
|
+
return width >= minimumWidth;
|
|
110
|
+
});
|
|
111
|
+
if (!$pos) {
|
|
112
|
+
return snapPoints;
|
|
113
|
+
}
|
|
114
|
+
snapPoints = isVideoFile ? snapPoints.filter(function (width) {
|
|
115
|
+
return width > 320;
|
|
116
|
+
}) : snapPoints;
|
|
117
|
+
var isTopLevel = $pos.parent.type.name === 'doc';
|
|
118
|
+
if (isTopLevel && allowBreakoutSnapPoints) {
|
|
119
|
+
snapPoints.push(akEditorWideLayoutWidth);
|
|
120
|
+
var fullWidthPoint = containerWidth - _editorSharedStyles.akEditorBreakoutPadding;
|
|
121
|
+
if (fullWidthPoint > akEditorWideLayoutWidth) {
|
|
122
|
+
snapPoints.push(fullWidthPoint);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// EDM-1107: Ensure new snapPoints are sorted with existing points
|
|
127
|
+
snapPoints = snapPoints.sort(function (a, b) {
|
|
128
|
+
return a - b;
|
|
129
|
+
});
|
|
130
|
+
return snapPoints;
|
|
131
|
+
}
|
package/dist/cjs/version.json
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, BROWSER_FREEZE_INTERACTION_TYPE, CONTENT_COMPONENT, DELETE_DIRECTION, EVENT_TYPE, FLOATING_CONTROLS_TITLE, FULL_WIDTH_MODE, GAP_CURSOR_POSITION, INDENT_DIRECTION, INDENT_TYPE, INPUT_METHOD, LAYOUT_TYPE, LINK_REPRESENTATION, LINK_RESOURCE, LINK_STATUS, LIST_TEXT_SCENARIOS, JOIN_SCENARIOS_WHEN_TYPING_TO_INSERT_LIST, OUTDENT_SCENARIOS, MODE, PLATFORMS, PUNC, PasteContents, PasteSources, PasteTypes, RESOLVE_METHOD, SELECTION_TYPE, SELECTION_POSITION, SMART_LINK_TYPE, SYMBOL, SmartLinkNodeContexts, TABLE_ACTION, TABLE_BREAKOUT, TARGET_SELECTION_SOURCE, TOOLBAR_ACTION_SUBJECT_ID, TRIGGER_METHOD, USER_CONTEXT } from './types';
|
|
2
2
|
export { fireAnalyticsEvent } from './fire-analytics-event';
|
|
3
|
-
export { getAnalyticsEventsFromTransaction } from './utils';
|
|
3
|
+
export { getAnalyticsEventsFromTransaction } from './utils';
|
|
4
|
+
export { buildEditLinkPayload, buildVisitedLinkPayload, buildOpenedSettingsPayload, unlinkPayload } from './linking-utils';
|