@atlaskit/editor-core 202.3.4 → 202.4.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 +12 -0
- package/dist/cjs/create-editor/create-schema.js +2 -2
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/es2019/create-editor/create-schema.js +1 -1
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/esm/create-editor/create-schema.js +1 -1
- package/dist/esm/version-wrapper.js +1 -1
- package/package.json +9 -5
- package/dist/cjs/utils/sanitizeNodes.js +0 -63
- package/dist/es2019/utils/sanitizeNodes.js +0 -49
- package/dist/esm/utils/sanitizeNodes.js +0 -56
- package/dist/types/utils/sanitizeNodes.d.ts +0 -8
- package/dist/types-ts4.5/utils/sanitizeNodes.d.ts +0 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/editor-core
|
|
2
2
|
|
|
3
|
+
## 202.4.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#165765](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/165765)
|
|
8
|
+
[`3f441f30e6507`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/3f441f30e6507) -
|
|
9
|
+
Bump adf-schema to 46.0.0
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies
|
|
14
|
+
|
|
3
15
|
## 202.3.4
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -8,10 +8,10 @@ exports.addMetadataAttributes = void 0;
|
|
|
8
8
|
exports.createSchema = createSchema;
|
|
9
9
|
exports.wrapToDOMProxy = exports.wrapNodeSpecProxy = void 0;
|
|
10
10
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
11
|
+
var _schema = require("@atlaskit/adf-schema/schema");
|
|
11
12
|
var _prosemirrorDomMetadata = require("@atlaskit/editor-common/prosemirror-dom-metadata");
|
|
12
13
|
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
13
14
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
14
|
-
var _sanitizeNodes = require("../utils/sanitizeNodes");
|
|
15
15
|
var _createEditor = require("./create-editor");
|
|
16
16
|
var _sortByOrder = require("./sort-by-order");
|
|
17
17
|
/**
|
|
@@ -103,7 +103,7 @@ function createSchema(editorConfig) {
|
|
|
103
103
|
}
|
|
104
104
|
return acc;
|
|
105
105
|
}, {}));
|
|
106
|
-
var nodes = (0,
|
|
106
|
+
var nodes = (0, _schema.sanitizeNodes)(editorConfig.nodes.sort((0, _sortByOrder.sortByOrder)('nodes')).reduce(function (acc, node) {
|
|
107
107
|
if ((0, _platformFeatureFlags.fg)('platform_editor_breakout_use_css')) {
|
|
108
108
|
acc[node.name] = wrapNodeSpecProxy(node.node);
|
|
109
109
|
} else {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { sanitizeNodes } from '@atlaskit/adf-schema/schema';
|
|
1
2
|
import { createProseMirrorMetadata } from '@atlaskit/editor-common/prosemirror-dom-metadata';
|
|
2
3
|
import { Schema } from '@atlaskit/editor-prosemirror/model';
|
|
3
4
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
|
-
import { sanitizeNodes } from '../utils/sanitizeNodes';
|
|
5
5
|
import { fixExcludes } from './create-editor';
|
|
6
6
|
import { sortByOrder } from './sort-by-order';
|
|
7
7
|
/**
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export const name = "@atlaskit/editor-core";
|
|
2
|
-
export const version = "202.
|
|
2
|
+
export const version = "202.4.0";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import _typeof from "@babel/runtime/helpers/typeof";
|
|
2
|
+
import { sanitizeNodes } from '@atlaskit/adf-schema/schema';
|
|
2
3
|
import { createProseMirrorMetadata } from '@atlaskit/editor-common/prosemirror-dom-metadata';
|
|
3
4
|
import { Schema } from '@atlaskit/editor-prosemirror/model';
|
|
4
5
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
5
|
-
import { sanitizeNodes } from '../utils/sanitizeNodes';
|
|
6
6
|
import { fixExcludes } from './create-editor';
|
|
7
7
|
import { sortByOrder } from './sort-by-order';
|
|
8
8
|
/**
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export var name = "@atlaskit/editor-core";
|
|
2
|
-
export var version = "202.
|
|
2
|
+
export var version = "202.4.0";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-core",
|
|
3
|
-
"version": "202.
|
|
3
|
+
"version": "202.4.0",
|
|
4
4
|
"description": "A package contains Atlassian editor core functionality",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -38,12 +38,12 @@
|
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@atlaskit/activity-provider": "^2.5.0",
|
|
41
|
-
"@atlaskit/adf-schema": "^
|
|
41
|
+
"@atlaskit/adf-schema": "^46.1.0",
|
|
42
42
|
"@atlaskit/analytics-namespaced-context": "^6.12.0",
|
|
43
43
|
"@atlaskit/analytics-next": "^10.1.0",
|
|
44
44
|
"@atlaskit/analytics-next-stable-react-context": "1.0.1",
|
|
45
45
|
"@atlaskit/button": "^20.3.0",
|
|
46
|
-
"@atlaskit/editor-common": "^95.
|
|
46
|
+
"@atlaskit/editor-common": "^95.7.0",
|
|
47
47
|
"@atlaskit/editor-json-transformer": "^8.21.0",
|
|
48
48
|
"@atlaskit/editor-plugin-quick-insert": "1.7.1",
|
|
49
49
|
"@atlaskit/editor-plugins": "^5.7.0",
|
|
@@ -83,8 +83,8 @@
|
|
|
83
83
|
"@af/visual-regression": "*",
|
|
84
84
|
"@atlaskit/adf-utils": "^19.13.0",
|
|
85
85
|
"@atlaskit/analytics-listeners": "^8.13.0",
|
|
86
|
-
"@atlaskit/collab-provider": "10.1.
|
|
87
|
-
"@atlaskit/editor-plugin-annotation": "1.25.
|
|
86
|
+
"@atlaskit/collab-provider": "10.1.3",
|
|
87
|
+
"@atlaskit/editor-plugin-annotation": "1.25.3",
|
|
88
88
|
"@atlaskit/editor-plugin-card": "^4.4.0",
|
|
89
89
|
"@atlaskit/editor-plugin-list": "^3.9.0",
|
|
90
90
|
"@atlaskit/editor-plugin-paste": "^2.0.0",
|
|
@@ -356,6 +356,10 @@
|
|
|
356
356
|
"platform_inline_node_as_valid_annotation_selection": {
|
|
357
357
|
"type": "boolean",
|
|
358
358
|
"referenceOnly": true
|
|
359
|
+
},
|
|
360
|
+
"platform_editor_hide_external_media_badge": {
|
|
361
|
+
"type": "boolean",
|
|
362
|
+
"referenceOnly": true
|
|
359
363
|
}
|
|
360
364
|
},
|
|
361
365
|
"stricter": {
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.sanitizeNodes = sanitizeNodes;
|
|
8
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
10
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
11
|
-
function sanitizeNodes(nodes, supportedMarks) {
|
|
12
|
-
var nodeNames = Object.keys(nodes);
|
|
13
|
-
nodeNames.forEach(function (nodeKey) {
|
|
14
|
-
var nodeSpec = _objectSpread({}, nodes[nodeKey]);
|
|
15
|
-
if (nodeSpec.marks && nodeSpec.marks !== '_') {
|
|
16
|
-
nodeSpec.marks = nodeSpec.marks.split(' ').filter(function (mark) {
|
|
17
|
-
return !!supportedMarks[mark];
|
|
18
|
-
}).join(' ');
|
|
19
|
-
}
|
|
20
|
-
if (nodeSpec.content) {
|
|
21
|
-
nodeSpec.content = sanitizeNodeSpecContent(nodes, nodeSpec.content);
|
|
22
|
-
}
|
|
23
|
-
nodes[nodeKey] = nodeSpec;
|
|
24
|
-
});
|
|
25
|
-
return nodes;
|
|
26
|
-
}
|
|
27
|
-
function sanitizeNodeSpecContent(nodes, rawContent) {
|
|
28
|
-
var content = rawContent.replace(/\W/g, ' ');
|
|
29
|
-
var contentKeys = content.split(' ');
|
|
30
|
-
var unsupportedContentKeys = contentKeys.filter(function (contentKey) {
|
|
31
|
-
return !isContentSupported(nodes, contentKey);
|
|
32
|
-
});
|
|
33
|
-
return unsupportedContentKeys.reduce(function (newContent, nodeName) {
|
|
34
|
-
return sanitizedContent(newContent, nodeName);
|
|
35
|
-
}, rawContent);
|
|
36
|
-
}
|
|
37
|
-
function sanitizedContent(content, invalidContent) {
|
|
38
|
-
if (!invalidContent.length) {
|
|
39
|
-
return content || '';
|
|
40
|
-
}
|
|
41
|
-
if (!content || !content.match(/\w/)) {
|
|
42
|
-
return '';
|
|
43
|
-
}
|
|
44
|
-
var pattern = "(".concat(invalidContent, "((\\s)*\\|)+)|((\\|(\\s)*)+").concat(invalidContent, ")|(").concat(invalidContent, "$)|(").concat(invalidContent, "(\\+|\\*))");
|
|
45
|
-
return content.replace(new RegExp(pattern, 'g'), '').replace(' ', ' ').trim();
|
|
46
|
-
}
|
|
47
|
-
function isContentSupported(nodes, contentKey) {
|
|
48
|
-
var nodeKeys = Object.keys(nodes);
|
|
49
|
-
|
|
50
|
-
// content is with valid node
|
|
51
|
-
if (nodeKeys.indexOf(contentKey) > -1) {
|
|
52
|
-
return true;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// content is with valid group
|
|
56
|
-
for (var supportedKey in nodes) {
|
|
57
|
-
var nodeSpec = nodes[supportedKey];
|
|
58
|
-
if (nodeSpec && nodeSpec.group === contentKey) {
|
|
59
|
-
return true;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
return false;
|
|
63
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
export function sanitizeNodes(nodes, supportedMarks) {
|
|
2
|
-
const nodeNames = Object.keys(nodes);
|
|
3
|
-
nodeNames.forEach(nodeKey => {
|
|
4
|
-
const nodeSpec = {
|
|
5
|
-
...nodes[nodeKey]
|
|
6
|
-
};
|
|
7
|
-
if (nodeSpec.marks && nodeSpec.marks !== '_') {
|
|
8
|
-
nodeSpec.marks = nodeSpec.marks.split(' ').filter(mark => !!supportedMarks[mark]).join(' ');
|
|
9
|
-
}
|
|
10
|
-
if (nodeSpec.content) {
|
|
11
|
-
nodeSpec.content = sanitizeNodeSpecContent(nodes, nodeSpec.content);
|
|
12
|
-
}
|
|
13
|
-
nodes[nodeKey] = nodeSpec;
|
|
14
|
-
});
|
|
15
|
-
return nodes;
|
|
16
|
-
}
|
|
17
|
-
function sanitizeNodeSpecContent(nodes, rawContent) {
|
|
18
|
-
const content = rawContent.replace(/\W/g, ' ');
|
|
19
|
-
const contentKeys = content.split(' ');
|
|
20
|
-
const unsupportedContentKeys = contentKeys.filter(contentKey => !isContentSupported(nodes, contentKey));
|
|
21
|
-
return unsupportedContentKeys.reduce((newContent, nodeName) => sanitizedContent(newContent, nodeName), rawContent);
|
|
22
|
-
}
|
|
23
|
-
function sanitizedContent(content, invalidContent) {
|
|
24
|
-
if (!invalidContent.length) {
|
|
25
|
-
return content || '';
|
|
26
|
-
}
|
|
27
|
-
if (!content || !content.match(/\w/)) {
|
|
28
|
-
return '';
|
|
29
|
-
}
|
|
30
|
-
const pattern = `(${invalidContent}((\\s)*\\|)+)|((\\|(\\s)*)+${invalidContent})|(${invalidContent}$)|(${invalidContent}(\\+|\\*))`;
|
|
31
|
-
return content.replace(new RegExp(pattern, 'g'), '').replace(' ', ' ').trim();
|
|
32
|
-
}
|
|
33
|
-
function isContentSupported(nodes, contentKey) {
|
|
34
|
-
const nodeKeys = Object.keys(nodes);
|
|
35
|
-
|
|
36
|
-
// content is with valid node
|
|
37
|
-
if (nodeKeys.indexOf(contentKey) > -1) {
|
|
38
|
-
return true;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// content is with valid group
|
|
42
|
-
for (const supportedKey in nodes) {
|
|
43
|
-
const nodeSpec = nodes[supportedKey];
|
|
44
|
-
if (nodeSpec && nodeSpec.group === contentKey) {
|
|
45
|
-
return true;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
return false;
|
|
49
|
-
}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
-
export function sanitizeNodes(nodes, supportedMarks) {
|
|
5
|
-
var nodeNames = Object.keys(nodes);
|
|
6
|
-
nodeNames.forEach(function (nodeKey) {
|
|
7
|
-
var nodeSpec = _objectSpread({}, nodes[nodeKey]);
|
|
8
|
-
if (nodeSpec.marks && nodeSpec.marks !== '_') {
|
|
9
|
-
nodeSpec.marks = nodeSpec.marks.split(' ').filter(function (mark) {
|
|
10
|
-
return !!supportedMarks[mark];
|
|
11
|
-
}).join(' ');
|
|
12
|
-
}
|
|
13
|
-
if (nodeSpec.content) {
|
|
14
|
-
nodeSpec.content = sanitizeNodeSpecContent(nodes, nodeSpec.content);
|
|
15
|
-
}
|
|
16
|
-
nodes[nodeKey] = nodeSpec;
|
|
17
|
-
});
|
|
18
|
-
return nodes;
|
|
19
|
-
}
|
|
20
|
-
function sanitizeNodeSpecContent(nodes, rawContent) {
|
|
21
|
-
var content = rawContent.replace(/\W/g, ' ');
|
|
22
|
-
var contentKeys = content.split(' ');
|
|
23
|
-
var unsupportedContentKeys = contentKeys.filter(function (contentKey) {
|
|
24
|
-
return !isContentSupported(nodes, contentKey);
|
|
25
|
-
});
|
|
26
|
-
return unsupportedContentKeys.reduce(function (newContent, nodeName) {
|
|
27
|
-
return sanitizedContent(newContent, nodeName);
|
|
28
|
-
}, rawContent);
|
|
29
|
-
}
|
|
30
|
-
function sanitizedContent(content, invalidContent) {
|
|
31
|
-
if (!invalidContent.length) {
|
|
32
|
-
return content || '';
|
|
33
|
-
}
|
|
34
|
-
if (!content || !content.match(/\w/)) {
|
|
35
|
-
return '';
|
|
36
|
-
}
|
|
37
|
-
var pattern = "(".concat(invalidContent, "((\\s)*\\|)+)|((\\|(\\s)*)+").concat(invalidContent, ")|(").concat(invalidContent, "$)|(").concat(invalidContent, "(\\+|\\*))");
|
|
38
|
-
return content.replace(new RegExp(pattern, 'g'), '').replace(' ', ' ').trim();
|
|
39
|
-
}
|
|
40
|
-
function isContentSupported(nodes, contentKey) {
|
|
41
|
-
var nodeKeys = Object.keys(nodes);
|
|
42
|
-
|
|
43
|
-
// content is with valid node
|
|
44
|
-
if (nodeKeys.indexOf(contentKey) > -1) {
|
|
45
|
-
return true;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// content is with valid group
|
|
49
|
-
for (var supportedKey in nodes) {
|
|
50
|
-
var nodeSpec = nodes[supportedKey];
|
|
51
|
-
if (nodeSpec && nodeSpec.group === contentKey) {
|
|
52
|
-
return true;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
return false;
|
|
56
|
-
}
|