Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Editor Component - Add support to custom Toolbar #6847

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/showcase/doc/editor/BasicDoc.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<div class="card">
<Editor v-model="value" editorStyle="height: 320px" />
</div>
<DocSectionCode :code="code" :dependencies="{ quill: '2.0.0' }" component="Editor" />
<DocSectionCode :code="code" :dependencies="{ quill: '2.0.2' }" component="Editor" />
</template>

<script>
Expand Down
70 changes: 70 additions & 0 deletions apps/showcase/doc/editor/CustomToolbarDoc.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<template>
<DocSectionText v-bind="$attrs">
<p>When <i>modules</i> is present, it's possible to customize the <i>Toolbar</i>.</p>
</DocSectionText>
<div class="card">
<Editor v-model="value" editorStyle="height: 320px" :modules="{toolbar: [
['bold', 'italic', 'underline', 'strike'],
[{ list: 'ordered' }, { list: 'bullet' }],
['link', { align: [] }, 'clean'],
]}" />
</div>
<DocSectionCode :code="code" :dependencies="{ quill: '2.0.2' }" component="Editor" />
</template>

<script>
export default {
data() {
return {
value: '',
code: {
basic: `
<Editor v-model="value" editorStyle="height: 320px" :modules="{toolbar: [
['bold', 'italic', 'underline', 'strike'],
[{ list: 'ordered' }, { list: 'bullet' }],
['link', { align: [] }, 'clean'],
]}" />
`,
options: `
<template>
<div class="card">
<Editor v-model="value" editorStyle="height: 320px" :modules="{toolbar: [
['bold', 'italic', 'underline', 'strike'],
[{ list: 'ordered' }, { list: 'bullet' }],
['link', { align: [] }, 'clean'],
]}" />
</div>
</template>

<script>
export default {
data() {
return {
value: ''
}
}
}
<\/script>
`,
composition: `
<template>
<div class="card">
<Editor v-model="value" editorStyle="height: 320px" :modules="{toolbar: [
['bold', 'italic', 'underline', 'strike'],
[{ list: 'ordered' }, { list: 'bullet' }],
['link', { align: [] }, 'clean'],
]}" />
</div>
</template>

<script setup>
import { ref } from "vue";

const value = ref('');
<\/script>
`
}
};
}
};
</script>
2 changes: 1 addition & 1 deletion apps/showcase/doc/editor/ReadOnlyDoc.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<div class="card">
<Editor v-model="value" editorStyle="height: 320px" readonly />
</div>
<DocSectionCode :code="code" :dependencies="{ quill: '2.0.0' }" component="Editor" />
<DocSectionCode :code="code" :dependencies="{ quill: '2.0.2' }" component="Editor" />
</template>

<script>
Expand Down
2 changes: 1 addition & 1 deletion apps/showcase/doc/editor/TemplateDoc.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</template>
</Editor>
</div>
<DocSectionCode :code="code" :dependencies="{ quill: '2.0.0' }" component="Editor" />
<DocSectionCode :code="code" :dependencies="{ quill: '2.0.2' }" component="Editor" />
</template>

<script>
Expand Down
4 changes: 2 additions & 2 deletions apps/showcase/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"postcss": "^8.4.31",
"prettier": "2.7.1",
"primeicons": "^7.0.0",
"quill": "2.0.0",
"quill": "2.0.2",
"sass": "1.45.0",
"sass-loader": "8.0.2",
"tailwindcss": "^3.4.1",
Expand All @@ -69,4 +69,4 @@
"engines": {
"node": ">=12.11.0"
}
}
}
6 changes: 6 additions & 0 deletions apps/showcase/pages/editor/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import FormsDoc from '@/doc/editor/FormsDoc.vue';
import ImportDoc from '@/doc/editor/ImportDoc.vue';
import QuillDoc from '@/doc/editor/QuillDoc.vue';
import ReadOnlyDoc from '@/doc/editor/ReadOnlyDoc.vue';
import CustomToolbarDoc from '@/doc/editor/CustomToolbarDoc.vue';
import TemplateDoc from '@/doc/editor/TemplateDoc.vue';
import PTComponent from '@/doc/editor/pt/index.vue';
import ThemingDoc from '@/doc/editor/theming/index.vue';
Expand Down Expand Up @@ -42,6 +43,11 @@ export default {
label: 'ReadOnly',
component: ReadOnlyDoc
},
{
id: 'customtoolbar',
label: 'Custom Toolbar',
component: CustomToolbarDoc
},
{
id: 'template',
label: 'Template',
Expand Down
4 changes: 3 additions & 1 deletion packages/primevue/src/editor/Editor.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div :class="cx('root')" v-bind="ptmi('root')">
<div ref="toolbarElement" :class="cx('toolbar')" v-bind="ptm('toolbar')">
<div v-if="!(modules && modules.toolbar)" ref="toolbarElement" class="ql-toolbar" :class="cx('toolbar')" v-bind="ptm('toolbar')">
<slot name="toolbar">
<span class="ql-formats" v-bind="ptm('formats')">
<select class="ql-header" defaultValue="0" v-bind="ptm('header')">
Expand Down Expand Up @@ -50,6 +50,7 @@
<script>
import { isExist } from '@primeuix/utils/dom';
import BaseEditor from './BaseEditor.vue';
import 'quill/dist/quill.snow.css';

const QuillJS = (function () {
try {
Expand Down Expand Up @@ -82,6 +83,7 @@ export default {
}
},
mounted() {

const configuration = {
modules: {
toolbar: this.$refs.toolbarElement,
Expand Down
Loading