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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
3e7770aa
Commit
3e7770aa
authored
May 26, 2016
by
Jacob Schatz
Committed by
Phil Hughes
Jun 17, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Overwrite undo history
parent
3d5b1c35
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
5 deletions
+51
-5
app/assets/javascripts/lib/text_utility.js.coffee
app/assets/javascripts/lib/text_utility.js.coffee
+44
-4
app/views/projects/issues/_discussion.html.haml
app/views/projects/issues/_discussion.html.haml
+6
-0
app/views/projects/merge_requests/_discussion.html.haml
app/views/projects/merge_requests/_discussion.html.haml
+1
-1
No files found.
app/assets/javascripts/lib/text_utility.js.coffee
View file @
3e7770aa
...
@@ -3,11 +3,14 @@
...
@@ -3,11 +3,14 @@
w
.
gl
.
text
?=
{}
w
.
gl
.
text
?=
{}
w
.
gl
.
text
.
undoManager
?=
{}
w
.
gl
.
text
.
undoManager
?=
{}
gl
.
text
.
randomString
=
->
Math
.
random
().
toString
(
36
).
substring
(
7
)
gl
.
text
.
replaceRange
=
(
s
,
start
,
end
,
substitute
)
->
gl
.
text
.
replaceRange
=
(
s
,
start
,
end
,
substitute
)
->
s
.
substring
(
0
,
start
)
+
substitute
+
s
.
substring
(
end
);
s
.
substring
(
0
,
start
)
+
substitute
+
s
.
substring
(
end
);
gl
.
text
.
wrap
=
(
textArea
,
tag
)
->
gl
.
text
.
wrap
=
(
textArea
,
tag
)
->
$textArea
=
$
(
textArea
)
$textArea
=
$
(
textArea
)
oldVal
=
$textArea
.
val
()
$textArea
.
focus
()
$textArea
.
focus
()
textArea
=
$textArea
.
get
(
0
)
textArea
=
$textArea
.
get
(
0
)
selObj
=
window
.
getSelection
()
selObj
=
window
.
getSelection
()
...
@@ -18,10 +21,12 @@
...
@@ -18,10 +21,12 @@
textArea
.
selectionStart
,
textArea
.
selectionStart
,
textArea
.
selectionEnd
,
textArea
.
selectionEnd
,
(
tag
+
selObj
.
toString
()
+
tag
))
(
tag
+
selObj
.
toString
()
+
tag
))
$textArea
.
data
(
'old-val'
,
text
).
val
(
replaceWith
);
$textArea
.
data
(
'old-val'
,
text
).
val
(
replaceWith
)
gl
.
text
.
undoManager
.
addUndo
(
oldVal
,
$textArea
.
val
())
gl
.
text
.
prepend
=
(
textArea
,
tag
)
->
gl
.
text
.
prepend
=
(
textArea
,
tag
)
->
$textArea
=
$
(
textArea
)
$textArea
=
$
(
textArea
)
oldVal
=
$textArea
.
val
()
$textArea
.
focus
()
$textArea
.
focus
()
textArea
=
$textArea
.
get
(
0
)
textArea
=
$textArea
.
get
(
0
)
selObj
=
window
.
getSelection
()
selObj
=
window
.
getSelection
()
...
@@ -36,12 +41,45 @@
...
@@ -36,12 +41,45 @@
(
"
#{
lineBreak
}#{
tag
}
#{
selObj
.
toString
()
}
\n
"
)
(
"
#{
lineBreak
}#{
tag
}
#{
selObj
.
toString
()
}
\n
"
)
)
)
$textArea
.
data
(
'old-val'
,
text
).
val
(
replaceWith
);
$textArea
.
data
(
'old-val'
,
text
).
val
(
replaceWith
);
# $textArea.val(replaceWith)
gl
.
text
.
undoManager
.
addUndo
(
oldVal
,
$textArea
.
val
())
gl
.
text
.
undoManager
.
history
=
{}
gl
.
text
.
undoManager
.
undoHistory
=
{}
gl
.
text
.
undoManager
.
addUniqueIfNotExists
=
(
$ta
)
->
unique
=
$ta
.
attr
(
'data-unique'
)
if
not
unique
?
unique
=
gl
.
text
.
randomString
()
$ta
.
attr
(
'data-unique'
,
unique
)
gl
.
text
.
undoManager
.
history
[
unique
]
=
[]
gl
.
text
.
undoManager
.
undoHistory
[
unique
]
=
[]
unique
gl
.
text
.
undoManager
.
addUndo
=
(
oldVal
,
newVal
)
->
$thisTextarea
=
$
(
'textarea:focus'
)
unique
=
gl
.
text
.
undoManager
.
addUniqueIfNotExists
(
$thisTextarea
)
gl
.
text
.
undoManager
.
history
[
unique
].
push
({
oldVal
:
oldVal
,
newVal
:
newVal
})
gl
.
text
.
undoManager
.
undo
=
()
->
gl
.
text
.
undoManager
.
undo
=
()
->
$thisTextarea
=
$
(
'textarea:focus'
)
unique
=
gl
.
text
.
undoManager
.
addUniqueIfNotExists
(
$thisTextarea
)
if
not
gl
.
text
.
undoManager
.
history
[
unique
].
length
return
latestChange
=
gl
.
text
.
undoManager
.
history
[
unique
].
pop
()
gl
.
text
.
undoManager
.
undoHistory
[
unique
].
push
(
latestChange
)
$thisTextarea
.
val
(
latestChange
.
oldVal
)
gl
.
text
.
undoManager
.
redo
=
()
->
$thisTextarea
=
$
(
'textarea:focus'
)
unique
=
gl
.
text
.
undoManager
.
addUniqueIfNotExists
(
$thisTextarea
)
if
not
gl
.
text
.
undoManager
.
undoHistory
[
unique
].
length
return
gl
.
text
.
addListeners
=
()
->
gl
.
text
.
addListeners
=
()
->
console
.
log
(
'addListeners'
)
self
=
@
self
=
@
$
(
'.js-md'
).
on
'click'
,
->
$
(
'.js-md'
).
on
'click'
,
->
$this
=
$
(
@
)
$this
=
$
(
@
)
...
@@ -61,12 +99,14 @@
...
@@ -61,12 +99,14 @@
$this
.
data
(
'md-tag'
)
$this
.
data
(
'md-tag'
)
)
)
$
(
window
).
on
'keydown'
,
(
e
)
-
>
$
(
window
).
on
'keydown'
,
(
e
)
=
>
if
e
.
ctrlKey
or
e
.
metaKey
if
e
.
ctrlKey
or
e
.
metaKey
if
String
.
fromCharCode
(
e
.
which
).
toLowerCase
()
is
'z'
and
!
e
.
shiftKey
if
String
.
fromCharCode
(
e
.
which
).
toLowerCase
()
is
'z'
and
!
e
.
shiftKey
e
.
preventDefault
()
e
.
preventDefault
()
self
.
undoManager
.
undo
()
else
if
((
String
.
fromCharCode
(
e
.
which
).
toLowerCase
()
is
'z'
and
e
.
shiftKey
)
or
(
String
.
fromCharCode
(
e
.
which
).
toLowerCase
()
is
'y'
))
else
if
((
String
.
fromCharCode
(
e
.
which
).
toLowerCase
()
is
'z'
and
e
.
shiftKey
)
or
(
String
.
fromCharCode
(
e
.
which
).
toLowerCase
()
is
'y'
))
e
.
preventDefault
()
e
.
preventDefault
()
self
.
undoManager
.
redo
()
gl
.
text
.
removeListeners
=
()
->
gl
.
text
.
removeListeners
=
()
->
$
(
'js-md.btn-bold'
).
off
()
$
(
'js-md.btn-bold'
).
off
()
...
...
app/views/projects/issues/_discussion.html.haml
View file @
3e7770aa
...
@@ -5,3 +5,9 @@
...
@@ -5,3 +5,9 @@
#notes
#notes
=
render
'projects/notes/notes_with_form'
=
render
'projects/notes/notes_with_form'
:javascript
$
(
function
(){
gl
.
text
.
removeListeners
();
gl
.
text
.
addListeners
();
})
\ No newline at end of file
app/views/projects/merge_requests/_discussion.html.haml
View file @
3e7770aa
...
@@ -11,4 +11,4 @@
...
@@ -11,4 +11,4 @@
$
(
function
(){
$
(
function
(){
gl
.
text
.
removeListeners
();
gl
.
text
.
removeListeners
();
gl
.
text
.
addListeners
();
gl
.
text
.
addListeners
();
})
})
\ No newline at end of file
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