Skip to content

Commit

Permalink
style: 💄 fix class name
Browse files Browse the repository at this point in the history
  • Loading branch information
zhxqc committed Sep 2, 2022
1 parent b6c09a3 commit 069c91f
Show file tree
Hide file tree
Showing 8 changed files with 125 additions and 137 deletions.
20 changes: 10 additions & 10 deletions src/components/Editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
:style="editorStyle"
:class="[
{
'el-tiptap-editor': true,
'el-tiptap-editor--fullscreen': isFullscreen,
'el-tiptap-editor--with-footer': showFooter,
'bons-editor': true,
'bons-editor--fullscreen': isFullscreen,
'bons-editor--with-footer': showFooter,
},
editorClass,
]"
Expand All @@ -24,7 +24,7 @@
<div
v-if="isCodeViewMode"
:class="{
'el-tiptap-editor__codemirror': true,
'bons-editor__codemirror': true,
'border-bottom-radius': isCodeViewMode,
}"
>
Expand All @@ -36,7 +36,7 @@
:editor="editor"
:class="[
{
'el-tiptap-editor__content': true,
'bons-editor__content': true,
},
editorContentClass,
]"
Expand All @@ -46,12 +46,12 @@
v-if="showFooter"
:class="[
{
'el-tiptap-editor__footer': true,
'bons-editor__footer': true,
},
editorFooterClass,
]"
>
<span class="el-tiptap-editor__characters">
<span class="bons-editor__characters">
{{ t('editor.characters') }}: {{ characters }}
</span>
</div>
Expand Down Expand Up @@ -194,16 +194,16 @@ const emit = defineEmits([
const extensions = props.extensions
.concat([
TiptapPlaceholder.configure({
emptyEditorClass: 'el-tiptap-editor--empty',
emptyNodeClass: 'el-tiptap-editor__placeholder',
emptyEditorClass: 'bons-editor--empty',
emptyNodeClass: 'bons-editor__placeholder',
showOnlyCurrent: false,
placeholder: () => props.placeholder,
}),
props.enableCharCount
? CharacterCount.configure({
limit: props.charCountMax,
})
: null,
: null as any,
])
.filter(Boolean);
Expand Down
4 changes: 2 additions & 2 deletions src/components/menuBar/Index.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div class="el-tiptap-editor__menu-bar">
<div class="bons-editor__menu-bar">
<component
:is="spec.component"
v-for="(spec, i) in generateCommandButtonComponentSpecs()"
Expand Down Expand Up @@ -35,7 +35,7 @@ const generateCommandButtonComponentSpecs = () => {
const menuBtnComponentSpec = button({
editor: props.editor,
t: t.value,
t,
extension,
});
Expand Down
6 changes: 3 additions & 3 deletions src/components/menuBubble/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
>
<div
:class="{
'el-tiptap-editor__menu-bubble--active': bubbleMenuEnable,
'bons-editor__menu-bubble--active': bubbleMenuEnable,
}"
class="el-tiptap-editor__menu-bubble"
class="bons-editor__menu-bubble"
>
<link-bubble-menu
v-if="activeMenu === 'link'"
Expand All @@ -16,7 +16,7 @@
<template #prepend>
<div
v-if="textMenuEnable"
class="el-tiptap-editor__command-button"
class="bons-editor__command-button"
@mousedown.prevent
@click="linkBack"
>
Expand Down
111 changes: 49 additions & 62 deletions src/components/menuCommands/CommandButton.vue
Original file line number Diff line number Diff line change
@@ -1,80 +1,67 @@
<template>
<div>
<el-tooltip
:content="tooltip"
:show-after="350"
:disabled="!enableTooltip || readonly"
effect="dark"
placement="top"
<el-tooltip
:content="tooltip"
:show-after="350"
:disabled="!enableTooltip || readonly"
effect="dark"
placement="top"
>
<div
:class="commandButtonClass"
@mousedown.prevent
@click="onClick"
>
<div
:class="commandButtonClass"
@mousedown.prevent
@click="onClick"
>
<v-icon :name="icon" />
</div>
</el-tooltip>
</div>
<v-icon :name="icon" />
</div>
</el-tooltip>
</template>

<script lang='ts'>
import { defineComponent } from 'vue';
<script lang='ts' setup>
import { computed } from 'vue';
import { ElTooltip } from 'element-plus';
import { noop } from '@/utils/shared';
import VIcon from '../Icon/Icon.vue';
export default defineComponent({
components: {
ElTooltip,
VIcon,
const props = defineProps({
icon: {
type: String,
required: true,
},
props: {
icon: {
type: String,
required: true,
},
isActive: {
type: Boolean,
default: false,
},
tooltip: {
type: String,
required: true,
},
enableTooltip: {
type: Boolean,
required: true,
},
isActive: {
type: Boolean,
default: false,
},
command: {
type: Function,
default: noop,
},
tooltip: {
type: String,
default: '',
required: true,
},
readonly: {
type: Boolean,
default: false,
},
enableTooltip: {
type: Boolean,
required: true,
},
computed: {
commandButtonClass(): object {
return {
'el-tiptap-editor__command-button': true,
'el-tiptap-editor__command-button--active': this.isActive,
'el-tiptap-editor__command-button--readonly': this.readonly,
};
},
command: {
type: Function,
default: noop,
},
methods: {
onClick() {
if (!this.readonly) this.command();
},
readonly: {
type: Boolean,
default: false,
},
});
})
const commandButtonClass = computed(() => ({
'bons-editor__command-button': true,
'bons-editor__command-button--active': props.isActive,
'bons-editor__command-button--readonly': props.readonly,
}))
const onClick = () => {
if (!props.readonly) props.command();
}
</script>
111 changes: 56 additions & 55 deletions src/components/menuCommands/image/InsertImageCommandButton.vue
Original file line number Diff line number Diff line change
@@ -1,63 +1,64 @@
<template>
<el-popover
:disabled="isCodeViewMode"
placement="bottom"
trigger="click"
popper-class="el-tiptap-popper"
>
<div class="el-tiptap-popper__menu">
<div
class="el-tiptap-popper__menu__item"
@click="openUrlPrompt"
>
<span>{{
t('editor.extensions.Image.buttons.insert_image.external')
}}</span>
</div>
<div>
<el-popover
:disabled="isCodeViewMode"
placement="bottom"
trigger="click"
popper-class="el-tiptap-popper"
>
<div class="el-tiptap-popper__menu">
<div
class="el-tiptap-popper__menu__item"
@click="openUrlPrompt"
>
<span>{{
t('editor.extensions.Image.buttons.insert_image.external')
}}</span>
</div>

<div
class="el-tiptap-popper__menu__item"
@click="imageUploadDialogVisible = true"
>
<span>{{
t('editor.extensions.Image.buttons.insert_image.upload')
}}</span>
<div
class="el-tiptap-popper__menu__item"
@click="imageUploadDialogVisible = true"
>
<span>{{
t('editor.extensions.Image.buttons.insert_image.upload')
}}</span>
</div>
</div>
</div>

<template #reference>
<span>
<command-button
:enable-tooltip="enableTooltip"
:tooltip="t('editor.extensions.Image.buttons.insert_image.tooltip')"
:readonly="isCodeViewMode"
icon="image"
/>
</span>
</template>
</el-popover>

<el-dialog
v-model="imageUploadDialogVisible"
:title="t('editor.extensions.Image.control.upload_image.title')"
:append-to-body="true"
>
<el-upload
:http-request="uploadImage"
:show-file-list="false"
class="el-tiptap-upload"
action="#"
drag
accept="image/*"
<template #reference>
<span>
<command-button
:enable-tooltip="enableTooltip"
:tooltip="t('editor.extensions.Image.buttons.insert_image.tooltip')"
:readonly="isCodeViewMode"
icon="image"
/>
</span>
</template>
</el-popover>
<el-dialog
v-model="imageUploadDialogVisible"
:title="t('editor.extensions.Image.control.upload_image.title')"
:append-to-body="true"
>
<div class="el-tiptap-upload__icon">
<i class="fa fa-upload" />
</div>
<div class="el-tiptap-upload__text">
{{ t('editor.extensions.Image.control.upload_image.button') }}
</div>
</el-upload>
</el-dialog>
<el-upload
:http-request="uploadImage"
:show-file-list="false"
class="el-tiptap-upload"
action="#"
drag
accept="image/*"
>
<div class="el-tiptap-upload__icon">
<i class="fa fa-upload" />
</div>
<div class="el-tiptap-upload__text">
{{ t('editor.extensions.Image.control.upload_image.button') }}
</div>
</el-upload>
</el-dialog>
</div>
</template>

<script lang="ts">
Expand Down
2 changes: 1 addition & 1 deletion src/styles/command-button.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@import './variables.scss';

.el-tiptap-editor {
.bons-editor {
$editor: &;

&__command-button {
Expand Down
6 changes: 3 additions & 3 deletions src/styles/editor.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@import './variables.scss';

.el-tiptap-editor {
.bons-editor {
$root: &;

box-sizing: border-box;
Expand All @@ -12,7 +12,7 @@
width: 100%;
max-width: 1200px;

*[class^='el-tiptap-editor'] {
*[class^='bons-editor'] {
box-sizing: border-box;
}

Expand Down Expand Up @@ -510,7 +510,7 @@
}

&__placeholder {
&.el-tiptap-editor--empty:first-child::before {
&.bons-editor--empty:first-child::before {
color: $placeholder-text-color;
content: attr(data-placeholder);
float: left;
Expand Down
2 changes: 1 addition & 1 deletion src/utils/print.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function printHtml(dom: Element) {
}

export function printEditorContent(view: EditorView) {
const editorContent = view.dom.closest('.el-tiptap-editor__content');
const editorContent = view.dom.closest('.bons-editor__content');
if (editorContent) {
printHtml(editorContent);
return true;
Expand Down

0 comments on commit 069c91f

Please sign in to comment.