mirror of
https://github.com/documize/community.git
synced 2025-07-19 21:29:42 +02:00
Allow rich rext for Site Message and Space Desc
Closes #291 Style both site-wide message and per space descriptions using the fully-featured rich text editor.
This commit is contained in:
parent
8970a21b58
commit
5c1ad25dc9
8 changed files with 156 additions and 10 deletions
|
@ -14,6 +14,7 @@ import { empty, and } from '@ember/object/computed';
|
||||||
import { isEmpty } from '@ember/utils';
|
import { isEmpty } from '@ember/utils';
|
||||||
import { set } from '@ember/object';
|
import { set } from '@ember/object';
|
||||||
import { inject as service } from '@ember/service';
|
import { inject as service } from '@ember/service';
|
||||||
|
import { schedule } from '@ember/runloop';
|
||||||
import Notifier from '../../mixins/notifier';
|
import Notifier from '../../mixins/notifier';
|
||||||
import Component from '@ember/component';
|
import Component from '@ember/component';
|
||||||
|
|
||||||
|
@ -31,6 +32,7 @@ export default Component.extend(Notifier, {
|
||||||
|
|
||||||
didReceiveAttrs() {
|
didReceiveAttrs() {
|
||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
|
|
||||||
this.set('maxTags', this.get('model.general.maxTags'));
|
this.set('maxTags', this.get('model.general.maxTags'));
|
||||||
this.set('domain', this.get('model.general.domain'));
|
this.set('domain', this.get('model.general.domain'));
|
||||||
},
|
},
|
||||||
|
@ -80,6 +82,69 @@ export default Component.extend(Notifier, {
|
||||||
dzone.removeFile(file);
|
dzone.removeFile(file);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
schedule('afterRender', () => {
|
||||||
|
let options = {
|
||||||
|
cache_suffix: '?v=510',
|
||||||
|
selector: '#editor-message',
|
||||||
|
relative_urls: false,
|
||||||
|
browser_spellcheck: true,
|
||||||
|
contextmenu: false,
|
||||||
|
statusbar: false,
|
||||||
|
inline: false,
|
||||||
|
paste_data_images: true,
|
||||||
|
images_upload_handler: function (blobInfo, success, failure) { // eslint-disable-line no-unused-vars
|
||||||
|
success("data:" + blobInfo.blob().type + ";base64," + blobInfo.base64());
|
||||||
|
},
|
||||||
|
image_advtab: true,
|
||||||
|
image_caption: true,
|
||||||
|
media_live_embeds: true,
|
||||||
|
theme: 'silver',
|
||||||
|
skin: 'oxide',
|
||||||
|
entity_encoding: 'raw',
|
||||||
|
extended_valid_elements: 'b,i,b/strong,i/em',
|
||||||
|
fontsize_formats:
|
||||||
|
'8px 10px 12px 14px 16px 18px 20px 22px 24px 26px 28px 30px 32px 34px 36px 38px 40px 42px 44px 46px 48px 50px 52px 54px 56px 58px 60px 70px 80px 90px 100px',
|
||||||
|
formats: {
|
||||||
|
bold: {
|
||||||
|
inline: 'b'
|
||||||
|
},
|
||||||
|
italic: {
|
||||||
|
inline: 'i'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
plugins: [
|
||||||
|
'advlist autolink autoresize lists link image charmap print hr pagebreak',
|
||||||
|
'searchreplace wordcount visualblocks visualchars',
|
||||||
|
'insertdatetime media nonbreaking save table directionality',
|
||||||
|
'template paste textpattern imagetools'
|
||||||
|
],
|
||||||
|
menu: {},
|
||||||
|
menubar: false,
|
||||||
|
toolbar: [
|
||||||
|
'formatselect fontsizeselect | bold italic underline strikethrough superscript subscript blockquote | forecolor backcolor link unlink',
|
||||||
|
'outdent indent bullist numlist | alignleft aligncenter alignright alignjustify | table uploadimage image media'
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
if (typeof tinymce === 'undefined') {
|
||||||
|
$.getScript('/tinymce/tinymce.min.js?v=510', function () {
|
||||||
|
window.tinymce.dom.Event.domLoaded = true;
|
||||||
|
tinymce.baseURL = '//' + window.location.host + '/tinymce';
|
||||||
|
tinymce.suffix = '.min';
|
||||||
|
tinymce.init(options);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
tinymce.init(options);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
willDestroyElement() {
|
||||||
|
this._super(...arguments);
|
||||||
|
|
||||||
|
tinymce.EditorManager.execCommand('mceRemoveEditor', true, 'editor-message');
|
||||||
},
|
},
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
|
@ -91,14 +156,17 @@ export default Component.extend(Notifier, {
|
||||||
},
|
},
|
||||||
|
|
||||||
save() {
|
save() {
|
||||||
|
let editor = tinymce.EditorManager.get('editor-message');
|
||||||
|
let message = editor.getContent();
|
||||||
|
|
||||||
if (isEmpty(this.get('model.general.title'))) {
|
if (isEmpty(this.get('model.general.title'))) {
|
||||||
set(this, 'titleError', true);
|
set(this, 'titleError', true);
|
||||||
return $("#siteTitle").focus();
|
return $("#siteTitle").focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isEmpty(this.get('model.general.message'))) {
|
if (isEmpty(message)) {
|
||||||
set(this, 'messageError', true);
|
set(this, 'messageError', true);
|
||||||
return $("#siteMessage").focus();
|
return editor.focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isEmpty(this.get('model.general.conversionEndpoint'))) {
|
if (isEmpty(this.get('model.general.conversionEndpoint'))) {
|
||||||
|
@ -112,6 +180,7 @@ export default Component.extend(Notifier, {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.set('model.general.maxTags', this.get('maxTags'));
|
this.set('model.general.maxTags', this.get('maxTags'));
|
||||||
|
this.set('model.general.message', message);
|
||||||
|
|
||||||
let domainChanged = this.get('model.general.domain') !== this.get('domain').toLowerCase();
|
let domainChanged = this.get('model.general.domain') !== this.get('domain').toLowerCase();
|
||||||
this.set('model.general.domain', this.get('domain').toLowerCase());
|
this.set('model.general.domain', this.get('domain').toLowerCase());
|
||||||
|
|
|
@ -9,10 +9,12 @@
|
||||||
//
|
//
|
||||||
// https://documize.com
|
// https://documize.com
|
||||||
|
|
||||||
|
import $ from 'jquery';
|
||||||
import { A } from '@ember/array';
|
import { A } from '@ember/array';
|
||||||
import { inject as service } from '@ember/service';
|
import { inject as service } from '@ember/service';
|
||||||
import { computed } from '@ember/object';
|
import { computed } from '@ember/object';
|
||||||
import { empty } from '@ember/object/computed';
|
import { empty } from '@ember/object/computed';
|
||||||
|
import { schedule } from '@ember/runloop';
|
||||||
import AuthMixin from '../../mixins/auth';
|
import AuthMixin from '../../mixins/auth';
|
||||||
import Notifier from '../../mixins/notifier';
|
import Notifier from '../../mixins/notifier';
|
||||||
import Component from '@ember/component';
|
import Component from '@ember/component';
|
||||||
|
@ -44,6 +46,73 @@ export default Component.extend(AuthMixin, Notifier, {
|
||||||
this.set('iconList', this.get('iconSvc').getSpaceIconList());
|
this.set('iconList', this.get('iconSvc').getSpaceIconList());
|
||||||
},
|
},
|
||||||
|
|
||||||
|
didInsertElement() {
|
||||||
|
this._super(...arguments);
|
||||||
|
|
||||||
|
schedule('afterRender', () => {
|
||||||
|
let options = {
|
||||||
|
cache_suffix: '?v=510',
|
||||||
|
selector: '#space-desc',
|
||||||
|
relative_urls: false,
|
||||||
|
browser_spellcheck: true,
|
||||||
|
contextmenu: false,
|
||||||
|
statusbar: false,
|
||||||
|
inline: false,
|
||||||
|
paste_data_images: true,
|
||||||
|
images_upload_handler: function (blobInfo, success, failure) { // eslint-disable-line no-unused-vars
|
||||||
|
success("data:" + blobInfo.blob().type + ";base64," + blobInfo.base64());
|
||||||
|
},
|
||||||
|
image_advtab: true,
|
||||||
|
image_caption: true,
|
||||||
|
media_live_embeds: true,
|
||||||
|
theme: 'silver',
|
||||||
|
skin: 'oxide',
|
||||||
|
entity_encoding: 'raw',
|
||||||
|
extended_valid_elements: 'b,i,b/strong,i/em',
|
||||||
|
fontsize_formats:
|
||||||
|
'8px 10px 12px 14px 16px 18px 20px 22px 24px 26px 28px 30px 32px 34px 36px 38px 40px 42px 44px 46px 48px 50px 52px 54px 56px 58px 60px 70px 80px 90px 100px',
|
||||||
|
formats: {
|
||||||
|
bold: {
|
||||||
|
inline: 'b'
|
||||||
|
},
|
||||||
|
italic: {
|
||||||
|
inline: 'i'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
plugins: [
|
||||||
|
'advlist autolink autoresize lists link image charmap print hr pagebreak',
|
||||||
|
'searchreplace wordcount visualblocks visualchars',
|
||||||
|
'insertdatetime media nonbreaking save table directionality',
|
||||||
|
'template paste textpattern imagetools'
|
||||||
|
],
|
||||||
|
menu: {},
|
||||||
|
menubar: false,
|
||||||
|
toolbar: [
|
||||||
|
'formatselect fontsizeselect | bold italic underline strikethrough superscript subscript blockquote | forecolor backcolor link unlink',
|
||||||
|
'outdent indent bullist numlist | alignleft aligncenter alignright alignjustify | table uploadimage image media'
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
if (typeof tinymce === 'undefined') {
|
||||||
|
$.getScript('/tinymce/tinymce.min.js?v=510', function () {
|
||||||
|
window.tinymce.dom.Event.domLoaded = true;
|
||||||
|
tinymce.baseURL = '//' + window.location.host + '/tinymce';
|
||||||
|
tinymce.suffix = '.min';
|
||||||
|
tinymce.init(options);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
tinymce.init(options);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
willDestroyElement() {
|
||||||
|
this._super(...arguments);
|
||||||
|
|
||||||
|
tinymce.EditorManager.execCommand('mceRemoveEditor', true, 'space-desc');
|
||||||
|
},
|
||||||
|
|
||||||
didReceiveAttrs() {
|
didReceiveAttrs() {
|
||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
|
|
||||||
|
@ -107,8 +176,11 @@ export default Component.extend(AuthMixin, Notifier, {
|
||||||
if (spaceName.length === 0) return;
|
if (spaceName.length === 0) return;
|
||||||
space.set('name', spaceName);
|
space.set('name', spaceName);
|
||||||
|
|
||||||
|
let editor = tinymce.EditorManager.get('space-desc');
|
||||||
|
let spaceDesc = editor.getContent();
|
||||||
|
|
||||||
space.set('icon', this.get('spaceIcon'));
|
space.set('icon', this.get('spaceIcon'));
|
||||||
space.set('desc', this.get('spaceDesc'));
|
space.set('desc', spaceDesc);
|
||||||
space.set('labelId', this.get('spaceLabel'));
|
space.set('labelId', this.get('spaceLabel'));
|
||||||
|
|
||||||
this.get('spaceSvc').save(space).then(() => {
|
this.get('spaceSvc').save(space).then(() => {
|
||||||
|
|
|
@ -16,8 +16,9 @@
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
|
|
||||||
> .icon, > .meta-icon, > .meta-logo {
|
> .icon, > .meta-icon, > .meta-logo {
|
||||||
align-self: center;
|
align-self: flex-start;
|
||||||
margin-right: 25px;
|
margin-right: 25px;
|
||||||
|
margin-top: 10px;
|
||||||
|
|
||||||
> i {
|
> i {
|
||||||
font-size: 3.5rem;
|
font-size: 3.5rem;
|
||||||
|
|
|
@ -6,7 +6,9 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label id="siteMessage">Site Message</label>
|
<label id="siteMessage">Site Message</label>
|
||||||
{{textarea id="siteMessage" rows="3" value=model.general.message class=(if hasMessageInputError "form-control is-invalid" "form-control")}}
|
<div id="editor-message" class="wysiwyg wysiwyg-editor">
|
||||||
|
{{{model.general.message}}}
|
||||||
|
</div>
|
||||||
<small class="form-text text-muted">Provide short message explaining this Documize instance</small>
|
<small class="form-text text-muted">Provide short message explaining this Documize instance</small>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
|
|
@ -11,7 +11,9 @@
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>Description</label>
|
<label>Description</label>
|
||||||
{{focus-input id="space-desc" type="text" value=spaceDesc class="form-control" placeholder="Space description" autocomplete="off"}}
|
<div id="space-desc" class="wysiwyg wysiwyg-editor">
|
||||||
|
{{{spaceDesc}}}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
{{desc}}
|
{{{desc}}}
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
{{space.name}}
|
{{space.name}}
|
||||||
</div>
|
</div>
|
||||||
{{#if (not-eq viewDensity "3")}}
|
{{#if (not-eq viewDensity "3")}}
|
||||||
<div class="desc">{{space.desc}} </div>
|
<div class="desc">{{{space.desc}}}</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{#if (eq viewDensity "1")}}
|
{{#if (eq viewDensity "1")}}
|
||||||
<div class="meta">
|
<div class="meta">
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue