Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
coopwire-hypothesis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
孙灵跃 Leon Sun
coopwire-hypothesis
Commits
eb0c163c
Commit
eb0c163c
authored
Sep 18, 2014
by
RawKStar77
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename things, fix embarassing spelling error.
parent
bd2fb13e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
17 deletions
+18
-17
markdown.coffee
h/static/scripts/directives/markdown.coffee
+16
-15
annotations.scss
h/static/styles/annotations.scss
+2
-2
No files found.
h/static/scripts/directives/markdown.coffee
View file @
eb0c163c
...
...
@@ -12,19 +12,20 @@ markdown = ['$filter', '$timeout', '$window', ($filter, $timeout, $window) ->
return
unless
ctrl
?
input
=
elem
.
find
(
'textarea'
)
output
=
elem
.
find
(
'div'
)
output
=
elem
.
find
(
'div'
)[
1
]
textarea
=
input
[
0
]
returnSelection
=
->
ourIframeSelection
=
$window
.
getSelection
().
toString
()
if
input
[
0
]
.
selectionStart
!=
undefined
startPos
=
input
[
0
]
.
selectionStart
endPos
=
input
[
0
]
.
selectionEnd
if
textarea
.
selectionStart
!=
undefined
startPos
=
textarea
.
selectionStart
endPos
=
textarea
.
selectionEnd
if
ourIframeSelection
selectedText
=
ourIframeSelection
else
selectedText
=
input
[
0
]
.
value
.
substring
(
startPos
,
endPos
)
textBefore
=
input
[
0
]
.
value
.
substring
(
0
,
(
startPos
))
textAfter
=
input
[
0
]
.
value
.
substring
(
endPos
)
selectedText
=
textarea
.
value
.
substring
(
startPos
,
endPos
)
textBefore
=
textarea
.
value
.
substring
(
0
,
(
startPos
))
textAfter
=
textarea
.
value
.
substring
(
endPos
)
selection
=
{
before
:
textBefore
after
:
textAfter
...
...
@@ -37,10 +38,10 @@ markdown = ['$filter', '$timeout', '$window', ($filter, $timeout, $window) ->
insertMarkup
=
(
value
,
selectionStart
,
selectionEnd
)
->
# New value is set for the textarea
input
[
0
]
.
value
=
value
textarea
.
value
=
value
# A new selection is set, or the cursur is positioned inside the textarea.
input
[
0
]
.
selectionStart
=
selectionStart
input
[
0
]
.
selectionEnd
=
selectionEnd
textarea
.
selectionStart
=
selectionStart
textarea
.
selectionEnd
=
selectionEnd
applyInlineMarkup
=
(
markup
,
innertext
)
->
text
=
returnSelection
()
...
...
@@ -124,7 +125,7 @@ markdown = ['$filter', '$timeout', '$window', ($filter, $timeout, $window) ->
index
+=
1
else
newlinedetected
=
false
if
input
[
0
]
.
value
.
substring
(
index
-
1
).
charAt
(
0
)
==
"
\n
"
if
textarea
.
value
.
substring
(
index
-
1
).
charAt
(
0
)
==
"
\n
"
# Look to see if the selection falls at the beginning of a new line.
newstring
=
newstring
+
markup
newlinedetected
=
true
...
...
@@ -162,7 +163,7 @@ markdown = ['$filter', '$timeout', '$window', ($filter, $timeout, $window) ->
start
=
(
text
.
before
+
newstring
).
length
end
=
(
text
.
before
+
newstring
).
length
insertMarkup
(
value
,
start
,
end
)
else
if
input
[
0
]
.
value
.
substring
((
text
.
start
-
1
),
text
.
start
)
==
"
\n
"
else
if
textarea
.
value
.
substring
((
text
.
start
-
1
),
text
.
start
)
==
"
\n
"
# Edge case, no selection, the cursor is on a new line.
value
=
text
.
before
+
markup
+
text
.
selection
+
text
.
after
start
=
(
text
.
before
+
markup
).
length
...
...
@@ -232,10 +233,10 @@ markdown = ['$filter', '$timeout', '$window', ($filter, $timeout, $window) ->
if
!
scope
.
readonly
scope
.
preview
=
!
scope
.
preview
if
scope
.
preview
output
[
2
].
style
.
height
=
input
[
0
]
.
style
.
height
output
.
style
.
height
=
textarea
.
style
.
height
ctrl
.
$render
()
else
input
[
0
].
style
.
height
=
output
[
2
]
.
style
.
height
textarea
.
style
.
height
=
output
.
style
.
height
$timeout
->
input
.
focus
()
# Re-render the markdown when the view needs updating.
...
...
@@ -253,7 +254,7 @@ markdown = ['$filter', '$timeout', '$window', ($filter, $timeout, $window) ->
# Auto-focus the input box when the widget becomes editable.
scope
.
$watch
'readonly'
,
(
readonly
)
->
scope
.
preview
=
false
output
[
2
]
.
style
.
height
=
""
output
.
style
.
height
=
""
ctrl
.
$render
()
unless
readonly
then
$timeout
->
input
.
focus
()
...
...
h/static/styles/annotations.scss
View file @
eb0c163c
...
...
@@ -43,7 +43,7 @@
}
//
Markdown Editor Controls
////////////////////////
//
MARKDOWN EDITOR CONTROLS//
////////////////////////
[
markdown
]
{
.preview
{
overflow
:
auto
;
...
...
@@ -94,7 +94,7 @@
}
//
Privacy Controll
/////////////////////////
//
PRIVACY CONTROL///
/////////////////////////
privacy
{
position
:
relative
;
top
:
2px
;
...
...
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