@atlaskit/adf-schema 44.4.0 → 44.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 +13 -0
- package/dist/cjs/next-schema/nodes/blockCard.js +7 -34
- package/dist/cjs/schema/create-schema.js +2 -60
- package/dist/cjs/schema/index.js +2 -1
- package/dist/cjs/schema/sanitizeNodes.js +63 -0
- package/dist/es2019/next-schema/nodes/blockCard.js +7 -34
- package/dist/es2019/schema/create-schema.js +1 -49
- package/dist/es2019/schema/index.js +2 -1
- package/dist/es2019/schema/sanitizeNodes.js +49 -0
- package/dist/esm/next-schema/nodes/blockCard.js +7 -34
- package/dist/esm/schema/create-schema.js +1 -56
- package/dist/esm/schema/index.js +2 -1
- package/dist/esm/schema/sanitizeNodes.js +56 -0
- package/dist/json-schema/v1/full.json +2 -2
- package/dist/json-schema/v1/stage-0.json +2 -2
- package/dist/types/schema/create-schema.d.ts +0 -10
- package/dist/types/schema/index.d.ts +2 -1
- package/dist/types/schema/sanitizeNodes.d.ts +8 -0
- package/json-schema/v1/full.json +2 -2
- package/json-schema/v1/stage-0.json +2 -2
- package/package.json +2 -2
- package/sanitize-nodes/package.json +8 -0
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,18 @@
|
|
1
1
|
# @atlaskit/adf-schema
|
2
2
|
|
3
|
+
## 44.6.0
|
4
|
+
|
5
|
+
### Minor Changes
|
6
|
+
|
7
|
+
- c8a4a74: Fix ADF Inconsistency for Block Card
|
8
|
+
|
9
|
+
## 44.5.0
|
10
|
+
|
11
|
+
### Minor Changes
|
12
|
+
|
13
|
+
- bca057f: - fix content expressions cleanup logic
|
14
|
+
- add separate entry point for sanitizeNodes
|
15
|
+
|
3
16
|
## 44.4.0
|
4
17
|
|
5
18
|
### Minor Changes
|
@@ -28,13 +28,18 @@ var blockCard = exports.blockCard = (0, _adfSchemaGenerator.adfNode)('blockCard'
|
|
28
28
|
type: 'string'
|
29
29
|
},
|
30
30
|
// Empty parameters object carried over from original JSON Schema.
|
31
|
-
parameters: {
|
31
|
+
parameters: {
|
32
|
+
type: 'object'
|
33
|
+
},
|
32
34
|
views: {
|
33
35
|
items: {
|
34
36
|
additionalProperties: false,
|
35
37
|
properties: {
|
36
38
|
// Empty properties object carried over from original JSON Schema
|
37
|
-
properties: {
|
39
|
+
properties: {
|
40
|
+
optional: true,
|
41
|
+
type: 'object'
|
42
|
+
},
|
38
43
|
type: {
|
39
44
|
type: 'string'
|
40
45
|
}
|
@@ -70,37 +75,5 @@ var blockCard = exports.blockCard = (0, _adfSchemaGenerator.adfNode)('blockCard'
|
|
70
75
|
default: null
|
71
76
|
}
|
72
77
|
}]
|
73
|
-
},
|
74
|
-
DANGEROUS_MANUAL_OVERRIDE: {
|
75
|
-
'validator-spec': {
|
76
|
-
'props.attrs[0].props.datasource': {
|
77
|
-
reason: '@DSLCompatibilityException - mismatch for blockcard',
|
78
|
-
value: {
|
79
|
-
props: {
|
80
|
-
id: {
|
81
|
-
type: 'string'
|
82
|
-
},
|
83
|
-
parameters: {
|
84
|
-
type: 'object'
|
85
|
-
},
|
86
|
-
views: {
|
87
|
-
items: [{
|
88
|
-
props: {
|
89
|
-
properties: {
|
90
|
-
optional: true,
|
91
|
-
type: 'object'
|
92
|
-
},
|
93
|
-
type: {
|
94
|
-
type: 'string'
|
95
|
-
}
|
96
|
-
}
|
97
|
-
}],
|
98
|
-
minItems: 1,
|
99
|
-
type: 'array'
|
100
|
-
}
|
101
|
-
}
|
102
|
-
}
|
103
|
-
}
|
104
|
-
}
|
105
78
|
}
|
106
79
|
});
|
@@ -1,21 +1,16 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
5
4
|
value: true
|
6
5
|
});
|
7
6
|
exports.allowCustomPanel = void 0;
|
8
7
|
exports.createSchema = createSchema;
|
9
8
|
exports.getNodesAndMarksMap = getNodesAndMarksMap;
|
10
|
-
exports.sanitizeNodeSpecContent = sanitizeNodeSpecContent;
|
11
|
-
exports.sanitizeNodes = sanitizeNodes;
|
12
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
13
9
|
var _model = require("@atlaskit/editor-prosemirror/model");
|
14
10
|
var _groups = require("./groups");
|
11
|
+
var _sanitizeNodes = require("./sanitizeNodes");
|
15
12
|
var _marks = require("./marks");
|
16
13
|
var _nodes = require("./nodes");
|
17
|
-
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; }
|
18
|
-
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; }
|
19
14
|
function addItems(builtInItems, config) {
|
20
15
|
var customSpecs = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
21
16
|
if (!config) {
|
@@ -305,63 +300,10 @@ function createSchema(config) {
|
|
305
300
|
var marksConfig = Object.keys(customMarkSpecs || {}).concat(config.marks || []).concat(markGroupDeclarationsNames);
|
306
301
|
var nodes = addItems(nodesInOrder, nodesConfig, customNodeSpecs);
|
307
302
|
var marks = addItems(marksInOrder, marksConfig, customMarkSpecs);
|
308
|
-
nodes = sanitizeNodes(nodes, marks);
|
303
|
+
nodes = (0, _sanitizeNodes.sanitizeNodes)(nodes, marks);
|
309
304
|
return new _model.Schema({
|
310
305
|
nodes: nodes,
|
311
306
|
marks: marks
|
312
307
|
});
|
313
308
|
}
|
314
|
-
function sanitizeNodes(nodes, supportedMarks) {
|
315
|
-
var nodeNames = Object.keys(nodes);
|
316
|
-
nodeNames.forEach(function (nodeKey) {
|
317
|
-
var nodeSpec = _objectSpread({}, nodes[nodeKey]);
|
318
|
-
if (nodeSpec.marks && nodeSpec.marks !== '_') {
|
319
|
-
nodeSpec.marks = nodeSpec.marks.split(' ').filter(function (mark) {
|
320
|
-
return !!supportedMarks[mark];
|
321
|
-
}).join(' ');
|
322
|
-
}
|
323
|
-
if (nodeSpec.content) {
|
324
|
-
nodeSpec.content = sanitizeNodeSpecContent(nodes, nodeSpec.content);
|
325
|
-
}
|
326
|
-
nodes[nodeKey] = nodeSpec;
|
327
|
-
});
|
328
|
-
return nodes;
|
329
|
-
}
|
330
|
-
function sanitizeNodeSpecContent(nodes, rawContent) {
|
331
|
-
var content = rawContent.replace(/\W/g, ' ');
|
332
|
-
var contentKeys = content.split(' ');
|
333
|
-
var unsupportedContentKeys = contentKeys.filter(function (contentKey) {
|
334
|
-
return !isContentSupported(nodes, contentKey);
|
335
|
-
});
|
336
|
-
return unsupportedContentKeys.reduce(function (newContent, nodeName) {
|
337
|
-
return sanitizedContent(newContent, nodeName);
|
338
|
-
}, rawContent);
|
339
|
-
}
|
340
|
-
function sanitizedContent(content, invalidContent) {
|
341
|
-
if (!invalidContent.length) {
|
342
|
-
return content || '';
|
343
|
-
}
|
344
|
-
if (!content || !content.match(/\w/)) {
|
345
|
-
return '';
|
346
|
-
}
|
347
|
-
var pattern = "(".concat(invalidContent, "((\\s)*\\|)+)|((\\|(\\s)*)+").concat(invalidContent, ")|(").concat(invalidContent, "$)|(").concat(invalidContent, "(\\+|\\*))");
|
348
|
-
return content.replace(new RegExp(pattern, 'g'), '').replace(' ', ' ').trim();
|
349
|
-
}
|
350
|
-
function isContentSupported(nodes, contentKey) {
|
351
|
-
var nodeKeys = Object.keys(nodes);
|
352
|
-
|
353
|
-
// content is with valid node
|
354
|
-
if (nodeKeys.indexOf(contentKey) > -1) {
|
355
|
-
return true;
|
356
|
-
}
|
357
|
-
|
358
|
-
// content is with valid group
|
359
|
-
for (var supportedKey in nodes) {
|
360
|
-
var nodeSpec = nodes[supportedKey];
|
361
|
-
if (nodeSpec && nodeSpec.group === contentKey) {
|
362
|
-
return true;
|
363
|
-
}
|
364
|
-
}
|
365
|
-
return false;
|
366
|
-
}
|
367
309
|
var allowCustomPanel = exports.allowCustomPanel = true;
|
package/dist/cjs/schema/index.js
CHANGED
@@ -540,7 +540,7 @@ Object.defineProperty(exports, "rule", {
|
|
540
540
|
Object.defineProperty(exports, "sanitizeNodes", {
|
541
541
|
enumerable: true,
|
542
542
|
get: function get() {
|
543
|
-
return
|
543
|
+
return _sanitizeNodes.sanitizeNodes;
|
544
544
|
}
|
545
545
|
});
|
546
546
|
Object.defineProperty(exports, "status", {
|
@@ -776,4 +776,5 @@ var _marks = require("./marks");
|
|
776
776
|
var _unsupported = require("./unsupported");
|
777
777
|
var _inlineNodes = require("./inline-nodes");
|
778
778
|
var _createSchema = require("./create-schema");
|
779
|
+
var _sanitizeNodes = require("./sanitizeNodes");
|
779
780
|
var _createPMSpecFactory = require("./createPMSpecFactory");
|
@@ -0,0 +1,63 @@
|
|
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
|
+
}
|
@@ -22,13 +22,18 @@ export const blockCard = adfNode('blockCard').define({
|
|
22
22
|
type: 'string'
|
23
23
|
},
|
24
24
|
// Empty parameters object carried over from original JSON Schema.
|
25
|
-
parameters: {
|
25
|
+
parameters: {
|
26
|
+
type: 'object'
|
27
|
+
},
|
26
28
|
views: {
|
27
29
|
items: {
|
28
30
|
additionalProperties: false,
|
29
31
|
properties: {
|
30
32
|
// Empty properties object carried over from original JSON Schema
|
31
|
-
properties: {
|
33
|
+
properties: {
|
34
|
+
optional: true,
|
35
|
+
type: 'object'
|
36
|
+
},
|
32
37
|
type: {
|
33
38
|
type: 'string'
|
34
39
|
}
|
@@ -64,37 +69,5 @@ export const blockCard = adfNode('blockCard').define({
|
|
64
69
|
default: null
|
65
70
|
}
|
66
71
|
}]
|
67
|
-
},
|
68
|
-
DANGEROUS_MANUAL_OVERRIDE: {
|
69
|
-
'validator-spec': {
|
70
|
-
'props.attrs[0].props.datasource': {
|
71
|
-
reason: '@DSLCompatibilityException - mismatch for blockcard',
|
72
|
-
value: {
|
73
|
-
props: {
|
74
|
-
id: {
|
75
|
-
type: 'string'
|
76
|
-
},
|
77
|
-
parameters: {
|
78
|
-
type: 'object'
|
79
|
-
},
|
80
|
-
views: {
|
81
|
-
items: [{
|
82
|
-
props: {
|
83
|
-
properties: {
|
84
|
-
optional: true,
|
85
|
-
type: 'object'
|
86
|
-
},
|
87
|
-
type: {
|
88
|
-
type: 'string'
|
89
|
-
}
|
90
|
-
}
|
91
|
-
}],
|
92
|
-
minItems: 1,
|
93
|
-
type: 'array'
|
94
|
-
}
|
95
|
-
}
|
96
|
-
}
|
97
|
-
}
|
98
|
-
}
|
99
72
|
}
|
100
73
|
});
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import { Schema } from '@atlaskit/editor-prosemirror/model';
|
2
2
|
import { COLOR, FONT_STYLE, SEARCH_QUERY, LINK } from './groups';
|
3
|
+
import { sanitizeNodes } from './sanitizeNodes';
|
3
4
|
import { link, em, strong, textColor, strike, subsup, underline, code, typeAheadQuery, confluenceInlineComment, breakout, alignment, indentation, annotation, unsupportedMark, unsupportedNodeAttribute, dataConsumer, fragment, border, backgroundColor } from './marks';
|
4
5
|
import { confluenceJiraIssue, confluenceUnsupportedBlock, confluenceUnsupportedInline, doc, paragraph, text, bulletList, orderedListWithOrder, listItemWithTask, heading, blockquoteWithNestedCodeblockOrMedia, codeBlock, extendedPanel, rule, image, mention, media, mediaInline, mediaSingleFull, mediaGroup, hardBreak, emoji, table, tableCell, tableHeader, tableRow, decisionList, decisionItem, taskList, taskItem, unknownBlock, extension, inlineExtension, bodiedExtension, multiBodiedExtension, extensionFrame, date, placeholder, layoutSection, layoutColumn, inlineCard, blockCard, unsupportedBlock, unsupportedInline, status, expandWithNestedExpand, nestedExpand, embedCard, caption } from './nodes';
|
5
6
|
function addItems(builtInItems, config, customSpecs = {}) {
|
@@ -299,53 +300,4 @@ export function createSchema(config) {
|
|
299
300
|
marks
|
300
301
|
});
|
301
302
|
}
|
302
|
-
export function sanitizeNodes(nodes, supportedMarks) {
|
303
|
-
const nodeNames = Object.keys(nodes);
|
304
|
-
nodeNames.forEach(nodeKey => {
|
305
|
-
const nodeSpec = {
|
306
|
-
...nodes[nodeKey]
|
307
|
-
};
|
308
|
-
if (nodeSpec.marks && nodeSpec.marks !== '_') {
|
309
|
-
nodeSpec.marks = nodeSpec.marks.split(' ').filter(mark => !!supportedMarks[mark]).join(' ');
|
310
|
-
}
|
311
|
-
if (nodeSpec.content) {
|
312
|
-
nodeSpec.content = sanitizeNodeSpecContent(nodes, nodeSpec.content);
|
313
|
-
}
|
314
|
-
nodes[nodeKey] = nodeSpec;
|
315
|
-
});
|
316
|
-
return nodes;
|
317
|
-
}
|
318
|
-
export function sanitizeNodeSpecContent(nodes, rawContent) {
|
319
|
-
const content = rawContent.replace(/\W/g, ' ');
|
320
|
-
const contentKeys = content.split(' ');
|
321
|
-
const unsupportedContentKeys = contentKeys.filter(contentKey => !isContentSupported(nodes, contentKey));
|
322
|
-
return unsupportedContentKeys.reduce((newContent, nodeName) => sanitizedContent(newContent, nodeName), rawContent);
|
323
|
-
}
|
324
|
-
function sanitizedContent(content, invalidContent) {
|
325
|
-
if (!invalidContent.length) {
|
326
|
-
return content || '';
|
327
|
-
}
|
328
|
-
if (!content || !content.match(/\w/)) {
|
329
|
-
return '';
|
330
|
-
}
|
331
|
-
const pattern = `(${invalidContent}((\\s)*\\|)+)|((\\|(\\s)*)+${invalidContent})|(${invalidContent}$)|(${invalidContent}(\\+|\\*))`;
|
332
|
-
return content.replace(new RegExp(pattern, 'g'), '').replace(' ', ' ').trim();
|
333
|
-
}
|
334
|
-
function isContentSupported(nodes, contentKey) {
|
335
|
-
const nodeKeys = Object.keys(nodes);
|
336
|
-
|
337
|
-
// content is with valid node
|
338
|
-
if (nodeKeys.indexOf(contentKey) > -1) {
|
339
|
-
return true;
|
340
|
-
}
|
341
|
-
|
342
|
-
// content is with valid group
|
343
|
-
for (const supportedKey in nodes) {
|
344
|
-
const nodeSpec = nodes[supportedKey];
|
345
|
-
if (nodeSpec && nodeSpec.group === contentKey) {
|
346
|
-
return true;
|
347
|
-
}
|
348
|
-
}
|
349
|
-
return false;
|
350
|
-
}
|
351
303
|
export const allowCustomPanel = true;
|
@@ -3,7 +3,8 @@ export { AnnotationTypes, alignment, alignmentPositionMap, annotation, breakout,
|
|
3
3
|
colorPaletteExtended, confluenceInlineComment, dataConsumer, dataConsumerToJSON, em, fragment, fragmentToJSON, indentation, link, linkToJSON, strike, strong, subsup, textColor, typeAheadQuery, underline, buildAnnotationMarkDataAttributes, AnnotationMarkStates, unsupportedMark, unsupportedNodeAttribute, border, borderColorPalette, backgroundColor, backgroundColorPalette } from './marks';
|
4
4
|
export { unsupportedNodeTypesForMediaCards } from './unsupported';
|
5
5
|
export { inlineNodes } from './inline-nodes';
|
6
|
-
export {
|
6
|
+
export { createSchema } from './create-schema';
|
7
|
+
export { sanitizeNodes } from './sanitizeNodes';
|
7
8
|
|
8
9
|
// ADF createPMSpecFactory
|
9
10
|
|
@@ -0,0 +1,49 @@
|
|
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
|
+
}
|
@@ -22,13 +22,18 @@ export var blockCard = adfNode('blockCard').define({
|
|
22
22
|
type: 'string'
|
23
23
|
},
|
24
24
|
// Empty parameters object carried over from original JSON Schema.
|
25
|
-
parameters: {
|
25
|
+
parameters: {
|
26
|
+
type: 'object'
|
27
|
+
},
|
26
28
|
views: {
|
27
29
|
items: {
|
28
30
|
additionalProperties: false,
|
29
31
|
properties: {
|
30
32
|
// Empty properties object carried over from original JSON Schema
|
31
|
-
properties: {
|
33
|
+
properties: {
|
34
|
+
optional: true,
|
35
|
+
type: 'object'
|
36
|
+
},
|
32
37
|
type: {
|
33
38
|
type: 'string'
|
34
39
|
}
|
@@ -64,37 +69,5 @@ export var blockCard = adfNode('blockCard').define({
|
|
64
69
|
default: null
|
65
70
|
}
|
66
71
|
}]
|
67
|
-
},
|
68
|
-
DANGEROUS_MANUAL_OVERRIDE: {
|
69
|
-
'validator-spec': {
|
70
|
-
'props.attrs[0].props.datasource': {
|
71
|
-
reason: '@DSLCompatibilityException - mismatch for blockcard',
|
72
|
-
value: {
|
73
|
-
props: {
|
74
|
-
id: {
|
75
|
-
type: 'string'
|
76
|
-
},
|
77
|
-
parameters: {
|
78
|
-
type: 'object'
|
79
|
-
},
|
80
|
-
views: {
|
81
|
-
items: [{
|
82
|
-
props: {
|
83
|
-
properties: {
|
84
|
-
optional: true,
|
85
|
-
type: 'object'
|
86
|
-
},
|
87
|
-
type: {
|
88
|
-
type: 'string'
|
89
|
-
}
|
90
|
-
}
|
91
|
-
}],
|
92
|
-
minItems: 1,
|
93
|
-
type: 'array'
|
94
|
-
}
|
95
|
-
}
|
96
|
-
}
|
97
|
-
}
|
98
|
-
}
|
99
72
|
}
|
100
73
|
});
|
@@ -1,8 +1,6 @@
|
|
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
1
|
import { Schema } from '@atlaskit/editor-prosemirror/model';
|
5
2
|
import { COLOR, FONT_STYLE, SEARCH_QUERY, LINK } from './groups';
|
3
|
+
import { sanitizeNodes } from './sanitizeNodes';
|
6
4
|
import { link, em, strong, textColor, strike, subsup, underline, code, typeAheadQuery, confluenceInlineComment, breakout, alignment, indentation, annotation, unsupportedMark, unsupportedNodeAttribute, dataConsumer, fragment, border, backgroundColor } from './marks';
|
7
5
|
import { confluenceJiraIssue, confluenceUnsupportedBlock, confluenceUnsupportedInline, doc, paragraph, text, bulletList, orderedListWithOrder, listItemWithTask, heading, blockquoteWithNestedCodeblockOrMedia, codeBlock, extendedPanel, rule, image, mention, media, mediaInline, mediaSingleFull, mediaGroup, hardBreak, emoji, table, tableCell, tableHeader, tableRow, decisionList, decisionItem, taskList, taskItem, unknownBlock, extension, inlineExtension, bodiedExtension, multiBodiedExtension, extensionFrame, date, placeholder, layoutSection, layoutColumn, inlineCard, blockCard, unsupportedBlock, unsupportedInline, status, expandWithNestedExpand, nestedExpand, embedCard, caption } from './nodes';
|
8
6
|
function addItems(builtInItems, config) {
|
@@ -300,57 +298,4 @@ export function createSchema(config) {
|
|
300
298
|
marks: marks
|
301
299
|
});
|
302
300
|
}
|
303
|
-
export function sanitizeNodes(nodes, supportedMarks) {
|
304
|
-
var nodeNames = Object.keys(nodes);
|
305
|
-
nodeNames.forEach(function (nodeKey) {
|
306
|
-
var nodeSpec = _objectSpread({}, nodes[nodeKey]);
|
307
|
-
if (nodeSpec.marks && nodeSpec.marks !== '_') {
|
308
|
-
nodeSpec.marks = nodeSpec.marks.split(' ').filter(function (mark) {
|
309
|
-
return !!supportedMarks[mark];
|
310
|
-
}).join(' ');
|
311
|
-
}
|
312
|
-
if (nodeSpec.content) {
|
313
|
-
nodeSpec.content = sanitizeNodeSpecContent(nodes, nodeSpec.content);
|
314
|
-
}
|
315
|
-
nodes[nodeKey] = nodeSpec;
|
316
|
-
});
|
317
|
-
return nodes;
|
318
|
-
}
|
319
|
-
export function sanitizeNodeSpecContent(nodes, rawContent) {
|
320
|
-
var content = rawContent.replace(/\W/g, ' ');
|
321
|
-
var contentKeys = content.split(' ');
|
322
|
-
var unsupportedContentKeys = contentKeys.filter(function (contentKey) {
|
323
|
-
return !isContentSupported(nodes, contentKey);
|
324
|
-
});
|
325
|
-
return unsupportedContentKeys.reduce(function (newContent, nodeName) {
|
326
|
-
return sanitizedContent(newContent, nodeName);
|
327
|
-
}, rawContent);
|
328
|
-
}
|
329
|
-
function sanitizedContent(content, invalidContent) {
|
330
|
-
if (!invalidContent.length) {
|
331
|
-
return content || '';
|
332
|
-
}
|
333
|
-
if (!content || !content.match(/\w/)) {
|
334
|
-
return '';
|
335
|
-
}
|
336
|
-
var pattern = "(".concat(invalidContent, "((\\s)*\\|)+)|((\\|(\\s)*)+").concat(invalidContent, ")|(").concat(invalidContent, "$)|(").concat(invalidContent, "(\\+|\\*))");
|
337
|
-
return content.replace(new RegExp(pattern, 'g'), '').replace(' ', ' ').trim();
|
338
|
-
}
|
339
|
-
function isContentSupported(nodes, contentKey) {
|
340
|
-
var nodeKeys = Object.keys(nodes);
|
341
|
-
|
342
|
-
// content is with valid node
|
343
|
-
if (nodeKeys.indexOf(contentKey) > -1) {
|
344
|
-
return true;
|
345
|
-
}
|
346
|
-
|
347
|
-
// content is with valid group
|
348
|
-
for (var supportedKey in nodes) {
|
349
|
-
var nodeSpec = nodes[supportedKey];
|
350
|
-
if (nodeSpec && nodeSpec.group === contentKey) {
|
351
|
-
return true;
|
352
|
-
}
|
353
|
-
}
|
354
|
-
return false;
|
355
|
-
}
|
356
301
|
export var allowCustomPanel = true;
|
package/dist/esm/schema/index.js
CHANGED
@@ -3,7 +3,8 @@ export { AnnotationTypes, alignment, alignmentPositionMap, annotation, breakout,
|
|
3
3
|
colorPaletteExtended, confluenceInlineComment, dataConsumer, dataConsumerToJSON, em, fragment, fragmentToJSON, indentation, link, linkToJSON, strike, strong, subsup, textColor, typeAheadQuery, underline, buildAnnotationMarkDataAttributes, AnnotationMarkStates, unsupportedMark, unsupportedNodeAttribute, border, borderColorPalette, backgroundColor, backgroundColorPalette } from './marks';
|
4
4
|
export { unsupportedNodeTypesForMediaCards } from './unsupported';
|
5
5
|
export { inlineNodes } from './inline-nodes';
|
6
|
-
export {
|
6
|
+
export { createSchema } from './create-schema';
|
7
|
+
export { sanitizeNodes } from './sanitizeNodes';
|
7
8
|
|
8
9
|
// ADF createPMSpecFactory
|
9
10
|
|
@@ -0,0 +1,56 @@
|
|
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
|
+
}
|
@@ -27,7 +27,7 @@
|
|
27
27
|
"parameters": {},
|
28
28
|
"views": {
|
29
29
|
"items": {
|
30
|
-
"
|
30
|
+
"type": "object",
|
31
31
|
"properties": {
|
32
32
|
"properties": {},
|
33
33
|
"type": {
|
@@ -35,7 +35,7 @@
|
|
35
35
|
}
|
36
36
|
},
|
37
37
|
"required": ["type"],
|
38
|
-
"
|
38
|
+
"additionalProperties": false
|
39
39
|
},
|
40
40
|
"minItems": 1,
|
41
41
|
"type": "array"
|
@@ -27,7 +27,7 @@
|
|
27
27
|
"parameters": {},
|
28
28
|
"views": {
|
29
29
|
"items": {
|
30
|
-
"
|
30
|
+
"type": "object",
|
31
31
|
"properties": {
|
32
32
|
"properties": {},
|
33
33
|
"type": {
|
@@ -35,7 +35,7 @@
|
|
35
35
|
}
|
36
36
|
},
|
37
37
|
"required": ["type"],
|
38
|
-
"
|
38
|
+
"additionalProperties": false
|
39
39
|
},
|
40
40
|
"minItems": 1,
|
41
41
|
"type": "array"
|
@@ -7,16 +7,6 @@ export declare function getNodesAndMarksMap(): {
|
|
7
7
|
* Creates a schema preserving order of marks and nodes.
|
8
8
|
*/
|
9
9
|
export declare function createSchema<N extends string = string, M extends string = string>(config: SchemaConfig<N, M>): Schema<N, M>;
|
10
|
-
export declare function sanitizeNodes(nodes: {
|
11
|
-
[key: string]: NodeSpec;
|
12
|
-
}, supportedMarks: {
|
13
|
-
[key: string]: MarkSpec;
|
14
|
-
}): {
|
15
|
-
[key: string]: NodeSpec;
|
16
|
-
};
|
17
|
-
export declare function sanitizeNodeSpecContent(nodes: {
|
18
|
-
[key: string]: NodeSpec;
|
19
|
-
}, rawContent: string): string;
|
20
10
|
export interface SchemaConfig<N = string, M = string> {
|
21
11
|
nodes: N[];
|
22
12
|
customNodeSpecs?: SchemaCustomNodeSpecs;
|
@@ -6,6 +6,7 @@ colorPaletteExtended, confluenceInlineComment, dataConsumer, dataConsumerToJSON,
|
|
6
6
|
export type { AlignmentAttributes, AlignmentMarkDefinition, AnnotationMarkAttributes, AnnotationMarkDefinition, BreakoutMarkAttrs, BreakoutMarkDefinition, CodeDefinition, EmDefinition, FragmentAttributes, FragmentDefinition, IndentationMarkAttributes, IndentationMarkDefinition, LinkAttributes, LinkDefinition, StrikeDefinition, StrongDefinition, SubSupAttributes, SubSupDefinition, TextColorAttributes, TextColorDefinition, UnderlineDefinition, AnnotationId, AnnotationDataAttributes, DataConsumerAttributes, DataConsumerDefinition, BorderMarkAttributes, BorderMarkDefinition, BackgroundColorDefinition, } from './marks';
|
7
7
|
export { unsupportedNodeTypesForMediaCards } from './unsupported';
|
8
8
|
export { inlineNodes } from './inline-nodes';
|
9
|
-
export {
|
9
|
+
export { createSchema } from './create-schema';
|
10
|
+
export { sanitizeNodes } from './sanitizeNodes';
|
10
11
|
export type { NodeSpecOptions, MarkSpecOptions } from './createPMSpecFactory';
|
11
12
|
export { createPMNodeSpecFactory, createPMMarkSpecFactory, } from './createPMSpecFactory';
|
package/json-schema/v1/full.json
CHANGED
@@ -27,7 +27,7 @@
|
|
27
27
|
"parameters": {},
|
28
28
|
"views": {
|
29
29
|
"items": {
|
30
|
-
"
|
30
|
+
"type": "object",
|
31
31
|
"properties": {
|
32
32
|
"properties": {},
|
33
33
|
"type": {
|
@@ -35,7 +35,7 @@
|
|
35
35
|
}
|
36
36
|
},
|
37
37
|
"required": ["type"],
|
38
|
-
"
|
38
|
+
"additionalProperties": false
|
39
39
|
},
|
40
40
|
"minItems": 1,
|
41
41
|
"type": "array"
|
@@ -27,7 +27,7 @@
|
|
27
27
|
"parameters": {},
|
28
28
|
"views": {
|
29
29
|
"items": {
|
30
|
-
"
|
30
|
+
"type": "object",
|
31
31
|
"properties": {
|
32
32
|
"properties": {},
|
33
33
|
"type": {
|
@@ -35,7 +35,7 @@
|
|
35
35
|
}
|
36
36
|
},
|
37
37
|
"required": ["type"],
|
38
|
-
"
|
38
|
+
"additionalProperties": false
|
39
39
|
},
|
40
40
|
"minItems": 1,
|
41
41
|
"type": "array"
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@atlaskit/adf-schema",
|
3
|
-
"version": "44.
|
3
|
+
"version": "44.6.0",
|
4
4
|
"description": "Shared package that contains the ADF-schema (json) and ProseMirror node/mark specs",
|
5
5
|
"publishConfig": {
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
@@ -46,7 +46,7 @@
|
|
46
46
|
},
|
47
47
|
"devDependencies": {
|
48
48
|
"@atlassian/adf-schema-json": "^1.24.0",
|
49
|
-
"@atlaskit/adf-schema-generator": "^1.
|
49
|
+
"@atlaskit/adf-schema-generator": "^1.38.0",
|
50
50
|
"@atlaskit/codemod-utils": "^4.2.4",
|
51
51
|
"@babel/cli": "^7.22.9",
|
52
52
|
"@babel/core": "^7.22.9",
|
@@ -0,0 +1,8 @@
|
|
1
|
+
{
|
2
|
+
"name": "@atlaskit/adf-schema/sanitize-nodes",
|
3
|
+
"main": "../dist/cjs/schema/sanitizeNodes.js",
|
4
|
+
"module": "../dist/esm/schema/sanitizeNodes.js",
|
5
|
+
"module:es2019": "../dist/es2019/schema/sanitizeNodes.js",
|
6
|
+
"sideEffects": false,
|
7
|
+
"types": "../dist/types/schema/sanitizeNodes.d.ts"
|
8
|
+
}
|