Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
587f8cb2
Commit
587f8cb2
authored
Nov 18, 2021
by
orozot
Committed by
Natalia Tepluhina
Nov 18, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix: copy text from oneNote and PowerPoint
parent
0df08101
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
2 deletions
+35
-2
app/assets/javascripts/dropzone_input.js
app/assets/javascripts/dropzone_input.js
+7
-1
spec/frontend/dropzone_input_spec.js
spec/frontend/dropzone_input_spec.js
+28
-1
No files found.
app/assets/javascripts/dropzone_input.js
View file @
587f8cb2
...
...
@@ -44,6 +44,7 @@ export default function dropzoneInput(form, config = { parallelUploads: 2 }) {
let
addFileToForm
;
let
updateAttachingMessage
;
let
uploadFile
;
let
hasPlainText
;
formTextarea
.
wrap
(
'
<div class="div-dropzone"></div>
'
);
formTextarea
.
on
(
'
paste
'
,
(
event
)
=>
handlePaste
(
event
));
...
...
@@ -184,7 +185,7 @@ export default function dropzoneInput(form, config = { parallelUploads: 2 }) {
event
.
preventDefault
();
const
text
=
converter
.
convertToTableMarkdown
();
pasteText
(
text
);
}
else
{
}
else
if
(
!
hasPlainText
(
pasteEvent
))
{
const
fileList
=
[...
clipboardData
.
files
];
fileList
.
forEach
((
file
)
=>
{
if
(
file
.
type
.
indexOf
(
'
image
'
)
!==
-
1
)
{
...
...
@@ -203,6 +204,11 @@ export default function dropzoneInput(form, config = { parallelUploads: 2 }) {
}
};
hasPlainText
=
(
data
)
=>
{
const
clipboardDataList
=
[...
data
.
clipboardData
.
items
];
return
clipboardDataList
.
some
((
item
)
=>
item
.
type
===
'
text/plain
'
);
};
pasteText
=
(
text
,
shouldPad
)
=>
{
let
formattedText
=
text
;
if
(
shouldPad
)
{
...
...
spec/frontend/dropzone_input_spec.js
View file @
587f8cb2
...
...
@@ -32,6 +32,8 @@ describe('dropzone_input', () => {
});
describe
(
'
handlePaste
'
,
()
=>
{
let
form
;
const
triggerPasteEvent
=
(
clipboardData
=
{})
=>
{
const
event
=
$
.
Event
(
'
paste
'
);
const
origEvent
=
new
Event
(
'
paste
'
);
...
...
@@ -45,11 +47,15 @@ describe('dropzone_input', () => {
beforeEach
(()
=>
{
loadFixtures
(
'
issues/new-issue.html
'
);
const
form
=
$
(
'
#new_issue
'
);
form
=
$
(
'
#new_issue
'
);
form
.
data
(
'
uploads-path
'
,
TEST_UPLOAD_PATH
);
dropzoneInput
(
form
);
});
afterEach
(()
=>
{
form
=
null
;
});
it
(
'
pastes Markdown tables
'
,
()
=>
{
jest
.
spyOn
(
PasteMarkdownTable
.
prototype
,
'
isTable
'
);
jest
.
spyOn
(
PasteMarkdownTable
.
prototype
,
'
convertToTableMarkdown
'
);
...
...
@@ -86,6 +92,27 @@ describe('dropzone_input', () => {
expect
(
axiosMock
.
history
.
post
[
0
].
data
.
get
(
'
file
'
).
name
).
toHaveLength
(
246
);
});
it
(
'
disables generated image file when clipboardData have both image and text
'
,
()
=>
{
const
TEST_PLAIN_TEXT
=
'
This wording is a plain text.
'
;
triggerPasteEvent
({
types
:
[
'
text/plain
'
,
'
Files
'
],
getData
:
()
=>
TEST_PLAIN_TEXT
,
items
:
[
{
kind
:
'
text
'
,
type
:
'
text/plain
'
,
},
{
kind
:
'
file
'
,
type
:
'
image/png
'
,
getAsFile
:
()
=>
new
Blob
(),
},
],
});
expect
(
form
.
find
(
'
.js-gfm-input
'
)[
0
].
value
).
toBe
(
''
);
});
it
(
'
display original file name in comment box
'
,
async
()
=>
{
const
axiosMock
=
new
MockAdapter
(
axios
);
triggerPasteEvent
({
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment