@atlaskit/editor-plugin-show-diff 0.0.1 → 0.0.3

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 CHANGED
@@ -1,5 +1,21 @@
1
1
  # @atlaskit/editor-plugin-show-diff
2
2
 
3
+ ## 0.0.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [`3c2fe6ae106d8`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/3c2fe6ae106d8) -
8
+ Focus the editor after track changes is turned off.
9
+ - Updated dependencies
10
+
11
+ ## 0.0.2
12
+
13
+ ### Patch Changes
14
+
15
+ - [`9464a4f29a876`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/9464a4f29a876) -
16
+ [EDITOR-1194] Bugfix show diff new line if deleted half way
17
+ - Updated dependencies
18
+
3
19
  ## 0.0.1
4
20
 
5
21
  ### Patch Changes
@@ -0,0 +1,27 @@
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
+ }
@@ -23,7 +23,8 @@ var style = (0, _lazyNodeView.convertToInlineCss)({
23
23
  */
24
24
  var createInlineChangedDecoration = exports.createInlineChangedDecoration = function createInlineChangedDecoration(change) {
25
25
  return _view.Decoration.inline(change.fromB, change.toB, {
26
- style: style
26
+ style: style,
27
+ 'data-testid': 'show-diff-changed-decoration'
27
28
  }, {});
28
29
  };
29
30
  var deletedContentStyle = (0, _lazyNodeView.convertToInlineCss)({
@@ -45,11 +46,34 @@ var createDeletedContentDecoration = exports.createDeletedContentDecoration = fu
45
46
  tr = _ref.tr;
46
47
  var dom = document.createElement('span');
47
48
  dom.setAttribute('style', deletedContentStyle);
48
- dom.appendChild(_model.DOMSerializer.fromSchema(tr.doc.type.schema).serializeFragment(doc.slice(change.fromA, change.toA).content));
49
+
50
+ /*
51
+ * The thinking is we separate out the fragment we got from doc.slice
52
+ * and if it's the first or last content, we go in however many the sliced Open
53
+ * or sliced End depth is and match only the content and not with the entire node.
54
+ */
55
+ var slice = doc.slice(change.fromA, change.toA);
56
+ slice.content.forEach(function (node) {
57
+ var serializer = _model.DOMSerializer.fromSchema(tr.doc.type.schema);
58
+ var isFirst = slice.content.firstChild === node;
59
+ var isLast = slice.content.lastChild === node;
60
+ if (isFirst || isLast && slice.content.childCount > 2) {
61
+ if (node.content.childCount > 0 && node.type.inlineContent === true) {
62
+ dom.append(serializer.serializeFragment(node.content));
63
+ } else {
64
+ dom.append(serializer.serializeNode(node));
65
+ }
66
+ } else if (isLast && slice.content.childCount === 2) {
67
+ var lineBreak = document.createElement('br');
68
+ dom.append(lineBreak);
69
+ dom.append(serializer.serializeFragment(node.content));
70
+ } else {
71
+ dom.append(serializer.serializeNode(node));
72
+ }
73
+ });
74
+ dom.setAttribute('data-testid', 'show-diff-deleted-decoration');
49
75
 
50
76
  // Widget decoration used for deletions as the content is not in the document
51
77
  // and we want to display the deleted content with a style.
52
- return _view.Decoration.widget(change.fromB, dom, {
53
- marks: []
54
- });
78
+ return _view.Decoration.widget(change.fromB, dom, {});
55
79
  };
@@ -16,7 +16,8 @@ const style = convertToInlineCss({
16
16
  * @returns Prosemirror inline decoration
17
17
  */
18
18
  export const createInlineChangedDecoration = change => Decoration.inline(change.fromB, change.toB, {
19
- style
19
+ style,
20
+ 'data-testid': 'show-diff-changed-decoration'
20
21
  }, {});
21
22
  const deletedContentStyle = convertToInlineCss({
22
23
  color: "var(--ds-text-accent-gray, #44546F)",
@@ -38,11 +39,34 @@ export const createDeletedContentDecoration = ({
38
39
  }) => {
39
40
  const dom = document.createElement('span');
40
41
  dom.setAttribute('style', deletedContentStyle);
41
- dom.appendChild(DOMSerializer.fromSchema(tr.doc.type.schema).serializeFragment(doc.slice(change.fromA, change.toA).content));
42
+
43
+ /*
44
+ * The thinking is we separate out the fragment we got from doc.slice
45
+ * and if it's the first or last content, we go in however many the sliced Open
46
+ * or sliced End depth is and match only the content and not with the entire node.
47
+ */
48
+ const slice = doc.slice(change.fromA, change.toA);
49
+ slice.content.forEach(node => {
50
+ const serializer = DOMSerializer.fromSchema(tr.doc.type.schema);
51
+ const isFirst = slice.content.firstChild === node;
52
+ const isLast = slice.content.lastChild === node;
53
+ if (isFirst || isLast && slice.content.childCount > 2) {
54
+ if (node.content.childCount > 0 && node.type.inlineContent === true) {
55
+ dom.append(serializer.serializeFragment(node.content));
56
+ } else {
57
+ dom.append(serializer.serializeNode(node));
58
+ }
59
+ } else if (isLast && slice.content.childCount === 2) {
60
+ const lineBreak = document.createElement('br');
61
+ dom.append(lineBreak);
62
+ dom.append(serializer.serializeFragment(node.content));
63
+ } else {
64
+ dom.append(serializer.serializeNode(node));
65
+ }
66
+ });
67
+ dom.setAttribute('data-testid', 'show-diff-deleted-decoration');
42
68
 
43
69
  // Widget decoration used for deletions as the content is not in the document
44
70
  // and we want to display the deleted content with a style.
45
- return Decoration.widget(change.fromB, dom, {
46
- marks: []
47
- });
71
+ return Decoration.widget(change.fromB, dom, {});
48
72
  };
@@ -17,7 +17,8 @@ var style = convertToInlineCss({
17
17
  */
18
18
  export var createInlineChangedDecoration = function createInlineChangedDecoration(change) {
19
19
  return Decoration.inline(change.fromB, change.toB, {
20
- style: style
20
+ style: style,
21
+ 'data-testid': 'show-diff-changed-decoration'
21
22
  }, {});
22
23
  };
23
24
  var deletedContentStyle = convertToInlineCss({
@@ -39,11 +40,34 @@ export var createDeletedContentDecoration = function createDeletedContentDecorat
39
40
  tr = _ref.tr;
40
41
  var dom = document.createElement('span');
41
42
  dom.setAttribute('style', deletedContentStyle);
42
- dom.appendChild(DOMSerializer.fromSchema(tr.doc.type.schema).serializeFragment(doc.slice(change.fromA, change.toA).content));
43
+
44
+ /*
45
+ * The thinking is we separate out the fragment we got from doc.slice
46
+ * and if it's the first or last content, we go in however many the sliced Open
47
+ * or sliced End depth is and match only the content and not with the entire node.
48
+ */
49
+ var slice = doc.slice(change.fromA, change.toA);
50
+ slice.content.forEach(function (node) {
51
+ var serializer = DOMSerializer.fromSchema(tr.doc.type.schema);
52
+ var isFirst = slice.content.firstChild === node;
53
+ var isLast = slice.content.lastChild === node;
54
+ if (isFirst || isLast && slice.content.childCount > 2) {
55
+ if (node.content.childCount > 0 && node.type.inlineContent === true) {
56
+ dom.append(serializer.serializeFragment(node.content));
57
+ } else {
58
+ dom.append(serializer.serializeNode(node));
59
+ }
60
+ } else if (isLast && slice.content.childCount === 2) {
61
+ var lineBreak = document.createElement('br');
62
+ dom.append(lineBreak);
63
+ dom.append(serializer.serializeFragment(node.content));
64
+ } else {
65
+ dom.append(serializer.serializeNode(node));
66
+ }
67
+ });
68
+ dom.setAttribute('data-testid', 'show-diff-deleted-decoration');
43
69
 
44
70
  // Widget decoration used for deletions as the content is not in the document
45
71
  // and we want to display the deleted content with a style.
46
- return Decoration.widget(change.fromB, dom, {
47
- marks: []
48
- });
72
+ return Decoration.widget(change.fromB, dom, {});
49
73
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-show-diff",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "description": "ShowDiff plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -37,12 +37,9 @@
37
37
  "prosemirror-changeset": "^2.2.1"
38
38
  },
39
39
  "peerDependencies": {
40
- "@atlaskit/editor-common": "^107.16.0",
40
+ "@atlaskit/editor-common": "^107.19.0",
41
41
  "react": "^18.2.0"
42
42
  },
43
- "devDependencies": {
44
- "typescript": "~5.4.2"
45
- },
46
43
  "techstack": {
47
44
  "@atlassian/frontend": {
48
45
  "code-structure": [