Skip to content

Commit

Permalink
fix: in code view mode, disable menu button
Browse files Browse the repository at this point in the history
  • Loading branch information
Leecason committed Jul 8, 2022
1 parent 5817266 commit 3d5e8d8
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 18 deletions.
16 changes: 9 additions & 7 deletions src/components/MenuCommands/CodeViewCommandButton.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<template>
<command-button
:command="() => toggleIsCodeViewMode(!isCodeViewMode)"
:enable-tooltip="enableTooltip"
:tooltip="t('editor.extensions.CodeView.tooltip')"
icon="file-code"
:is-active="isCodeViewMode"
/>
<div>
<command-button
:command="() => toggleIsCodeViewMode(!isCodeViewMode)"
:enable-tooltip="enableTooltip"
:tooltip="t('editor.extensions.CodeView.tooltip')"
icon="file-code"
:is-active="isCodeViewMode"
/>
</div>
</template>

<script lang="ts">
Expand Down
16 changes: 9 additions & 7 deletions src/components/MenuCommands/FullscreenCommandButton.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<template>
<command-button
:command="() => toggleFullscreen(!isFullscreen)"
:enable-tooltip="enableTooltip"
:tooltip="buttonTooltip"
:icon="isFullscreen ? 'compress' : 'expand'"
:is-active="isFullscreen"
/>
<div>
<command-button
:command="() => toggleFullscreen(!isFullscreen)"
:enable-tooltip="enableTooltip"
:tooltip="buttonTooltip"
:icon="isFullscreen ? 'compress' : 'expand'"
:is-active="isFullscreen"
/>
</div>
</template>

<script lang="ts">
Expand Down
4 changes: 3 additions & 1 deletion src/components/MenuCommands/HeadingDropdown.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
:enable-tooltip="enableTooltip"
:is-active="editor.isActive('heading')"
:tooltip="t('editor.extensions.Heading.tooltip')"
:disabled="isCodeViewMode"
icon="heading"
/>
<template #dropdown>
Expand Down Expand Up @@ -78,8 +79,9 @@ export default defineComponent({
setup() {
const t = inject('t');
const enableTooltip = inject('enableTooltip', true);
const isCodeViewMode = inject('isCodeViewMode', false);
return { t, enableTooltip };
return { t, enableTooltip, isCodeViewMode };
},
methods: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<template>
<el-popover
:disabled="isCodeViewMode"
placement="bottom"
trigger="click"
popper-class="el-tiptap-popper"
Expand All @@ -26,6 +27,7 @@
<command-button
:enable-tooltip="enableTooltip"
:tooltip="t('editor.extensions.Image.buttons.insert_image.tooltip')"
:readonly="isCodeViewMode"
icon="image"
/>
</span>
Expand Down Expand Up @@ -89,8 +91,9 @@ export default defineComponent({
setup() {
const t = inject('t');
const enableTooltip = inject('enableTooltip', true);
const isCodeViewMode = inject('isCodeViewMode', false);
return { t, enableTooltip };
return { t, enableTooltip, isCodeViewMode };
},
data() {
Expand Down
4 changes: 3 additions & 1 deletion src/components/MenuCommands/Link/AddLinkCommandButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<div>
<command-button
:is-active="editor.isActive('link')"
:readonly="isCodeViewMode"
:command="openAddLinkDialog"
:enable-tooltip="enableTooltip"
:tooltip="t('editor.extensions.Link.add.tooltip')"
Expand Down Expand Up @@ -85,8 +86,9 @@ export default defineComponent({
setup() {
const t = inject('t');
const enableTooltip = inject('enableTooltip', true);
const isCodeViewMode = inject('isCodeViewMode', true);
return { t, enableTooltip };
return { t, enableTooltip, isCodeViewMode };
},
data() {
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/code-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const CodeView = Extension.create<CodeViewOptions>({
addOptions() {
return {
...this.parent?.(),
button({ editor, t }: { editor: Editor; t: (...args: any[]) => string }) {
button({ editor }: { editor: Editor }) {
return {
component: CodeViewCommandButton,
};
Expand Down

0 comments on commit 3d5e8d8

Please sign in to comment.