English 中文(简体)
当彩色被打上时,管道没有显示黑体或斜体。
原标题:Tip tap does not show bold or italic text when the color is also set

I am using Vue Tiptap with the Color extension. After an edit, I am getting the HTML and storing it in Firestore. However, the editor does not show bold or italic text when a color is also set. However, it does show up correctly in the HTML, which is fetched by another wesbite.

这里是我的编辑。

    <div class="editor">
        <div class="controls">
            <button @click="() => {
                editor?.chain().focus().toggleBold().run()
            }">
                &#119809;
            </button>
            <button @click="() => {
                editor?.chain().focus().toggleItalic().run()
            }">

                &#8520;

            </button>
            <VDropdown placement="top">
                <button>

                    &#127912;

                </button>
                <template #popper>
                    <div class="color-controls">
                        <div class="color-choices">

                            <div v-for="color in colors" :key="color"
                                @click="editor?.chain().focus().setColor(color).run()">
                                <div class="circle" :style="{ backgroundColor: color }"></div>

                            </div>
                        </div>
                        <button @click="editor?.chain().focus().unsetColor().run()">Remove Color</button>

                    </div>
                </template>
            </VDropdown>


        </div>
        <editor-content :editor="editor!" />
    </div>
</template>

<script setup lang="ts">
import { Color } from  @tiptap/extension-color ;
import { TextStyle } from  @tiptap/extension-text-style ;
import StarterKit from  @tiptap/starter-kit ;
import { EditorContent, useEditor } from  @tiptap/vue-3 ;

const colors = [
    "Red",
    "Orange",
    "Yellow",
    "Green",
    "Blue",
    "Indigo",
    "Violet",
    "Black",
    "White",
    "Gray",
    "Pink",
    "Brown",
    "Aqua",
    "Coral",
    "Lime",
    "Maroon",
    "Navy",
    "Olive",
    "Purple",
    "Teal"
];


Color.configure({
    types: [ textStyle ],
})

const props = defineProps({
    content: {
        type: String,
        required: true,
    },
    contentEditable: {
        type: Boolean,
        default: true,
    },


})

const emit = defineEmits(["update:content"])

const editor = useEditor({
    extensions: [
        StarterKit,
        TextStyle,
        Color,
    ],
    content: props.content,
    editable: props.contentEditable,
    onUpdate({ editor }) {
        emit( update:content , editor.getHTML())
    },
})


</script>

<style scoped>
strong span {
    font-weight: bold !important;
}


.color-controls {
    display: flex;
    flex-direction: column;
}

.color-choices {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.5rem;
}
</style>

在这次屏幕上,压缩字为黑体。 它显示了勇敢的姿态。 然后,我把颜色划入绿线,黑体没有显示。

“Editor

在这一屏幕上,客户网站显示的是超文本。 它正确显示了黑色。

“Website

我需要编辑准确显示黑体和斜体,即使有颜色。

这里的一个例子是,在检查员中,有色和果敢的编辑超文本:

“Editor

问题回答

你再次经历的问题似乎与《社会保障法》的特殊性规则有关,因为彩色属性(如线性)超越了黑体和斜体。

你们可以尝试通过增加特别安全局的规则来解决这个问题,使黑体和斜体更具体:

.editor-content span[style*="color"] strong {
    font-weight: bold !important;
}

.editor-content span[style*="color"] em {
    font-style: italic !important;
}

如果这项工作不成功,则考虑制定一种将文字规范和科罗特征相结合的习俗主延伸。

Hope this helps!





相关问题
Nuxt 3 useRoute import cannot find

I am using latest nuxt version and when I tried to use the useRoute method is triggers a "Cannot Find name useRoute" but it works so I would like to know what could I be missing My package ...

Vue array dependent select not display data

I have dependent selection like this. Selection image when i console log, they have data but not render data in selection data This is what i ve tried. for Product selection has default selected value ...

How to inject Bearer Token in Axios boot file

Quasar has a different setup using boot files and my current axios.ts looks liek this: import { boot } from quasar/wrappers ; import axios, { AxiosInstance } from axios ; declare module @vue/...

Vue router and Vite Base url conflict

I use Vue Router to develop my single page application and use Vite to package my project. I want to deploy all static files (such as index.js and index.css) under another CDN domain name (cdn.example....

Vue.js change class on mounted

I have a button element with a .hover property and I need the hover animation to also happen as soon as the page is mounted. How can I attribute a class to a button on the mounted function and then ...

Laravel +Vuejs CORS issue

I am facing a dilemma wit the CORS issue. I have application that is configured as follow: API: https://abc.mydomain.com (laravel) front end: https://subdomain.mydomain.com(VueJS) Both applications ...

热门标签