@modusoperandi/licit 0.14.1 → 0.14.3

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.
Files changed (48) hide show
  1. package/README.md +1 -0
  2. package/dist/EditorCommands.js +1 -7
  3. package/dist/EditorCommands.js.flow +0 -4
  4. package/dist/EditorNodes.js +0 -3
  5. package/dist/EditorNodes.js.flow +0 -3
  6. package/dist/bom.xml +225 -227
  7. package/dist/buildEditorPlugins.js +1 -2
  8. package/dist/buildEditorPlugins.js.flow +0 -2
  9. package/dist/client/Licit.js +7 -0
  10. package/dist/client/Licit.js.flow +9 -0
  11. package/dist/ui/Editor.js +0 -2
  12. package/dist/ui/Editor.js.flow +1 -3
  13. package/dist/ui/EditorToolbarConfig.js +0 -6
  14. package/dist/ui/EditorToolbarConfig.js.flow +0 -8
  15. package/package.json +6 -12
  16. package/src/EditorCommands.js +0 -4
  17. package/src/EditorNodes.js +0 -3
  18. package/src/buildEditorPlugins.js +0 -2
  19. package/src/client/Licit.js +9 -0
  20. package/src/ui/Editor.js +1 -3
  21. package/src/ui/EditorToolbarConfig.js +0 -8
  22. package/dist/ImageFromURLCommand.js +0 -19
  23. package/dist/ImageFromURLCommand.js.flow +0 -14
  24. package/dist/ImageNodeSpec.js +0 -109
  25. package/dist/ImageNodeSpec.js.flow +0 -90
  26. package/dist/ImageSourceCommand.js +0 -117
  27. package/dist/ImageSourceCommand.js.flow +0 -117
  28. package/dist/ImageUploadCommand.js +0 -49
  29. package/dist/ImageUploadCommand.js.flow +0 -36
  30. package/dist/ui/ImageAlignEditor.js +0 -71
  31. package/dist/ui/ImageAlignEditor.js.flow +0 -60
  32. package/dist/ui/ImageNodeView.js +0 -404
  33. package/dist/ui/ImageNodeView.js.flow +0 -405
  34. package/dist/ui/ImageResizeBox.js +0 -206
  35. package/dist/ui/ImageResizeBox.js.flow +0 -219
  36. package/dist/ui/ImageURLEditor.js +0 -108
  37. package/dist/ui/ImageURLEditor.js.flow +0 -119
  38. package/dist/ui/ImageUploadEditor.js +0 -123
  39. package/dist/ui/ImageUploadEditor.js.flow +0 -117
  40. package/src/ImageFromURLCommand.js +0 -14
  41. package/src/ImageNodeSpec.js +0 -90
  42. package/src/ImageSourceCommand.js +0 -117
  43. package/src/ImageUploadCommand.js +0 -36
  44. package/src/ui/ImageAlignEditor.js +0 -60
  45. package/src/ui/ImageNodeView.js +0 -405
  46. package/src/ui/ImageResizeBox.js +0 -219
  47. package/src/ui/ImageURLEditor.js +0 -119
  48. package/src/ui/ImageUploadEditor.js +0 -117
@@ -14,7 +14,6 @@ var _prosemirrorState = require("prosemirror-state");
14
14
  var _ContentPlaceholderPlugin = _interopRequireDefault(require("./ContentPlaceholderPlugin"));
15
15
  var _CursorPlaceholderPlugin = _interopRequireDefault(require("./CursorPlaceholderPlugin"));
16
16
  var _EditorPageLayoutPlugin = _interopRequireDefault(require("./EditorPageLayoutPlugin"));
17
- var _ImageUploadPlaceholderPlugin = _interopRequireDefault(require("./ImageUploadPlaceholderPlugin"));
18
17
  var _LinkTooltipPlugin = _interopRequireDefault(require("./LinkTooltipPlugin"));
19
18
  var _SelectionPlaceholderPlugin = _interopRequireDefault(require("./SelectionPlaceholderPlugin"));
20
19
  var _TablePlugins = _interopRequireDefault(require("./TablePlugins"));
