@modusoperandi/licit 0.13.25 → 0.14.0
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/.eslintrc.js +1 -1
- package/README.md +1 -0
- package/dist/BlockquoteInsertNewLineCommand.js +3 -23
- package/dist/BlockquoteNodeSpec.js +3 -13
- package/dist/BlockquoteToggleCommand.js +3 -16
- package/dist/BookmarkNodeSpec.js +0 -6
- package/dist/BulletListNodeSpec.js +2 -16
- package/dist/CZIProseMirror.js +3 -27
- package/dist/CodeBlockCommand.js +3 -19
- package/dist/CodeBlockNodeSpec.js +3 -4
- package/dist/CodeMarkSpec.js +0 -4
- package/dist/ContentPlaceholderPlugin.js +6 -58
- package/dist/CursorPlaceholderPlugin.js +2 -32
- package/dist/DocLayoutCommand.js +5 -28
- package/dist/DocNodeSpec.js +0 -9
- package/dist/EMMarkSpec.js +0 -4
- package/dist/EditorCommands.js +5 -33
- package/dist/EditorKeyMap.js +4 -18
- package/dist/EditorMarks.js +2 -26
- package/dist/EditorNodes.js +4 -22
- package/dist/EditorPageLayoutPlugin.js +3 -15
- package/dist/EditorPlugins.js +0 -4
- package/dist/EditorSchema.js +0 -5
- package/dist/EditorState.js +0 -2
- package/dist/FontSizeMarkSpec.js +0 -12
- package/dist/FontTypeMarkSpec.js +15 -19
- package/dist/HTMLMutator.js +5 -24
- package/dist/HardBreakNodeSpec.js +0 -2
- package/dist/HeadingNodeSpec.js +6 -15
- package/dist/HistoryRedoCommand.js +3 -11
- package/dist/HistoryUndoCommand.js +3 -11
- package/dist/HorizontalRuleCommand.js +3 -22
- package/dist/HorizontalRuleNodeSpec.js +0 -10
- package/dist/ImageFromURLCommand.js +0 -9
- package/dist/ImageNodeSpec.js +2 -14
- package/dist/ImageSourceCommand.js +3 -39
- package/dist/ImageUploadCommand.js +3 -21
- package/dist/ImageUploadPlaceholderPlugin.js +10 -48
- package/dist/LinkMarkSpec.js +0 -4
- package/dist/LinkSetURLCommand.js +3 -28
- package/dist/LinkTooltipPlugin.js +6 -52
- package/dist/ListItemInsertNewLineCommand.js +3 -23
- package/dist/ListItemMergeCommand.js +15 -66
- package/dist/ListItemNodeSpec.js +0 -11
- package/dist/ListSplitCommand.js +3 -14
- package/dist/ListToggleCommand.js +5 -26
- package/dist/MarksClearCommand.js +6 -17
- package/dist/MathEditCommand.js +3 -38
- package/dist/MathNodeSpec.js +0 -10
- package/dist/OrderedListNodeSpec.js +0 -24
- package/dist/ParagraphNodeSpec.js +5 -26
- package/dist/ParagraphSpacingCommand.js +3 -32
- package/dist/PrintCommand.js +3 -13
- package/dist/SelectionPlaceholderPlugin.js +2 -31
- package/dist/SpacerMarkSpec.js +2 -6
- package/dist/StrikeMarkSpec.js +0 -4
- package/dist/StrongMarkSpec.js +2 -5
- package/dist/StyleView.js +1 -7
- package/dist/TableBackgroundColorCommand.js +3 -24
- package/dist/TableBorderColorCommand.js +3 -24
- package/dist/TableCellColorCommand.js +3 -23
- package/dist/TableCellMenuPlugin.js +9 -45
- package/dist/TableInsertCommand.js +7 -39
- package/dist/TableMergeCellsCommand.js +5 -30
- package/dist/TableNodesSpecs.js +4 -23
- package/dist/TablePlugins.js +0 -5
- package/dist/TableResizePlugin.js +54 -138
- package/dist/TextColorMarkSpec.js +0 -9
- package/dist/TextHighlightMarkSpec.js +0 -8
- package/dist/TextInsertTabSpaceCommand.js +3 -28
- package/dist/TextNoWrapMarkSpec.js +0 -4
- package/dist/TextSelectionMarkSpec.js +0 -5
- package/dist/TextSubMarkSpec.js +0 -4
- package/dist/TextSuperMarkSpec.js +0 -4
- package/dist/TextUnderlineMarkSpec.js +0 -4
- package/dist/Types.js +0 -6
- package/dist/WebFontLoader.js +3 -8
- package/dist/blockQuoteInputRule.js +0 -13
- package/dist/bom.xml +1492 -1645
- package/dist/buildEditorPlugins.js +5 -27
- package/dist/buildInputRules.js +12 -24
- package/dist/client/CollabConnector.js +6 -30
- package/dist/client/EditorConnection.js +23 -69
- package/dist/client/Licit.js +79 -163
- package/dist/client/Licit.js.flow +16 -2
- package/dist/client/Licit.test.js +6 -13
- package/dist/client/Reporter.js +1 -8
- package/dist/client/SimpleConnector.js +6 -26
- package/dist/client/http.js +8 -15
- package/dist/client/throttle.js +0 -2
- package/dist/convertFromDOMElement.js +2 -10
- package/dist/convertFromHTML.js +0 -5
- package/dist/convertFromJSON.js +3 -13
- package/dist/convertToCSSPTValue.js +0 -6
- package/dist/convertToJSON.js +0 -2
- package/dist/createCommand.js +3 -11
- package/dist/createEditorKeyMap.js +0 -13
- package/dist/createEmptyEditorState.js +0 -7
- package/dist/createTableResizingPlugin.js +5 -16
- package/dist/findActionableCell.js +0 -19
- package/dist/findActiveMark.js +0 -11
- package/dist/hyphenize.js +2 -4
- package/dist/index.js +0 -9
- package/dist/insertTable.js +0 -16
- package/dist/isEditorStateEmpty.js +0 -6
- package/dist/isTableNode.js +0 -3
- package/dist/joinDown.js +0 -7
- package/dist/joinListNode.js +0 -15
- package/dist/joinUp.js +0 -9
- package/dist/keymaps.js +0 -15
- package/dist/lookUpElement.js +0 -3
- package/dist/nodeAt.js +0 -3
- package/dist/normalizeHTML.js +9 -25
- package/dist/patchAnchorElements.js +5 -12
- package/dist/patchBreakElements.js +0 -6
- package/dist/patchElementInlineStyles.js +5 -15
- package/dist/patchListElements.js +20 -54
- package/dist/patchMathElements.js +11 -21
- package/dist/patchParagraphElements.js +0 -5
- package/dist/patchStyleElements.js +12 -41
- package/dist/patchTableElements.js +9 -37
- package/dist/rebaseDocWithSteps.js +0 -6
- package/dist/sanitizeURL.js +0 -3
- package/dist/splitListItem.js +12 -43
- package/dist/toClosestFontPtSize.js +1 -5
- package/dist/toSafeHTMLDocument.js +0 -1
- package/dist/toggleBlockquote.js +2 -19
- package/dist/toggleCodeBlock.js +2 -22
- package/dist/ui/AlertInfo.js +6 -22
- package/dist/ui/BookmarkNodeView.js +7 -28
- package/dist/ui/CommandButton.js +3 -19
- package/dist/ui/CommandMenu.js +3 -25
- package/dist/ui/CommandMenuButton.js +3 -36
- package/dist/ui/CustomEditorView.js +3 -16
- package/dist/ui/CustomMenu.js +0 -8
- package/dist/ui/CustomMenuItem.js +4 -18
- package/dist/ui/CustomNodeView.js +21 -67
- package/dist/ui/CustomRadioButton.js +14 -33
- package/dist/ui/DocLayoutEditor.js +5 -27
- package/dist/ui/Editor.js +18 -79
- package/dist/ui/EditorFrameset.js +3 -18
- package/dist/ui/EditorToolbar.js +10 -46
- package/dist/ui/EditorToolbarConfig.js +10 -20
- package/dist/ui/FontSizeCommandMenuButton.js +5 -19
- package/dist/ui/FontTypeCommandMenuButton.js +5 -22
- package/dist/ui/Frag.js +0 -7
- package/dist/ui/Icon.js +5 -25
- package/dist/ui/ImageAlignEditor.js +3 -16
- package/dist/ui/ImageInlineEditor.js +3 -16
- package/dist/ui/ImageNodeView.js +20 -109
- package/dist/ui/ImageResizeBox.js +3 -53
- package/dist/ui/ImageURLEditor.js +3 -28
- package/dist/ui/ImageUploadEditor.js +3 -35
- package/dist/ui/LinkTooltip.js +5 -25
- package/dist/ui/LinkURLEditor.js +3 -29
- package/dist/ui/ListItemNodeView.js +15 -30
- package/dist/ui/ListTypeButton.js +5 -37
- package/dist/ui/ListTypeCommandButton.js +3 -19
- package/dist/ui/ListTypeMenu.js +4 -25
- package/dist/ui/LoadingIndicator.js +0 -7
- package/dist/ui/MathEditor.js +3 -24
- package/dist/ui/MathInlineEditor.js +3 -26
- package/dist/ui/MathNodeView.js +9 -59
- package/dist/ui/PasteMenu.js +4 -20
- package/dist/ui/ResizeObserver.js +0 -18
- package/dist/ui/RichTextEditor.js +5 -27
- package/dist/ui/SelectionObserver.js +3 -29
- package/dist/ui/TableCellMenu.js +3 -18
- package/dist/ui/TableGridSizeEditor.js +5 -51
- package/dist/ui/TableNodeView.js +0 -11
- package/dist/ui/bindScrollHandler.js +2 -9
- package/dist/ui/canUseCSSFont.js +2 -8
- package/dist/ui/czi-icon.css +4 -4
- package/dist/ui/findActiveFontSize.js +2 -18
- package/dist/ui/findActiveFontType.js +0 -12
- package/dist/ui/handleEditorDrop.js +0 -9
- package/dist/ui/handleEditorKeyDown.js +0 -7
- package/dist/ui/handleEditorPaste.js +0 -9
- package/dist/ui/htmlElementToRect.js +0 -4
- package/dist/ui/injectStyleSheet.js +0 -10
- package/dist/ui/isElementFullyVisible.js +2 -8
- package/dist/ui/isOffline.js +0 -2
- package/dist/ui/isReactClass.js +0 -4
- package/dist/ui/mathquill-editor/MathQuillEditor.js +9 -44
- package/dist/ui/mathquill-editor/MathQuillEditorSymbols.js +1 -3
- package/dist/ui/mathquill-editor/MathQuillEditorSymbolsPanel.js +3 -16
- package/dist/ui/mathquill-editor/mathquill-import-kludge.js +5 -7
- package/dist/ui/renderLaTeXAsHTML.js +2 -13
- package/dist/ui/resolveImage.js +7 -32
- package/dist/ui/toCSSColor.js +0 -14
- package/dist/ui/toCSSLineSpacing.js +10 -11
- package/dist/ui/toHexColor.js +0 -8
- package/dist/ui/uuid.js +0 -2
- package/dist/uuid.js +0 -2
- package/package-lock.json.old +32889 -0
- package/package.json +45 -69
- package/src/client/Licit.js +16 -2
- package/src/ui/czi-icon.css +4 -4
- package/utils/build_web_server.js +1 -7
- package/webpack.config.js +3 -3
package/dist/ui/ImageNodeView.js
CHANGED
|
@@ -4,56 +4,34 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
9
|
-
|
|
10
8
|
var _prosemirrorModel = require("prosemirror-model");
|
|
11
|
-
|
|
12
9
|
var _prosemirrorView = require("prosemirror-view");
|
|
13
|
-
|
|
14
10
|
var _prosemirrorState = require("prosemirror-state");
|
|
15
|
-
|
|
16
11
|
var React = _interopRequireWildcard(require("react"));
|
|
17
|
-
|
|
18
12
|
var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
19
|
-
|
|
20
13
|
var _CustomNodeView = _interopRequireWildcard(require("./CustomNodeView"));
|
|
21
|
-
|
|
22
14
|
var _EditorFrameset = require("./EditorFrameset");
|
|
23
|
-
|
|
24
15
|
var _Icon = _interopRequireDefault(require("./Icon"));
|
|
25
|
-
|
|
26
16
|
var _ImageInlineEditor = _interopRequireDefault(require("./ImageInlineEditor"));
|
|
27
|
-
|
|
28
17
|
var _ImageResizeBox = _interopRequireWildcard(require("./ImageResizeBox"));
|
|
29
|
-
|
|
30
18
|
var _licitUiCommands = require("@modusoperandi/licit-ui-commands");
|
|
31
|
-
|
|
32
19
|
var _ResizeObserver = _interopRequireWildcard(require("./ResizeObserver"));
|
|
33
|
-
|
|
34
20
|
var _resolveImage = _interopRequireDefault(require("./resolveImage"));
|
|
35
|
-
|
|
36
21
|
var _uuid = _interopRequireDefault(require("./uuid"));
|
|
37
|
-
|
|
38
22
|
require("./czi-image-view.css");
|
|
39
|
-
|
|
40
23
|
var _Types = require("../Types");
|
|
41
|
-
|
|
42
24
|
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); }
|
|
43
|
-
|
|
44
25
|
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; }
|
|
45
|
-
|
|
46
26
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
47
|
-
|
|
48
27
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
49
|
-
|
|
50
28
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
51
|
-
|
|
52
|
-
function
|
|
53
|
-
|
|
29
|
+
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; }
|
|
30
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
31
|
+
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); }
|
|
54
32
|
const EMPTY_SRC = 'data:image/gif;base64,' + 'R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7';
|
|
55
|
-
/* This value must be synced with the margin defined at .czi-image-view */
|
|
56
33
|
|
|
34
|
+
/* This value must be synced with the margin defined at .czi-image-view */
|
|
57
35
|
const IMAGE_MARGIN = 2;
|
|
58
36
|
const MAX_SIZE = 100000;
|
|
59
37
|
const IMAGE_PLACEHOLDER_SIZE = 24;
|
|
@@ -62,67 +40,52 @@ const DEFAULT_ORIGINAL_SIZE = {
|
|
|
62
40
|
complete: false,
|
|
63
41
|
height: 0,
|
|
64
42
|
width: 0
|
|
65
|
-
};
|
|
43
|
+
};
|
|
66
44
|
|
|
45
|
+
// Get the maxWidth that the image could be resized to.
|
|
67
46
|
function getMaxResizeWidth(el) {
|
|
68
47
|
// Ideally, the image should bot be wider then its containing element.
|
|
69
48
|
let node = el.parentElement;
|
|
70
|
-
|
|
71
49
|
while (node && !node.offsetParent) {
|
|
72
50
|
node = node.parentElement;
|
|
73
51
|
}
|
|
74
|
-
|
|
75
52
|
if (node && node.offsetParent && node.offsetParent.offsetWidth && node.offsetParent.offsetWidth > 0) {
|
|
76
53
|
const {
|
|
77
54
|
offsetParent
|
|
78
55
|
} = node;
|
|
79
56
|
const style = el.ownerDocument.defaultView.getComputedStyle(offsetParent);
|
|
80
57
|
let width = offsetParent.clientWidth - IMAGE_MARGIN * 2;
|
|
81
|
-
|
|
82
58
|
if (style.boxSizing === 'border-box') {
|
|
83
59
|
const pl = parseInt(style.paddingLeft, 10);
|
|
84
60
|
const pr = parseInt(style.paddingRight, 10);
|
|
85
61
|
width -= pl + pr;
|
|
86
62
|
}
|
|
87
|
-
|
|
88
63
|
return Math.max(width, _ImageResizeBox.MIN_SIZE);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
|
|
64
|
+
}
|
|
65
|
+
// Let the image resize freely.
|
|
92
66
|
return MAX_SIZE;
|
|
93
67
|
}
|
|
94
|
-
|
|
95
68
|
async function resolveURL(runtime, src) {
|
|
96
69
|
if (!runtime) {
|
|
97
70
|
return src;
|
|
98
71
|
}
|
|
99
|
-
|
|
100
72
|
const {
|
|
101
73
|
canProxyImageSrc,
|
|
102
74
|
getProxyImageSrc
|
|
103
75
|
} = runtime;
|
|
104
|
-
|
|
105
76
|
if (src && canProxyImageSrc && getProxyImageSrc && canProxyImageSrc(src)) {
|
|
106
77
|
return await getProxyImageSrc(src);
|
|
107
78
|
}
|
|
108
|
-
|
|
109
79
|
return src;
|
|
110
80
|
}
|
|
111
|
-
|
|
112
81
|
class ImageViewBody extends React.PureComponent {
|
|
113
82
|
constructor() {
|
|
114
83
|
super(...arguments);
|
|
115
|
-
|
|
116
84
|
_defineProperty(this, "props", void 0);
|
|
117
|
-
|
|
118
85
|
_defineProperty(this, "_body", null);
|
|
119
|
-
|
|
120
86
|
_defineProperty(this, "_id", (0, _uuid.default)());
|
|
121
|
-
|
|
122
87
|
_defineProperty(this, "_inlineEditor", null);
|
|
123
|
-
|
|
124
88
|
_defineProperty(this, "_mounted", false);
|
|
125
|
-
|
|
126
89
|
_defineProperty(this, "state", {
|
|
127
90
|
maxSize: {
|
|
128
91
|
width: MAX_SIZE,
|
|
@@ -131,40 +94,33 @@ class ImageViewBody extends React.PureComponent {
|
|
|
131
94
|
},
|
|
132
95
|
originalSize: DEFAULT_ORIGINAL_SIZE
|
|
133
96
|
});
|
|
134
|
-
|
|
135
97
|
_defineProperty(this, "_resolveOriginalSize", async () => {
|
|
136
98
|
if (!this._mounted) {
|
|
137
99
|
// unmounted;
|
|
138
100
|
return;
|
|
139
101
|
}
|
|
140
|
-
|
|
141
102
|
this.setState({
|
|
142
103
|
originalSize: DEFAULT_ORIGINAL_SIZE
|
|
143
104
|
});
|
|
144
105
|
const src = this.props.node.attrs.src;
|
|
145
106
|
const url = await resolveURL(this.props.editorView.runtime, src);
|
|
146
107
|
const originalSize = await (0, _resolveImage.default)(url);
|
|
147
|
-
|
|
148
108
|
if (!this._mounted) {
|
|
149
109
|
// unmounted;
|
|
150
110
|
return;
|
|
151
111
|
}
|
|
152
|
-
|
|
153
112
|
if (this.props.node.attrs.src !== src) {
|
|
154
113
|
// src had changed.
|
|
155
114
|
return;
|
|
156
115
|
}
|
|
157
|
-
|
|
158
116
|
if (!originalSize.complete) {
|
|
159
117
|
originalSize.width = _ImageResizeBox.MIN_SIZE;
|
|
160
118
|
originalSize.height = _ImageResizeBox.MIN_SIZE;
|
|
161
119
|
}
|
|
162
|
-
|
|
163
120
|
this.setState({
|
|
164
121
|
originalSize
|
|
165
122
|
});
|
|
166
123
|
});
|
|
167
|
-
|
|
168
124
|
_defineProperty(this, "_onResizeEnd", (width, height) => {
|
|
169
125
|
const {
|
|
170
126
|
getPos,
|
|
@@ -172,33 +128,28 @@ class ImageViewBody extends React.PureComponent {
|
|
|
172
128
|
editorView
|
|
173
129
|
} = this.props;
|
|
174
130
|
const pos = getPos();
|
|
175
|
-
|
|
176
131
|
const attrs = _objectSpread(_objectSpread({}, node.attrs), {}, {
|
|
177
132
|
// TODO: Support UI for cropping later.
|
|
178
133
|
crop: null,
|
|
179
134
|
width,
|
|
180
135
|
height
|
|
181
136
|
});
|
|
182
|
-
|
|
183
137
|
let tr = editorView.state.tr;
|
|
184
138
|
const {
|
|
185
139
|
selection
|
|
186
140
|
} = editorView.state;
|
|
187
|
-
tr = tr.setNodeMarkup(pos, null, attrs);
|
|
141
|
+
tr = tr.setNodeMarkup(pos, null, attrs);
|
|
142
|
+
// [FS] IRAD-1005 2020-07-09
|
|
188
143
|
// Upgrade outdated packages.
|
|
189
144
|
// reset selection to original using the latest doc.
|
|
190
|
-
|
|
191
145
|
const origSelection = _prosemirrorState.NodeSelection.create(tr.doc, selection.from);
|
|
192
|
-
|
|
193
146
|
tr = tr.setSelection(origSelection);
|
|
194
147
|
editorView.dispatch(tr);
|
|
195
148
|
});
|
|
196
|
-
|
|
197
149
|
_defineProperty(this, "_onChange", value => {
|
|
198
150
|
if (!this._mounted) {
|
|
199
151
|
return;
|
|
200
152
|
}
|
|
201
|
-
|
|
202
153
|
const align = value ? value.align : null;
|
|
203
154
|
const {
|
|
204
155
|
getPos,
|
|
@@ -206,46 +157,38 @@ class ImageViewBody extends React.PureComponent {
|
|
|
206
157
|
editorView
|
|
207
158
|
} = this.props;
|
|
208
159
|
const pos = getPos();
|
|
209
|
-
|
|
210
160
|
const attrs = _objectSpread(_objectSpread({}, node.attrs), {}, {
|
|
211
161
|
align
|
|
212
162
|
});
|
|
213
|
-
|
|
214
163
|
let tr = editorView.state.tr;
|
|
215
164
|
const {
|
|
216
165
|
selection
|
|
217
166
|
} = editorView.state;
|
|
218
|
-
tr = tr.setNodeMarkup(pos, null, attrs);
|
|
167
|
+
tr = tr.setNodeMarkup(pos, null, attrs);
|
|
168
|
+
// [FS] IRAD-1005 2020-07-09
|
|
219
169
|
// Upgrade outdated packages.
|
|
220
170
|
// reset selection to original using the latest doc.
|
|
221
|
-
|
|
222
171
|
const origSelection = _prosemirrorState.NodeSelection.create(tr.doc, selection.from);
|
|
223
|
-
|
|
224
172
|
tr = tr.setSelection(origSelection);
|
|
225
173
|
editorView.dispatch(tr);
|
|
226
174
|
});
|
|
227
|
-
|
|
228
175
|
_defineProperty(this, "_onBodyRef", ref => {
|
|
229
176
|
if (ref) {
|
|
230
|
-
this._body = ref;
|
|
231
|
-
|
|
177
|
+
this._body = ref;
|
|
178
|
+
// Mounting
|
|
232
179
|
const el = _reactDom.default.findDOMNode(ref);
|
|
233
|
-
|
|
234
180
|
if (el instanceof HTMLElement) {
|
|
235
181
|
_ResizeObserver.default.observe(el, this._onBodyResize);
|
|
236
182
|
}
|
|
237
183
|
} else {
|
|
238
184
|
// Unmounting.
|
|
239
185
|
const el = this._body && _reactDom.default.findDOMNode(this._body);
|
|
240
|
-
|
|
241
186
|
if (el instanceof HTMLElement) {
|
|
242
187
|
_ResizeObserver.default.unobserve(el);
|
|
243
188
|
}
|
|
244
|
-
|
|
245
189
|
this._body = null;
|
|
246
190
|
}
|
|
247
191
|
});
|
|
248
|
-
|
|
249
192
|
_defineProperty(this, "_onBodyResize", info => {
|
|
250
193
|
const width = this._body ? getMaxResizeWidth(_reactDom.default.findDOMNode(this._body)) : MAX_SIZE;
|
|
251
194
|
this.setState({
|
|
@@ -257,21 +200,16 @@ class ImageViewBody extends React.PureComponent {
|
|
|
257
200
|
});
|
|
258
201
|
});
|
|
259
202
|
}
|
|
260
|
-
|
|
261
203
|
componentDidMount() {
|
|
262
204
|
this._mounted = true;
|
|
263
|
-
|
|
264
205
|
this._resolveOriginalSize();
|
|
265
|
-
|
|
266
206
|
this._renderInlineEditor();
|
|
267
207
|
}
|
|
268
|
-
|
|
269
208
|
componentWillUnmount() {
|
|
270
209
|
this._mounted = false;
|
|
271
210
|
this._inlineEditor && this._inlineEditor.close();
|
|
272
211
|
this._inlineEditor = null;
|
|
273
212
|
}
|
|
274
|
-
|
|
275
213
|
componentDidUpdate(prevProps) {
|
|
276
214
|
const prevSrc = prevProps.node.attrs.src;
|
|
277
215
|
const {
|
|
@@ -280,15 +218,12 @@ class ImageViewBody extends React.PureComponent {
|
|
|
280
218
|
const {
|
|
281
219
|
src
|
|
282
220
|
} = node.attrs;
|
|
283
|
-
|
|
284
221
|
if (prevSrc !== src) {
|
|
285
222
|
// A new image is provided, resolve it.
|
|
286
223
|
this._resolveOriginalSize();
|
|
287
224
|
}
|
|
288
|
-
|
|
289
225
|
this._renderInlineEditor();
|
|
290
226
|
}
|
|
291
|
-
|
|
292
227
|
render() {
|
|
293
228
|
const {
|
|
294
229
|
originalSize,
|
|
@@ -310,8 +245,9 @@ class ImageViewBody extends React.PureComponent {
|
|
|
310
245
|
align,
|
|
311
246
|
crop,
|
|
312
247
|
rotate
|
|
313
|
-
} = attrs;
|
|
248
|
+
} = attrs;
|
|
314
249
|
|
|
250
|
+
// It's only active when the image's fully loaded.
|
|
315
251
|
const loading = originalSize === DEFAULT_ORIGINAL_SIZE;
|
|
316
252
|
const active = !loading && focused && !readOnly && originalSize.complete;
|
|
317
253
|
const src = originalSize.complete ? originalSize.src : EMPTY_SRC;
|
|
@@ -321,12 +257,10 @@ class ImageViewBody extends React.PureComponent {
|
|
|
321
257
|
width,
|
|
322
258
|
height
|
|
323
259
|
} = attrs;
|
|
324
|
-
|
|
325
260
|
if (loading) {
|
|
326
261
|
width = width || IMAGE_PLACEHOLDER_SIZE;
|
|
327
262
|
height = height || IMAGE_PLACEHOLDER_SIZE;
|
|
328
263
|
}
|
|
329
|
-
|
|
330
264
|
if (width && !height) {
|
|
331
265
|
height = width / aspectRatio;
|
|
332
266
|
} else if (height && !width) {
|
|
@@ -335,9 +269,7 @@ class ImageViewBody extends React.PureComponent {
|
|
|
335
269
|
width = originalSize.width;
|
|
336
270
|
height = originalSize.height;
|
|
337
271
|
}
|
|
338
|
-
|
|
339
272
|
let scale = 1;
|
|
340
|
-
|
|
341
273
|
if (width > maxSize.width && (!crop || crop.width > maxSize.width)) {
|
|
342
274
|
// Scale image to fit its containing space.
|
|
343
275
|
// If the image is not cropped.
|
|
@@ -345,7 +277,6 @@ class ImageViewBody extends React.PureComponent {
|
|
|
345
277
|
height = width / aspectRatio;
|
|
346
278
|
scale = maxSize.width / width;
|
|
347
279
|
}
|
|
348
|
-
|
|
349
280
|
const className = (0, _classnames.default)('czi-image-view-body', {
|
|
350
281
|
active,
|
|
351
282
|
error,
|
|
@@ -368,10 +299,8 @@ class ImageViewBody extends React.PureComponent {
|
|
|
368
299
|
position: 'relative'
|
|
369
300
|
};
|
|
370
301
|
const clipStyle = {};
|
|
371
|
-
|
|
372
302
|
if (crop) {
|
|
373
303
|
const cropped = _objectSpread({}, crop);
|
|
374
|
-
|
|
375
304
|
if (scale !== 1) {
|
|
376
305
|
scale = maxSize.width / cropped.width;
|
|
377
306
|
cropped.width *= scale;
|
|
@@ -379,17 +308,14 @@ class ImageViewBody extends React.PureComponent {
|
|
|
379
308
|
cropped.left *= scale;
|
|
380
309
|
cropped.top *= scale;
|
|
381
310
|
}
|
|
382
|
-
|
|
383
311
|
clipStyle.width = cropped.width + 'px';
|
|
384
312
|
clipStyle.height = cropped.height + 'px';
|
|
385
313
|
imageStyle.left = cropped.left + 'px';
|
|
386
314
|
imageStyle.top = cropped.top + 'px';
|
|
387
315
|
}
|
|
388
|
-
|
|
389
316
|
if (rotate) {
|
|
390
317
|
clipStyle.transform = `rotate(${rotate}rad)`;
|
|
391
318
|
}
|
|
392
|
-
|
|
393
319
|
const errorView = error ? _Icon.default.get('error') : null;
|
|
394
320
|
const errorTitle = error ? `Unable to load image from ${attrs.src || ''}` : undefined;
|
|
395
321
|
return /*#__PURE__*/React.createElement("span", {
|
|
@@ -414,15 +340,12 @@ class ImageViewBody extends React.PureComponent {
|
|
|
414
340
|
width: width
|
|
415
341
|
}), errorView)), resizeBox);
|
|
416
342
|
}
|
|
417
|
-
|
|
418
343
|
_renderInlineEditor() {
|
|
419
344
|
const el = document.getElementById(this._id);
|
|
420
|
-
|
|
421
345
|
if (!el || el.getAttribute('data-active') !== 'true') {
|
|
422
346
|
this._inlineEditor && this._inlineEditor.close();
|
|
423
347
|
return;
|
|
424
348
|
}
|
|
425
|
-
|
|
426
349
|
const {
|
|
427
350
|
node
|
|
428
351
|
} = this.props;
|
|
@@ -430,7 +353,6 @@ class ImageViewBody extends React.PureComponent {
|
|
|
430
353
|
value: node.attrs,
|
|
431
354
|
onSelect: this._onChange
|
|
432
355
|
};
|
|
433
|
-
|
|
434
356
|
if (this._inlineEditor) {
|
|
435
357
|
this._inlineEditor.update(editorProps);
|
|
436
358
|
} else {
|
|
@@ -445,48 +367,37 @@ class ImageViewBody extends React.PureComponent {
|
|
|
445
367
|
});
|
|
446
368
|
}
|
|
447
369
|
}
|
|
448
|
-
|
|
449
370
|
}
|
|
450
|
-
|
|
451
371
|
class ImageNodeView extends _CustomNodeView.default {
|
|
452
372
|
// @override
|
|
453
373
|
createDOMElement() {
|
|
454
374
|
const el = document.createElement('span');
|
|
455
375
|
el.className = 'czi-image-view';
|
|
456
|
-
|
|
457
376
|
this._updateDOM(el);
|
|
458
|
-
|
|
459
377
|
return el;
|
|
460
|
-
}
|
|
461
|
-
|
|
378
|
+
}
|
|
462
379
|
|
|
380
|
+
// @override
|
|
463
381
|
update(node, decorations) {
|
|
464
382
|
super.update(node, decorations);
|
|
465
|
-
|
|
466
383
|
this._updateDOM(this.dom);
|
|
467
|
-
|
|
468
384
|
return true;
|
|
469
|
-
}
|
|
470
|
-
|
|
385
|
+
}
|
|
471
386
|
|
|
387
|
+
// @override
|
|
472
388
|
renderReactComponent() {
|
|
473
389
|
return /*#__PURE__*/React.createElement(ImageViewBody, this.props);
|
|
474
390
|
}
|
|
475
|
-
|
|
476
391
|
_updateDOM(el) {
|
|
477
392
|
const {
|
|
478
393
|
align
|
|
479
394
|
} = this.props.node.attrs;
|
|
480
395
|
let className = 'czi-image-view';
|
|
481
|
-
|
|
482
396
|
if (align) {
|
|
483
397
|
className += ' align-' + align;
|
|
484
398
|
}
|
|
485
|
-
|
|
486
399
|
el.className = className;
|
|
487
400
|
}
|
|
488
|
-
|
|
489
401
|
}
|
|
490
|
-
|
|
491
402
|
var _default = ImageNodeView;
|
|
492
403
|
exports.default = _default;
|
|
@@ -4,45 +4,32 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = exports.MIN_SIZE = exports.MAX_SIZE = void 0;
|
|
7
|
-
|
|
8
7
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
9
|
-
|
|
10
8
|
var _nullthrows = _interopRequireDefault(require("nullthrows"));
|
|
11
|
-
|
|
12
9
|
var React = _interopRequireWildcard(require("react"));
|
|
13
|
-
|
|
14
10
|
var _licitUiCommands = require("@modusoperandi/licit-ui-commands");
|
|
15
|
-
|
|
16
11
|
var _uuid = _interopRequireDefault(require("./uuid"));
|
|
17
|
-
|
|
18
12
|
require("./czi-image-resize-box.css");
|
|
19
|
-
|
|
20
13
|
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); }
|
|
21
|
-
|
|
22
14
|
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; }
|
|
23
|
-
|
|
24
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
25
|
-
|
|
26
|
-
function
|
|
27
|
-
|
|
16
|
+
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; }
|
|
17
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
18
|
+
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); }
|
|
28
19
|
const MIN_SIZE = 20;
|
|
29
20
|
exports.MIN_SIZE = MIN_SIZE;
|
|
30
21
|
const MAX_SIZE = 10000;
|
|
31
22
|
exports.MAX_SIZE = MAX_SIZE;
|
|
32
|
-
|
|
33
23
|
function setWidth(el, width, height) {
|
|
34
24
|
el.style.width = width + 'px';
|
|
35
25
|
}
|
|
36
|
-
|
|
37
26
|
function setHeight(el, width, height) {
|
|
38
27
|
el.style.height = height + 'px';
|
|
39
28
|
}
|
|
40
|
-
|
|
41
29
|
function setSize(el, width, height) {
|
|
42
30
|
el.style.width = Math.round(width) + 'px';
|
|
43
31
|
el.style.height = Math.round(height) + 'px';
|
|
44
32
|
}
|
|
45
|
-
|
|
46
33
|
const ResizeDirection = {
|
|
47
34
|
top: setHeight,
|
|
48
35
|
top_right: setSize,
|
|
@@ -53,40 +40,25 @@ const ResizeDirection = {
|
|
|
53
40
|
left: setWidth,
|
|
54
41
|
top_left: setSize
|
|
55
42
|
};
|
|
56
|
-
|
|
57
43
|
class ImageResizeBoxControl extends React.PureComponent {
|
|
58
44
|
constructor() {
|
|
59
45
|
super(...arguments);
|
|
60
|
-
|
|
61
46
|
_defineProperty(this, "props", void 0);
|
|
62
|
-
|
|
63
47
|
_defineProperty(this, "_active", false);
|
|
64
|
-
|
|
65
48
|
_defineProperty(this, "_el", null);
|
|
66
|
-
|
|
67
49
|
_defineProperty(this, "_h", '');
|
|
68
|
-
|
|
69
50
|
_defineProperty(this, "_rafID", 0);
|
|
70
|
-
|
|
71
51
|
_defineProperty(this, "_w", '');
|
|
72
|
-
|
|
73
52
|
_defineProperty(this, "_x1", 0);
|
|
74
|
-
|
|
75
53
|
_defineProperty(this, "_x2", 0);
|
|
76
|
-
|
|
77
54
|
_defineProperty(this, "_y1", 0);
|
|
78
|
-
|
|
79
55
|
_defineProperty(this, "_y2", 0);
|
|
80
|
-
|
|
81
56
|
_defineProperty(this, "_ww", 0);
|
|
82
|
-
|
|
83
57
|
_defineProperty(this, "_hh", 0);
|
|
84
|
-
|
|
85
58
|
_defineProperty(this, "_syncSize", () => {
|
|
86
59
|
if (!this._active) {
|
|
87
60
|
return;
|
|
88
61
|
}
|
|
89
|
-
|
|
90
62
|
const {
|
|
91
63
|
direction,
|
|
92
64
|
width,
|
|
@@ -99,26 +71,20 @@ class ImageResizeBoxControl extends React.PureComponent {
|
|
|
99
71
|
const aspect = width / height;
|
|
100
72
|
let ww = (0, _licitUiCommands.clamp)(MIN_SIZE, width + Math.round(dx), MAX_SIZE);
|
|
101
73
|
let hh = (0, _licitUiCommands.clamp)(MIN_SIZE, height + Math.round(dy), MAX_SIZE);
|
|
102
|
-
|
|
103
74
|
if (fn === setSize) {
|
|
104
75
|
hh = Math.max(ww / aspect, MIN_SIZE);
|
|
105
76
|
ww = hh * aspect;
|
|
106
77
|
}
|
|
107
|
-
|
|
108
78
|
fn(el, Math.round(ww), Math.round(hh));
|
|
109
79
|
this._ww = ww;
|
|
110
80
|
this._hh = hh;
|
|
111
81
|
});
|
|
112
|
-
|
|
113
82
|
_defineProperty(this, "_onMouseDown", e => {
|
|
114
83
|
e.preventDefault();
|
|
115
84
|
e.stopPropagation();
|
|
116
|
-
|
|
117
85
|
this._end();
|
|
118
|
-
|
|
119
86
|
this._start(e);
|
|
120
87
|
});
|
|
121
|
-
|
|
122
88
|
_defineProperty(this, "_onMouseMove", e => {
|
|
123
89
|
e.preventDefault();
|
|
124
90
|
e.stopPropagation();
|
|
@@ -126,7 +92,6 @@ class ImageResizeBoxControl extends React.PureComponent {
|
|
|
126
92
|
this._y2 = e.clientY;
|
|
127
93
|
this._rafID = requestAnimationFrame(this._syncSize);
|
|
128
94
|
});
|
|
129
|
-
|
|
130
95
|
_defineProperty(this, "_onMouseUp", e => {
|
|
131
96
|
e.preventDefault();
|
|
132
97
|
e.stopPropagation();
|
|
@@ -137,17 +102,13 @@ class ImageResizeBoxControl extends React.PureComponent {
|
|
|
137
102
|
} = this.props;
|
|
138
103
|
const el = (0, _nullthrows.default)(this._el);
|
|
139
104
|
el.classList.remove(direction);
|
|
140
|
-
|
|
141
105
|
this._end();
|
|
142
|
-
|
|
143
106
|
this.props.onResizeEnd(this._ww, this._hh);
|
|
144
107
|
});
|
|
145
108
|
}
|
|
146
|
-
|
|
147
109
|
componentWillUnmount() {
|
|
148
110
|
this._end();
|
|
149
111
|
}
|
|
150
|
-
|
|
151
112
|
render() {
|
|
152
113
|
const {
|
|
153
114
|
direction
|
|
@@ -161,12 +122,10 @@ class ImageResizeBoxControl extends React.PureComponent {
|
|
|
161
122
|
onMouseDown: this._onMouseDown
|
|
162
123
|
});
|
|
163
124
|
}
|
|
164
|
-
|
|
165
125
|
_start(e) {
|
|
166
126
|
if (this._active) {
|
|
167
127
|
this._end();
|
|
168
128
|
}
|
|
169
|
-
|
|
170
129
|
this._active = true;
|
|
171
130
|
const {
|
|
172
131
|
boxID,
|
|
@@ -188,12 +147,10 @@ class ImageResizeBoxControl extends React.PureComponent {
|
|
|
188
147
|
document.addEventListener('mousemove', this._onMouseMove, true);
|
|
189
148
|
document.addEventListener('mouseup', this._onMouseUp, true);
|
|
190
149
|
}
|
|
191
|
-
|
|
192
150
|
_end() {
|
|
193
151
|
if (!this._active) {
|
|
194
152
|
return;
|
|
195
153
|
}
|
|
196
|
-
|
|
197
154
|
this._active = false;
|
|
198
155
|
document.removeEventListener('mousemove', this._onMouseMove, true);
|
|
199
156
|
document.removeEventListener('mouseup', this._onMouseUp, true);
|
|
@@ -205,18 +162,13 @@ class ImageResizeBoxControl extends React.PureComponent {
|
|
|
205
162
|
this._rafID && cancelAnimationFrame(this._rafID);
|
|
206
163
|
this._rafID = null;
|
|
207
164
|
}
|
|
208
|
-
|
|
209
165
|
}
|
|
210
|
-
|
|
211
166
|
class ImageResizeBox extends React.PureComponent {
|
|
212
167
|
constructor() {
|
|
213
168
|
super(...arguments);
|
|
214
|
-
|
|
215
169
|
_defineProperty(this, "props", void 0);
|
|
216
|
-
|
|
217
170
|
_defineProperty(this, "_id", (0, _uuid.default)());
|
|
218
171
|
}
|
|
219
|
-
|
|
220
172
|
render() {
|
|
221
173
|
const {
|
|
222
174
|
onResizeEnd,
|
|
@@ -249,8 +201,6 @@ class ImageResizeBox extends React.PureComponent {
|
|
|
249
201
|
src: src
|
|
250
202
|
}));
|
|
251
203
|
}
|
|
252
|
-
|
|
253
204
|
}
|
|
254
|
-
|
|
255
205
|
var _default = ImageResizeBox;
|
|
256
206
|
exports.default = _default;
|