@modusoperandi/licit 1.1.0 → 1.1.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/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@modusoperandi/licit",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
+ "license": "MIT",
4
5
  "type": "module",
5
6
  "subversion": "1",
6
7
  "description": "Rich text editor built with React and ProseMirror",
@@ -25,7 +26,6 @@
25
26
  "build:licit": "node utils/build_bin.js",
26
27
  "ci:bom": "cyclonedx-npm --ignore-npm-errors --short-PURLs --output-format XML --output-file dist/bom.xml",
27
28
  "ci:build": "npm run build:clean && npm run build:babel && npm run build:flow && npm run build:css && npm run build:fonts && npm run build:bom && copyfiles --up 1 \"src/**/*.d.ts\" dist/ && copyfiles --up 1 \"src/**/*.css\" dist && copyfiles package.json LICENSE dist",
28
- "flow": "flow --show-all-errors",
29
29
  "lint:css": "stylelint \"**/*.css\"",
30
30
  "lint:js": "eslint \"src/**/*.js\"",
31
31
  "lint": "npm run lint:css & npm run lint:js",
@@ -34,6 +34,22 @@
34
34
  "build:style-service-docker": "docker build . -f style-service.Dockerfile -t style-service:latest",
35
35
  "verify": "npm run lint -- --fix && npm run ci:build && npm run test:coverage && echo 'All Tests Passed!'"
36
36
  },
37
+ "peerDependencies": {
38
+ "@modusoperandi/licit-ui-commands": "^1.0.8",
39
+ "prosemirror-collab": "^1.2.2",
40
+ "prosemirror-tables": "^1.2.5"
41
+ },
42
+ "dependencies": {
43
+ "@modusoperandi/color-picker": "^1.0.4",
44
+ "browserkeymap": "^2.0.2",
45
+ "flatted": "^3.1.0",
46
+ "jquery": "^3.5.1",
47
+ "react-tooltip": "^5.28.0",
48
+ "resize-observer-polyfill": "^1.5.1",
49
+ "smooth-scroll-into-view-if-needed": "^2.0.2",
50
+ "url": "^0.11.0",
51
+ "webfontloader": "^1.6.28"
52
+ },
37
53
  "devDependencies": {
38
54
  "@babel/cli": "^7.19.3",
39
55
  "@babel/core": "^7.19.3",
@@ -85,7 +101,6 @@
85
101
  "html-webpack-plugin": "^5.5.0",
86
102
  "husky": "^9.0.10",
87
103
  "identity-obj-proxy": "^3.0.0",
88
- "invariant": "^2.2.4",
89
104
  "jest": "^29.2.0",
90
105
  "jest-environment-jsdom": "^29.3.1",
91
106
  "jest-junit": "^16.0.0",
@@ -97,7 +112,7 @@
97
112
  "prettier": "^3.2.5",
98
113
  "style-loader": "^4.0.0",
99
114
  "stylelint": "^16.2.1",
100
- "stylelint-config-standard": "^36.0.0",
115
+ "stylelint-config-standard": "^37.0.0",
101
116
  "stylelint-prettier": "^5.0.0",
102
117
  "terser-webpack-plugin": "^5.3.10",
103
118
  "ts-jest": "^29.1.2",
@@ -109,32 +124,8 @@
109
124
  "webpack-dev-server": "^5.0.2",
110
125
  "write-file-webpack-plugin": "^4.5.1"
111
126
  },
112
- "dependencies": {
113
- "@modusoperandi/color-picker": "^1.0.4",
114
- "body-parser": "^1.19.0",
115
- "browserkeymap": "^2.0.2",
116
- "flatted": "^3.1.0",
117
- "flow-typed": "^4.0.0",
118
- "formidable": "^3.5.1",
119
- "invariant": "^2.2.4",
120
- "jquery": "^3.5.1",
121
- "react-tooltip": "^5.28.0",
122
- "resize-observer-polyfill": "^1.5.1",
123
- "smooth-scroll-into-view-if-needed": "^2.0.2",
124
- "style-loader": "^4.0.0",
125
- "url": "^0.11.0",
126
- "webfontloader": "^1.6.28"
127
- },
128
- "peerDependencies": {
129
- "@modusoperandi/licit-ui-commands": "^1.0.8",
130
- "jquery": "^3.5.1",
131
- "prosemirror-collab": "^1.2.2",
132
- "prosemirror-tables": "^1.2.5"
133
- },
134
127
  "overrides": {
135
- "libxmljs2": "^1.0.0",
136
- "react": "^18.3.1",
137
- "react-dom": "^18.3.1"
128
+ "libxmljs2": "^1.0.0"
138
129
  },
