Commit 62031fc7 authored by Maxym Borodenko's avatar Maxym Borodenko Committed by Matija Obreza

Fix: Pasting image instead of text from Word on Mac OS

- Paste Markdown from Word
parent 55fa6a45
Pipeline #7563 passed with stages
in 5 minutes and 26 seconds
......@@ -90,7 +90,8 @@
"yes": "Yes",
"basicMarkdown": "Basic markdown supported",
"fullMarkdown": "Full markdown supported",
"previewMarkdown": "Preview markdown"
"previewMarkdown": "Preview markdown",
"editMarkdown": "Edit Markdown"
},
"message": {
"confirmDelete": "Deleting the {{what, lowercase}} record is only possible when there is no associated data."
......
......@@ -277,8 +277,8 @@ class FileRepositoryService {
// console.log(`Fetching from ${apiUrl}`);
const data = new FormData();
data.append('file', file);
data.append('metadata', JSON.stringify(metadata));
// data.append('metadata', new Blob([ JSON.stringify(metadata) ], { type : 'application/json' }));
// data.append('metadata', JSON.stringify(metadata));
data.append('metadata', new Blob([ JSON.stringify(metadata) ], { type : 'application/json' }));
const content = { data };
return axiosBackend.request({
......
......@@ -42,6 +42,11 @@ class MarkdownField extends OriginalMarkdownField {
const { uploadMarkdownAttachment } = this.props;
const textarea = this.textarea;
// only trigger the upload in case of a real picture
if (! file.type.startsWith('image/')) {
return;
}
// console.log('Uploading file', file);
return uploadMarkdownAttachment(file)
.then((r) => {
......@@ -81,9 +86,9 @@ class MarkdownField extends OriginalMarkdownField {
private dataPasted = async (e) => {
const { clipboardData: { files } } = e;
const types: string[] = e.clipboardData.types;
// console.log('Pasted', e.clipboardData, types, files, items);
if (files.length) {
if (files.length && (types.indexOf('text/plain') === -1)) {
e.preventDefault();
for (const f of files) {
await this.addFile(f);
......@@ -91,7 +96,6 @@ class MarkdownField extends OriginalMarkdownField {
} else {
// NOOP
}
// console.log(e.clipboardData.getData('text/plain'));
}
// Bind event listeners
......@@ -148,7 +152,7 @@ class MarkdownField extends OriginalMarkdownField {
<div style={ { paddingTop: '1.5rem' } }>
<Markdown source={ input.value } />
</div>
<h6><a onClick={ this.onChangePreviewMode }>Edit Markdown</a></h6>
<h6><a onClick={ this.onChangePreviewMode }>{ t('common:label.editMarkdown') }</a></h6>
</FormControl>
}
</div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment