.pageFooter {
box-shadow: 0 0 10px rgba(0, 0, 0, .6);
}
+
+.codemirrorToolbar {
+ background-color: rgb(52, 73, 94);
+ display: flex;
+ flex-wrap: wrap;
+
+ > li {
+ flex: 0 0 auto;
+ margin-bottom: 1px;
+
+ > a {
+ color: rgb(255, 255, 255);
+ display: block;
+ font-size: 12px;
+ outline: none;
+ padding: 10px;
+ text-align: center;
+ font-weight: 400;
+
+ &:hover {
+ background-color: rgb(19, 34, 48);
+ }
+
+ .icon {
+ color: inherit;
+ }
+ }
+ }
+}
-<textarea name="content[{@$languageID}]" id="content{@$languageID}">{if !$content[$languageID]|empty}{$content[$languageID]}{/if}</textarea>
-{if $pageType == 'text'}
- {capture append='__redactorJavaScript'}, '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabPage.js?v={@LAST_UPDATE_TIME}'{/capture}
- {capture append='__redactorConfig'}
+{assign var='__pageContentID' value='content'|concat:$languageID}
+
+<script data-relocate="true">
+ require(['Language'], function (Language) {
Language.addObject({
'wcf.page.search': '{lang}wcf.page.search{/lang}',
'wcf.page.search.error.tooShort': '{lang}wcf.page.search.error.tooShort{/lang}',
'wcf.page.search.results': '{lang}wcf.page.search.results{/lang}',
'wcf.page.search.results.description': '{lang}wcf.page.search.results.description{/lang}'
});
-
+ })
+</script>
+
+{if $pageType == 'html' || $pageType == 'tpl'}
+ <ul class="codemirrorToolbar">
+ <li><a href="#" id="codemirror-{@$__pageContentID}-media" class="jsTooltip" title="{lang}wcf.editor.button.media{/lang}"><span class="icon icon16 fa-file-o"></span></a></li>
+ <li><a href="#" id="codemirror-{@$__pageContentID}-page" class="jsTooltip" title="{lang}wcf.editor.button.page{/lang}"><span class="icon icon16 fa-file-text-o"></span></a></li>
+ </ul>
+ <script data-relocate="true">
+ require(['WoltLab/WCF/Acp/Ui/CodeMirror/Media', 'WoltLab/WCF/Acp/Ui/CodeMirror/Page'], function(AcpUiCodeMirrorMedia, AcpUiCodeMirrorPage) {
+ new AcpUiCodeMirrorMedia('{@$__pageContentID}');
+ new AcpUiCodeMirrorPage('{@$__pageContentID}');
+ });
+ </script>
+{/if}
+
+<textarea name="content[{@$languageID}]" id="{@$__pageContentID}">{if !$content[$languageID]|empty}{$content[$languageID]}{/if}</textarea>
+{if $pageType == 'text'}
+ {capture append='__redactorJavaScript'}, '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabPage.js?v={@LAST_UPDATE_TIME}'{/capture}
+ {capture append='__redactorConfig'}
buttonOptions.woltlabPage = { icon: 'fa-file-text-o', title: '{lang}wcf.editor.button.page{/lang}' };
buttons.push('woltlabPage');
config.plugins.push('WoltLabPage');
{/capture}
- {include file='wysiwyg' wysiwygSelector='content'|concat:$languageID}
+ {include file='wysiwyg' wysiwygSelector=$__pageContentID}
{elseif $pageType == 'html'}
{include file='codemirror' codemirrorMode='htmlmixed' codemirrorSelector='#content'|concat:$languageID}
{elseif $pageType == 'tpl'}
--- /dev/null
+define(['WoltLab/WCF/Media/Manager/Editor'], function(MediaManagerEditor) {
+ "use strict";
+
+ function AcpUiCodeMirrorMedia(elementId) { this.init(elementId); }
+ AcpUiCodeMirrorMedia.prototype = {
+ init: function(elementId) {
+ this._element = elById(elementId);
+
+ var button = elById('codemirror-' + elementId + '-media');
+ button.classList.add(button.id);
+
+ new MediaManagerEditor({
+ buttonClass: button.id,
+ callbackInsert: this._insert.bind(this),
+ editor: null
+ });
+ },
+
+ _insert: function (mediaList, insertType, thumbnailSize) {
+ var content = '';
+
+ if (insertType === 'gallery') {
+ var mediaIds = [];
+ mediaList.forEach(function(item) {
+ mediaIds.push(item.mediaID);
+ });
+
+ content = '{{ mediaGallery="' + mediaIds.join(',') + '" }}';
+ }
+ else {
+ mediaList.forEach(function(item) {
+ content += '{{ media="' + item.mediaID + '" size="' + thumbnailSize + '" }}';
+ });
+ }
+
+ this._element.codemirror.replaceSelection(content);
+ }
+ };
+
+ return AcpUiCodeMirrorMedia;
+});
--- /dev/null
+define(['WoltLab/WCF/Ui/Page/Search'], function(UiPageSearch) {
+ "use strict";
+
+ function AcpUiCodeMirrorPage(elementId) { this.init(elementId); }
+ AcpUiCodeMirrorPage.prototype = {
+ init: function(elementId) {
+ this._element = elById(elementId);
+
+ elById('codemirror-' + elementId + '-page').addEventListener(WCF_CLICK_EVENT, this._click.bind(this));
+ },
+
+ _click: function (event) {
+ event.preventDefault();
+
+ UiPageSearch.open(this._insert.bind(this));
+ },
+
+ _insert: function (pageID) {
+ this._element.codemirror.replaceSelection('{{ page="' + pageID + '" }}');
+ }
+ };
+
+ return AcpUiCodeMirrorPage;
+});