Initial commit

This commit is contained in:
2018-06-17 19:53:51 +02:00
commit 9faf28fd96
12 changed files with 7221 additions and 0 deletions

15
src/coffee/script.coffee Normal file
View File

@ -0,0 +1,15 @@
$(document).ready ->
$('.editor').summernote {
minHeight: 300,
toolbar: [
['style', ['bold', 'italic', 'underline', 'clear']],
['font', ['strikethrough', 'superscript', 'subscript']],
['fontsize', ['fontsize']],
['color', ['color']],
['para', ['ul', 'ol', 'paragraph']],
['height', ['height']],
['codeWrapper', ['codeWrapper']],
['insert', ['gxcode']],
['misc', ['codeview']]
]
}

View File

@ -0,0 +1,111 @@
(
((factory) ->
if typeof define is 'function' and define.amd
define ['jquery'], factory
else if typeof module is 'object' and module.exports
module.exports = factory require 'jquery'
else
factory window.jQuery
return
) (($) ->
$.extend $.summernote.options, {
codewrapper: {
menu: [
'Update',
'javascript',
'css',
'html'
]
}
},
$.extend $.summernote.plugins, {
'codeWrapper': (context) ->
this.events = {
'summernote.enter': (u, e, $editable) ->
selection = window.getSelection()
correct = selection.anchorNode.nodeName is "CODE" or selection.anchorNode.parentNode.nodeName is "CODE"
if correct
e.preventDefault()
range = window.getSelection().getRangeAt 0
range.deleteContents()
range.insertNode document.createElement('br')
range.addRange 4
range.collapse()
return
'summernote.keydown': (u, e) ->
selection = window.getSelection()
correct = selection.anchorNode.nodeName is "CODE" or selection.anchorNode.parentNode.nodeName is "CODE"
if e.key is 'Tab' and correct
e.preventDefault()
range = selection.getRangeAt 0
range.deleteContents()
range.insertNode document.createTextNode(' ')
range.collapse()
return
}
ui = $.summernote.ui
options = context.options
context.memo 'button.codeWrapper', ->
button = ui.buttonGroup [
ui.button {
container: false
contents: '<i /> Code'
tooltip: 'Code Wrapper'
data: {
toggle: 'dropdown'
}
}
ui.dropdown {
items: options.codewrapper.menu
click: (e) ->
button = e.target.innerText
highlight = window.getSelection()
correct = highlight.anchorNode.nodeName is "CODE" or highlight.anchorNode.parentNode.nodeName is "CODE"
if button is "Update"
$('pre code').each (i, code) ->
node = document.createElement 'code'
code.childNodes.forEach (el) ->
if el.nodeName is '#text' then node.innerHTML += el.wholeText
else if el.nodeName is 'BR' then node.innerHTML += '<br />'
else node.innerHTML += el.innerText
return
node.classList = code.classList
node.classList.remove 'hljs'
parent = code.parentNode
parent.removeChild code
if hljs then hljs.highlightBlock node
parent.appendChild node
return
else if correct then null
else
pre = document.createElement 'pre'
pre.setAttribute 'autocomplete', 'off'
pre.setAttribute 'spellcheck', false
code = document.createElement 'code'
code.classList.add button
code.innerText = highlight
pre.appendChild code
range = highlight.getRangeAt 0
range.deleteContents()
range.insertNode pre
if hljs then hljs.highlightBlock code
range.collapse()
return
}
]
button.render()
@destroy = ->
@$panel.remove()
@$panel = null
return
return
}
return
)
)

66
src/css/androidstudio.css Normal file
View File

@ -0,0 +1,66 @@
/*
Date: 24 Fev 2015
Author: Pedro Oliveira <kanytu@gmail . com>
*/
.hljs {
color: #a9b7c6;
background: #282b2e;
display: block;
overflow-x: auto;
padding: 0.5em;
}
.hljs-number,
.hljs-literal,
.hljs-symbol,
.hljs-bullet {
color: #6897BB;
}
.hljs-keyword,
.hljs-selector-tag,
.hljs-deletion {
color: #cc7832;
}
.hljs-variable,
.hljs-template-variable,
.hljs-link {
color: #629755;
}
.hljs-comment,
.hljs-quote {
color: #808080;
}
.hljs-meta {
color: #bbb529;
}
.hljs-string,
.hljs-attribute,
.hljs-addition {
color: #6A8759;
}
.hljs-section,
.hljs-title,
.hljs-type {
color: #ffc66d;
}
.hljs-name,
.hljs-selector-id,
.hljs-selector-class {
color: #e8bf6a;
}
.hljs-emphasis {
font-style: italic;
}
.hljs-strong {
font-weight: bold;
}

File diff suppressed because one or more lines are too long

2
src/js/highlight.pack.js Normal file

File diff suppressed because one or more lines are too long

28
src/pug/index.pug Normal file
View File

@ -0,0 +1,28 @@
<!DOCTYPE html>
html(lang="en")
head
meta(charset="UTF-8")
meta(name="viewport", content="width=device-width, initial-scale=1.0")
meta(http-equiv="X-UA-Compatible", content="ie=edge")
title Summernote Code Wrapper
link(rel="stylesheet" href="css/bootstrap.min.css")
link(rel="stylesheet" href="css/androidstudio.css")
link(rel="stylesheet", href="css/summernote-bs4.css")
body
.container
.row
.editor.col-md-6
.col-md-6.markdown-body#result
script(src="js/jquery.min.js")
script(src="js/popper.min.js")
script(src="js/bootstrap.min.js")
script(src="js/highlight.pack.js")
script(src="js/summernote-bs4.min.js")
script(src="js/summernote-codewrapper.js")
script(src="js/script.js")