fix wysiwyg translation
parent
0047dd07c5
commit
cf0a341058
|
@ -130,6 +130,53 @@ MarkitupDirective = ($rootscope, $rs, $selectedText, $template, $compile, $trans
|
|||
else
|
||||
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 =
|
||||
nameSpace: "markdown"
|
||||
onShiftEnter: {keepDefault:false, openWith:"\n\n"}
|
||||
|
@ -293,59 +340,20 @@ MarkitupDirective = ($rootscope, $rs, $selectedText, $template, $compile, $trans
|
|||
target = angular.element(event.textarea)
|
||||
$model.$setViewValue(target.val())
|
||||
|
||||
prepareUrlFormatting = (markItUp) ->
|
||||
regex = /(<<<|>>>)/gi
|
||||
result = 0
|
||||
indices = []
|
||||
(indices.push(result.index)) while ( (result = regex.exec(markItUp.textarea.value)) )
|
||||
markItUp.donotparse = indices
|
||||
element
|
||||
.markItUpRemove()
|
||||
.markItUp(markdownSettings)
|
||||
|
||||
urlFormatting = (markItUp) ->
|
||||
console.log(markItUp.donotparse)
|
||||
regex = /<<</gi
|
||||
result = 0
|
||||
startIndex = 0
|
||||
renderMarkItUp()
|
||||
|
||||
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"
|
||||
|
||||
element.markItUp(markdownSettings)
|
||||
unbind = $rootscope.$on "$translateChangeEnd", renderMarkItUp
|
||||
|
||||
element.on "keypress", (event) ->
|
||||
$scope.$apply()
|
||||
|
||||
$scope.$on "$destroy", ->
|
||||
$el.off()
|
||||
unbind()
|
||||
|
||||
return {link:link, require:"ngModel"}
|
||||
|
||||
|
|
Loading…
Reference in New Issue