Added autosave support for ACP
authorAlexander Ebert <ebert@woltlab.com>
Fri, 29 Jul 2016 14:35:38 +0000 (16:35 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Fri, 29 Jul 2016 14:35:45 +0000 (16:35 +0200)
wcfsetup/install/files/acp/templates/__boxAddContent.tpl
wcfsetup/install/files/acp/templates/__pageAddContent.tpl
wcfsetup/install/files/acp/templates/articleAdd.tpl
wcfsetup/install/files/acp/templates/wysiwyg.tpl

index 9813c547ed4d18862a935863a06dce0364ca7852..bbb9e8c7fc71adc94c5c274c9940042a4f11c7b5 100644 (file)
@@ -1,4 +1,8 @@
-<textarea name="content[{@$languageID}]" id="content{@$languageID}">{if !$content[$languageID]|empty}{$content[$languageID]}{/if}</textarea>
+<textarea name="content[{@$languageID}]" id="content{@$languageID}"
+       {if $boxType == 'text'}
+               class="wysiwygTextarea" data-autosave="com.woltlab.wcf.box{$action|ucfirst}-{if $action == 'edit'}{@$boxID}{else}0{/if}-{@$languageID}"
+       {/if}
+>{if !$content[$languageID]|empty}{$content[$languageID]}{/if}</textarea>
 {if $boxType == 'text'}
        {include file='wysiwyg' wysiwygSelector='content'|concat:$languageID}
 {elseif $boxType == 'html'}
index da388b07a7f9bac610576096b6a246837b9e9078..015ba9b205c348ef5961376232c19854347269c2 100644 (file)
        </script>
 {/if}
 
-<textarea name="content[{@$languageID}]" id="{@$__pageContentID}">{if !$content[$languageID]|empty}{$content[$languageID]}{/if}</textarea>
+<textarea name="content[{@$languageID}]" id="{@$__pageContentID}"
+          {if $pageType == 'text'}
+                 class="wysiwygTextarea" data-autosave="com.woltlab.wcf.page{$action|ucfirst}-{if $action == 'edit'}{@$pageID}{else}0{/if}-{@$languageID}"
+          {/if}
+>{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'}
index e11fb68fd7742c06ea24f6796c165893c46d7c1a..2d4b8ba513ebde930841cfd1c4c37e050ead5fb0 100644 (file)
                        <dl{if $errorField == 'content'} class="formError"{/if}>
                                <dt><label for="content0">{lang}wcf.acp.article.content{/lang}</label></dt>
                                <dd>
-                                       <textarea name="content[0]" id="content0" rows="10">{if !$content[0]|empty}{$content[0]}{/if}</textarea>
+                                       <textarea name="content[0]" id="content0" class="wysiwygTextarea" data-autosave="com.woltlab.wcf.article{$action|ucfirst}-{if $action == 'edit'}{@$articleID}{else}0{/if}-0">{if !$content[0]|empty}{$content[0]}{/if}</textarea>
                                        {include file='wysiwyg' wysiwygSelector='content0'}
                                        {if $errorField == 'content'}
                                                <small class="innerError">
                                                <dl{if $errorField == 'content'|concat:$availableLanguage->languageID} class="formError"{/if}>
                                                        <dt><label for="content{@$availableLanguage->languageID}">{lang}wcf.acp.article.content{/lang}</label></dt>
                                                        <dd>
-                                                               <textarea name="content[{@$availableLanguage->languageID}]" id="content{@$availableLanguage->languageID}" rows="10">{if !$content[$availableLanguage->languageID]|empty}{$content[$availableLanguage->languageID]}{/if}</textarea>
+                                                               <textarea name="content[{@$availableLanguage->languageID}]" id="content{@$availableLanguage->languageID}" class="wysiwygTextarea" data-autosave="com.woltlab.wcf.article{$action|ucfirst}-{if $action == 'edit'}{@$articleID}{else}0{/if}-{@$availableLanguage->languageID}">{if !$content[$availableLanguage->languageID]|empty}{$content[$availableLanguage->languageID]}{/if}</textarea>
                                                                {include file='wysiwyg' wysiwygSelector='content'|concat:$availableLanguage->languageID}
                                                                {if $errorField == 'content'|concat:$availableLanguage->languageID}
                                                                        <small class="innerError">
index cd19fe024db6e54e1579c8ad4d6a2a198241fd87..e7bb151a13dac2ca4f56f758437d79a81e3bf7c9 100644 (file)
@@ -20,6 +20,7 @@
                        {* WoltLab *}
                        '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabAlignment.js?v={@LAST_UPDATE_TIME}',
                        '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabAttachment.js?v={@LAST_UPDATE_TIME}',
+                       '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabAutosave.js?v={@LAST_UPDATE_TIME}',
                        '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabBlock.js?v={@LAST_UPDATE_TIME}',
                        '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabButton.js?v={@LAST_UPDATE_TIME}',
                        '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabCode.js?v={@LAST_UPDATE_TIME}',
@@ -47,7 +48,7 @@
                
                {event name='redactorJavaScript'}
        ], function () {
-               require(['Language', 'WoltLab/WCF/Ui/Redactor/Metacode'], function(Language, UiRedactorMetacode) {
+               require(['Language', 'WoltLab/WCF/Ui/Redactor/Autosave', 'WoltLab/WCF/Ui/Redactor/Metacode'], function(Language, UiRedactorAutosave, UiRedactorMetacode) {
                        Language.addObject({
                                'wcf.editor.code.edit': '{lang}wcf.editor.code.edit{/lang}',
                                'wcf.editor.code.file': '{lang}wcf.editor.code.file{/lang}',
@@ -79,6 +80,7 @@
                                'wcf.editor.quote.title': '{lang __literal=true}wcf.editor.quote.title{/lang}',
                                'wcf.editor.quote.url': '{lang}wcf.editor.quote.url{/lang}',
                                'wcf.editor.quote.url.description': '{lang}wcf.editor.quote.url.description{/lang}',
+                               'wcf.editor.quote.url.error.invalid': '{lang}wcf.editor.quote.url.error.invalid{/lang}',
                                
                                'wcf.editor.spoiler.label': '{lang}wcf.editor.spoiler.label{/lang}',
                                'wcf.editor.spoiler.label.description': '{lang}wcf.editor.spoiler.label.description{/lang}',
                        var element = elById('{if $wysiwygSelector|isset}{$wysiwygSelector|encodeJS}{else}text{/if}');
                        UiRedactorMetacode.convert(element);
                        
-                       var autosave = elData(element, 'autosave') || '';
+                       var autosave = elData(element, 'autosave') || null;
                        if (autosave) {
-                               element.removeAttribute('data-autosave');
+                               autosave = new UiRedactorAutosave(element);
+                               element.value = autosave.getInitialValue();
                        }
                        
                        var config = {
                                        // WoltLab core
                                        'WoltLabAlignment',
                                        'WoltLabAttachment',
+                                       'WoltLabAutosave',
                                        'WoltLabCode',
                                        'WoltLabColor',
                                        'WoltLabDropdown',