@modusoperandi/licit 0.1.10 → 0.13.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.
@@ -173,7 +173,14 @@ class Licit extends React.Component {
173
173
 
174
174
  if (transaction.docChanged) {
175
175
  const docJson = transaction.doc.toJSON();
176
- const isEmpty = this.isDocEmpty(docJson); // setCFlags is/was always the opposite of isEmpty.
176
+ let isEmpty = false;
177
+
178
+ if (docJson.content && docJson.content.length === 1) {
179
+ if (!docJson.content[0].content || docJson.content[0].content && docJson.content[0].content[0].text && '' === docJson.content[0].content[0].text.trim()) {
180
+ isEmpty = true;
181
+ }
182
+ } // setCFlags is/was always the opposite of isEmpty.
183
+
177
184
 
178
185
  if (isEmpty) {
179
186
  this.resetCounters(transaction);
@@ -199,15 +206,11 @@ class Licit extends React.Component {
199
206
  } = editorView;
200
207
  this._editorView = editorView;
201
208
  const tr = state.tr;
202
- const doc = state.doc; // [FS] IRAD-1710 2022-03-04
203
-
204
- if (!this.isDocEmpty(doc.toJSON())) {
205
- const trx = tr.setSelection(_prosemirrorState.TextSelection.create(doc, 0, doc.content.size));
206
- dispatch(trx.scrollIntoView());
207
- } // [FS] IRAD-1578 2021-09-27
209
+ const doc = state.doc;
210
+ const trx = tr.setSelection(_prosemirrorState.TextSelection.create(doc, 0, doc.content.size));
211
+ dispatch(trx.scrollIntoView()); // [FS] IRAD-1578 2021-09-27
208
212
  // In collab mode, fire onRead only after getting the response from collab server.
209
213
 
210
-
211
214
  if (this.state.onReadyCB && this.state.docID === '') {
212
215
  editorView.focus();
213
216
  this.state.onReadyCB(this);
@@ -487,22 +490,8 @@ class Licit extends React.Component {
487
490
  });
488
491
  }
489
492
 
490
- isDocEmpty(docJson) {
491
- let isEmpty = false;
492
-
493
- if (docJson.content && docJson.content.length === 1) {
494
- if (!docJson.content[0].content || docJson.content[0].content && // [FS] IRAD-1710 2022-03-04
495
- // Empty if no content OR when the one & only text content is empty.
496
- 1 === docJson.content[0].content.length && 'text' === docJson.content[0].content[0].type && docJson.content[0].content[0].text && '' === docJson.content[0].content[0].text) {
497
- isEmpty = true;
498
- }
499
- }
500
-
501
- return isEmpty;
502
- } // [FS] IRAD-1173 2021-02-25
493
+ // [FS] IRAD-1173 2021-02-25
503
494
  // Bug fix: Transaction mismatch error when a dialog is opened and keep typing.
504
-
505
-
506
495
  closeOpenedPopupModels() {
507
496
  const element = document.getElementsByClassName('czi-pop-up-element')[0];
508
497
 
@@ -73,7 +73,7 @@ class Licit extends React.Component<any, any> {
73
73
  this._editorView = null;
74
74
  this._skipSCU = true;
75
75
 
76
- const noop = function () { };
76
+ const noop = function () {};
77
77
 
78
78
  // [FS] IRAD-981 2020-06-10
79
79
  // Component's configurations.
@@ -132,17 +132,17 @@ class Licit extends React.Component<any, any> {
132
132
  const setState = this.setState.bind(this);
133
133
  this._connector = collaborative
134
134
  ? new CollabConnector(
135
- editorState,
136
- setState,
137
- {
138
- docID,
139
- collabServiceURL,
140
- },
141
- this._defaultEditorSchema,
142
- this._defaultEditorPlugins,
143
- // [FS] IRAD-1578 2021-09-27
144
- this.onReady.bind(this)
145
- )
135
+ editorState,
136
+ setState,
137
+ {
138
+ docID,
139
+ collabServiceURL,
140
+ },
141
+ this._defaultEditorSchema,
142
+ this._defaultEditorPlugins,
143
+ // [FS] IRAD-1578 2021-09-27
144
+ this.onReady.bind(this)
145
+ )
146
146
  : new SimpleConnector(editorState, setState);
147
147
 
148
148
  // FS IRAD-989 2020-18-06
@@ -265,7 +265,7 @@ class Licit extends React.Component<any, any> {
265
265
 
266
266
  setContent = (content: any = {}): void => {
267
267
  // [FS] IRAD-1571 2021-09-27
268
- // dispatch a transaction that MUST start from the view�s current state;
268
+ // dispatch a transaction that MUST start from the view�s current state;
269
269
  const editorState = this._editorView.state;
270
270
  const { doc, schema } = editorState;
271
271
  let { tr } = editorState;
@@ -278,8 +278,8 @@ class Licit extends React.Component<any, any> {
278
278
  // set the value for object metadata and objectId
279
279
  tr = this.isNodeHasAttribute(document, ATTR_OBJMETADATA)
280
280
  ? tr.step(
281
- new SetDocAttrStep(ATTR_OBJMETADATA, document.attrs.objectMetaData)
282
- )
281
+ new SetDocAttrStep(ATTR_OBJMETADATA, document.attrs.objectMetaData)
282
+ )
283
283
  : tr;
284
284
  tr = this.isNodeHasAttribute(document, ATTR_OBJID)
285
285
  ? tr.step(new SetDocAttrStep(ATTR_OBJID, document.attrs.objectId))
@@ -296,7 +296,7 @@ class Licit extends React.Component<any, any> {
296
296
  let dataChanged = false;
297
297
 
298
298
  // [FS] IRAD-1571 2021-09-27
299
- // dispatch a transaction that MUST start from the view�s current state;
299
+ // dispatch a transaction that MUST start from the view�s current state;
300
300
  // [FS] IRAD-1589 2021-10-04
301
301
  // Do a proper circular JSON comparison.
302
302
  if (stringify(this.state.data) !== stringify(nextState.data)) {
@@ -323,17 +323,17 @@ class Licit extends React.Component<any, any> {
323
323
  // create new connector
324
324
  this._connector = collabEditing
325
325
  ? new CollabConnector(
326
- editorState,
327
- setState,
328
- {
329
- docID,
330
- collabServiceURL,
331
- },
332
- this._defaultEditorSchema,
333
- this._defaultEditorPlugins,
334
- // [FS] IRAD-1578 2021-09-27
335
- this.onReady.bind(this)
336
- )
326
+ editorState,
327
+ setState,
328
+ {
329
+ docID,
330
+ collabServiceURL,
331
+ },
332
+ this._defaultEditorSchema,
333
+ this._defaultEditorPlugins,
334
+ // [FS] IRAD-1578 2021-09-27
335
+ this.onReady.bind(this)
336
+ )
337
337
  : new SimpleConnector(editorState, setState);
338
338
  }
339
339
  }
@@ -401,7 +401,18 @@ class Licit extends React.Component<any, any> {
401
401
 
402
402
  if (transaction.docChanged) {
403
403
  const docJson = transaction.doc.toJSON();
404
- const isEmpty = this.isDocEmpty(docJson);
404
+ let isEmpty = false;
405
+
406
+ if (docJson.content && docJson.content.length === 1) {
407
+ if (
408
+ !docJson.content[0].content ||
409
+ (docJson.content[0].content &&
410
+ docJson.content[0].content[0].text &&
411
+ '' === docJson.content[0].content[0].text.trim())
412
+ ) {
413
+ isEmpty = true;
414
+ }
415
+ }
405
416
 
406
417
  // setCFlags is/was always the opposite of isEmpty.
407
418
  if (isEmpty) {
@@ -419,27 +430,6 @@ class Licit extends React.Component<any, any> {
419
430
  }
420
431
  }
421
432
  };
422
-
423
- isDocEmpty(docJson: Object) {
424
- let isEmpty = false;
425
-
426
- if (docJson.content && docJson.content.length === 1) {
427
- if (
428
- !docJson.content[0].content ||
429
- (docJson.content[0].content &&
430
- // [FS] IRAD-1710 2022-03-04
431
- // Empty if no content OR when the one & only text content is empty.
432
- 1 === docJson.content[0].content.length &&
433
- 'text' === docJson.content[0].content[0].type &&
434
- docJson.content[0].content[0].text &&
435
- '' === docJson.content[0].content[0].text)
436
- ) {
437
- isEmpty = true;
438
- }
439
- }
440
- return isEmpty;
441
- }
442
-
443
433
  // [FS] IRAD-1173 2021-02-25
444
434
  // Bug fix: Transaction mismatch error when a dialog is opened and keep typing.
445
435
  closeOpenedPopupModels() {
@@ -456,14 +446,8 @@ class Licit extends React.Component<any, any> {
456
446
  this._editorView = editorView;
457
447
  const tr = state.tr;
458
448
  const doc = state.doc;
459
-
460
- // [FS] IRAD-1710 2022-03-04
461
- if (!this.isDocEmpty(doc.toJSON())) {
462
- const trx = tr.setSelection(
463
- TextSelection.create(doc, 0, doc.content.size)
464
- );
465
- dispatch(trx.scrollIntoView());
466
- }
449
+ const trx = tr.setSelection(TextSelection.create(doc, 0, doc.content.size));
450
+ dispatch(trx.scrollIntoView());
467
451
 
468
452
  // [FS] IRAD-1578 2021-09-27
469
453
  // In collab mode, fire onRead only after getting the response from collab server.
@@ -22,18 +22,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
22
22
  });
23
23
  describe('<Licit />', () => {
24
24
  let wrapper;
25
- let licit; // provide an empty document just to shut up that warning
26
-
27
- const data = {
28
- type: 'doc',
29
- content: [{
30
- type: 'paragraph',
31
- content: [{
32
- type: 'text',
33
- text: ' '
34
- }]
35
- }]
36
- }; // Mocking the functions used in _onReady
25
+ let licit; // Mocking the functions used in _onReady
37
26
 
38
27
  const fakeEditorView = {
39
28
  focus: _noop.default,
@@ -46,8 +35,7 @@ describe('<Licit />', () => {
46
35
  resolve: () => ({
47
36
  min: () => 0,
48
37
  max: () => 10
49
- }),
50
- toJSON: () => data
38
+ })
51
39
  },
52
40
  tr: {
53
41
  setSelection: () => fakeEditorView.state.tr,
@@ -56,6 +44,17 @@ describe('<Licit />', () => {
56
44
  }
57
45
  };
58
46
  beforeEach(() => {
47
+ // provide an empty document just to shut up that warning
48
+ const data = {
49
+ type: 'doc',
50
+ content: [{
51
+ type: 'paragraph',
52
+ content: [{
53
+ type: 'text',
54
+ text: ' '
55
+ }]
56
+ }]
57
+ };
59
58
  wrapper = (0, _enzyme.shallow)( /*#__PURE__*/_react.default.createElement(_Licit.default, {
60
59
  data: data
61
60
  }));
@@ -16,17 +16,6 @@ describe('<Licit />', () => {
16
16
  let wrapper;
17
17
  let licit;
18
18
 
19
- // provide an empty document just to shut up that warning
20
- const data = {
21
- type: 'doc',
22
- content: [
23
- {
24
- type: 'paragraph',
25
- content: [{ type: 'text', text: ' ' }],
26
- },
27
- ],
28
- };
29
-
30
19
  // Mocking the functions used in _onReady
31
20
  const fakeEditorView = {
32
21
  focus: noop,
@@ -35,7 +24,6 @@ describe('<Licit />', () => {
35
24
  doc: {
36
25
  content: { size: 10 },
37
26
  resolve: () => ({ min: () => 0, max: () => 10 }),
38
- toJSON: () => data,
39
27
  },
40
28
  tr: {
41
29
  setSelection: () => fakeEditorView.state.tr,
@@ -45,6 +33,16 @@ describe('<Licit />', () => {
45
33
  };
46
34
 
47
35
  beforeEach(() => {
36
+ // provide an empty document just to shut up that warning
37
+ const data = {
38
+ type: 'doc',
39
+ content: [
40
+ {
41
+ type: 'paragraph',
42
+ content: [{ type: 'text', text: ' ' }],
43
+ },
44
+ ],
45
+ };
48
46
  wrapper = shallow(<Licit data={data} />);
49
47
  licit = wrapper.instance();
50
48
  });
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+
3
+ /* eslint-disable */
4
+ var jumpToCode = function init() {
5
+ // Classes of code we would like to highlight in the file view
6
+ var missingCoverageClasses = ['.cbranch-no', '.cstat-no', '.fstat-no']; // Elements to highlight in the file listing view
7
+
8
+ var fileListingElements = ['td.pct.low']; // We don't want to select elements that are direct descendants of another match
9
+
10
+ var notSelector = ':not(' + missingCoverageClasses.join('):not(') + ') > '; // becomes `:not(a):not(b) > `
11
+ // Selecter that finds elements on the page to which we can jump
12
+
13
+ var selector = fileListingElements.join(', ') + ', ' + notSelector + missingCoverageClasses.join(', ' + notSelector); // becomes `:not(a):not(b) > a, :not(a):not(b) > b`
14
+ // The NodeList of matching elements
15
+
16
+ var missingCoverageElements = document.querySelectorAll(selector);
17
+ var currentIndex;
18
+
19
+ function toggleClass(index) {
20
+ missingCoverageElements.item(currentIndex).classList.remove('highlighted');
21
+ missingCoverageElements.item(index).classList.add('highlighted');
22
+ }
23
+
24
+ function makeCurrent(index) {
25
+ toggleClass(index);
26
+ currentIndex = index;
27
+ missingCoverageElements.item(index).scrollIntoView({
28
+ behavior: 'smooth',
29
+ block: 'center',
30
+ inline: 'center'
31
+ });
32
+ }
33
+
34
+ function goToPrevious() {
35
+ var nextIndex = 0;
36
+
37
+ if (typeof currentIndex !== 'number' || currentIndex === 0) {
38
+ nextIndex = missingCoverageElements.length - 1;
39
+ } else if (missingCoverageElements.length > 1) {
40
+ nextIndex = currentIndex - 1;
41
+ }
42
+
43
+ makeCurrent(nextIndex);
44
+ }
45
+
46
+ function goToNext() {
47
+ var nextIndex = 0;
48
+
49
+ if (typeof currentIndex === 'number' && currentIndex < missingCoverageElements.length - 1) {
50
+ nextIndex = currentIndex + 1;
51
+ }
52
+
53
+ makeCurrent(nextIndex);
54
+ }
55
+
56
+ return function jump(event) {
57
+ if (document.getElementById('fileSearch') === document.activeElement && document.activeElement != null) {
58
+ // if we're currently focused on the search input, we don't want to navigate
59
+ return;
60
+ }
61
+
62
+ switch (event.which) {
63
+ case 78: // n
64
+
65
+ case 74:
66
+ // j
67
+ goToNext();
68
+ break;
69
+
70
+ case 66: // b
71
+
72
+ case 75: // k
73
+
74
+ case 80:
75
+ // p
76
+ goToPrevious();
77
+ break;
78
+ }
79
+ };
80
+ }();
81
+
82
+ window.addEventListener('keydown', jumpToCode);
@@ -0,0 +1,87 @@
1
+ /* eslint-disable */
2
+ var jumpToCode = (function init() {
3
+ // Classes of code we would like to highlight in the file view
4
+ var missingCoverageClasses = ['.cbranch-no', '.cstat-no', '.fstat-no'];
5
+
6
+ // Elements to highlight in the file listing view
7
+ var fileListingElements = ['td.pct.low'];
8
+
9
+ // We don't want to select elements that are direct descendants of another match
10
+ var notSelector = ':not(' + missingCoverageClasses.join('):not(') + ') > '; // becomes `:not(a):not(b) > `
11
+
12
+ // Selecter that finds elements on the page to which we can jump
13
+ var selector =
14
+ fileListingElements.join(', ') +
15
+ ', ' +
16
+ notSelector +
17
+ missingCoverageClasses.join(', ' + notSelector); // becomes `:not(a):not(b) > a, :not(a):not(b) > b`
18
+
19
+ // The NodeList of matching elements
20
+ var missingCoverageElements = document.querySelectorAll(selector);
21
+
22
+ var currentIndex;
23
+
24
+ function toggleClass(index) {
25
+ missingCoverageElements
26
+ .item(currentIndex)
27
+ .classList.remove('highlighted');
28
+ missingCoverageElements.item(index).classList.add('highlighted');
29
+ }
30
+
31
+ function makeCurrent(index) {
32
+ toggleClass(index);
33
+ currentIndex = index;
34
+ missingCoverageElements.item(index).scrollIntoView({
35
+ behavior: 'smooth',
36
+ block: 'center',
37
+ inline: 'center'
38
+ });
39
+ }
40
+
41
+ function goToPrevious() {
42
+ var nextIndex = 0;
43
+ if (typeof currentIndex !== 'number' || currentIndex === 0) {
44
+ nextIndex = missingCoverageElements.length - 1;
45
+ } else if (missingCoverageElements.length > 1) {
46
+ nextIndex = currentIndex - 1;
47
+ }
48
+
49
+ makeCurrent(nextIndex);
50
+ }
51
+
52
+ function goToNext() {
53
+ var nextIndex = 0;
54
+
55
+ if (
56
+ typeof currentIndex === 'number' &&
57
+ currentIndex < missingCoverageElements.length - 1
58
+ ) {
59
+ nextIndex = currentIndex + 1;
60
+ }
61
+
62
+ makeCurrent(nextIndex);
63
+ }
64
+
65
+ return function jump(event) {
66
+ if (
67
+ document.getElementById('fileSearch') === document.activeElement &&
68
+ document.activeElement != null
69
+ ) {
70
+ // if we're currently focused on the search input, we don't want to navigate
71
+ return;
72
+ }
73
+
74
+ switch (event.which) {
75
+ case 78: // n
76
+ case 74: // j
77
+ goToNext();
78
+ break;
79
+ case 66: // b
80
+ case 75: // k
81
+ case 80: // p
82
+ goToPrevious();
83
+ break;
84
+ }
85
+ };
86
+ })();
87
+ window.addEventListener('keydown', jumpToCode);