Some features are still missing and have not been implemented yet, this commit ensures that everyone is able to test the current implementation.
var __REDACTOR_SMILIES = { {implode from=$__wcf->getSmileyCache()->getCategorySmilies() item=smiley}'{@$smiley->smileyCode|encodeJS}': '{@$smiley->getURL()|encodeJS}'{/implode} };
var __REDACTOR_SOURCE_BBCODES = [ {implode from=$__wcf->getBBCodeHandler()->getSourceBBCodes() item=__bbcode}'{@$__bbcode->bbcodeTag}'{/implode} ];
var __REDACTOR_CODE_HIGHLIGHTERS = { {implode from=$__wcf->getBBCodeHandler()->getHighlighters() item=__highlighter}'{@$__highlighter}': '{lang}wcf.bbcode.code.{@$__highlighter}.title{/lang}'{/implode} };
-</script>
-<script data-relocate="true">
-$(function() {
- WCF.Language.addObject({
+var __REDACTOR_AMD_DEPENDENCIES = { };
+
+require(['Language', 'WoltLab/WCF/BBCode/FromHtml', 'WoltLab/WCF/BBCode/ToHtml'], function(Language, BBCodeFromHTML, BBCodeToHTML) {
+ __REDACTOR_AMD_DEPENDENCIES = {
+ BBCodeFromHTML: BBCodeFromHTML,
+ BBCodeToHTML: BBCodeToHTML
+ };
+
+ Language.addObject({
'wcf.attachment.dragAndDrop.dropHere': '{lang}wcf.attachment.dragAndDrop.dropHere{/lang}',
'wcf.attachment.dragAndDrop.dropNow': '{lang}wcf.attachment.dragAndDrop.dropNow{/lang}',
'wcf.bbcode.button.fontColor': '{lang}wcf.bbcode.button.fontColor{/lang}',
convertVideoLinks: false,
direction: '{lang}wcf.global.pageDirection{/lang}',
lang: '{@$__wcf->getLanguage()->getFixedLanguageCode()}',
+ linebreaks: true,
maxHeight: 500,
minHeight: 200,
plugins: [ 'wutil', 'wmonkeypatch', 'wbutton', 'wbbcode', 'wfontcolor', 'wfontfamily', 'wfontsize' ],
$config.plugins.splice(2, 0, 'table');
{/if}
+ // TODO: is this still required?
if ($.browser.iOS) {
// using a zero-width space breaks iOS' detection of the start of a sentence, causing the first word to be lowercased
$config.emptyHtml = '<p><br></p>';
/**
* Converts source contents from HTML into BBCode.
*
- * @param string html
+ * @param string message
*/
- convertFromHtml: function(html) {
+ convertFromHtml: function(message) {
// DEBUG ONLY
- return this.opts.woltlab.bbcode.fromHtml.convert(html);
+ return __REDACTOR_AMD_DEPENDENCIES.BBCodeFromHTML.convert(message);
var $searchFor = [ ];
/**
* Converts source contents from BBCode to HTML.
*
- * @param string data
+ * @param string message
*/
- convertToHtml: function(data) {
+ convertToHtml: function(message) {
// DEBUG ONLY
- return this.opts.woltlab.bbcode.toHtml.convert(data);
+ return __REDACTOR_AMD_DEPENDENCIES.BBCodeToHTML.convert(message);
WCF.System.Event.fireEvent('com.woltlab.wcf.redactor', 'beforeConvertToHtml', { data: data });
* Sets the selection after the last direct children of the editor.
*/
selectionEndOfEditor: function() {
- this.focus.setEnd();
-
- var $lastChild = this.$editor.children(':last')[0];
- if ($lastChild.tagName === 'P') {
- // sometimes the last <p> is just empty, causing the method to fail
- if ($lastChild.innerHTML === '') {
- $lastChild.remove();
- $lastChild = $(this.opts.emptyHtml).appendTo(this.$editor)[0];
- }
+ var lastChild = this.$editor[0].lastElementChild;
+ if (lastChild === null || lastChild.nodeName === 'BLOCKQUOTE' || (lastChild.nodeName === 'DIV' && lastChild.classList.contains('codeBox'))) {
+ var element = this.utils.createSpaceElement();
+ this.$editor[0].appendChild(element);
- if ($lastChild.lastChild.nodeType === Element.TEXT_NODE) {
- this.caret.set($lastChild.lastChild, $lastChild.lastChild.length, $lastChild.lastChild, $lastChild.lastChild.length);
- }
- else {
- this.caret.setEnd($lastChild);
- }
+ this.caret.setEnd(element);
+ this.wutil.saveSelection();
}
else {
- this.wutil.setCaretAfter($lastChild);
+ this.focus.setEnd();
}
-
- this.wutil.saveSelection();
},
/**
}
message = stack.join('');
- var x = message;
- console.debug(x);
+
message = message.replace(/\n/g, '<br>');
return message;
* @param {object<string, *>} options confirmation options
*/
show: function(options) {
+ if (UIDialog === undefined) UIDialog = require('UI/Dialog');
+
if (_active) {
return;
}