@atlaskit/editor-ssr-renderer 1.4.0 → 1.5.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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # @atlaskit/editor-ssr-renderer
2
2
 
3
+ ## 1.5.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`cbf58f8500db4`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/cbf58f8500db4) -
8
+ [https://hello.jira.atlassian.cloud/browse/EDITOR-3893](EDITOR-3893) - fix mussing <br /> in empty
9
+ textblocks in the `EditorSSRRenderer`
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies
14
+
3
15
  ## 1.4.0
4
16
 
5
17
  ### Minor Changes
@@ -161,6 +161,31 @@ function EditorSSRRenderer(_ref) {
161
161
  var _nodePositions$get;
162
162
  return (_nodePositions$get = nodePositions.get(node)) !== null && _nodePositions$get !== void 0 ? _nodePositions$get : 0;
163
163
  }, [], _view.DecorationSet.create(node, []));
164
+
165
+ // ProseMirror View adds <br class="ProseMirror-trailingBreak" /> to empty nodes. Because we are using
166
+ // DOMSerializer, we should simulate the same behaviour to get the same HTML document.
167
+ //
168
+ // There are a lot of conditions that check for adding `<br />` but we could implement only the case when we
169
+ // are adding `<br />` to empty texblock, because if we add `<br />` in other cases it will change order of DOM nodes inside
170
+ // this node (`<br />`) will be the first, after will be other nodes. It's because we are adding `<br />` to root node before
171
+ // we are rendering child node.
172
+ //
173
+ // See: https://discuss.prosemirror.net/t/where-can-i-read-about-prosemirror-trailingbreak/6665
174
+ // See: https://github.com/ProseMirror/prosemirror-view/blob/76c7c47f03730b18397b94bd269ece8a9cb7f486/src/viewdesc.ts#L803
175
+ // See: https://github.com/ProseMirror/prosemirror-view/blob/76c7c47f03730b18397b94bd269ece8a9cb7f486/src/viewdesc.ts#L1365
176
+ if (nodeViewInstance.contentDOM &&
177
+ // if (this.node.isTextblock) updater.addTextblockHacks()
178
+ node.isTextblock &&
179
+ // !lastChild || // Empty textblock
180
+ !node.lastChild
181
+ // NOT IMPLEMENTED CASE !(lastChild instanceof TextViewDesc) ||
182
+ // NOT IMPLEMENTED CASE /\n$/.test(lastChild.node.text!) ||
183
+ // NOT IMPLEMENTED CASE (this.view.requiresGeckoHackNode && /\s$/.test(lastChild.node.text!))
184
+ ) {
185
+ var br = document.createElement('br');
186
+ br.classList.add('ProseMirror-trailingBreak');
187
+ nodeViewInstance.contentDOM.appendChild(br);
188
+ }
164
189
  return {
165
190
  dom: nodeViewInstance.dom,
166
191
  contentDOM: nodeViewInstance.contentDOM
@@ -105,6 +105,31 @@ export function EditorSSRRenderer({
105
105
  var _nodePositions$get;
106
106
  return (_nodePositions$get = nodePositions.get(node)) !== null && _nodePositions$get !== void 0 ? _nodePositions$get : 0;
107
107
  }, [], DecorationSet.create(node, []));
108
+
109
+ // ProseMirror View adds <br class="ProseMirror-trailingBreak" /> to empty nodes. Because we are using
110
+ // DOMSerializer, we should simulate the same behaviour to get the same HTML document.
111
+ //
112
+ // There are a lot of conditions that check for adding `<br />` but we could implement only the case when we
113
+ // are adding `<br />` to empty texblock, because if we add `<br />` in other cases it will change order of DOM nodes inside
114
+ // this node (`<br />`) will be the first, after will be other nodes. It's because we are adding `<br />` to root node before
115
+ // we are rendering child node.
116
+ //
117
+ // See: https://discuss.prosemirror.net/t/where-can-i-read-about-prosemirror-trailingbreak/6665
118
+ // See: https://github.com/ProseMirror/prosemirror-view/blob/76c7c47f03730b18397b94bd269ece8a9cb7f486/src/viewdesc.ts#L803
119
+ // See: https://github.com/ProseMirror/prosemirror-view/blob/76c7c47f03730b18397b94bd269ece8a9cb7f486/src/viewdesc.ts#L1365
120
+ if (nodeViewInstance.contentDOM &&
121
+ // if (this.node.isTextblock) updater.addTextblockHacks()
122
+ node.isTextblock &&
123
+ // !lastChild || // Empty textblock
124
+ !node.lastChild
125
+ // NOT IMPLEMENTED CASE !(lastChild instanceof TextViewDesc) ||
126
+ // NOT IMPLEMENTED CASE /\n$/.test(lastChild.node.text!) ||
127
+ // NOT IMPLEMENTED CASE (this.view.requiresGeckoHackNode && /\s$/.test(lastChild.node.text!))
128
+ ) {
129
+ const br = document.createElement('br');
130
+ br.classList.add('ProseMirror-trailingBreak');
131
+ nodeViewInstance.contentDOM.appendChild(br);
132
+ }
108
133
  return {
109
134
  dom: nodeViewInstance.dom,
110
135
  contentDOM: nodeViewInstance.contentDOM
@@ -153,6 +153,31 @@ export function EditorSSRRenderer(_ref) {
153
153
  var _nodePositions$get;
154
154
  return (_nodePositions$get = nodePositions.get(node)) !== null && _nodePositions$get !== void 0 ? _nodePositions$get : 0;
155
155
  }, [], DecorationSet.create(node, []));
156
+
157
+ // ProseMirror View adds <br class="ProseMirror-trailingBreak" /> to empty nodes. Because we are using
158
+ // DOMSerializer, we should simulate the same behaviour to get the same HTML document.
159
+ //
160
+ // There are a lot of conditions that check for adding `<br />` but we could implement only the case when we
161
+ // are adding `<br />` to empty texblock, because if we add `<br />` in other cases it will change order of DOM nodes inside
162
+ // this node (`<br />`) will be the first, after will be other nodes. It's because we are adding `<br />` to root node before
163
+ // we are rendering child node.
164
+ //
165
+ // See: https://discuss.prosemirror.net/t/where-can-i-read-about-prosemirror-trailingbreak/6665
166
+ // See: https://github.com/ProseMirror/prosemirror-view/blob/76c7c47f03730b18397b94bd269ece8a9cb7f486/src/viewdesc.ts#L803
167
+ // See: https://github.com/ProseMirror/prosemirror-view/blob/76c7c47f03730b18397b94bd269ece8a9cb7f486/src/viewdesc.ts#L1365
168
+ if (nodeViewInstance.contentDOM &&
169
+ // if (this.node.isTextblock) updater.addTextblockHacks()
170
+ node.isTextblock &&
171
+ // !lastChild || // Empty textblock
172
+ !node.lastChild
173
+ // NOT IMPLEMENTED CASE !(lastChild instanceof TextViewDesc) ||
174
+ // NOT IMPLEMENTED CASE /\n$/.test(lastChild.node.text!) ||
175
+ // NOT IMPLEMENTED CASE (this.view.requiresGeckoHackNode && /\s$/.test(lastChild.node.text!))
176
+ ) {
177
+ var br = document.createElement('br');
178
+ br.classList.add('ProseMirror-trailingBreak');
179
+ nodeViewInstance.contentDOM.appendChild(br);
180
+ }
156
181
  return {
157
182
  dom: nodeViewInstance.dom,
158
183
  contentDOM: nodeViewInstance.contentDOM
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-ssr-renderer",
3
- "version": "1.4.0",
3
+ "version": "1.5.0",
4
4
  "description": "SSR Renderer based on Editor",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "atlassian": {
@@ -33,7 +33,7 @@
33
33
  "react-intl-next": "npm:react-intl@^5.18.1"
34
34
  },
35
35
  "peerDependencies": {
36
- "@atlaskit/editor-common": "^110.44.0",
36
+ "@atlaskit/editor-common": "^110.46.0",
37
37
  "react": "^18.2.0"
38
38
  }
39
39
  }