inline-attachment: move to local copy + handle xhr errors
(1) Move from Node to local copy (2) Handle xhr errors more gracefully. Instead of erasing the syntax, we should say that it failed through the URL.
This commit is contained in:
parent
c41c6bc2bb
commit
a61f943465
6 changed files with 11 additions and 9 deletions
|
@ -2,5 +2,6 @@ node_modules/*
|
|||
./node_modules/**
|
||||
**/node_modules/**
|
||||
web/dist/**
|
||||
**/plugins/inline-attachment/**
|
||||
|
||||
ui/component/viewers/videoViewer/internal/plugins/canAutoplay.js
|
||||
|
|
1
.prettierignore
Normal file
1
.prettierignore
Normal file
|
@ -0,0 +1 @@
|
|||
**/plugins/inline-attachment/**
|
|
@ -63,7 +63,6 @@
|
|||
"express": "^4.17.1",
|
||||
"humanize-duration": "^3.27.0",
|
||||
"if-env": "^1.0.4",
|
||||
"inline-attachment": "^2.0.3",
|
||||
"match-sorter": "^6.3.0",
|
||||
"parse-duration": "^1.0.0",
|
||||
"player.js": "^0.1.0",
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
// @flow
|
||||
import 'easymde/dist/easymde.min.css';
|
||||
|
||||
import 'inline-attachment/src/inline-attachment';
|
||||
import 'inline-attachment/src/codemirror-4.inline-attachment';
|
||||
import './plugins/inline-attachment/inline-attachment';
|
||||
import './plugins/inline-attachment/codemirror-4.inline-attachment';
|
||||
import { IMG_CDN_PUBLISH_URL, JSON_RESPONSE_KEYS, UPLOAD_CONFIG } from 'constants/cdn_urls';
|
||||
import { FF_MAX_CHARS_DEFAULT } from 'constants/form-field';
|
||||
import { openEditorMenu, stopContextMenu } from 'util/context-menu';
|
||||
|
@ -239,6 +239,7 @@ export class FormField extends React.PureComponent<Props, State> {
|
|||
filenameTag: '{filename}',
|
||||
urlText: '![image]({filename})',
|
||||
jsonFieldName: JSON_RESPONSE_KEYS.UPLOADED_URL,
|
||||
errorText: '![image]("failed to upload file")',
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -274,6 +274,11 @@
|
|||
me.onFileUploadError(xhr);
|
||||
}
|
||||
};
|
||||
|
||||
xhr.onerror = () => {
|
||||
me.onFileUploadError(xhr);
|
||||
};
|
||||
|
||||
if (settings.beforeFileUpload(xhr) !== false) {
|
||||
xhr.send(formData);
|
||||
}
|
||||
|
@ -328,7 +333,7 @@
|
|||
*/
|
||||
inlineAttachment.prototype.onFileUploadError = function(xhr) {
|
||||
if (this.settings.onFileUploadError.call(this, xhr) !== false) {
|
||||
var text = this.editor.getValue().replace(this.lastValue, "");
|
||||
var text = this.editor.getValue().replace(this.lastValue, this.settings.errorText);
|
||||
this.editor.setValue(text);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -9234,11 +9234,6 @@ ini@^1.3.4, ini@^1.3.5, ini@~1.3.0:
|
|||
resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.7.tgz#a09363e1911972ea16d7a8851005d84cf09a9a84"
|
||||
integrity sha512-iKpRpXP+CrP2jyrxvg1kMUpXDyRUFDWurxbnVT1vQPx+Wz9uCYsMIqYuSBLV+PAaZG/d7kRLKRFc9oDMsH+mFQ==
|
||||
|
||||
inline-attachment@^2.0.3:
|
||||
version "2.0.3"
|
||||
resolved "https://registry.yarnpkg.com/inline-attachment/-/inline-attachment-2.0.3.tgz#5ee32374583fabd3b7206df2e20f251ba20c4306"
|
||||
integrity sha1-XuMjdFg/q9O3IG3y4g8lG6IMQwY=
|
||||
|
||||
inline-style-parser@0.1.1:
|
||||
version "0.1.1"
|
||||
resolved "https://registry.yarnpkg.com/inline-style-parser/-/inline-style-parser-0.1.1.tgz#ec8a3b429274e9c0a1f1c4ffa9453a7fef72cea1"
|
||||
|
|
Loading…
Reference in a new issue