当前位置:网站首页>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
边栏推荐
- 迅为iTOP-IMX6ULL开发板Pinctrl和GPIO子系统实验-修改设备树文件
- Some principles of mongodb optimization
- Vscade editor esp32 header file wavy line does not jump completely solved
- JS slow motion animation principle teaching (super detail)
- 单片机原理期末复习笔记
- PACP学习笔记一:使用 PCAP 编程
- 自定义线程池拒绝策略
- Users, groups, and permissions
- 工具箱之 IKVM.NET 项目新进展
- MongoDB的导入导出、备份恢复总结
猜你喜欢
将数学公式在el-table里面展示出来
Japanese government and enterprise employees got drunk and lost 460000 information USB flash drives. They publicly apologized and disclosed password rules
Fast development board pinctrl and GPIO subsystem experiment for itop-imx6ull - modify the device tree file
Esp32 construction engineering add components
Vscode编辑器ESP32头文件波浪线不跳转彻底解决
OSI 七层模型
LIS 最长上升子序列问题(动态规划、贪心+二分)
My "troublesome" subordinates after 00: not bad for money, against leaders, and resist overtime
TPG x AIDU|AI领军人才招募计划进行中!
提升树莓派性能的方法
随机推荐
Analysis of DHCP dynamic host setting protocol
Milkdown 控件图标
Initialization script
记一次 .NET 某新能源系统 线程疯涨 分析
Read PG in data warehouse in one article_ stat
How to make the new window opened by electorn on the window taskbar
[Presto profile series] timeline use
How to make join run faster?
滑轨步进电机调试(全国海洋航行器大赛)(STM32主控)
为租客提供帮助
【学习笔记】线段树选做
MongoDB 遇见 spark(进行整合)
LeetCode_二分搜索_中等_153.寻找旋转排序数组中的最小值
《开源圆桌派》第十一期“冰与火之歌”——如何平衡开源与安全间的天然矛盾?
抓细抓实抓好安全生产各项工作 全力确保人民群众生命财产安全
[dark horse morning post] Huawei refutes rumors about "military master" Chen Chunhua; Hengchi 5 has a pre-sale price of 179000 yuan; Jay Chou's new album MV has played more than 100 million in 3 hours
[QNX hypervisor 2.2 user manual]6.3.4 virtual register (guest_shm.h)
Cinnamon Applet 入门
How far can it go to adopt a cow by selling the concept to the market?
[untitled]