@@ -28,7 +27,7 @@ function _toPrimitive(input, hint) { if (typeof input !== "object" || input ===
28
27
  class DefaultEditorPlugins {
29
28
  constructor(schema) {
30
29
  _defineProperty(this, "plugins", void 0);
31
- this.plugins = [new _ContentPlaceholderPlugin.default(), new _CursorPlaceholderPlugin.default(), new _EditorPageLayoutPlugin.default(), new _ImageUploadPlaceholderPlugin.default(), new _LinkTooltipPlugin.default(), new _SelectionPlaceholderPlugin.default(), this.setPluginKey((0, _buildInputRules.default)(schema), 'InputRules'), this.setPluginKey((0, _prosemirrorDropcursor.dropCursor)(), 'DropCursor'), this.setPluginKey((0, _prosemirrorGapcursor.gapCursor)(), 'GapCursor'), (0, _prosemirrorHistory.history)(), this.setPluginKey((0, _prosemirrorKeymap.keymap)((0, _createEditorKeyMap.default)()), 'EditorKeyMap'), this.setPluginKey((0, _prosemirrorKeymap.keymap)(_prosemirrorCommands.baseKeymap), 'BaseKeymap')].concat(_TablePlugins.default);
30
+ this.plugins = [new _ContentPlaceholderPlugin.default(), new _CursorPlaceholderPlugin.default(), new _EditorPageLayoutPlugin.default(), new _LinkTooltipPlugin.default(), new _SelectionPlaceholderPlugin.default(), this.setPluginKey((0, _buildInputRules.default)(schema), 'InputRules'), this.setPluginKey((0, _prosemirrorDropcursor.dropCursor)(), 'DropCursor'), this.setPluginKey((0, _prosemirrorGapcursor.gapCursor)(), 'GapCursor'), (0, _prosemirrorHistory.history)(), this.setPluginKey((0, _prosemirrorKeymap.keymap)((0, _createEditorKeyMap.default)()), 'EditorKeyMap'), this.setPluginKey((0, _prosemirrorKeymap.keymap)(_prosemirrorCommands.baseKeymap), 'BaseKeymap')].concat(_TablePlugins.default);
32
31
  }
33
32
  // [FS] IRAD-1005 2020-07-07
34
33
  // Upgrade outdated packages.
@@ -9,7 +9,6 @@ import {Plugin, PluginKey} from 'prosemirror-state';
9
9
  import ContentPlaceholderPlugin from './ContentPlaceholderPlugin';
10
10
  import CursorPlaceholderPlugin from './CursorPlaceholderPlugin';
11
11
  import EditorPageLayoutPlugin from './EditorPageLayoutPlugin';
12
- import ImageUploadPlaceholderPlugin from './ImageUploadPlaceholderPlugin';
13
12
  import LinkTooltipPlugin from './LinkTooltipPlugin';
14
13
  import SelectionPlaceholderPlugin from './SelectionPlaceholderPlugin';
15
14
  import TablePlugins from './TablePlugins';
@@ -25,7 +24,6 @@ export default class DefaultEditorPlugins {
25
24
  new ContentPlaceholderPlugin(),
26
25
  new CursorPlaceholderPlugin(),
27
26
  new EditorPageLayoutPlugin(),
28
- new ImageUploadPlaceholderPlugin(),
29
27
  new LinkTooltipPlugin(),
30
28
  new SelectionPlaceholderPlugin(),
31
29
  this.setPluginKey(buildInputRules(schema), 'InputRules'),
@@ -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;
package/dist/ui/Editor.js CHANGED
@@ -22,7 +22,6 @@ var _normalizeHTML = _interopRequireDefault(require("../normalizeHTML"));
22
22
  var _BookmarkNodeView = _interopRequireDefault(require("./BookmarkNodeView"));
23
23
  var _CustomEditorView = _interopRequireDefault(require("./CustomEditorView"));
24
24
  var _CustomNodeView = _interopRequireDefault(require("./CustomNodeView"));
25
- var _ImageNodeView = _interopRequireDefault(require("./ImageNodeView"));
26
25
  var _ListItemNodeView = _interopRequireDefault(require("./ListItemNodeView"));
27
26
  var _MathNodeView = _interopRequireDefault(require("./MathNodeView"));
28
27
  var _handleEditorDrop = _interopRequireDefault(require("./handleEditorDrop"));
@@ -70,7 +69,6 @@ const AUTO_FOCUS_DELAY = 350;
70
69
 
71
70
  // Default custom node views.
72
71
  const DEFAULT_NODE_VIEWS = Object.freeze({
73
- [_NodeNames.IMAGE]: _ImageNodeView.default,
74
72
  [_NodeNames.MATH]: _MathNodeView.default,
75
73
  [_NodeNames.BOOKMARK]: _BookmarkNodeView.default,
76
74
  [_NodeNames.LIST_ITEM]: _ListItemNodeView.default
@@ -17,7 +17,7 @@ import {
17
17
  registeryKeys,
18
18
  releaseEditorView,
19
19
  } from '../CZIProseMirror';
20
- import { BOOKMARK, IMAGE, LIST_ITEM, MATH } from '../NodeNames';
20
+ import { BOOKMARK, LIST_ITEM, MATH } from '../NodeNames';
21
21
  import WebFontLoader from '../WebFontLoader';
22
22
  import { preLoadFonts } from '../FontTypeMarkSpec';
23
23
  import createEmptyEditorState from '../createEmptyEditorState';
@@ -25,7 +25,6 @@ import normalizeHTML from '../normalizeHTML';
25
25
  import BookmarkNodeView from './BookmarkNodeView';
26
26
  import CustomEditorView from './CustomEditorView';
27
27
  import CustomNodeView from './CustomNodeView';
28
- import ImageNodeView from './ImageNodeView';
29
28
  import ListItemNodeView from './ListItemNodeView';
30
29
  import MathNodeView from './MathNodeView';
31
30
  import handleEditorDrop from './handleEditorDrop';
@@ -62,7 +61,6 @@ const AUTO_FOCUS_DELAY = 350;
62
61
 
63
62
  // Default custom node views.
64
63
  export const DEFAULT_NODE_VIEWS = Object.freeze({
65
- [IMAGE]: ImageNodeView,
66
64
  [MATH]: MathNodeView,
67
65
  [BOOKMARK]: BookmarkNodeView,
68
66
  [LIST_ITEM]: ListItemNodeView,
@@ -41,8 +41,6 @@ const {
41
41
  HISTORY_REDO,
42
42
  HISTORY_UNDO,
43
43
  HR,
44
- IMAGE_FROM_URL,
45
- IMAGE_UPLOAD,
46
44
  INDENT_LESS,
47
45
  INDENT_MORE,
48
46
  LINK_SET_URL,
@@ -135,10 +133,6 @@ const COMMAND_GROUPS = [{
135
133
  '[format_list_bulleted] Bulleted list': UL
136
134
  }, {
137
135
  '[link] Apply link': LINK_SET_URL,
138
- '[image] Insert image': [{
139
- 'Insert image by URL': IMAGE_FROM_URL,
140
- 'Upload image from computer': IMAGE_UPLOAD
141
- }],
142
136
  '[grid_on] Table...': TABLE_COMMANDS_GROUP,
143
137
  '[hr] Horizontal line': HR,
144
138
  '[functions] Math': MATH_EDIT
@@ -40,8 +40,6 @@ const {
40
40
  HISTORY_REDO,
41
41
  HISTORY_UNDO,
42
42
  HR,
43
- IMAGE_FROM_URL,
44
- IMAGE_UPLOAD,
45
43
  INDENT_LESS,
46
44
  INDENT_MORE,
47
45
  LINK_SET_URL,
@@ -149,12 +147,6 @@ export const COMMAND_GROUPS = [
149
147
  },
150
148
  {
151
149
  '[link] Apply link': LINK_SET_URL,
152
- '[image] Insert image': [
153
- {
154
- 'Insert image by URL': IMAGE_FROM_URL,
155
- 'Upload image from computer': IMAGE_UPLOAD,
156
- },
157
- ],
158
150
  '[grid_on] Table...': TABLE_COMMANDS_GROUP,
159
151
  '[hr] Horizontal line': HR,
160
152
  '[functions] Math': MATH_EDIT,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@modusoperandi/licit",
3
- "version": "0.14.1",
3
+ "version": "0.14.3",
4
4
  "subversion": "1",
5
5
  "description": "Rich text editor built with React and ProseMirror",
6
6
  "main": "dist/index.js",
@@ -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.11",
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": {
@@ -9,8 +9,6 @@ import { HeadingCommand } from '@modusoperandi/licit-ui-commands';
9
9
  import HistoryRedoCommand from './HistoryRedoCommand';
10
10
  import HistoryUndoCommand from './HistoryUndoCommand';
11
11
  import HorizontalRuleCommand from './HorizontalRuleCommand';
12
- import ImageFromURLCommand from './ImageFromURLCommand';
13
- import ImageUploadCommand from './ImageUploadCommand';
14
12
  import { IndentCommand } from '@modusoperandi/licit-ui-commands';
15
13
  import LinkSetURLCommand from './LinkSetURLCommand';
16
14
  import ListItemInsertNewLineCommand from './ListItemInsertNewLineCommand';
@@ -84,8 +82,6 @@ export const H6 = new HeadingCommand(6);
84
82
  export const HISTORY_REDO = new HistoryRedoCommand();
85
83
  export const HISTORY_UNDO = new HistoryUndoCommand();
86
84
  export const HR = new HorizontalRuleCommand();
87
- export const IMAGE_FROM_URL = new ImageFromURLCommand();
88
- export const IMAGE_UPLOAD = new ImageUploadCommand();
89
85
  export const INDENT_LESS = new IndentCommand(-1);
90
86
  export const INDENT_MORE = new IndentCommand(1);
91
87
  export const LINK_SET_URL = new LinkSetURLCommand();
@@ -8,7 +8,6 @@ import DocNodeSpec from './DocNodeSpec';
8
8
  import HardBreakNodeSpec from './HardBreakNodeSpec';
9
9
  import HeadingNodeSpec from './HeadingNodeSpec';
10
10
  import HorizontalRuleNodeSpec from './HorizontalRuleNodeSpec';
11
- import ImageNodeSpec from './ImageNodeSpec';
12
11
  import ListItemNodeSpec from './ListItemNodeSpec';
13
12
  import MathNodeSpec from './MathNodeSpec';
14
13
  import * as NodeNames from './NodeNames';
@@ -26,7 +25,6 @@ const {
26
25
  HARD_BREAK,
27
26
  HEADING,
28
27
  HORIZONTAL_RULE,
29
- IMAGE,
30
28
  LIST_ITEM,
31
29
  MATH,
32
30
  ORDERED_LIST,
@@ -45,7 +43,6 @@ const nodes = {
45
43
  [HORIZONTAL_RULE]: HorizontalRuleNodeSpec,
46
44
  [HEADING]: HeadingNodeSpec,
47
45
  [TEXT]: TextNodeSpec,
48
- [IMAGE]: ImageNodeSpec,
49
46
  [MATH]: MathNodeSpec,
50
47
  [HARD_BREAK]: HardBreakNodeSpec,
51
48
  [BULLET_LIST]: BulletListNodeSpec,
@@ -9,7 +9,6 @@ import {Plugin, PluginKey} from 'prosemirror-state';
9
9
  import ContentPlaceholderPlugin from './ContentPlaceholderPlugin';
10
10
  import CursorPlaceholderPlugin from './CursorPlaceholderPlugin';
11
11
  import EditorPageLayoutPlugin from './EditorPageLayoutPlugin';
12
- import ImageUploadPlaceholderPlugin from './ImageUploadPlaceholderPlugin';
13
12
  import LinkTooltipPlugin from './LinkTooltipPlugin';
14
13
  import SelectionPlaceholderPlugin from './SelectionPlaceholderPlugin';
15
14
  import TablePlugins from './TablePlugins';
@@ -25,7 +24,6 @@ export default class DefaultEditorPlugins {
25
24
  new ContentPlaceholderPlugin(),
26
25
  new CursorPlaceholderPlugin(),
27
26
  new EditorPageLayoutPlugin(),
28
- new ImageUploadPlaceholderPlugin(),
29
27
  new LinkTooltipPlugin(),
30
28
  new SelectionPlaceholderPlugin(),
31
29
  this.setPluginKey(buildInputRules(schema), 'InputRules'),
@@ -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;
package/src/ui/Editor.js CHANGED
@@ -17,7 +17,7 @@ import {
17
17
  registeryKeys,
18
18
  releaseEditorView,
19
19
  } from '../CZIProseMirror';
20
- import { BOOKMARK, IMAGE, LIST_ITEM, MATH } from '../NodeNames';
20
+ import { BOOKMARK, LIST_ITEM, MATH } from '../NodeNames';
21
21
  import WebFontLoader from '../WebFontLoader';
22
22
  import { preLoadFonts } from '../FontTypeMarkSpec';
23
23
  import createEmptyEditorState from '../createEmptyEditorState';
@@ -25,7 +25,6 @@ import normalizeHTML from '../normalizeHTML';
25
25
  import BookmarkNodeView from './BookmarkNodeView';
26
26
  import CustomEditorView from './CustomEditorView';
27
27
  import CustomNodeView from './CustomNodeView';
28
- import ImageNodeView from './ImageNodeView';
29
28
  import ListItemNodeView from './ListItemNodeView';
30
29
  import MathNodeView from './MathNodeView';
31
30
  import handleEditorDrop from './handleEditorDrop';
@@ -62,7 +61,6 @@ const AUTO_FOCUS_DELAY = 350;
62
61
 
63
62
  // Default custom node views.
64
63
  export const DEFAULT_NODE_VIEWS = Object.freeze({
65
- [IMAGE]: ImageNodeView,
66
64
  [MATH]: MathNodeView,
67
65
  [BOOKMARK]: BookmarkNodeView,
68
66
  [LIST_ITEM]: ListItemNodeView,
@@ -40,8 +40,6 @@ const {
40
40
  HISTORY_REDO,
41
41
  HISTORY_UNDO,
42
42
  HR,
43
- IMAGE_FROM_URL,
44
- IMAGE_UPLOAD,
45
43
  INDENT_LESS,
46
44
  INDENT_MORE,
47
45
  LINK_SET_URL,
@@ -149,12 +147,6 @@ export const COMMAND_GROUPS = [
149
147
  },
150
148
  {
151
149
  '[link] Apply link': LINK_SET_URL,
152
- '[image] Insert image': [
153
- {
154
- 'Insert image by URL': IMAGE_FROM_URL,
155
- 'Upload image from computer': IMAGE_UPLOAD,
156
- },
157
- ],
158
150
  '[grid_on] Table...': TABLE_COMMANDS_GROUP,
159
151
  '[hr] Horizontal line': HR,
160
152
  '[functions] Math': MATH_EDIT,
@@ -1,19 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var React = _interopRequireWildcard(require("react"));
8
- var _ImageSourceCommand = _interopRequireDefault(require("./ImageSourceCommand"));
9
- var _ImageURLEditor = _interopRequireDefault(require("./ui/ImageURLEditor"));
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
12
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
13
- class ImageFromURLCommand extends _ImageSourceCommand.default {
14
- getEditor() {
15
- return _ImageURLEditor.default;
16
- }
17
- }
18
- var _default = ImageFromURLCommand;
19
- exports.default = _default;
@@ -1,14 +0,0 @@
1
- // @flow
2
-
3
- import * as React from 'react';
4
-
5
- import ImageSourceCommand from './ImageSourceCommand';
6
- import ImageURLEditor from './ui/ImageURLEditor';
7
-
8
- class ImageFromURLCommand extends ImageSourceCommand {
9
- getEditor(): Class<React.Component<any, any>> {
10
- return ImageURLEditor;
11
- }
12
- }
13
-
14
- export default ImageFromURLCommand;
@@ -1,109 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _Types = require("./Types");
8
- const CSS_ROTATE_PATTERN = /rotate\(([0-9\.]+)rad\)/i;
9
- const EMPTY_CSS_VALUE = new Set(['0%', '0pt', '0px']);
10
- function getAttrs(dom) {
11
- const {
12
- cssFloat,
13
- display,
14
- marginTop,
15
- marginLeft
16
- } = dom.style;
17
- let {
18
- width,
19
- height
20
- } = dom.style;
21
- let align = dom.getAttribute('data-align') || dom.getAttribute('align');
22
- if (align) {
23
- align = /(left|right|center)/.test(align) ? align : null;
24
- } else if (cssFloat === 'left' && !display) {
25
- align = 'left';
26
- } else if (cssFloat === 'right' && !display) {
27
- align = 'right';
28
- } else if (!cssFloat && display === 'block') {
29
- align = 'block';
30
- }
31
- width = width || dom.getAttribute('width');
32
- height = height || dom.getAttribute('height');
33
- let crop = null;
34
- let rotate = null;
35
- const {
36
- parentElement
37
- } = dom;
38
- if (parentElement instanceof HTMLElement) {
39
- // Special case for Google doc's image.
40
- const ps = parentElement.style;
41
- if (ps.display === 'inline-block' && ps.overflow === 'hidden' && ps.width && ps.height && marginLeft && !EMPTY_CSS_VALUE.has(marginLeft) && marginTop && !EMPTY_CSS_VALUE.has(marginTop)) {
42
- crop = {
43
- width: parseInt(ps.width, 10) || 0,
44
- height: parseInt(ps.height, 10) || 0,
45
- left: parseInt(marginLeft, 10) || 0,
46
- top: parseInt(marginTop, 10) || 0
47
- };
48
- }
49
- if (ps.transform) {
50
- // example: `rotate(1.57rad) translateZ(0px)`;
51
- const mm = ps.transform.match(CSS_ROTATE_PATTERN);
52
- if (mm && mm[1]) {
53
- rotate = parseFloat(mm[1]) || null;
54
- }
55
- }
56
- }
57
- return {
58
- align,
59
- alt: dom.getAttribute('alt') || null,
60
- crop,
61
- height: parseInt(height, 10) || null,
62
- rotate,
63
- src: dom.getAttribute('src') || null,
64
- title: dom.getAttribute('title') || null,
65
- width: parseInt(width, 10) || null
66
- };
67
- }
68
-
69
- // https://github.com/ProseMirror/prosemirror-schema-basic/blob/master/src/schema-basic.js
70
- const ImageNodeSpec = {
71
- inline: true,
72
- attrs: {
73
- align: {
74
- default: null
75
- },
76
- alt: {
77
- default: ''
78
- },
79
- crop: {
80
- default: null
81
- },
82
- height: {
83
- default: null
84
- },
85
- rotate: {
86
- default: null
87
- },
88
- src: {
89
- default: null
90
- },
91
- title: {
92
- default: ''
93
- },
94
- width: {
95
- default: null
96
- }
97
- },
98
- group: 'inline',
99
- draggable: true,
100
- parseDOM: [{
101
- tag: 'img[src]',
102
- getAttrs
103
- }],
104
- toDOM(node) {
105
- return ['img', node.attrs];
106
- }
107
- };
108
- var _default = ImageNodeSpec;
109
- exports.default = _default;
@@ -1,90 +0,0 @@
1
- // @flow
2
-
3
- import type { NodeSpec } from './Types';
4
-
5
- const CSS_ROTATE_PATTERN = /rotate\(([0-9\.]+)rad\)/i;
6
- const EMPTY_CSS_VALUE = new Set(['0%', '0pt', '0px']);
7
-
8
- function getAttrs(dom: HTMLElement) {
9
- const { cssFloat, display, marginTop, marginLeft } = dom.style;
10
- let { width, height } = dom.style;
11
- let align = dom.getAttribute('data-align') || dom.getAttribute('align');
12
- if (align) {
13
- align = /(left|right|center)/.test(align) ? align : null;
14
- } else if (cssFloat === 'left' && !display) {
15
- align = 'left';
16
- } else if (cssFloat === 'right' && !display) {
17
- align = 'right';
18
- } else if (!cssFloat && display === 'block') {
19
- align = 'block';
20
- }
21
-
22
- width = width || dom.getAttribute('width');
23
- height = height || dom.getAttribute('height');
24
-
25
- let crop = null;
26
- let rotate = null;
27
- const { parentElement } = dom;
28
- if (parentElement instanceof HTMLElement) {
29
- // Special case for Google doc's image.
30
- const ps = parentElement.style;
31
- if (
32
- ps.display === 'inline-block' &&
33
- ps.overflow === 'hidden' &&
34
- ps.width &&
35
- ps.height &&
36
- marginLeft &&
37
- !EMPTY_CSS_VALUE.has(marginLeft) &&
38
- marginTop &&
39
- !EMPTY_CSS_VALUE.has(marginTop)
40
- ) {
41
- crop = {
42
- width: parseInt(ps.width, 10) || 0,
43
- height: parseInt(ps.height, 10) || 0,
44
- left: parseInt(marginLeft, 10) || 0,
45
- top: parseInt(marginTop, 10) || 0,
46
- };
47
- }
48
- if (ps.transform) {
49
- // example: `rotate(1.57rad) translateZ(0px)`;
50
- const mm = ps.transform.match(CSS_ROTATE_PATTERN);
51
- if (mm && mm[1]) {
52
- rotate = parseFloat(mm[1]) || null;
53
- }
54
- }
55
- }
56
-
57
- return {
58
- align,
59
- alt: dom.getAttribute('alt') || null,
60
- crop,
61
- height: parseInt(height, 10) || null,
62
- rotate,
63
- src: dom.getAttribute('src') || null,
64
- title: dom.getAttribute('title') || null,
65
- width: parseInt(width, 10) || null,
66
- };
67
- }
68
-
69
- // https://github.com/ProseMirror/prosemirror-schema-basic/blob/master/src/schema-basic.js
70
- const ImageNodeSpec: NodeSpec = {
71
- inline: true,
72
- attrs: {
73
- align: { default: null },
74
- alt: { default: '' },
75
- crop: { default: null },
76
- height: { default: null },
77
- rotate: { default: null },
78
- src: { default: null },
79
- title: { default: '' },
80
- width: { default: null },
81
- },
82
- group: 'inline',
83
- draggable: true,
84
- parseDOM: [{ tag: 'img[src]', getAttrs }],
85
- toDOM(node) {
86
- return ['img', node.attrs];
87
- },
88
- };
89
-
90
- export default ImageNodeSpec;
@@ -1,117 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _prosemirrorModel = require("prosemirror-model");
8
- var _prosemirrorState = require("prosemirror-state");
9
- var _prosemirrorTransform = require("prosemirror-transform");
10
- var _prosemirrorView = require("prosemirror-view");
11
- var React = _interopRequireWildcard(require("react"));
12
- var _CursorPlaceholderPlugin = require("./CursorPlaceholderPlugin");
13
- var _NodeNames = require("./NodeNames");
14
- var _licitDocAttrsStep = require("@modusoperandi/licit-doc-attrs-step");
15
- var _licitUiCommands = require("@modusoperandi/licit-ui-commands");
16
- var _Types = require("./Types");
17
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
18
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
19
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
20
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
21
- function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
22
- function insertImage(tr, schema, src) {
23
- const {
24
- selection
25
- } = tr;
26
- if (!selection) {
27
- return tr;
28
- }
29
- const {
30
- from,
31
- to
32
- } = selection;
33
- if (from !== to) {
34
- return tr;
35
- }
36
- const image = schema.nodes[_NodeNames.IMAGE];
37
- if (!image) {
38
- return tr;
39
- }
40
- const attrs = {
41
- src: src || '',
42
- alt: '',
43
- title: ''
44
- };
45
- const node = image.create(attrs, null, null);
46
- const frag = _prosemirrorModel.Fragment.from(node);
47
- tr = tr.insert(from, frag);
48
- return tr;
49
- }
50
- class ImageSourceCommand extends _licitDocAttrsStep.UICommand {
51
- constructor() {
52
- super(...arguments);
53
- _defineProperty(this, "_popUp", null);
54
- _defineProperty(this, "isEnabled", (state, view) => {
55
- return this.__isEnabled(state, view);
56
- });
57
- _defineProperty(this, "waitForUserInput", (state, dispatch, view, event) => {
58
- if (this._popUp) {
59
- return Promise.resolve(undefined);
60
- }
61
- if (dispatch) {
62
- dispatch((0, _CursorPlaceholderPlugin.showCursorPlaceholder)(state));
63
- }
64
- return new Promise(resolve => {
65
- const props = {
66
- runtime: view ? view.runtime : null
67
- };
68
- this._popUp = (0, _licitUiCommands.createPopUp)(this.getEditor(), props, {
69
- modal: true,
70
- onClose: val => {
71
- if (this._popUp) {
72
- this._popUp = null;
73
- resolve(val);
74
- }
75
- }
76
- });
77
- });
78
- });
79
- _defineProperty(this, "executeWithUserInput", (state, dispatch, view, inputs) => {
80
- if (dispatch) {
81
- const {
82
- selection,
83
- schema
84
- } = state;
85
- let {
86
- tr
87
- } = state;
88
- tr = view ? (0, _CursorPlaceholderPlugin.hideCursorPlaceholder)(view.state) : tr;
89
- tr = tr.setSelection(selection);
90
- if (inputs) {
91
- const {
92
- src
93
- } = inputs;
94
- tr = insertImage(tr, schema, src);
95
- }
96
- dispatch(tr);
97
- view && view.focus();
98
- }
99
- return false;
100
- });
101
- _defineProperty(this, "__isEnabled", (state, view) => {
102
- const tr = state;
103
- const {
104
- selection
105
- } = tr;
106
- if (selection instanceof _prosemirrorState.TextSelection) {
107
- return selection.from === selection.to;
108
- }
109
- return false;
110
- });
111
- }
112
- getEditor() {
113
- throw new Error('Not implemented');
114
- }
115
- }
116
- var _default = ImageSourceCommand;
117
- exports.default = _default;