imzbf / md-editor-v3

Markdown editor for vue3, developed in jsx and typescript, dark theme、beautify content by prettier、render articles directly、paste or clip the picture and upload it...
https://imzbf.github.io/md-editor-v3
MIT License
1.51k stars 145 forks source link

动态更改 pageFullScreen 值后,编辑器并没有全屏 #620

Closed maoruibin closed 1 month ago

maoruibin commented 1 month ago

Describe the issue

你好,作者,我在 Vue3 中使用 MdEditor,如下是我的配置:

    <MdEditor
      class="editor-input-impl"
      v-model="inputContent"
      :preview="false"
      :pageFullScreen="isPageFull"
      noMermaid
      noKatex
      :onChange="onEditorChange"
      placeholder="记录你的想法..."
      :footers="[]"
      :toolbars="[]"
      :maxLength="50000"
      :style="{
        height: editorHeightRef,
        backgroundColor: '#fff',
        borderColor: 'transparent',
        borderRadius: '8px',
      }"
      ref="editorRef"
    />

其中 isPageFull 用来控制是否全屏,然后自定义了一个按钮去动态改变这个值,如下所示:

const onEditorFull = () => {
  console.log("全屏");
  isPageFull.value = true
};

但是执行后,界面没有任何变化,不过,我如果开始在代码写死 :pageFullScreen="true" 是可以的, :toolbars="[]" 中如果配置全屏按钮,点击也是可以的,为什么我手动控制就不生效呢,帮忙看下这个问题,多谢。

Procedure version

4.17.3

Reproduction link

No response

maoruibin commented 1 month ago

我另外尝试使用自定义 toolabr

    <MdEditor :toolbars="['bold', '-', 0, '=', 'github']">
      <template #defToolbars>
      <NormalToolbar title="mark" @onClick="handler">
        <template #trigger>
          <img class="md-editor-icon" src="../assets/icon-attach.png" alt="Icon Mark" />
        </template>
      </NormalToolbar>
    </template>

按照文档 https://imzbf.github.io/md-editor-v3/en-US/docs#%F0%9F%92%AA%20defToolbars 但我把 svg 改为了 img ,不过不显示我自定义的 icon,这是什么原因呢? image

imzbf commented 1 month ago

pageFullScreen并不是响应式的,它只支持预设,想要切换状态需要使用这里的示例:https://imzbf.github.io/md-editor-v3/zh-CN/docs#%F0%9F%92%BB%20togglePageFullscreen

图片不显示需要你确认样式和路径

maoruibin commented 1 month ago

第一个问题 ok ,用实例方法可以解决,但是第二个我确认了路径,没有问题,但是不论使用 img 标签还是 element-ui 中的 icon 都还是不展示,我看代码没看出问题,你再看下我自己的代码:

    <MdEditor
      class="editor-input-impl"
      v-model="inputContent"
      :preview="false"
      noMermaid
      noKatex
      :onChange="onEditorChange"
      placeholder="记录你的想法..."
      :footers="[]"
      :toolbars="['bold','underline',]"
      :maxLength="50000"
      :style="{

        backgroundColor: '#fff',
        borderColor: 'transparent',
        borderRadius: '8px',
      }"
      ref="editorRef"
    >

    <template #defToolbars>
      <NormalToolbar title="link" @onClick="handler">
        <template #trigger>
          <el-icon>
              <Search />
            </el-icon>
        </template>
      </NormalToolbar>
    </template>

    </MdEditor>

import { ref, onMounted } from "vue";
import { Search, Close,MoreFilled } from "@element-plus/icons-vue";
import { MdEditor, NormalToolbar } from 'md-editor-v3';
import 'md-editor-v3/lib/style.css';
import type { ExposeParam } from "md-editor-v3";

样式上 toolbar 依旧没有出现 这个自定义 icon

image

maoruibin commented 1 month ago

我知道问题了 照着你的文档又看了一遍,需要 那个占位 的 0 😂

:toolbars="['bold', '-', 0, '=', 'github']">