close #1341 Changed: Remove code and image buttons from settings editor

This commit is contained in:
Cüneyt Şentürk 2020-03-10 17:43:19 +03:00
parent f75635c4ae
commit 64cd21d5ea
4 changed files with 104 additions and 13 deletions

View File

@ -0,0 +1,94 @@
<template>
<div class="quill">
<div :id="toolbarId">
<div class="ql-formats">
<button class="ql-bold"></button>
<button class="ql-italic"></button>
<button class="ql-underline"></button>
<button class="ql-link"></button>
<button class="ql-blockquote"></button>
<button type="button" class="ql-list" value="ordered"></button>
<button type="button" class="ql-list" value="bullet"></button>
</div>
</div>
<div :id="editorId" :name="name" class="" ref="editor">
</div>
</div>
</template>
<script>
export default {
name: 'akaunting-html-editor',
props: {
value: {
type: String,
default: ''
},
name: String
},
data () {
return {
editor: null,
content: null,
lastHtmlValue: '',
editorId: null,
toolbarId: null
}
},
methods: {
initialize (Quill) {
this.editor = new Quill(`#${this.editorId}`, {
theme: 'snow',
modules: {
toolbar: `#${this.toolbarId}`
}
})
if (this.value.length > 0) {
this.editor.pasteHTML(this.value)
}
let editorRef = this.$refs.editor;
let node = editorRef.children[0];
this.editor.on('text-change', () => {
let html = node.innerHTML
if (html === '<p><br></p>') {
html = '';
}
this.content = html
this.$emit('input', this.content);
})
},
pasteHTML () {
if (!this.editor) {
return
}
this.editor.pasteHTML(this.value)
},
randomString() {
let text = "";
let possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
for (let i = 0; i < 5; i++)
text += possible.charAt(Math.floor(Math.random() * possible.length));
return text;
}
},
async mounted () {
let Quill = await import('quill')
Quill = Quill.default || Quill
this.editorId = this.randomString();
this.toolbarId = this.randomString();
this.$nextTick(() => {
this.initialize(Quill)
});
},
watch: {
value (newVal) {
if (newVal !== this.content) {
this.pasteHTML(newVal);
}
}
}
}
</script>

View File

@ -11,12 +11,13 @@ import AkauntingSelect from './../components/AkauntingSelect';
import AkauntingSelectRemote from './../components/AkauntingSelectRemote'; import AkauntingSelectRemote from './../components/AkauntingSelectRemote';
import AkauntingDate from './../components/AkauntingDate'; import AkauntingDate from './../components/AkauntingDate';
import AkauntingRecurring from './../components/AkauntingRecurring'; import AkauntingRecurring from './../components/AkauntingRecurring';
import AkauntingHtmlEditor from './../components/AkauntingHtmlEditor';
import NProgress from 'nprogress'; import NProgress from 'nprogress';
import 'nprogress/nprogress.css'; import 'nprogress/nprogress.css';
import NProgressAxios from './../plugins/nprogress-axios'; import NProgressAxios from './../plugins/nprogress-axios';
import { Select, Option, Steps, Step, Button, Link, Tooltip } from 'element-ui'; import { Select, Option, Steps, Step, Button, Link, Tooltip, ColorPicker } from 'element-ui';
import Form from './../plugins/form'; import Form from './../plugins/form';
@ -31,6 +32,7 @@ export default {
AkauntingModalAddNew, AkauntingModalAddNew,
AkauntingDate, AkauntingDate,
AkauntingRecurring, AkauntingRecurring,
AkauntingHtmlEditor,
[Select.name]: Select, [Select.name]: Select,
[Option.name]: Option, [Option.name]: Option,
[Steps.name]: Steps, [Steps.name]: Steps,
@ -38,6 +40,7 @@ export default {
[Button.name]: Button, [Button.name]: Button,
[Link.name]: Link, [Link.name]: Link,
[Tooltip.name]: Tooltip, [Tooltip.name]: Tooltip,
[ColorPicker.name]: ColorPicker,
}, },
data: function () { data: function () {

View File

@ -14,11 +14,9 @@ import Global from './../../mixins/global';
import Form from './../../plugins/form'; import Form from './../../plugins/form';
import BulkAction from './../../plugins/bulk-action'; import BulkAction from './../../plugins/bulk-action';
import HtmlEditor from './../../components/Inputs/HtmlEditor';
import {ColorPicker} from 'element-ui';
// plugin setup // plugin setup
Vue.use(DashboardPlugin, ColorPicker); Vue.use(DashboardPlugin);
const app = new Vue({ const app = new Vue({
el: '#app', el: '#app',
@ -27,13 +25,9 @@ const app = new Vue({
Global Global
], ],
components: {
HtmlEditor,
[ColorPicker.name]: ColorPicker,
},
mounted() { mounted() {
this.onChangeProtocol(this.form.protocol); this.onChangeProtocol(this.form.protocol);
this.color = this.form.color; this.color = this.form.color;
}, },

View File

@ -7,7 +7,7 @@
{!! Form::label($name, $text, ['class' => 'form-control-label'])!!} {!! Form::label($name, $text, ['class' => 'form-control-label'])!!}
@endif @endif
<html-editor <akaunting-html-editor
name="{{ $name }}" name="{{ $name }}"
@if (!empty($attributes['v-model'])) @if (!empty($attributes['v-model']))
@ -29,7 +29,7 @@
@if (isset($attributes['disabled'])) @if (isset($attributes['disabled']))
:disabled="'{{ $attributes['disabled'] }}'" :disabled="'{{ $attributes['disabled'] }}'"
@endif @endif
></html-editor> ></akaunting-html-editor>
<div class="invalid-feedback d-block" <div class="invalid-feedback d-block"
v-if="{{ isset($attributes['v-error']) ? $attributes['v-error'] : 'form.errors.has("' . $name . '")' }}" v-if="{{ isset($attributes['v-error']) ? $attributes['v-error'] : 'form.errors.has("' . $name . '")' }}"