@modusoperandi/licit 0.13.25 → 0.14.1
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 +1472 -1624
- 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 +22 -110
- package/dist/ui/ImageNodeView.js.flow +2 -1
- 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.json +46 -70
- package/src/client/Licit.js +16 -2
- package/src/ui/ImageNodeView.js +2 -1
- 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,53 @@ 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
|
+
const imageSrc = await getProxyImageSrc(src);
|
|
78
|
+
return imageSrc;
|
|
107
79
|
}
|
|
108
|
-
|
|
109
80
|
return src;
|
|
110
81
|
}
|
|
111
|
-
|
|
112
82
|
class ImageViewBody extends React.PureComponent {
|
|
113
83
|
constructor() {
|
|
114
84
|
super(...arguments);
|
|
115
|
-
|
|
116
85
|
_defineProperty(this, "props", void 0);
|
|
117
|
-
|
|
118
86
|
_defineProperty(this, "_body", null);
|
|
119
|
-
|
|
120
87
|
_defineProperty(this, "_id", (0, _uuid.default)());
|
|
121
|
-
|
|
122
88
|
_defineProperty(this, "_inlineEditor", null);
|
|
123
|
-
|
|
124
89
|
_defineProperty(this, "_mounted", false);
|
|
125
|
-
|
|
126
90
|
_defineProperty(this, "state", {
|
|
127
91
|
maxSize: {
|
|
128
92
|
width: MAX_SIZE,
|
|
@@ -131,40 +95,33 @@ class ImageViewBody extends React.PureComponent {
|
|
|
131
95
|
},
|
|
132
96
|
originalSize: DEFAULT_ORIGINAL_SIZE
|
|
133
97
|
});
|
|
134
|
-
|
|
135
98
|
_defineProperty(this, "_resolveOriginalSize", async () => {
|
|
136
99
|
if (!this._mounted) {
|
|
137
100
|
// unmounted;
|
|
138
101
|
return;
|
|
139
102
|
}
|
|
140
|
-
|
|
141
103
|
this.setState({
|
|
142
104
|
originalSize: DEFAULT_ORIGINAL_SIZE
|
|
143
105
|
});
|
|
144
106
|
const src = this.props.node.attrs.src;
|
|
145
107
|
const url = await resolveURL(this.props.editorView.runtime, src);
|
|
146
108
|
const originalSize = await (0, _resolveImage.default)(url);
|
|
147
|
-
|
|
148
109
|
if (!this._mounted) {
|
|
149
110
|
// unmounted;
|
|
150
111
|
return;
|
|
151
112
|
}
|
|
152
|
-
|
|
153
113
|
if (this.props.node.attrs.src !== src) {
|
|
154
114
|
// src had changed.
|
|
155
115
|
return;
|
|
156
116
|
}
|
|
157
|
-
|
|
158
117
|
if (!originalSize.complete) {
|
|
159
118
|
originalSize.width = _ImageResizeBox.MIN_SIZE;
|
|
160
119
|
originalSize.height = _ImageResizeBox.MIN_SIZE;
|
|
161
120
|
}
|
|
162
|
-
|
|
163
121
|
this.setState({
|
|
164
122
|
originalSize
|
|
165
123
|
});
|
|
166
124
|
});
|
|
167
|
-
|
|
168
125
|
_defineProperty(this, "_onResizeEnd", (width, height) => {
|
|
169
126
|
const {
|
|
170
127
|
getPos,
|
|
@@ -172,33 +129,28 @@ class ImageViewBody extends React.PureComponent {
|
|
|
172
129
|
editorView
|
|
173
130
|
} = this.props;
|
|
174
131
|
const pos = getPos();
|
|
175
|
-
|
|
176
132
|
const attrs = _objectSpread(_objectSpread({}, node.attrs), {}, {
|
|
177
133
|
// TODO: Support UI for cropping later.
|
|
178
134
|
crop: null,
|
|
179
135
|
width,
|
|
180
136
|
height
|
|
181
137
|
});
|
|
182
|
-
|
|
183
138
|
let tr = editorView.state.tr;
|
|
184
139
|
const {
|
|
185
140
|
selection
|
|
186
141
|
} = editorView.state;
|
|
187
|
-
tr = tr.setNodeMarkup(pos, null, attrs);
|
|
142
|
+
tr = tr.setNodeMarkup(pos, null, attrs);
|
|
143
|
+
// [FS] IRAD-1005 2020-07-09
|
|
188
144
|
// Upgrade outdated packages.
|
|
189
145
|
// reset selection to original using the latest doc.
|
|
190
|
-
|
|
191
146
|
const origSelection = _prosemirrorState.NodeSelection.create(tr.doc, selection.from);
|
|
192
|
-
|
|
193
147
|
tr = tr.setSelection(origSelection);
|
|
194
148
|
editorView.dispatch(tr);
|
|
195
149
|
});
|
|
196
|
-
|
|
197
150
|
_defineProperty(this, "_onChange", value => {
|
|
198
151
|
if (!this._mounted) {
|
|
199
152
|
return;
|
|
200
153
|
}
|
|
201
|
-
|
|
202
154
|
const align = value ? value.align : null;
|
|
203
155
|
const {
|
|
204
156
|
getPos,
|
|
@@ -206,46 +158,38 @@ class ImageViewBody extends React.PureComponent {
|
|
|
206
158
|
editorView
|
|
207
159
|
} = this.props;
|
|
208
160
|
const pos = getPos();
|
|
209
|
-
|
|
210
161
|
const attrs = _objectSpread(_objectSpread({}, node.attrs), {}, {
|
|
211
162
|
align
|
|
212
163
|
});
|
|
213
|
-
|
|
214
164
|
let tr = editorView.state.tr;
|
|
215
165
|
const {
|
|
216
166
|
selection
|
|
217
167
|
} = editorView.state;
|
|
218
|
-
tr = tr.setNodeMarkup(pos, null, attrs);
|
|
168
|
+
tr = tr.setNodeMarkup(pos, null, attrs);
|
|
169
|
+
// [FS] IRAD-1005 2020-07-09
|
|
219
170
|
// Upgrade outdated packages.
|
|
220
171
|
// reset selection to original using the latest doc.
|
|
221
|
-
|
|
222
172
|
const origSelection = _prosemirrorState.NodeSelection.create(tr.doc, selection.from);
|
|
223
|
-
|
|
224
173
|
tr = tr.setSelection(origSelection);
|
|
225
174
|
editorView.dispatch(tr);
|
|
226
175
|
});
|
|
227
|
-
|
|
228
176
|
_defineProperty(this, "_onBodyRef", ref => {
|
|
229
177
|
if (ref) {
|
|
230
|
-
this._body = ref;
|
|
231
|
-
|
|
178
|
+
this._body = ref;
|
|
179
|
+
// Mounting
|
|
232
180
|
const el = _reactDom.default.findDOMNode(ref);
|
|
233
|
-
|
|
234
181
|
if (el instanceof HTMLElement) {
|
|
235
182
|
_ResizeObserver.default.observe(el, this._onBodyResize);
|
|
236
183
|
}
|
|
237
184
|
} else {
|
|
238
185
|
// Unmounting.
|
|
239
186
|
const el = this._body && _reactDom.default.findDOMNode(this._body);
|
|
240
|
-
|
|
241
187
|
if (el instanceof HTMLElement) {
|
|
242
188
|
_ResizeObserver.default.unobserve(el);
|
|
243
189
|
}
|
|
244
|
-
|
|
245
190
|
this._body = null;
|
|
246
191
|
}
|
|
247
192
|
});
|
|
248
|
-
|
|
249
193
|
_defineProperty(this, "_onBodyResize", info => {
|
|
250
194
|
const width = this._body ? getMaxResizeWidth(_reactDom.default.findDOMNode(this._body)) : MAX_SIZE;
|
|
251
195
|
this.setState({
|
|
@@ -257,21 +201,16 @@ class ImageViewBody extends React.PureComponent {
|
|
|
257
201
|
});
|
|
258
202
|
});
|
|
259
203
|
}
|
|
260
|
-
|
|
261
204
|
componentDidMount() {
|
|
262
205
|
this._mounted = true;
|
|
263
|
-
|
|
264
206
|
this._resolveOriginalSize();
|
|
265
|
-
|
|
266
207
|
this._renderInlineEditor();
|
|
267
208
|
}
|
|
268
|
-
|
|
269
209
|
componentWillUnmount() {
|
|
270
210
|
this._mounted = false;
|
|
271
211
|
this._inlineEditor && this._inlineEditor.close();
|
|
272
212
|
this._inlineEditor = null;
|
|
273
213
|
}
|
|
274
|
-
|
|
275
214
|
componentDidUpdate(prevProps) {
|
|
276
215
|
const prevSrc = prevProps.node.attrs.src;
|
|
277
216
|
const {
|
|
@@ -280,15 +219,12 @@ class ImageViewBody extends React.PureComponent {
|
|
|
280
219
|
const {
|
|
281
220
|
src
|
|
282
221
|
} = node.attrs;
|
|
283
|
-
|
|
284
222
|
if (prevSrc !== src) {
|
|
285
223
|
// A new image is provided, resolve it.
|
|
286
224
|
this._resolveOriginalSize();
|
|
287
225
|
}
|
|
288
|
-
|
|
289
226
|
this._renderInlineEditor();
|
|
290
227
|
}
|
|
291
|
-
|
|
292
228
|
render() {
|
|
293
229
|
const {
|
|
294
230
|
originalSize,
|
|
@@ -310,8 +246,9 @@ class ImageViewBody extends React.PureComponent {
|
|
|
310
246
|
align,
|
|
311
247
|
crop,
|
|
312
248
|
rotate
|
|
313
|
-
} = attrs;
|
|
249
|
+
} = attrs;
|
|
314
250
|
|
|
251
|
+
// It's only active when the image's fully loaded.
|
|
315
252
|
const loading = originalSize === DEFAULT_ORIGINAL_SIZE;
|
|
316
253
|
const active = !loading && focused && !readOnly && originalSize.complete;
|
|
317
254
|
const src = originalSize.complete ? originalSize.src : EMPTY_SRC;
|
|
@@ -321,12 +258,10 @@ class ImageViewBody extends React.PureComponent {
|
|
|
321
258
|
width,
|
|
322
259
|
height
|
|
323
260
|
} = attrs;
|
|
324
|
-
|
|
325
261
|
if (loading) {
|
|
326
262
|
width = width || IMAGE_PLACEHOLDER_SIZE;
|
|
327
263
|
height = height || IMAGE_PLACEHOLDER_SIZE;
|
|
328
264
|
}
|
|
329
|
-
|
|
330
265
|
if (width && !height) {
|
|
331
266
|
height = width / aspectRatio;
|
|
332
267
|
} else if (height && !width) {
|
|
@@ -335,9 +270,7 @@ class ImageViewBody extends React.PureComponent {
|
|
|
335
270
|
width = originalSize.width;
|
|
336
271
|
height = originalSize.height;
|
|
337
272
|
}
|
|
338
|
-
|
|
339
273
|
let scale = 1;
|
|
340
|
-
|
|
341
274
|
if (width > maxSize.width && (!crop || crop.width > maxSize.width)) {
|
|
342
275
|
// Scale image to fit its containing space.
|
|
343
276
|
// If the image is not cropped.
|
|
@@ -345,7 +278,6 @@ class ImageViewBody extends React.PureComponent {
|
|
|
345
278
|
height = width / aspectRatio;
|
|
346
279
|
scale = maxSize.width / width;
|
|
347
280
|
}
|
|
348
|
-
|
|
349
281
|
const className = (0, _classnames.default)('czi-image-view-body', {
|
|
350
282
|
active,
|
|
351
283
|
error,
|
|
@@ -368,10 +300,8 @@ class ImageViewBody extends React.PureComponent {
|
|
|
368
300
|
position: 'relative'
|
|
369
301
|
};
|
|
370
302
|
const clipStyle = {};
|
|
371
|
-
|
|
372
303
|
if (crop) {
|
|
373
304
|
const cropped = _objectSpread({}, crop);
|
|
374
|
-
|
|
375
305
|
if (scale !== 1) {
|
|
376
306
|
scale = maxSize.width / cropped.width;
|
|
377
307
|
cropped.width *= scale;
|
|
@@ -379,17 +309,14 @@ class ImageViewBody extends React.PureComponent {
|
|
|
379
309
|
cropped.left *= scale;
|
|
380
310
|
cropped.top *= scale;
|
|
381
311
|
}
|
|
382
|
-
|
|
383
312
|
clipStyle.width = cropped.width + 'px';
|
|
384
313
|
clipStyle.height = cropped.height + 'px';
|
|
385
314
|
imageStyle.left = cropped.left + 'px';
|
|
386
315
|
imageStyle.top = cropped.top + 'px';
|
|
387
316
|
}
|
|
388
|
-
|
|
389
317
|
if (rotate) {
|
|
390
318
|
clipStyle.transform = `rotate(${rotate}rad)`;
|
|
391
319
|
}
|
|
392
|
-
|
|
393
320
|
const errorView = error ? _Icon.default.get('error') : null;
|
|
394
321
|
const errorTitle = error ? `Unable to load image from ${attrs.src || ''}` : undefined;
|
|
395
322
|
return /*#__PURE__*/React.createElement("span", {
|
|
@@ -414,15 +341,12 @@ class ImageViewBody extends React.PureComponent {
|
|
|
414
341
|
width: width
|
|
415
342
|
}), errorView)), resizeBox);
|
|
416
343
|
}
|
|
417
|
-
|
|
418
344
|
_renderInlineEditor() {
|
|
419
345
|
const el = document.getElementById(this._id);
|
|
420
|
-
|
|
421
346
|
if (!el || el.getAttribute('data-active') !== 'true') {
|
|
422
347
|
this._inlineEditor && this._inlineEditor.close();
|
|
423
348
|
return;
|
|
424
349
|
}
|
|
425
|
-
|
|
426
350
|
const {
|
|
427
351
|
node
|
|
428
352
|
} = this.props;
|
|
@@ -430,7 +354,6 @@ class ImageViewBody extends React.PureComponent {
|
|
|
430
354
|
value: node.attrs,
|
|
431
355
|
onSelect: this._onChange
|
|
432
356
|
};
|
|
433
|
-
|
|
434
357
|
if (this._inlineEditor) {
|
|
435
358
|
this._inlineEditor.update(editorProps);
|
|
436
359
|
} else {
|
|
@@ -445,48 +368,37 @@ class ImageViewBody extends React.PureComponent {
|
|
|
445
368
|
});
|
|
446
369
|
}
|
|
447
370
|
}
|
|
448
|
-
|
|
449
371
|
}
|
|
450
|
-
|
|
451
372
|
class ImageNodeView extends _CustomNodeView.default {
|
|
452
373
|
// @override
|
|
453
374
|
createDOMElement() {
|
|
454
375
|
const el = document.createElement('span');
|
|
455
376
|
el.className = 'czi-image-view';
|
|
456
|
-
|
|
457
377
|
this._updateDOM(el);
|
|
458
|
-
|
|
459
378
|
return el;
|
|
460
|
-
}
|
|
461
|
-
|
|
379
|
+
}
|
|
462
380
|
|
|
381
|
+
// @override
|
|
463
382
|
update(node, decorations) {
|
|
464
383
|
super.update(node, decorations);
|
|
465
|
-
|
|
466
384
|
this._updateDOM(this.dom);
|
|
467
|
-
|
|
468
385
|
return true;
|
|
469
|
-
}
|
|
470
|
-
|
|
386
|
+
}
|
|
471
387
|
|
|
388
|
+
// @override
|
|
472
389
|
renderReactComponent() {
|
|
473
390
|
return /*#__PURE__*/React.createElement(ImageViewBody, this.props);
|
|
474
391
|
}
|
|
475
|
-
|
|
476
392
|
_updateDOM(el) {
|
|
477
393
|
const {
|
|
478
394
|
align
|
|
479
395
|
} = this.props.node.attrs;
|
|
480
396
|
let className = 'czi-image-view';
|
|
481
|
-
|
|
482
397
|
if (align) {
|
|
483
398
|
className += ' align-' + align;
|
|
484
399
|
}
|
|
485
|
-
|
|
486
400
|
el.className = className;
|
|
487
401
|
}
|
|
488
|
-
|
|
489
402
|
}
|
|
490
|
-
|
|
491
403
|
var _default = ImageNodeView;
|
|
492
404
|
exports.default = _default;
|
|
@@ -75,7 +75,8 @@ async function resolveURL(runtime: ?EditorRuntime, src: ?string): ?string {
|
|
|
75
75
|
}
|
|
76
76
|
const { canProxyImageSrc, getProxyImageSrc } = runtime;
|
|
77
77
|
if (src && canProxyImageSrc && getProxyImageSrc && canProxyImageSrc(src)) {
|
|
78
|
-
|
|
78
|
+
const imageSrc = await getProxyImageSrc(src);
|
|
79
|
+
return imageSrc;
|
|
79
80
|
}
|
|
80
81
|
return src;
|
|
81
82
|
}
|
|
@@ -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;
|