139
130
  "importSort": {
140
131
  ".js": {
@@ -1,8 +1,8 @@
1
1
  var _excluded = ["title", "className", "checked", "label", "inline", "name", "onSelect", "disabled"];
2
2
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
3
3
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
4
- function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var s = Object.getOwnPropertySymbols(e); for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
5
- function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.includes(n)) continue; t[n] = r[n]; } return t; }
4
+ function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
5
+ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
6
6
  function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
7
7
  function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
8
8
  function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
package/ui/LinkTooltip.js CHANGED
@@ -102,6 +102,7 @@ var LinkTooltip = /*#__PURE__*/function (_React$PureComponent) {
102
102
  onRemove = _this$props2.onRemove,
103
103
  tocItemPos_ = _this$props2.tocItemPos_,
104
104
  selectionId_ = _this$props2.selectionId_;
105
+ var canEdit = editorView.editable;
105
106
  // [FS] IRAD-1013 2020-07-09
106
107
  var getLabel = function getLabel() {
107
108
  if (tocItemPos_ && selectionId_) {
@@ -131,11 +132,11 @@ var LinkTooltip = /*#__PURE__*/function (_React$PureComponent) {
131
132
  target: "new",
132
133
  title: label,
133
134
  value: label
134
- }), /*#__PURE__*/React.createElement(CustomButton, {
135
+ }), canEdit && /*#__PURE__*/React.createElement(CustomButton, {
135
136
  label: "Change",
136
137
  onClick: onEdit,
137
138
  value: editorView
138
- }), /*#__PURE__*/React.createElement(CustomButton, {
139
+ }), canEdit && /*#__PURE__*/React.createElement(CustomButton, {
139
140
  label: "Remove",
140
141
  onClick: onRemove,
141
142
  value: editorView
@@ -24,6 +24,7 @@ class LinkTooltip extends React.PureComponent<any, any> {
24
24
  render(): React.Element<any> {
25
25
  const { href, editorView, onEdit, onRemove, tocItemPos_, selectionId_ } =
26
26
  this.props;
27
+ const canEdit = editorView.editable;
27
28
  // [FS] IRAD-1013 2020-07-09
28
29
  const getLabel = () => {
29
30
  if (tocItemPos_ && selectionId_) {
@@ -53,8 +54,16 @@ class LinkTooltip extends React.PureComponent<any, any> {
53
54
  title={label}
54
55
  value={label}
55
56
  />
56
- <CustomButton label="Change" onClick={onEdit} value={editorView} />
57
- <CustomButton label="Remove" onClick={onRemove} value={editorView} />
57
+ {canEdit && (
58
+ <CustomButton label="Change" onClick={onEdit} value={editorView} />
59
+ )}
60
+ {canEdit && (
61
+ <CustomButton
62
+ label="Remove"
63
+ onClick={onRemove}
64
+ value={editorView}
65
+ />
66
+ )}
58
67
  </div>
59
68
  </div>
60
69
  </div>
@@ -1,4 +1,6 @@
1
1
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
2
4
  function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
3
5
  function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
4
6
  function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
@@ -63,14 +65,15 @@ var LinkURLEditor = /*#__PURE__*/function (_React$PureComponent) {
63
65
  if (!(TocNode !== null && TocNode !== void 0 && (_TocNode$attrs = TocNode.attrs) !== null && _TocNode$attrs !== void 0 && _TocNode$attrs.innerLink)) {
64
66
  var nodeUUID = uuid();
65
67
  var texthash = '#';
66
- var nodeAttrs = TocNode.attrs;
68
+ var nodeAttrs = _objectSpread({}, TocNode.attrs);
67
69
  var nodeconcat_UUID = texthash.concat(nodeUUID);
68
70
  nodeAttrs.innerLink = nodeconcat_UUID;
69
- tr.setNodeMarkup(tocNodePosition_, undefined, nodeAttrs);
71
+ tr = tr.setNodeMarkup(tocNodePosition_, undefined, nodeAttrs);
70
72
  textContent = nodeconcat_UUID.concat(INNER_LINK, textContent_);
71
73
  } else {
72
74
  textContent = TocNode.attrs.innerLink.concat(INNER_LINK, textContent_);
73
75
  }
76
+ view.dispatch(tr);
74
77
  _this.props.close(textContent);
75
78
  });
76
79
  _defineProperty(_this, "_onKeyDown", function (e) {
@@ -64,8 +64,7 @@ class LinkURLEditor extends React.PureComponent<any, any> {
64
64
  };
65
65
 
66
66
  render(): React.Element<any> {
67
- const { url, TOCselectedNode_, view_, selectionId } =
68
- this.state;
67
+ const { url, TOCselectedNode_, view_, selectionId } = this.state;
69
68
 
70
69
  const isTOCValid = () => {
71
70
  if (!TOCselectedNode_ || TOCselectedNode_.length === 0) {
@@ -73,7 +72,7 @@ class LinkURLEditor extends React.PureComponent<any, any> {
73
72
  }
74
73
 
75
74
  return TOCselectedNode_.some(
76
- item => item.node_ && item.node_.textContent.trim() !== ''
75
+ (item) => item.node_ && item.node_.textContent.trim() !== ''
77
76
  );
78
77
  };
79
78
  const isValid = isTOCValid();
@@ -92,7 +91,7 @@ class LinkURLEditor extends React.PureComponent<any, any> {
92
91
 
93
92
  return (
94
93
  <div className="czi-image-url-editor">
95
- <div className="czi-form" style={{padding:'10px', display:'flex'}}>
94
+ <div className="czi-form" style={{ padding: '10px', display: 'flex' }}>
96
95
  <div className="tab">
97
96
  <button
98
97
  className="tablinks"
@@ -138,7 +137,7 @@ class LinkURLEditor extends React.PureComponent<any, any> {
138
137
  </form>
139
138
  </div>
140
139
  {!isValid ? (
141
- <div className="tabcontent" id="innerlink" >
140
+ <div className="tabcontent" id="innerlink">
142
141
  <p>No TOC styles</p>
143
142
  <div className="czi-form-buttons">
144
143
  <CustomButton label="Cancel" onClick={this._cancel} />
@@ -151,13 +150,19 @@ class LinkURLEditor extends React.PureComponent<any, any> {
151
150
  <br></br>
152
151
  <select
153
152
  defaultValue={
154
- TOCselectedNode_.some(res => res.node_.textContent === url) ? url : null
153
+ TOCselectedNode_.some(
154
+ (res) => res.node_.textContent === url
155
+ )
156
+ ? url
157
+ : null
155
158
  }
156
159
  id="toc"
157
160
  name="toccontents"
158
161
  size="3"
159
162
  >
160
- {TOCselectedNode_?.filter(res => res.node_.textContent.trim() !== '').map((res, index) => (
163
+ {TOCselectedNode_?.filter(
164
+ (res) => res.node_.textContent.trim() !== ''
165
+ ).map((res, index) => (
161
166
  <option
162
167
  data-tooltip-content={res.node_.textContent}
163
168
  data-tooltip-id="select-toc-tooltip"
@@ -193,20 +198,21 @@ class LinkURLEditor extends React.PureComponent<any, any> {
193
198
  }
194
199
 
195
200
  handleOptionChange = (textContent_, tocNodePosition_, view: EditorView) => {
196
- const tr = view.state.tr;
201
+ let tr = view.state.tr;
197
202
  const TocNode = view.state.doc.nodeAt(tocNodePosition_);
198
203
  let textContent;
199
204
  if (!TocNode?.attrs?.innerLink) {
200
205
  const nodeUUID = uuid();
201
206
  const texthash = '#';
202
- const nodeAttrs = TocNode.attrs;
207
+ const nodeAttrs = { ...TocNode.attrs };
203
208
  const nodeconcat_UUID = texthash.concat(nodeUUID);
204
209
  nodeAttrs.innerLink = nodeconcat_UUID;
205
- tr.setNodeMarkup(tocNodePosition_, undefined, nodeAttrs);
210
+ tr = tr.setNodeMarkup(tocNodePosition_, undefined, nodeAttrs);
206
211
  textContent = nodeconcat_UUID.concat(INNER_LINK, textContent_);
207
212
  } else {
208
213
  textContent = TocNode.attrs.innerLink.concat(INNER_LINK, textContent_);
209
214
  }
215
+ view.dispatch(tr);
210
216
  this.props.close(textContent);
211
217
  };
212
218
 
package/ui/czi-editor.css CHANGED
@@ -126,6 +126,9 @@
126
126
  line-height: var(--czi-content-line-height);
127
127
  margin: 0;
128
128
  }
129
+ .prosemirror-editor-wrapper.readOnly a {
130
+ pointer-events: none; /* Disable interaction */
131
+ }
129
132
 
130
133
  .ProseMirror a:link,
131
134
  .ProseMirror a:visited,