-
Notifications
You must be signed in to change notification settings - Fork 453
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added custom Summernote library (wip, currently inactive)
- Loading branch information
1 parent
600179e
commit 62bae4e
Showing
62 changed files
with
8,406 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 29 additions & 22 deletions
51
src/Smartstore.Web/wwwroot/lib/editors/summernote/plugins/lang/de-DE.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,31 @@ | ||
$.extend(true, $.summernote.lang, { | ||
'de-DE': { /* German */ | ||
attrs: { | ||
cssClass: 'CSS Klasse', | ||
cssStyle: 'CSS Stil', | ||
rel: 'Rel', | ||
}, | ||
link: { | ||
browse: 'Durchsuchen' | ||
}, | ||
image: { | ||
imageProps: 'Bild Eigenschaften' | ||
}, | ||
tableStyles: { | ||
tooltip: "Tabellenstil", | ||
stylesExclusive: ["Standard", "Eingerahmt"], | ||
stylesInclusive: ["Streifen", "Kompakt", "Hover Effekt"] | ||
}, | ||
imageShapes: { | ||
tooltip: 'Stil', | ||
tooltipShapeOptions: ['Responsiv', 'Rahmen', 'Abgerundet', 'Kreis', 'Thumbnail', 'Schatten (klein)', 'Schatten (mittel)', 'Schatten (groß)'] | ||
} | ||
} | ||
'de-DE': { /* German */ | ||
common: { | ||
ok: 'OK', | ||
cancel: 'Abbrechen' | ||
}, | ||
font: { | ||
code: 'Code' | ||
}, | ||
attrs: { | ||
cssClass: 'CSS Klasse', | ||
cssStyle: 'CSS Stil', | ||
rel: 'Rel', | ||
}, | ||
link: { | ||
browse: 'Durchsuchen' | ||
}, | ||
image: { | ||
imageProps: 'Bild Eigenschaften' | ||
}, | ||
tableStyles: { | ||
tooltip: "Tabellenstil", | ||
stylesExclusive: ["Standard", "Eingerahmt"], | ||
stylesInclusive: ["Streifen", "Kompakt", "Hover Effekt"] | ||
}, | ||
imageShapes: { | ||
tooltip: 'Stil', | ||
tooltipShapeOptions: ['Responsiv', 'Rahmen', 'Abgerundet', 'Kreis', 'Thumbnail', 'Schatten (klein)', 'Schatten (mittel)', 'Schatten (groß)'] | ||
} | ||
} | ||
}); |
237 changes: 237 additions & 0 deletions
237
src/Smartstore.Web/wwwroot/lib/editors/summernote2/globalinit.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,237 @@ | ||
let summernote_global_config; | ||
let summernote_image_upload_url; | ||
|
||
(function () { | ||
const beautifyOpts = { | ||
indent_size: 2, | ||
indent_with_tabs: true, | ||
indent_char: " ", | ||
max_preserve_newlines: "2", | ||
preserve_newlines: true, | ||
keep_array_indentation: false, | ||
break_chained_methods: false, | ||
indent_scripts: "normal", | ||
brace_style: "collapse", | ||
space_before_conditional: true, | ||
unescape_strings: false, | ||
jslint_happy: false, | ||
end_with_newline: false, | ||
wrap_line_length: "140", | ||
indent_inner_html: true, | ||
comma_first: false, | ||
e4x: false, | ||
indent_empty_lines: false | ||
}; | ||
|
||
summernote_global_config = { | ||
disableDragAndDrop: false, | ||
dialogsInBody: true, | ||
container: 'body', | ||
dialogsFade: true, | ||
height: 300, | ||
prettifyHtml: true, | ||
popatmouse: true, | ||
hideArrow: false, | ||
recordEveryKeystroke: false, | ||
// TODO: Turn on spellCheck again | ||
spellCheck: false, | ||
callbacks: { | ||
onBlurCodeview(code, e) { | ||
// Summernote does not update WYSIWYG content on codable blur, | ||
// only when switched back to editor | ||
$(this).val(code); | ||
}, | ||
//onFileBrowse(e, mediaType, deferred) { | ||
// Smartstore.media.openFileManager({ | ||
// el: e.target, | ||
// type: mediaType, | ||
// backdrop: false, | ||
// onSelect: (files) => { | ||
// if (!files.length) { | ||
// deferred.reject(); | ||
// } | ||
// else { | ||
// deferred.resolve(files[0].url); | ||
// } | ||
// } | ||
// }); | ||
//}, | ||
onImageUpload(files) { | ||
if (summernote_image_upload_url) { | ||
sendFile(files[0], this); | ||
} | ||
}, | ||
onSanitizeHtml(html, opts) { | ||
if (opts.prettify && window.html_beautify) { | ||
return window.html_beautify(html, beautifyOpts); | ||
} | ||
return html; | ||
} | ||
}, | ||
toolbar: [ | ||
['edit', ['undo', 'redo']], | ||
['text', ['bold', 'italic', 'underline', 'moreFontStyles']], | ||
//['color', ['forecolor', 'backcolor']], | ||
//['font', ['fontname', 'x-color', 'fontsize']], | ||
['para', ['style', 'cssclass', 'ul', 'ol', 'paragraph', 'clear', 'cleaner']], | ||
['insert', ['link', 'image', 'video', 'table', 'hr']], | ||
['view', ['codeview', 'fullscreen', 'help']] | ||
], | ||
popover: { | ||
image: [ | ||
['custom', ['imageAttributes', 'link', 'unlink', 'imageShapes']], | ||
['imagesize', ['resizeFull', 'resizeHalf', 'resizeQuarter', 'resizeNone']], | ||
['float', ['floatLeft', 'floatRight', 'floatNone']], | ||
['remove', ['removeMedia']] | ||
], | ||
link: [ | ||
['link', ['linkDialogShow', 'unlink']] | ||
], | ||
table: [ | ||
['add', ['addRowDown', 'addRowUp', 'addColLeft', 'addColRight']], | ||
['delete', ['deleteRow', 'deleteCol', 'deleteTable']], | ||
['custom', ['tableStyles']] | ||
], | ||
air: [ | ||
['color', ['color']], | ||
['font', ['bold', 'underline', 'clear']], | ||
['para', ['ul', 'paragraph']], | ||
['table', ['table']], | ||
['insert', ['link', 'picture']] | ||
] | ||
}, | ||
styleTags: [ | ||
'p', | ||
'h1', 'h2', 'h3', 'h4', 'h5', 'h6', | ||
'pre', | ||
{ title: 'Blockquote', tag: 'blockquote', className: 'blockquote', value: 'blockquote' } | ||
], | ||
imageAttributes: { | ||
icon: '<i class="fa fa-pencil"/>', | ||
removeEmpty: true, // true = remove attributes | false = leave empty if present | ||
disableUpload: true // true = don't display Upload Options | Display Upload Options | ||
} | ||
}; | ||
|
||
if (CodeMirror?.hint) { | ||
const cmOptions = summernote_global_config.codemirror = { | ||
mode: "htmlmixed", | ||
theme: "eclipse", | ||
lineNumbers: true, | ||
lineWrapping: false, | ||
tabSize: 2, | ||
indentWithTabs: true, | ||
smartIndent: true, | ||
matchTags: true, | ||
matchBrackets: true, | ||
autoCloseTags: true, | ||
autoCloseBrackets: true, | ||
styleActiveLine: true, | ||
hintOptions: { | ||
closeCharacters: /[\s()\[\]{};:>,.|%]/, | ||
completeSingle: false | ||
} | ||
}; | ||
|
||
if (CodeMirror?.hint) { | ||
cmOptions.extraKeys = { | ||
"'.'": CodeMirror.hint.completeAfter, | ||
"'<'": CodeMirror.hint.completeAfter, | ||
"'/'": CodeMirror.hint.completeIfAfterLt, | ||
"' '": CodeMirror.hint.completeIfAfterSpace, | ||
"'='": CodeMirror.hint.completeIfInTag, | ||
"Ctrl-Space": "autocomplete", | ||
"F11": function (cm) { cm.setOption("fullScreen", !cm.getOption("fullScreen")); }, | ||
"Esc": function (cm) { if (cm.getOption("fullScreen")) cm.setOption("fullScreen", false); } | ||
} | ||
} | ||
} | ||
|
||
function sendFile(file, editor, welEditable) { | ||
data = new FormData(); | ||
data.append("file", file); | ||
data.append("a", "UPLOAD"); | ||
data.append("d", "file"); | ||
data.append("ext", true); | ||
|
||
$.ajax({ | ||
data: data, | ||
type: "POST", | ||
url: summernote_image_upload_url, | ||
cache: false, | ||
contentType: false, | ||
processData: false, | ||
success: function (result) { | ||
if (result.Success) { | ||
$(editor).summernote('insertImage', result.Url); | ||
} | ||
else { | ||
EventBroker.publish("message", { | ||
title: 'Image upload error', | ||
text: result.Message, | ||
type: 'error', | ||
hide: false | ||
}); | ||
} | ||
} | ||
}); | ||
} | ||
})(); | ||
|
||
// Initialize summernote | ||
$(function () { | ||
|
||
// Extend base language | ||
$.extend(true, $.summernote.lang, { | ||
'en-US': { | ||
common: { | ||
ok: 'OK', | ||
cancel: 'Cancel' | ||
}, | ||
font: { | ||
code: 'Code' | ||
}, | ||
attrs: { | ||
cssClass: 'CSS Class', | ||
cssStyle: 'CSS Style', | ||
rel: 'Rel', | ||
}, | ||
link: { | ||
browse: 'Browse' | ||
}, | ||
image: { | ||
imageProps: 'Image Attributes' | ||
}, | ||
imageShapes: { | ||
tooltip: 'Shape', | ||
tooltipShapeOptions: ['Responsive', 'Border', 'Rounded', 'Circle', 'Thumbnail', 'Shadow (small)', 'Shadow (medium)', 'Shadow (large)'] | ||
}, | ||
tableStyles: { | ||
tooltip: "Table style", | ||
stylesExclusive: ["Basic", "Bordered"], | ||
stylesInclusive: ["Striped", "Condensed", "Hoverable"] | ||
} | ||
} | ||
}); | ||
|
||
// Custom events | ||
// Editor toggling | ||
$(document).on('click', '.note-editor-preview', function (e) { | ||
var div = $(this); | ||
var textarea = $(div.data("target")); | ||
var lang = div.data("lang"); | ||
|
||
div.remove(); | ||
textarea | ||
.removeClass('d-none') | ||
.summernote($.extend(true, {}, summernote_global_config, { lang: lang, focus: true })); | ||
}); | ||
|
||
// Fix "CodeMirror too wide" issue | ||
$(document).on('click', '.note-toolbar .btn-codeview', function (e) { | ||
var wrapper = $(this).closest('.adminData'); | ||
if (wrapper.length) { | ||
wrapper.css('overflow-x', $(this).is('.active') ? 'auto' : ''); | ||
} | ||
}); | ||
}); |
Oops, something went wrong.