@modusoperandi/licit 0.14.2 → 0.14.10

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.
@@ -240,6 +240,13 @@ class Licit extends React.Component {
240
240
  }
241
241
  });
242
242
  });
243
+ _defineProperty(this, "goToEnd", () => {
244
+ // Return focus to the editor with cursor at end of document.
245
+ const view = this.editorView;
246
+ const tr = view.state.tr;
247
+ view.dispatch(tr.setSelection(_prosemirrorState.TextSelection.atEnd(view.state.doc)).scrollIntoView());
248
+ view.focus();
249
+ });
243
250
  this.initialize(_props);
244
251
  }
245
252
  initialize(props) {
@@ -696,6 +696,15 @@ class Licit extends React.Component<any, any> {
696
696
  }
697
697
  });
698
698
  };
699
+
700
+ goToEnd = (): void => {
701
+ // Return focus to the editor with cursor at end of document.
702
+ const view: EditorView = this.editorView;
703
+ const tr = view.state.tr;
704
+ view.dispatch(tr.setSelection(TextSelection.atEnd(view.state.doc)).scrollIntoView());
705
+ view.focus();
706
+ };
707
+
699
708
  }
700
709
 
701
710
  export default Licit;
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = void 0;
7
7
  var _prosemirrorState = require("prosemirror-state");
8
8
  var _prosemirrorView = require("prosemirror-view");
9
+ var _prosemirrorModel = require("prosemirror-model");
9
10
  var React = _interopRequireWildcard(require("react"));
10
11
  var _CommandMenuButton = _interopRequireDefault(require("./CommandMenuButton"));
11
12
  var _EditorToolbarConfig = require("./EditorToolbarConfig");
