@modusoperandi/licit 1.4.0 → 1.4.1

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/client/Licit.js CHANGED
@@ -133,9 +133,9 @@ var Licit = /*#__PURE__*/function (_React$Component) {
133
133
  // Only need to call if there is any difference in collab mode OR always in non-collab mode.
134
134
  _this._connector.onEdit(transaction, _this._editorView);
135
135
  }
136
- if (transaction.docChanged) {
137
- var _docJson$attrs;
138
- var docJson = transaction.doc.toJSON();
136
+ if (transaction.docChanged || !isSameState) {
137
+ var _this$_editorView, _docJson$attrs;
138
+ var docJson = (_this$_editorView = _this._editorView) === null || _this$_editorView === void 0 || (_this$_editorView = _this$_editorView.state) === null || _this$_editorView === void 0 || (_this$_editorView = _this$_editorView.doc) === null || _this$_editorView === void 0 ? void 0 : _this$_editorView.toJSON();
139
139
  if (!Object.isFrozen(docJson === null || docJson === void 0 || (_docJson$attrs = docJson.attrs) === null || _docJson$attrs === void 0 ? void 0 : _docJson$attrs.objectMetaData)) {
140
140
  docJson.attrs.objectMetaData = _objectSpread(_objectSpread({}, docJson.attrs.objectMetaData), {}, {
141
141
  lastEditedOn: new Date().toISOString().replace('Z', '+00:00')
@@ -172,7 +172,23 @@ var Licit = /*#__PURE__*/function (_React$Component) {
172
172
  _this._editorView = editorView;
173
173
  var tr = state.tr;
174
174
  dispatch(tr.scrollIntoView());
175
-
175
+ if (!_this._editorView.editable) {
176
+ var _tr = _this._editorView.state.tr;
177
+ var modified = false;
178
+ _this._editorView.state.doc.descendants(function (node, pos) {
179
+ if (node.type.name === 'table') {
180
+ var _tr2;
181
+ // Apply setNodeMarkup with same type and attrs to force a refresh
182
+ _tr = (_tr2 = _tr) === null || _tr2 === void 0 ? void 0 : _tr2.setNodeMarkup(pos, undefined, _objectSpread(_objectSpread({}, node.attrs), {}, {
183
+ Id: pos
184
+ }));
185
+ modified = true;
186
+ }
187
+ });
188
+ if (modified) {
189
+ _this._editorView.dispatch(_tr);
190
+ }
191
+ }
176
192
  // [FS] IRAD-1578 2021-09-27
177
193
  // In collab mode, fire onRead only after getting the response from collab server.
178
194
  if (_this.state.onReadyCB && _this.state.docID === '') {
@@ -77,7 +77,7 @@ class Licit extends React.Component<any, any> {
77
77
  this._editorView = null;
78
78
  this._skipSCU = true;
79
79
 
80
- const noop = function () { };
80
+ const noop = function () {};
81
81
 
82
82
  // [FS] IRAD-981 2020-06-10
83
83
  // Component's configurations.
@@ -508,14 +508,13 @@ class Licit extends React.Component<any, any> {
508
508
  this._connector.onEdit(transaction, this._editorView);
509
509
  }
510
510
 
511
- if (transaction.docChanged) {
512
- const docJson = transaction.doc.toJSON();
511
+ if (transaction.docChanged || !isSameState) {
512
+ const docJson = this._editorView?.state?.doc?.toJSON();
513
513
  if (!Object.isFrozen(docJson?.attrs?.objectMetaData)) {
514
514
  docJson.attrs.objectMetaData = {
515
515
  ...docJson.attrs.objectMetaData,
516
- lastEditedOn: new Date().toISOString().replace('Z', '+00:00')
516
+ lastEditedOn: new Date().toISOString().replace('Z', '+00:00'),
517
517
  };
518
-
519
518
  }
520
519
  let isEmpty = false;
521
520
  if (docJson.content && docJson.content.length === 1) {
@@ -560,7 +559,20 @@ class Licit extends React.Component<any, any> {
560
559
  this._editorView = editorView;
561
560
  const tr = state.tr;
562
561
  dispatch(tr.scrollIntoView());
563
-
562
+ if (!this._editorView.editable) {
563
+ let _tr = this._editorView.state.tr;
564
+ let modified = false;
565
+ this._editorView.state.doc.descendants((node, pos) => {
566
+ if (node.type.name === 'table') {
567
+ // Apply setNodeMarkup with same type and attrs to force a refresh
568
+ _tr = _tr?.setNodeMarkup(pos, undefined, { ...node.attrs, Id: pos });
569
+ modified = true;
570
+ }
571
+ });
572
+ if (modified) {
573
+ this._editorView.dispatch(_tr);
574
+ }
575
+ }
564
576
  // [FS] IRAD-1578 2021-09-27
565
577
  // In collab mode, fire onRead only after getting the response from collab server.
566
578
  if (this.state.onReadyCB && this.state.docID === '') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@modusoperandi/licit",
3
- "version": "1.4.0",
3
+ "version": "1.4.1",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "subversion": "1",
@@ -90,7 +90,7 @@
90
90
  "exports-loader": "^5.0.0",
91
91
  "express": "^5.1.0",
92
92
  "file-loader": "^6.2.0",
93
- "flow-bin": "^0.272.1",
93
+ "flow-bin": "^0.273.1",
94
94
  "flow-copy-source": "^2.0.9",
95
95
  "flow-typed": "^4.0.0",
96
96
  "flow-webpack-plugin": "^1.2.0",
@@ -102,7 +102,7 @@
102
102
  "husky": "^9.0.10",
103
103
  "identity-obj-proxy": "^3.0.0",
104
104
  "jest": "^29.2.0",
105
- "jest-environment-jsdom": "^29.3.1",
105
+ "jest-environment-jsdom": "^30.0.0",
106
106
  "jest-junit": "^16.0.0",
107
107
  "jest-prosemirror": "^3.0.0",
108
108
  "jest-sonar-reporter": "^2.0.0",
@@ -103,8 +103,8 @@ var LinkURLEditor = /*#__PURE__*/function (_React$PureComponent) {
103
103
  return false;
104
104
  }
105
105
  return TOCselectedNode_.some(function (item) {
106
- var _item$node_;
107
- return ((_item$node_ = item.node_) === null || _item$node_ === void 0 || (_item$node_ = _item$node_.content[0]) === null || _item$node_ === void 0 || (_item$node_ = _item$node_.text) === null || _item$node_ === void 0 ? void 0 : _item$node_.trim()) !== '';
106
+ var _item$content$;
107
+ return (item === null || item === void 0 || (_item$content$ = item.content[0]) === null || _item$content$ === void 0 || (_item$content$ = _item$content$.text) === null || _item$content$ === void 0 ? void 0 : _item$content$.trim()) !== '';
108
108
  });
109
109
  };
110
110
  var isValid = isTOCValid();
@@ -179,27 +179,27 @@ var LinkURLEditor = /*#__PURE__*/function (_React$PureComponent) {
179
179
  action: "#"
180
180
  }, /*#__PURE__*/React.createElement("label", null, "Select the Inner Link"), /*#__PURE__*/React.createElement("br", null), /*#__PURE__*/React.createElement("select", {
181
181
  defaultValue: TOCselectedNode_.some(function (res) {
182
- var _res$node_;
183
- return ((_res$node_ = res.node_) === null || _res$node_ === void 0 || (_res$node_ = _res$node_.content[0]) === null || _res$node_ === void 0 ? void 0 : _res$node_.text) === url;
182
+ var _res$content$;
183
+ return (res === null || res === void 0 || (_res$content$ = res.content[0]) === null || _res$content$ === void 0 ? void 0 : _res$content$.text) === url;
184
184
  }) ? url : null,
185
185
  id: "toc",
186
186
  name: "toccontents",
187
187
  size: "3"
188
188
  }, TOCselectedNode_ === null || TOCselectedNode_ === void 0 ? void 0 : TOCselectedNode_.filter(function (res) {
189
- var _res$node_2;
190
- return ((_res$node_2 = res.node_) === null || _res$node_2 === void 0 || (_res$node_2 = _res$node_2.content[0]) === null || _res$node_2 === void 0 || (_res$node_2 = _res$node_2.text) === null || _res$node_2 === void 0 ? void 0 : _res$node_2.trim()) !== '';
189
+ var _res$content$2;
190
+ return (res === null || res === void 0 || (_res$content$2 = res.content[0]) === null || _res$content$2 === void 0 || (_res$content$2 = _res$content$2.text) === null || _res$content$2 === void 0 ? void 0 : _res$content$2.trim()) !== '';
191
191
  }).map(function (res, index) {
192
- var _res$node_3, _res$node_6, _res$node_7;
192
+ var _res$content$3, _res$content$5, _res$content$6;
193
193
  return /*#__PURE__*/React.createElement("option", {
194
- "data-tooltip-content": (_res$node_3 = res.node_) === null || _res$node_3 === void 0 || (_res$node_3 = _res$node_3.content[0]) === null || _res$node_3 === void 0 ? void 0 : _res$node_3.text,
194
+ "data-tooltip-content": res === null || res === void 0 || (_res$content$3 = res.content[0]) === null || _res$content$3 === void 0 ? void 0 : _res$content$3.text,
195
195
  "data-tooltip-id": "select-toc-tooltip",
196
196
  key: index,
197
197
  onClick: function onClick() {
198
- var _res$node_4, _res$node_5;
199
- _this2.handleOptionChange((_res$node_4 = res.node_) === null || _res$node_4 === void 0 || (_res$node_4 = _res$node_4.content[0]) === null || _res$node_4 === void 0 ? void 0 : _res$node_4.text, (_res$node_5 = res.node_) === null || _res$node_5 === void 0 ? void 0 : _res$node_5.attrs.selectionId);
198
+ var _res$content$4;
199
+ _this2.handleOptionChange(res === null || res === void 0 || (_res$content$4 = res.content[0]) === null || _res$content$4 === void 0 ? void 0 : _res$content$4.text, res === null || res === void 0 ? void 0 : res.attrs.selectionId);
200
200
  },
201
- value: (_res$node_6 = res.node_) === null || _res$node_6 === void 0 || (_res$node_6 = _res$node_6.content[0]) === null || _res$node_6 === void 0 ? void 0 : _res$node_6.text
202
- }, (_res$node_7 = res.node_) === null || _res$node_7 === void 0 || (_res$node_7 = _res$node_7.content[0]) === null || _res$node_7 === void 0 ? void 0 : _res$node_7.text);
201
+ value: res === null || res === void 0 || (_res$content$5 = res.content[0]) === null || _res$content$5 === void 0 ? void 0 : _res$content$5.text
202
+ }, res === null || res === void 0 || (_res$content$6 = res.content[0]) === null || _res$content$6 === void 0 ? void 0 : _res$content$6.text);
203
203
  })), /*#__PURE__*/React.createElement(ReactTooltip, {
204
204
  effect: "solid",
205
205
  id: "select-toc-tooltip",
@@ -69,7 +69,7 @@ class LinkURLEditor extends React.PureComponent<any, any> {
69
69
  }
70
70
 
71
71
  return TOCselectedNode_.some(
72
- (item) => item.node_?.content[0]?.text?.trim() !== ''
72
+ (item) => item?.content[0]?.text?.trim() !== ''
73
73
  );
74
74
  };
75
75
  const isValid = isTOCValid();
@@ -146,7 +146,7 @@ class LinkURLEditor extends React.PureComponent<any, any> {
146
146
  <select
147
147
  defaultValue={
148
148
  TOCselectedNode_.some(
149
- (res) => res.node_?.content[0]?.text === url
149
+ (res) => res?.content[0]?.text === url
150
150
  )
151
151
  ? url
152
152
  : null
@@ -156,21 +156,21 @@ class LinkURLEditor extends React.PureComponent<any, any> {
156
156
  size="3"
157
157
  >
158
158
  {TOCselectedNode_?.filter(
159
- (res) => res.node_?.content[0]?.text?.trim() !== ''
159
+ (res) => res?.content[0]?.text?.trim() !== ''
160
160
  ).map((res, index) => (
161
161
  <option
162
- data-tooltip-content={res.node_?.content[0]?.text}
162
+ data-tooltip-content={res?.content[0]?.text}
163
163
  data-tooltip-id="select-toc-tooltip"
164
164
  key={index}
165
165
  onClick={() => {
166
166
  this.handleOptionChange(
167
- res.node_?.content[0]?.text,
168
- res.node_?.attrs.selectionId
167
+ res?.content[0]?.text,
168
+ res?.attrs.selectionId
169
169
  );
170
170
  }}
171
- value={res.node_?.content[0]?.text}
171
+ value={res?.content[0]?.text}
172
172
  >
173
- {res.node_?.content[0]?.text}
173
+ {res?.content[0]?.text}
174
174
  </option>
175
175
  ))}
176
176
  </select>