当前位置:网站首页>Milkdown control icon
Milkdown control icon
2022-07-07 13:27:00 【Cliven_】
Phenomenon description
stay vite + vue3 In the project , Use Milkdown As Markdown Edit box
Milkdown.vue
<template>
<VueEditor :editor="editor" />
</template>
<script setup> import {
Editor, rootCtx, defaultValueCtx } from "@milkdown/core"; import {
nord } from "@milkdown/theme-nord"; import {
VueEditor, useEditor } from "@milkdown/vue"; import {
commonmark } from "@milkdown/preset-commonmark"; import {
emoji } from "@milkdown/plugin-emoji"; import {
history } from '@milkdown/plugin-history'; import {
tooltip } from '@milkdown/plugin-tooltip'; import {
menu } from "@milkdown/plugin-menu"; const {
editor } = useEditor((root) => Editor.make() .config((ctx) => {
ctx.set(rootCtx, root); ctx.set(defaultValueCtx, "# Milkdown Vue"); }) .use(nord) .use(emoji) .use(commonmark) .use(history) .use(menu) .use(tooltip) ); </script>
The display effect is as shown in the figure
All icon areas become text , And crowded together very ugly , This is because milkdown/theme-nord
The theme uses google Provided Google material icons
from Milkdown Official example You can see
stay index.html
The document introduces Google Icon font library .
solve
Mode one Introduce... Online
The reason why there is no icon in our space is that there is no Google Icon font library causes , We can be as official , Directly in index.html
Add a line to the file CSS The reference of the file can .
index.html
<html>
<head>
...
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons+Outlined" />
...
</head>
...
</html>
This method will use Google Of CSS2 API Automatically reference and related fonts and configurations , There is a problem with this method when network conditions do not allow , It will cause the icon to still fail to load .
Mode two Offline import
according to Google material icons#setup_method_2_self_hosting Description in , We can download relevant font files , Then manually configure css Use font files .
For simplicity, I directly visited Google Of
Got it CSS Configuration file and font file .
CSS As shown below
/* fallback */
@font-face {
font-family: 'Material Icons Outlined';
font-style: normal;
font-weight: 400;
src: url(https://fonts.gstatic.com/s/materialiconsoutlined/v106/gok-H7zzDkdnRel8-DQ6KAXJ69wP1tGnf4ZGhUce.woff2) format('woff2');
}
.material-icons-outlined {
font-family: 'Material Icons Outlined';
font-weight: normal;
font-style: normal;
font-size: 24px;
line-height: 1;
letter-spacing: normal;
text-transform: none;
display: inline-block;
white-space: nowrap;
word-wrap: normal;
direction: ltr;
-webkit-font-feature-settings: 'liga';
-webkit-font-smoothing: antialiased;
}
A font file also appears here
Here I also manually download and place the file in the project public/
Under the table of contents .
And then modified Milkdown.vue, Added the above CSS, And replaced the address of the font file with the local address , The modified file is as follows .
<template>
<VueEditor :editor="editor" />
</template>
<script setup> import {
Editor, rootCtx, defaultValueCtx } from "@milkdown/core"; import {
nord } from "@milkdown/theme-nord"; import {
VueEditor, useEditor } from "@milkdown/vue"; import {
commonmark } from "@milkdown/preset-commonmark"; import {
emoji } from "@milkdown/plugin-emoji"; import {
history } from '@milkdown/plugin-history'; import {
tooltip } from '@milkdown/plugin-tooltip'; import {
menu } from "@milkdown/plugin-menu"; const {
editor } = useEditor((root) => Editor.make() .config((ctx) => {
ctx.set(rootCtx, root); ctx.set(defaultValueCtx, "# Milkdown Vue"); }) .use(nord) .use(emoji) .use(commonmark) .use(history) .use(menu) .use(tooltip) ); </script>
<style> @font-face {
font-family: 'Material Icons Outlined'; font-style: normal; font-weight: 400; src: url(./gok-H7zzDkdnRel8-DQ6KAXJ69wP1tGnf4ZGhUce.woff2) format('woff2'); } .material-icons-outlined {
font-family: 'Material Icons Outlined'; font-weight: normal; font-style: normal; font-size: 24px; line-height: 1; letter-spacing: normal; text-transform: none; display: inline-block; white-space: nowrap; word-wrap: normal; direction: ltr; -webkit-font-feature-settings: 'liga'; -webkit-font-smoothing: antialiased; } </style>
In addition to CSS And font, you can see that the icon on the control has been normal .
reference
[1]. milkdown . demo . https://milkdown.dev/online-demo
[2]. milkdown . Integrations vue. https://milkdown.dev/vue
[3]. google . fonts . Material Icons Guide . 2022.03 . https://developers.google.com/fonts/docs/material_icons
边栏推荐
- 【学习笔记】AGC010
- centso7 openssl 报错Verify return code: 20 (unable to get local issuer certificate)
- Read PG in data warehouse in one article_ stat
- MongoDB优化的几点原则
- Summary of import, export, backup and recovery of mongodb
- xshell连接服务器把密钥登陆改为密码登陆
- 【Presto Profile系列】Timeline使用
- Cookie and session comparison
- Mongodb meets spark (for integration)
- 10 张图打开 CPU 缓存一致性的大门
猜你喜欢
随机推荐
MongoDB命令汇总
Scripy tutorial classic practice [New Concept English]
[untitled]
一文读懂数仓中的pg_stat
Awk of three swordsmen in text processing
滑轨步进电机调试(全国海洋航行器大赛)(STM32主控)
分布式事务解决方案
[untitled]
JS判断一个对象是否为空
MongoDB内部的存储原理
Mongodb replication (replica set) summary
Mongodb command summary
MongoDB的导入导出、备份恢复总结
[Presto profile series] timeline use
COSCon'22 社区召集令来啦!Open the World,邀请所有社区一起拥抱开源,打开新世界~
JS function returns multiple values
JS slow motion animation principle teaching (super detail)
LeetCode_二分搜索_中等_153.寻找旋转排序数组中的最小值
JNA学习笔记一:概念
Go language learning notes - structure