@@ -26,11 +27,20 @@ class TableCellMenu extends React.PureComponent {
26
27
  render() {
27
28
  const {
28
29
  editorState,
29
- editorView
30
+ editorView,
31
+ pluginView,
32
+ actionNode
30
33
  } = this.props;
34
+ let cmdGrps = null;
35
+ if (pluginView.getMenu) {
36
+ cmdGrps = pluginView.getMenu(editorState, actionNode, _EditorToolbarConfig.TABLE_COMMANDS_GROUP);
37
+ }
38
+ if (!cmdGrps) {
39
+ cmdGrps = _EditorToolbarConfig.TABLE_COMMANDS_GROUP;
40
+ }
31
41
  return /*#__PURE__*/React.createElement(_CommandMenuButton.default, {
32
42
  className: "czi-table-cell-menu",
33
- commandGroups: _EditorToolbarConfig.TABLE_COMMANDS_GROUP,
43
+ commandGroups: cmdGrps,
34
44
  dispatch: editorView.dispatch,
35
45
  editorState: editorState,
36
46
  editorView: editorView,
@@ -1,6 +1,7 @@
1
1
  // @flow
2
- import { EditorState } from 'prosemirror-state';
2
+ import { EditorState, PluginView } from 'prosemirror-state';
3
3
  import { EditorView } from 'prosemirror-view';
4
+ import { Node } from 'prosemirror-model';
4
5
  import * as React from 'react';
5
6
 
6
7
  import CommandMenuButton from './CommandMenuButton';
@@ -12,6 +13,8 @@ import './czi-table-cell-menu.css';
12
13
  type Props = {
13
14
  editorState: EditorState,
14
15
  editorView: EditorView,
16
+ pluginView: PluginView,
17
+ actionNode: Node,
15
18
  };
16
19
 
17
20
  class TableCellMenu extends React.PureComponent<any, any> {
@@ -20,11 +23,21 @@ class TableCellMenu extends React.PureComponent<any, any> {
20
23
  props: Props;
21
24
 
22
25
  render(): React.Element<any> {
23
- const { editorState, editorView } = this.props;
26
+ const { editorState, editorView, pluginView, actionNode } = this.props;
27
+ let cmdGrps = null;
28
+
29
+ if (pluginView.getMenu) {
30
+ cmdGrps = pluginView.getMenu(editorState, actionNode, TABLE_COMMANDS_GROUP);
31
+ }
32
+
33
+ if (!cmdGrps) {
34
+ cmdGrps = TABLE_COMMANDS_GROUP;
35
+ }
36
+
24
37
  return (
25
38
  <CommandMenuButton
26
39
  className="czi-table-cell-menu"
27
- commandGroups={TABLE_COMMANDS_GROUP}
40
+ commandGroups={cmdGrps}
28
41
  dispatch={editorView.dispatch}
29
42
  editorState={editorState}
30
43
  editorView={editorView}
@@ -12,8 +12,10 @@ function isElementFullyVisible(el) {
12
12
  w,
13
13
  h
14
14
  } = (0, _licitUiCommands.fromHTMlElement)(el);
15
+ // to handle the rounded border scenario.
16
+ const factor = '10px' === el.style.borderRadius ? 3 : 1;
15
17
  // Only checks the top-left point.
16
- const nwEl = w && h ? el.ownerDocument.elementFromPoint(x + 1, y + 1) : null;
18
+ const nwEl = w && h ? el.ownerDocument.elementFromPoint(x + factor, y + factor) : null;
17
19
  if (!nwEl) {
18
20
  return false;
19
21
  }
@@ -4,8 +4,11 @@ import { fromHTMlElement } from '@modusoperandi/licit-ui-commands';
4
4
 
5
5
  export default function isElementFullyVisible(el: HTMLElement): boolean {
6
6
  const { x, y, w, h } = fromHTMlElement(el);
7
+ // to handle the rounded border scenario.
8
+ const factor = '10px' === el.style.borderRadius ? 3 : 1;
7
9
  // Only checks the top-left point.
8
- const nwEl = w && h ? el.ownerDocument.elementFromPoint(x + 1, y + 1) : null;
10
+ const nwEl =
11
+ w && h ? el.ownerDocument.elementFromPoint(x + factor, y + factor) : null;
9
12
 
10
13
  if (!nwEl) {
11
14
  return false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@modusoperandi/licit",
3
- "version": "0.14.2",
3
+ "version": "0.14.10",
4
4
  "subversion": "1",
5
5
  "description": "Rich text editor built with React and ProseMirror",
6
6
  "main": "dist/index.js",
@@ -56,7 +56,7 @@
56
56
  "babel-plugin-transform-react-remove-prop-types": "0.4.24",
57
57
  "clean-webpack-plugin": "4.0.0",
58
58
  "copy-webpack-plugin": "^11.0.0",
59
- "css-loader": "3.6.0",
59
+ "css-loader": "6.7.3",
60
60
  "enzyme": "^3.11.0",
61
61
  "eslint": "^8.25.0",
62
62
  "eslint-config-prettier": "^8.5.0",
@@ -70,7 +70,7 @@
70
70
  "flow-webpack-plugin": "1.2.0",
71
71
  "html-loader": "1.1.0",
72
72
  "html-webpack-inline-source-plugin": "1.0.0-beta.2",
73
- "html-webpack-plugin": "^4.5.0",
73
+ "html-webpack-plugin": "^5.5.0",
74
74
  "husky": "^8.0.1",
75
75
  "identity-obj-proxy": "^3.0.0",
76
76
  "jest": "^29.2.0",
@@ -90,13 +90,9 @@
90
90
  "write-file-webpack-plugin": "4.5.1"
91
91
  },
92
92
  "dependencies": {
93
- "@modusoperandi/licit-doc-attrs-step": "^0.1.4",
94
- "@modusoperandi/licit-ui-commands": "^0.1.12",
93
+ "@modusoperandi/licit-ui-commands": "^0.1.13",
95
94
  "@wojtekmaj/enzyme-adapter-react-17": "^0.6.7",
96
95
  "body-parser": "^1.19.0",
97
- "browserkeymap": "2.0.2",
98
- "classnames": "2.3.2",
99
- "color": "^4.2.3",
100
96
  "cors": "^2.8.5",
101
97
  "express": "^4.17.1",
102
98
  "flatted": "^3.1.0",
@@ -107,17 +103,15 @@
107
103
  "katex": "0.11.1",
108
104
  "mv": "^2.1.1",
109
105
  "node-mathquill": "0.10.2",
110
- "nullthrows": "1.1.1",
106
+ "prosemirror-collab": "1.2.2",
107
+ "prosemirror-dev-tools": "3.0.2",
111
108
  "prosemirror-model": "~1.16.0",
112
- "prosemirror-view": "1.27.0",
113
109
  "prosemirror-tables": "1.2.5",
114
- "prosemirror-dev-tools": "3.0.2",
115
- "prosemirror-collab": "1.2.2",
110
+ "prosemirror-view": "1.27.0",
116
111
  "query-string": "6.13.1",
117
112
  "resize-observer-polyfill": "1.5.1",
118
113
  "smooth-scroll-into-view-if-needed": "1.1.28",
119
- "url": "^0.11.0",
120
- "uuid": "9.0.0"
114
+ "url": "^0.11.0"
121
115
  },
122
116
  "importSort": {
123
117
  ".js": {
@@ -13,6 +13,7 @@ import { createPopUp } from '@modusoperandi/licit-ui-commands';
13
13
  import isElementFullyVisible from './ui/isElementFullyVisible';
14
14
 
15
15
  import '@modusoperandi/licit-ui-commands/dist/ui/czi-pop-up.css';
16
+ import { CellSelection } from 'prosemirror-tables';
16
17
 
17
18
  class TableCellTooltipView {
18
19
  _cellElement: null;
@@ -41,9 +42,15 @@ class TableCellTooltipView {
41
42
 
42
43
  let cellEl = domFound.node;
43
44
  const popUp = this._popUp;
45
+ let actionNode = null;
46
+ if (result && state.selection instanceof CellSelection) {
47
+ actionNode = state.selection.$anchorCell.node(-1);
48
+ }
44
49
  const viewPops = {
45
50
  editorState: state,
46
51
  editorView: view,
52
+ pluginView: this,
53
+ actionNode,
47
54
  };
48
55
 
49
56
  if (cellEl && !isElementFullyVisible(cellEl)) {
@@ -595,9 +595,10 @@ export default class TableResizePlugin extends Plugin {
595
595
  key: PLUGIN_KEY,
596
596
  state: {
597
597
  init(_: any, state: EditorState): ResizeState {
598
- this.spec.props.nodeViews[
599
- tableNodeTypes(state.schema).table.name
600
- ] = createTableView;
598
+ if (!this.spec.props.nodeViews['table']) {
599
+ this.spec.props.nodeViews[tableNodeTypes(state.schema).table.name] =
600
+ createTableView;
601
+ }
601
602
  return new ResizeState(-1, null);
602
603
  },
603
604
  apply(tr: Transform, prev: EditorState): EditorState {
@@ -696,6 +696,15 @@ class Licit extends React.Component<any, any> {
696
696
  }
697
697
  });
698
698
  };
699
+
700
+ goToEnd = (): void => {
701
+ // Return focus to the editor with cursor at end of document.
702
+ const view: EditorView = this.editorView;
703
+ const tr = view.state.tr;
704
+ view.dispatch(tr.setSelection(TextSelection.atEnd(view.state.doc)).scrollIntoView());
705
+ view.focus();
706
+ };
707
+
699
708
  }
700
709
 
701
710
  export default Licit;
@@ -1,6 +1,7 @@
1
1
  // @flow
2
- import { EditorState } from 'prosemirror-state';
2
+ import { EditorState, PluginView } from 'prosemirror-state';
3
3
  import { EditorView } from 'prosemirror-view';
4
+ import { Node } from 'prosemirror-model';
4
5
  import * as React from 'react';
5
6
 
6
7
  import CommandMenuButton from './CommandMenuButton';
@@ -12,6 +13,8 @@ import './czi-table-cell-menu.css';
12
13
  type Props = {
13
14
  editorState: EditorState,
14
15
  editorView: EditorView,
16
+ pluginView: PluginView,
17
+ actionNode: Node,
15
18
  };
16
19
 
17
20
  class TableCellMenu extends React.PureComponent<any, any> {
@@ -20,11 +23,21 @@ class TableCellMenu extends React.PureComponent<any, any> {
20
23
  props: Props;
21
24
 
22
25
  render(): React.Element<any> {
23
- const { editorState, editorView } = this.props;
26
+ const { editorState, editorView, pluginView, actionNode } = this.props;
27
+ let cmdGrps = null;
28
+
29
+ if (pluginView.getMenu) {
30
+ cmdGrps = pluginView.getMenu(editorState, actionNode, TABLE_COMMANDS_GROUP);
31
+ }
32
+
33
+ if (!cmdGrps) {
34
+ cmdGrps = TABLE_COMMANDS_GROUP;
35
+ }
36
+
24
37
  return (
25
38
  <CommandMenuButton
26
39
  className="czi-table-cell-menu"
27
- commandGroups={TABLE_COMMANDS_GROUP}
40
+ commandGroups={cmdGrps}
28
41
  dispatch={editorView.dispatch}
29
42
  editorState={editorState}
30
43
  editorView={editorView}
@@ -4,8 +4,11 @@ import { fromHTMlElement } from '@modusoperandi/licit-ui-commands';
4
4
 
5
5
  export default function isElementFullyVisible(el: HTMLElement): boolean {
6
6
  const { x, y, w, h } = fromHTMlElement(el);
7
+ // to handle the rounded border scenario.
8
+ const factor = '10px' === el.style.borderRadius ? 3 : 1;
7
9
  // Only checks the top-left point.
8
- const nwEl = w && h ? el.ownerDocument.elementFromPoint(x + 1, y + 1) : null;
10
+ const nwEl =
11
+ w && h ? el.ownerDocument.elementFromPoint(x + factor, y + factor) : null;
9
12
 
10
13
  if (!nwEl) {
11
14
  return false;