@atlaskit/editor-plugin-show-diff 3.1.4 → 3.1.5
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 +7 -0
- package/dist/cjs/pm-plugins/attributeDecorations.js +33 -0
- package/dist/cjs/pm-plugins/calculateDiffDecorations.js +4 -0
- package/dist/es2019/pm-plugins/attributeDecorations.js +21 -0
- package/dist/es2019/pm-plugins/calculateDiffDecorations.js +4 -0
- package/dist/esm/pm-plugins/attributeDecorations.js +26 -0
- package/dist/esm/pm-plugins/calculateDiffDecorations.js +4 -0
- package/dist/types/pm-plugins/attributeDecorations.d.ts +8 -0
- package/dist/types-ts4.5/pm-plugins/attributeDecorations.d.ts +8 -0
- package/package.json +1 -1
- package/afm-dev-agents/tsconfig.json +0 -27
- package/afm-passionfruit/tsconfig.json +0 -27
- package/afm-rovo-extension/tsconfig.json +0 -27
- package/afm-volt/tsconfig.json +0 -27
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-show-diff
|
|
2
2
|
|
|
3
|
+
## 3.1.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`7c8492867be97`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/7c8492867be97) -
|
|
8
|
+
[ux] Add support for media attribute changes in the diff
|
|
9
|
+
|
|
3
10
|
## 3.1.4
|
|
4
11
|
|
|
5
12
|
### Patch Changes
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.getAttrChangeRanges = void 0;
|
|
8
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
|
+
var _steps = require("@atlaskit/adf-schema/steps");
|
|
10
|
+
var _transform = require("@atlaskit/editor-prosemirror/transform");
|
|
11
|
+
var filterUndefined = function filterUndefined(x) {
|
|
12
|
+
return !!x;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
// Currently allow attributes that indicats a change in media image
|
|
16
|
+
var allowedAttrs = ['id', 'collection', 'url'];
|
|
17
|
+
var getAttrChangeRanges = exports.getAttrChangeRanges = function getAttrChangeRanges(doc, steps) {
|
|
18
|
+
return steps.map(function (step) {
|
|
19
|
+
if (step instanceof _transform.AttrStep && allowedAttrs.includes(step.attr) || step instanceof _steps.SetAttrsStep && (0, _toConsumableArray2.default)(Object.keys(step.attrs)).some(function (v) {
|
|
20
|
+
return allowedAttrs.includes(v);
|
|
21
|
+
})) {
|
|
22
|
+
var $pos = doc.resolve(step.pos);
|
|
23
|
+
if ($pos.parent.type === doc.type.schema.nodes.mediaSingle) {
|
|
24
|
+
var startPos = $pos.pos + $pos.parentOffset;
|
|
25
|
+
return {
|
|
26
|
+
fromB: startPos,
|
|
27
|
+
toB: startPos + $pos.parent.nodeSize - 1
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return undefined;
|
|
32
|
+
}).filter(filterUndefined);
|
|
33
|
+
};
|
|
@@ -15,6 +15,7 @@ var _steps = require("@atlaskit/adf-schema/steps");
|
|
|
15
15
|
var _document = require("@atlaskit/editor-common/utils/document");
|
|
16
16
|
var _transform = require("@atlaskit/editor-prosemirror/transform");
|
|
17
17
|
var _view = require("@atlaskit/editor-prosemirror/view");
|
|
18
|
+
var _attributeDecorations = require("./attributeDecorations");
|
|
18
19
|
var _decorations = require("./decorations");
|
|
19
20
|
var _markDecorations = require("./markDecorations");
|
|
20
21
|
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
@@ -151,6 +152,9 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref)
|
|
|
151
152
|
(0, _markDecorations.getMarkChangeRanges)(steps).forEach(function (change) {
|
|
152
153
|
decorations.push((0, _decorations.createInlineChangedDecoration)(change, colourScheme));
|
|
153
154
|
});
|
|
155
|
+
(0, _attributeDecorations.getAttrChangeRanges)(tr.doc, rawSteps).forEach(function (change) {
|
|
156
|
+
decorations.push.apply(decorations, (0, _toConsumableArray2.default)(calculateNodesForBlockDecoration(tr.doc, change.fromB, change.toB, colourScheme)));
|
|
157
|
+
});
|
|
154
158
|
return _view.DecorationSet.empty.add(tr.doc, decorations);
|
|
155
159
|
};
|
|
156
160
|
var calculateDiffDecorations = exports.calculateDiffDecorations = (0, _memoizeOne.default)(calculateDiffDecorationsInner,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { SetAttrsStep } from '@atlaskit/adf-schema/steps';
|
|
2
|
+
import { AttrStep } from '@atlaskit/editor-prosemirror/transform';
|
|
3
|
+
const filterUndefined = x => !!x;
|
|
4
|
+
|
|
5
|
+
// Currently allow attributes that indicats a change in media image
|
|
6
|
+
const allowedAttrs = ['id', 'collection', 'url'];
|
|
7
|
+
export const getAttrChangeRanges = (doc, steps) => {
|
|
8
|
+
return steps.map(step => {
|
|
9
|
+
if (step instanceof AttrStep && allowedAttrs.includes(step.attr) || step instanceof SetAttrsStep && [...Object.keys(step.attrs)].some(v => allowedAttrs.includes(v))) {
|
|
10
|
+
const $pos = doc.resolve(step.pos);
|
|
11
|
+
if ($pos.parent.type === doc.type.schema.nodes.mediaSingle) {
|
|
12
|
+
const startPos = $pos.pos + $pos.parentOffset;
|
|
13
|
+
return {
|
|
14
|
+
fromB: startPos,
|
|
15
|
+
toB: startPos + $pos.parent.nodeSize - 1
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return undefined;
|
|
20
|
+
}).filter(filterUndefined);
|
|
21
|
+
};
|
|
@@ -6,6 +6,7 @@ import { AnalyticsStep, SetAttrsStep } from '@atlaskit/adf-schema/steps';
|
|
|
6
6
|
import { areNodesEqualIgnoreAttrs } from '@atlaskit/editor-common/utils/document';
|
|
7
7
|
import { AttrStep } from '@atlaskit/editor-prosemirror/transform';
|
|
8
8
|
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
9
|
+
import { getAttrChangeRanges } from './attributeDecorations';
|
|
9
10
|
import { createInlineChangedDecoration, createDeletedContentDecoration, createBlockChangedDecoration } from './decorations';
|
|
10
11
|
import { getMarkChangeRanges } from './markDecorations';
|
|
11
12
|
const calculateNodesForBlockDecoration = (doc, from, to, colourScheme) => {
|
|
@@ -135,6 +136,9 @@ const calculateDiffDecorationsInner = ({
|
|
|
135
136
|
getMarkChangeRanges(steps).forEach(change => {
|
|
136
137
|
decorations.push(createInlineChangedDecoration(change, colourScheme));
|
|
137
138
|
});
|
|
139
|
+
getAttrChangeRanges(tr.doc, rawSteps).forEach(change => {
|
|
140
|
+
decorations.push(...calculateNodesForBlockDecoration(tr.doc, change.fromB, change.toB, colourScheme));
|
|
141
|
+
});
|
|
138
142
|
return DecorationSet.empty.add(tr.doc, decorations);
|
|
139
143
|
};
|
|
140
144
|
export const calculateDiffDecorations = memoizeOne(calculateDiffDecorationsInner,
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
+
import { SetAttrsStep } from '@atlaskit/adf-schema/steps';
|
|
3
|
+
import { AttrStep } from '@atlaskit/editor-prosemirror/transform';
|
|
4
|
+
var filterUndefined = function filterUndefined(x) {
|
|
5
|
+
return !!x;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
// Currently allow attributes that indicats a change in media image
|
|
9
|
+
var allowedAttrs = ['id', 'collection', 'url'];
|
|
10
|
+
export var getAttrChangeRanges = function getAttrChangeRanges(doc, steps) {
|
|
11
|
+
return steps.map(function (step) {
|
|
12
|
+
if (step instanceof AttrStep && allowedAttrs.includes(step.attr) || step instanceof SetAttrsStep && _toConsumableArray(Object.keys(step.attrs)).some(function (v) {
|
|
13
|
+
return allowedAttrs.includes(v);
|
|
14
|
+
})) {
|
|
15
|
+
var $pos = doc.resolve(step.pos);
|
|
16
|
+
if ($pos.parent.type === doc.type.schema.nodes.mediaSingle) {
|
|
17
|
+
var startPos = $pos.pos + $pos.parentOffset;
|
|
18
|
+
return {
|
|
19
|
+
fromB: startPos,
|
|
20
|
+
toB: startPos + $pos.parent.nodeSize - 1
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return undefined;
|
|
25
|
+
}).filter(filterUndefined);
|
|
26
|
+
};
|
|
@@ -14,6 +14,7 @@ import { AnalyticsStep, SetAttrsStep } from '@atlaskit/adf-schema/steps';
|
|
|
14
14
|
import { areNodesEqualIgnoreAttrs } from '@atlaskit/editor-common/utils/document';
|
|
15
15
|
import { AttrStep } from '@atlaskit/editor-prosemirror/transform';
|
|
16
16
|
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
17
|
+
import { getAttrChangeRanges } from './attributeDecorations';
|
|
17
18
|
import { createInlineChangedDecoration, createDeletedContentDecoration, createBlockChangedDecoration } from './decorations';
|
|
18
19
|
import { getMarkChangeRanges } from './markDecorations';
|
|
19
20
|
var calculateNodesForBlockDecoration = function calculateNodesForBlockDecoration(doc, from, to, colourScheme) {
|
|
@@ -145,6 +146,9 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref)
|
|
|
145
146
|
getMarkChangeRanges(steps).forEach(function (change) {
|
|
146
147
|
decorations.push(createInlineChangedDecoration(change, colourScheme));
|
|
147
148
|
});
|
|
149
|
+
getAttrChangeRanges(tr.doc, rawSteps).forEach(function (change) {
|
|
150
|
+
decorations.push.apply(decorations, _toConsumableArray(calculateNodesForBlockDecoration(tr.doc, change.fromB, change.toB, colourScheme)));
|
|
151
|
+
});
|
|
148
152
|
return DecorationSet.empty.add(tr.doc, decorations);
|
|
149
153
|
};
|
|
150
154
|
export var calculateDiffDecorations = memoizeOne(calculateDiffDecorationsInner,
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
import { type Step as ProseMirrorStep } from '@atlaskit/editor-prosemirror/transform';
|
|
3
|
+
type StepRange = {
|
|
4
|
+
fromB: number;
|
|
5
|
+
toB: number;
|
|
6
|
+
};
|
|
7
|
+
export declare const getAttrChangeRanges: (doc: PMNode, steps: ProseMirrorStep[]) => StepRange[];
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
import { type Step as ProseMirrorStep } from '@atlaskit/editor-prosemirror/transform';
|
|
3
|
+
type StepRange = {
|
|
4
|
+
fromB: number;
|
|
5
|
+
toB: number;
|
|
6
|
+
};
|
|
7
|
+
export declare const getAttrChangeRanges: (doc: PMNode, steps: ProseMirrorStep[]) => StepRange[];
|
|
8
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "../../../../tsconfig.entry-points.dev-agents.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"target": "es5",
|
|
5
|
-
"outDir": "../../../../../dev-agents/tsDist/@atlaskit__editor-plugin-show-diff/app",
|
|
6
|
-
"rootDir": "../",
|
|
7
|
-
"composite": true
|
|
8
|
-
},
|
|
9
|
-
"include": [
|
|
10
|
-
"../src/**/*.ts",
|
|
11
|
-
"../src/**/*.tsx"
|
|
12
|
-
],
|
|
13
|
-
"exclude": [
|
|
14
|
-
"../src/**/__tests__/*",
|
|
15
|
-
"../src/**/*.test.*",
|
|
16
|
-
"../src/**/test.*",
|
|
17
|
-
"../src/**/examples.*"
|
|
18
|
-
],
|
|
19
|
-
"references": [
|
|
20
|
-
{
|
|
21
|
-
"path": "../../../design-system/tokens/afm-dev-agents/tsconfig.json"
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
"path": "../../editor-common/afm-dev-agents/tsconfig.json"
|
|
25
|
-
}
|
|
26
|
-
]
|
|
27
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "../../../../tsconfig.entry-points.passionfruit.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"target": "es5",
|
|
5
|
-
"outDir": "../../../../../passionfruit/tsDist/@atlaskit__editor-plugin-show-diff/app",
|
|
6
|
-
"rootDir": "../",
|
|
7
|
-
"composite": true
|
|
8
|
-
},
|
|
9
|
-
"include": [
|
|
10
|
-
"../src/**/*.ts",
|
|
11
|
-
"../src/**/*.tsx"
|
|
12
|
-
],
|
|
13
|
-
"exclude": [
|
|
14
|
-
"../src/**/__tests__/*",
|
|
15
|
-
"../src/**/*.test.*",
|
|
16
|
-
"../src/**/test.*",
|
|
17
|
-
"../src/**/examples.*"
|
|
18
|
-
],
|
|
19
|
-
"references": [
|
|
20
|
-
{
|
|
21
|
-
"path": "../../../design-system/tokens/afm-passionfruit/tsconfig.json"
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
"path": "../../editor-common/afm-passionfruit/tsconfig.json"
|
|
25
|
-
}
|
|
26
|
-
]
|
|
27
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "../../../../tsconfig.entry-points.rovo-extension.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"target": "es5",
|
|
5
|
-
"outDir": "../../../../../rovo-extension/tsDist/@atlaskit__editor-plugin-show-diff/app",
|
|
6
|
-
"rootDir": "../",
|
|
7
|
-
"composite": true
|
|
8
|
-
},
|
|
9
|
-
"include": [
|
|
10
|
-
"../src/**/*.ts",
|
|
11
|
-
"../src/**/*.tsx"
|
|
12
|
-
],
|
|
13
|
-
"exclude": [
|
|
14
|
-
"../src/**/__tests__/*",
|
|
15
|
-
"../src/**/*.test.*",
|
|
16
|
-
"../src/**/test.*",
|
|
17
|
-
"../src/**/examples.*"
|
|
18
|
-
],
|
|
19
|
-
"references": [
|
|
20
|
-
{
|
|
21
|
-
"path": "../../../design-system/tokens/afm-rovo-extension/tsconfig.json"
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
"path": "../../editor-common/afm-rovo-extension/tsconfig.json"
|
|
25
|
-
}
|
|
26
|
-
]
|
|
27
|
-
}
|
package/afm-volt/tsconfig.json
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "../../../../tsconfig.entry-points.volt.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"target": "es5",
|
|
5
|
-
"outDir": "../../../../../volt/tsDist/@atlaskit__editor-plugin-show-diff/app",
|
|
6
|
-
"rootDir": "../",
|
|
7
|
-
"composite": true
|
|
8
|
-
},
|
|
9
|
-
"include": [
|
|
10
|
-
"../src/**/*.ts",
|
|
11
|
-
"../src/**/*.tsx"
|
|
12
|
-
],
|
|
13
|
-
"exclude": [
|
|
14
|
-
"../src/**/__tests__/*",
|
|
15
|
-
"../src/**/*.test.*",
|
|
16
|
-
"../src/**/test.*",
|
|
17
|
-
"../src/**/examples.*"
|
|
18
|
-
],
|
|
19
|
-
"references": [
|
|
20
|
-
{
|
|
21
|
-
"path": "../../../design-system/tokens/afm-volt/tsconfig.json"
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
"path": "../../editor-common/afm-volt/tsconfig.json"
|
|
25
|
-
}
|
|
26
|
-
]
|
|
27
|
-
}
|