@atlaskit/editor-plugin-show-diff 0.0.0 → 0.0.2

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 ADDED
@@ -0,0 +1,15 @@
1
+ # @atlaskit/editor-plugin-show-diff
2
+
3
+ ## 0.0.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [`9464a4f29a876`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/9464a4f29a876) -
8
+ [EDITOR-1194] Bugfix show diff new line if deleted half way
9
+ - Updated dependencies
10
+
11
+ ## 0.0.1
12
+
13
+ ### Patch Changes
14
+
15
+ - Updated dependencies
@@ -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
+ }
@@ -45,11 +45,33 @@ var createDeletedContentDecoration = exports.createDeletedContentDecoration = fu
45
45
  tr = _ref.tr;
46
46
  var dom = document.createElement('span');
47
47
  dom.setAttribute('style', deletedContentStyle);
48
- dom.appendChild(_model.DOMSerializer.fromSchema(tr.doc.type.schema).serializeFragment(doc.slice(change.fromA, change.toA).content));
48
+
49
+ /*
50
+ * The thinking is we separate out the fragment we got from doc.slice
51
+ * and if it's the first or last content, we go in however many the sliced Open
52
+ * or sliced End depth is and match only the content and not with the entire node.
53
+ */
54
+ var slice = doc.slice(change.fromA, change.toA);
55
+ slice.content.forEach(function (node) {
56
+ var serializer = _model.DOMSerializer.fromSchema(tr.doc.type.schema);
57
+ var isFirst = slice.content.firstChild === node;
58
+ var isLast = slice.content.lastChild === node;
59
+ if (isFirst || isLast && slice.content.childCount > 2) {
60
+ if (node.content.childCount > 0 && node.type.inlineContent === true) {
61
+ dom.append(serializer.serializeFragment(node.content));
62
+ } else {
63
+ dom.append(serializer.serializeNode(node));
64
+ }
65
+ } else if (isLast && slice.content.childCount === 2) {
66
+ var lineBreak = document.createElement('br');
67
+ dom.append(lineBreak);
68
+ dom.append(serializer.serializeFragment(node.content));
69
+ } else {
70
+ dom.append(serializer.serializeNode(node));
71
+ }
72
+ });
49
73
 
50
74
  // Widget decoration used for deletions as the content is not in the document
51
75
  // and we want to display the deleted content with a style.
52
- return _view.Decoration.widget(change.fromB, dom, {
53
- marks: []
54
- });
76
+ return _view.Decoration.widget(change.fromB, dom, {});
55
77
  };
@@ -38,11 +38,33 @@ export const createDeletedContentDecoration = ({
38
38
  }) => {
39
39
  const dom = document.createElement('span');
40
40
  dom.setAttribute('style', deletedContentStyle);
41
- dom.appendChild(DOMSerializer.fromSchema(tr.doc.type.schema).serializeFragment(doc.slice(change.fromA, change.toA).content));
41
+
42
+ /*
43
+ * The thinking is we separate out the fragment we got from doc.slice
44
+ * and if it's the first or last content, we go in however many the sliced Open
45
+ * or sliced End depth is and match only the content and not with the entire node.
46
+ */
47
+ const slice = doc.slice(change.fromA, change.toA);
48
+ slice.content.forEach(node => {
49
+ const serializer = DOMSerializer.fromSchema(tr.doc.type.schema);
50
+ const isFirst = slice.content.firstChild === node;
51
+ const isLast = slice.content.lastChild === node;
52
+ if (isFirst || isLast && slice.content.childCount > 2) {
53
+ if (node.content.childCount > 0 && node.type.inlineContent === true) {
54
+ dom.append(serializer.serializeFragment(node.content));
55
+ } else {
56
+ dom.append(serializer.serializeNode(node));
57
+ }
58
+ } else if (isLast && slice.content.childCount === 2) {
59
+ const lineBreak = document.createElement('br');
60
+ dom.append(lineBreak);
61
+ dom.append(serializer.serializeFragment(node.content));
62
+ } else {
63
+ dom.append(serializer.serializeNode(node));
64
+ }
65
+ });
42
66
 
43
67
  // Widget decoration used for deletions as the content is not in the document
44
68
  // and we want to display the deleted content with a style.
45
- return Decoration.widget(change.fromB, dom, {
46
- marks: []
47
- });
69
+ return Decoration.widget(change.fromB, dom, {});
48
70
  };
@@ -39,11 +39,33 @@ export var createDeletedContentDecoration = function createDeletedContentDecorat
39
39
  tr = _ref.tr;
40
40
  var dom = document.createElement('span');
41
41
  dom.setAttribute('style', deletedContentStyle);
42
- 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
+ var slice = doc.slice(change.fromA, change.toA);
49
+ slice.content.forEach(function (node) {
50
+ var serializer = DOMSerializer.fromSchema(tr.doc.type.schema);
51
+ var isFirst = slice.content.firstChild === node;
52
+ var 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
+ var 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
+ });
43
67
 
44
68
  // Widget decoration used for deletions as the content is not in the document
45
69
  // and we want to display the deleted content with a style.
46
- return Decoration.widget(change.fromB, dom, {
47
- marks: []
48
- });
70
+ return Decoration.widget(change.fromB, dom, {});
49
71
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-show-diff",
3
- "version": "0.0.0",
3
+ "version": "0.0.2",
4
4
  "description": "ShowDiff plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -32,17 +32,14 @@
32
32
  },
33
33
  "dependencies": {
34
34
  "@atlaskit/editor-prosemirror": "7.0.0",
35
- "@atlaskit/tokens": "^5.6.0",
35
+ "@atlaskit/tokens": "^6.0.0",
36
36
  "@babel/runtime": "^7.0.0",
37
37
  "prosemirror-changeset": "^2.2.1"
38
38
  },
39
39
  "peerDependencies": {
40
- "@atlaskit/editor-common": "^107.12.0",
40
+ "@atlaskit/editor-common": "^107.18.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": [
package/tsconfig.json CHANGED
@@ -1,14 +1,18 @@
1
1
  {
2
- "extends": "../../../tsconfig.json",
3
- "include": [
2
+ "extends": "../../../tsconfig.json",
3
+ "include": [
4
4
  "__tests__/**/*.ts",
5
5
  "__tests__/**/*.tsx",
6
- "docs/**/*.ts",
7
- "docs/**/*.tsx",
8
6
  "examples/**/*.ts",
9
7
  "examples/**/*.tsx",
10
8
  "src/**/*.ts",
11
- "src/**/*.tsx"
12
- ],
13
- "compilerOptions": {}
9
+ "src/**/*.tsx",
10
+ "**/stories.ts",
11
+ "**/stories.tsx",
12
+ "**/stories/*.ts",
13
+ "**/stories/*.tsx",
14
+ "**/stories/**/*.ts",
15
+ "**/stories/**/*.tsx"
16
+ ],
17
+ "compilerOptions": {}
14
18
  }