@modusoperandi/licit 1.6.1 → 1.6.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/TableNodesSpecs.js +147 -5
- package/TableNodesSpecs.js.flow +150 -6
- package/TableNodesSpecs.test.js +49 -0
- package/TableNodesSpecs.test.js.flow +76 -0
- package/bom.xml +8232 -8111
- package/insertTable.js +3 -1
- package/insertTable.js.flow +4 -1
- package/package.json +7 -7
- package/ui/TableNodeView.js +12 -4
- package/ui/TableNodeView.js.flow +9 -0
- package/ui/toCSSLength.js +38 -0
- package/ui/toCSSLength.js.flow +38 -0
package/insertTable.js
CHANGED
|
@@ -32,7 +32,9 @@ export default function insertTable(tr, schema, rows, cols) {
|
|
|
32
32
|
var rowNode = row.create({}, Fragment.from(cellNodes));
|
|
33
33
|
rowNodes.push(rowNode);
|
|
34
34
|
}
|
|
35
|
-
var tableNode = table.create({
|
|
35
|
+
var tableNode = table.create({
|
|
36
|
+
noOfColumns: cols
|
|
37
|
+
}, Fragment.from(rowNodes));
|
|
36
38
|
tr = tr.insert(from, Fragment.from(tableNode));
|
|
37
39
|
var selection = TextSelection.create(tr.doc, from + 5, from + 5);
|
|
38
40
|
tr = tr.setSelection(selection);
|
package/insertTable.js.flow
CHANGED
|
@@ -44,7 +44,10 @@ export default function insertTable(
|
|
|
44
44
|
const rowNode = row.create({}, Fragment.from(cellNodes));
|
|
45
45
|
rowNodes.push(rowNode);
|
|
46
46
|
}
|
|
47
|
-
const tableNode = table.create(
|
|
47
|
+
const tableNode = table.create(
|
|
48
|
+
{ noOfColumns: cols },
|
|
49
|
+
Fragment.from(rowNodes)
|
|
50
|
+
);
|
|
48
51
|
tr = tr.insert(from, Fragment.from(tableNode));
|
|
49
52
|
|
|
50
53
|
const selection = TextSelection.create(tr.doc, from + 5, from + 5);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@modusoperandi/licit",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"subversion": "1",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"@modusoperandi/color-picker": "^1.0.7",
|
|
44
44
|
"browserkeymap": "^2.0.2",
|
|
45
|
-
"flatted": "^3.3.
|
|
45
|
+
"flatted": "^3.3.4",
|
|
46
46
|
"prop-types": "^15.8.1",
|
|
47
47
|
"react-tooltip": "^5.30.0",
|
|
48
48
|
"resize-observer-polyfill": "^1.5.1",
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
"copyfiles": "^2.4.1",
|
|
83
83
|
"cors": "^2.8.6",
|
|
84
84
|
"css-loader": "^7.1.4",
|
|
85
|
-
"eslint": "^9.39.
|
|
85
|
+
"eslint": "^9.39.3",
|
|
86
86
|
"eslint-config-prettier": "^10.1.8",
|
|
87
87
|
"eslint-plugin-jest": "^29.15.0",
|
|
88
88
|
"eslint-plugin-prettier": "^5.5.5",
|
|
@@ -90,12 +90,12 @@
|
|
|
90
90
|
"exports-loader": "^5.0.0",
|
|
91
91
|
"express": "^5.2.1",
|
|
92
92
|
"file-loader": "^6.2.0",
|
|
93
|
-
"flow-bin": "^0.
|
|
93
|
+
"flow-bin": "^0.303.0",
|
|
94
94
|
"flow-copy-source": "^2.0.9",
|
|
95
95
|
"flow-typed": "^4.1.1",
|
|
96
96
|
"flow-webpack-plugin": "^1.2.0",
|
|
97
97
|
"formidable": "^3.5.4",
|
|
98
|
-
"globals": "^17.
|
|
98
|
+
"globals": "^17.4.0",
|
|
99
99
|
"html-loader": "^5.1.0",
|
|
100
100
|
"html-webpack-inline-source-plugin": "1.0.0-beta.2",
|
|
101
101
|
"html-webpack-plugin": "^5.6.6",
|
|
@@ -106,7 +106,7 @@
|
|
|
106
106
|
"jest-junit": "^16.0.0",
|
|
107
107
|
"jest-prosemirror": "^3.0.1",
|
|
108
108
|
"jest-sonar-reporter": "^2.0.0",
|
|
109
|
-
"lint-staged": "^16.
|
|
109
|
+
"lint-staged": "^16.3.1",
|
|
110
110
|
"mkdirp": "^3.0.1",
|
|
111
111
|
"mv": "^2.1.1",
|
|
112
112
|
"prettier": "^3.8.1",
|
|
@@ -119,7 +119,7 @@
|
|
|
119
119
|
"ts-loader": "^9.5.4",
|
|
120
120
|
"ts-node": "^10.9.2",
|
|
121
121
|
"typescript": "5.9.3",
|
|
122
|
-
"webpack": "^5.105.
|
|
122
|
+
"webpack": "^5.105.3",
|
|
123
123
|
"webpack-cli": "^6.0.1",
|
|
124
124
|
"webpack-dev-server": "^5.2.3",
|
|
125
125
|
"write-file-webpack-plugin": "^4.5.1"
|
package/ui/TableNodeView.js
CHANGED
|
@@ -17,6 +17,7 @@ function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf
|
|
|
17
17
|
import { Node } from 'prosemirror-model';
|
|
18
18
|
import { EditorView } from 'prosemirror-view';
|
|
19
19
|
import { TableView } from 'prosemirror-tables';
|
|
20
|
+
import toCSSLength from './toCSSLength.js';
|
|
20
21
|
|
|
21
22
|
// A custom table view that renders the margin-left style.
|
|
22
23
|
var TableNodeView = /*#__PURE__*/function (_TableView) {
|
|
@@ -40,23 +41,30 @@ var TableNodeView = /*#__PURE__*/function (_TableView) {
|
|
|
40
41
|
}, {
|
|
41
42
|
key: "_updateAttrs",
|
|
42
43
|
value: function _updateAttrs(node) {
|
|
43
|
-
var _node$attrs, _node$attrs2, _node$attrs3, _node$attrs4;
|
|
44
|
+
var _node$attrs, _node$attrs2, _node$attrs3, _node$attrs4, _node$attrs5, _node$attrs6;
|
|
44
45
|
// Handle marginLeft
|
|
45
46
|
var marginLeft = ((_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.marginLeft) || 0;
|
|
46
47
|
this.table.style.marginLeft = marginLeft ? "".concat(marginLeft, "px") : '';
|
|
48
|
+
this.table.style.height = toCSSLength((_node$attrs2 = node.attrs) === null || _node$attrs2 === void 0 ? void 0 : _node$attrs2.tableheight);
|
|
49
|
+
var noOfColumns = (_node$attrs3 = node.attrs) === null || _node$attrs3 === void 0 ? void 0 : _node$attrs3.noOfColumns;
|
|
50
|
+
if (typeof noOfColumns === 'number' && noOfColumns > 0) {
|
|
51
|
+
this.table.setAttribute('data-no-of-columns', String(noOfColumns));
|
|
52
|
+
} else {
|
|
53
|
+
this.table.removeAttribute('data-no-of-columns');
|
|
54
|
+
}
|
|
47
55
|
|
|
48
56
|
// Handle vignette
|
|
49
|
-
if ((_node$
|
|
57
|
+
if ((_node$attrs4 = node.attrs) !== null && _node$attrs4 !== void 0 && _node$attrs4.vignette) {
|
|
50
58
|
this.table.style.border = 'none';
|
|
51
59
|
}
|
|
52
60
|
|
|
53
61
|
// Handle dirty -> sets a data attribute for DOM/state sync
|
|
54
|
-
if ((_node$
|
|
62
|
+
if ((_node$attrs5 = node.attrs) !== null && _node$attrs5 !== void 0 && _node$attrs5.dirty) {
|
|
55
63
|
this.table.setAttribute('dirty', 'true');
|
|
56
64
|
} else {
|
|
57
65
|
this.table.removeAttribute('dirty');
|
|
58
66
|
}
|
|
59
|
-
if ((_node$
|
|
67
|
+
if ((_node$attrs6 = node.attrs) !== null && _node$attrs6 !== void 0 && _node$attrs6.coverPage) {
|
|
60
68
|
this.table.setAttribute('data-cover-page', 'true');
|
|
61
69
|
} else {
|
|
62
70
|
this.table.removeAttribute('data-cover-page');
|
package/ui/TableNodeView.js.flow
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Node } from 'prosemirror-model';
|
|
2
2
|
import { EditorView } from 'prosemirror-view';
|
|
3
3
|
import { TableView } from 'prosemirror-tables';
|
|
4
|
+
import toCSSLength from './toCSSLength.js';
|
|
4
5
|
|
|
5
6
|
// A custom table view that renders the margin-left style.
|
|
6
7
|
export default class TableNodeView extends TableView {
|
|
@@ -20,6 +21,14 @@ export default class TableNodeView extends TableView {
|
|
|
20
21
|
// Handle marginLeft
|
|
21
22
|
const marginLeft = node.attrs?.marginLeft || 0;
|
|
22
23
|
this.table.style.marginLeft = marginLeft ? `${marginLeft}px` : '';
|
|
24
|
+
this.table.style.height = toCSSLength(node.attrs?.tableheight);
|
|
25
|
+
|
|
26
|
+
const noOfColumns = node.attrs?.noOfColumns;
|
|
27
|
+
if (typeof noOfColumns === 'number' && noOfColumns > 0) {
|
|
28
|
+
this.table.setAttribute('data-no-of-columns', String(noOfColumns));
|
|
29
|
+
} else {
|
|
30
|
+
this.table.removeAttribute('data-no-of-columns');
|
|
31
|
+
}
|
|
23
32
|
|
|
24
33
|
// Handle vignette
|
|
25
34
|
if (node.attrs?.vignette) {
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
var NUMERIC_LENGTH_PATTERN = /^-?\d{1,1000}(\.\d{1,1000})?$/;
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @param {unknown} value
|
|
5
|
+
* @returns {string | null}
|
|
6
|
+
*/
|
|
7
|
+
function normalizeCSSLength(value) {
|
|
8
|
+
if (value === null || value === undefined) {
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
if (typeof value === 'number' && isFinite(value)) {
|
|
12
|
+
return "".concat(value, "px");
|
|
13
|
+
}
|
|
14
|
+
var stringValue = String(value).trim();
|
|
15
|
+
if (!stringValue) {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
if (NUMERIC_LENGTH_PATTERN.test(stringValue)) {
|
|
19
|
+
return "".concat(stringValue, "px");
|
|
20
|
+
}
|
|
21
|
+
return stringValue;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @param {unknown} value
|
|
26
|
+
* @returns {string | null}
|
|
27
|
+
*/
|
|
28
|
+
export function toCSSLengthOrNull(value) {
|
|
29
|
+
return normalizeCSSLength(value);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* @param {unknown} value
|
|
34
|
+
* @returns {string}
|
|
35
|
+
*/
|
|
36
|
+
export default function toCSSLength(value) {
|
|
37
|
+
return normalizeCSSLength(value) || '';
|
|
38
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
const NUMERIC_LENGTH_PATTERN = /^-?\d{1,1000}(\.\d{1,1000})?$/;
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @param {unknown} value
|
|
5
|
+
* @returns {string | null}
|
|
6
|
+
*/
|
|
7
|
+
function normalizeCSSLength(value) {
|
|
8
|
+
if (value === null || value === undefined) {
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
if (typeof value === 'number' && isFinite(value)) {
|
|
12
|
+
return `${value}px`;
|
|
13
|
+
}
|
|
14
|
+
const stringValue = String(value).trim();
|
|
15
|
+
if (!stringValue) {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
if (NUMERIC_LENGTH_PATTERN.test(stringValue)) {
|
|
19
|
+
return `${stringValue}px`;
|
|
20
|
+
}
|
|
21
|
+
return stringValue;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @param {unknown} value
|
|
26
|
+
* @returns {string | null}
|
|
27
|
+
*/
|
|
28
|
+
export function toCSSLengthOrNull(value) {
|
|
29
|
+
return normalizeCSSLength(value);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* @param {unknown} value
|
|
34
|
+
* @returns {string}
|
|
35
|
+
*/
|
|
36
|
+
export default function toCSSLength(value) {
|
|
37
|
+
return normalizeCSSLength(value) || '';
|
|
38
|
+
}
|