fix wysiwyg translation
parent
0047dd07c5
commit
cf0a341058
|
@ -130,6 +130,53 @@ MarkitupDirective = ($rootscope, $rs, $selectedText, $template, $compile, $trans
|
||||||
else
|
else
|
||||||
return cursorPosition
|
return cursorPosition
|
||||||
|
|
||||||
|
prepareUrlFormatting = (markItUp) ->
|
||||||
|
regex = /(<<<|>>>)/gi
|
||||||
|
result = 0
|
||||||
|
indices = []
|
||||||
|
(indices.push(result.index)) while ( (result = regex.exec(markItUp.textarea.value)) )
|
||||||
|
markItUp.donotparse = indices
|
||||||
|
|
||||||
|
urlFormatting = (markItUp) ->
|
||||||
|
console.log(markItUp.donotparse)
|
||||||
|
regex = /<<</gi
|
||||||
|
result = 0
|
||||||
|
startIndex = 0
|
||||||
|
|
||||||
|
loop
|
||||||
|
result = regex.exec(markItUp.textarea.value)
|
||||||
|
break if !result
|
||||||
|
if result.index not in markItUp.donotparse
|
||||||
|
startIndex = result.index
|
||||||
|
break
|
||||||
|
|
||||||
|
regex = />>>/gi
|
||||||
|
endIndex = 0
|
||||||
|
loop
|
||||||
|
result = regex.exec(markItUp.textarea.value)
|
||||||
|
break if !result
|
||||||
|
if result.index not in markItUp.donotparse
|
||||||
|
endIndex = result.index
|
||||||
|
break
|
||||||
|
|
||||||
|
value = markItUp.textarea.value
|
||||||
|
url = value.substring(startIndex, endIndex).replace('<<<', '').replace('>>>', '')
|
||||||
|
url = url.replace('(', '%28').replace(')', '%29')
|
||||||
|
url = url.replace('[', '%5B').replace(']', '%5D')
|
||||||
|
value = value.substring(0, startIndex) + url + value.substring(endIndex+3, value.length)
|
||||||
|
markItUp.textarea.value = value
|
||||||
|
markItUp.donotparse = undefined
|
||||||
|
|
||||||
|
markdownTitle = (markItUp, char) ->
|
||||||
|
heading = ""
|
||||||
|
n = $.trim(markItUp.selection or markItUp.placeHolder).length
|
||||||
|
|
||||||
|
for i in [0..n-1]
|
||||||
|
heading += char
|
||||||
|
|
||||||
|
return "\n"+heading+"\n"
|
||||||
|
|
||||||
|
renderMarkItUp = () ->
|
||||||
markdownSettings =
|
markdownSettings =
|
||||||
nameSpace: "markdown"
|
nameSpace: "markdown"
|
||||||
onShiftEnter: {keepDefault:false, openWith:"\n\n"}
|
onShiftEnter: {keepDefault:false, openWith:"\n\n"}
|
||||||
|
@ -293,59 +340,20 @@ MarkitupDirective = ($rootscope, $rs, $selectedText, $template, $compile, $trans
|
||||||
target = angular.element(event.textarea)
|
target = angular.element(event.textarea)
|
||||||
$model.$setViewValue(target.val())
|
$model.$setViewValue(target.val())
|
||||||
|
|
||||||
prepareUrlFormatting = (markItUp) ->
|
element
|
||||||
regex = /(<<<|>>>)/gi
|
.markItUpRemove()
|
||||||
result = 0
|
.markItUp(markdownSettings)
|
||||||
indices = []
|
|
||||||
(indices.push(result.index)) while ( (result = regex.exec(markItUp.textarea.value)) )
|
|
||||||
markItUp.donotparse = indices
|
|
||||||
|
|
||||||
urlFormatting = (markItUp) ->
|
renderMarkItUp()
|
||||||
console.log(markItUp.donotparse)
|
|
||||||
regex = /<<</gi
|
|
||||||
result = 0
|
|
||||||
startIndex = 0
|
|
||||||
|
|
||||||
loop
|
unbind = $rootscope.$on "$translateChangeEnd", renderMarkItUp
|
||||||
result = regex.exec(markItUp.textarea.value)
|
|
||||||
break if !result
|
|
||||||
if result.index not in markItUp.donotparse
|
|
||||||
startIndex = result.index
|
|
||||||
break
|
|
||||||
|
|
||||||
regex = />>>/gi
|
|
||||||
endIndex = 0
|
|
||||||
loop
|
|
||||||
result = regex.exec(markItUp.textarea.value)
|
|
||||||
break if !result
|
|
||||||
if result.index not in markItUp.donotparse
|
|
||||||
endIndex = result.index
|
|
||||||
break
|
|
||||||
|
|
||||||
value = markItUp.textarea.value
|
|
||||||
url = value.substring(startIndex, endIndex).replace('<<<', '').replace('>>>', '')
|
|
||||||
url = url.replace('(', '%28').replace(')', '%29')
|
|
||||||
url = url.replace('[', '%5B').replace(']', '%5D')
|
|
||||||
value = value.substring(0, startIndex) + url + value.substring(endIndex+3, value.length)
|
|
||||||
markItUp.textarea.value = value
|
|
||||||
markItUp.donotparse = undefined
|
|
||||||
|
|
||||||
markdownTitle = (markItUp, char) ->
|
|
||||||
heading = ""
|
|
||||||
n = $.trim(markItUp.selection or markItUp.placeHolder).length
|
|
||||||
|
|
||||||
for i in [0..n-1]
|
|
||||||
heading += char
|
|
||||||
|
|
||||||
return "\n"+heading+"\n"
|
|
||||||
|
|
||||||
element.markItUp(markdownSettings)
|
|
||||||
|
|
||||||
element.on "keypress", (event) ->
|
element.on "keypress", (event) ->
|
||||||
$scope.$apply()
|
$scope.$apply()
|
||||||
|
|
||||||
$scope.$on "$destroy", ->
|
$scope.$on "$destroy", ->
|
||||||
$el.off()
|
$el.off()
|
||||||
|
unbind()
|
||||||
|
|
||||||
return {link:link, require:"ngModel"}
|
return {link:link, require:"ngModel"}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue