mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-07-24 05:26:16 +00:00
fix: emoji fix
This commit is contained in:
@@ -71,6 +71,16 @@ body {
|
|||||||
top: var(--header-height) !important;
|
top: var(--header-height) !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.vditor-panel {
|
||||||
|
min-width: 400px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.emoji {
|
||||||
|
width: 20px;
|
||||||
|
height: 20px;
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
|
||||||
/* .vditor {
|
/* .vditor {
|
||||||
--textarea-background-color: transparent;
|
--textarea-background-color: transparent;
|
||||||
border: none !important;
|
border: none !important;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import MarkdownIt from 'markdown-it'
|
|||||||
import hljs from 'highlight.js'
|
import hljs from 'highlight.js'
|
||||||
import 'highlight.js/styles/github.css'
|
import 'highlight.js/styles/github.css'
|
||||||
import { toast } from '../main'
|
import { toast } from '../main'
|
||||||
import { tiebaEmoji, TIEBA_EMOJI_CDN } from './tiebaEmoji'
|
import { tiebaEmoji } from './tiebaEmoji'
|
||||||
|
|
||||||
function mentionPlugin(md) {
|
function mentionPlugin(md) {
|
||||||
const mentionReg = /^@\[([^\]]+)\]/
|
const mentionReg = /^@\[([^\]]+)\]/
|
||||||
@@ -32,7 +32,7 @@ function tiebaEmojiPlugin(md) {
|
|||||||
md.renderer.rules['tieba-emoji'] = (tokens, idx) => {
|
md.renderer.rules['tieba-emoji'] = (tokens, idx) => {
|
||||||
const name = tokens[idx].content
|
const name = tokens[idx].content
|
||||||
const file = tiebaEmoji[name]
|
const file = tiebaEmoji[name]
|
||||||
return `<img class="emoji" src="${TIEBA_EMOJI_CDN}${file}" alt="${name}">`
|
return `<img class="emoji" src="${file}" alt="${name}">`
|
||||||
}
|
}
|
||||||
md.inline.ruler.before('emphasis', 'tieba-emoji', (state, silent) => {
|
md.inline.ruler.before('emphasis', 'tieba-emoji', (state, silent) => {
|
||||||
const pos = state.pos
|
const pos = state.pos
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
export const TIEBA_EMOJI_CDN = 'https://cdn.jsdelivr.net/gh/microlong666/tieba_mobile_emotions@master/'
|
export const TIEBA_EMOJI_CDN = 'https://cdn.jsdelivr.net/gh/microlong666/tieba_mobile_emotions@master/'
|
||||||
|
// export const TIEBA_EMOJI_CDN = 'https://openisle-1307107697.cos.ap-guangzhou.myqcloud.com/assert/vditor/dist/images/emoji/'
|
||||||
|
|
||||||
export const tiebaEmoji = (() => {
|
export const tiebaEmoji = (() => {
|
||||||
const map = { tieba1: 'image_emoticon.png' }
|
const map = { tieba1: TIEBA_EMOJI_CDN + 'image_emoticon.png' }
|
||||||
for (let i = 2; i <= 124; i++) {
|
for (let i = 2; i <= 124; i++) {
|
||||||
if (i > 50 && i < 62) continue
|
if (i > 50 && i < 62) continue
|
||||||
map[`tieba${i}`] = `image_emoticon${i}.png`
|
map[`tieba${i}`] = TIEBA_EMOJI_CDN + `image_emoticon${i}.png`
|
||||||
}
|
}
|
||||||
return map
|
return map
|
||||||
})()
|
})()
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import 'vditor/dist/index.css'
|
|||||||
import { API_BASE_URL } from '../main'
|
import { API_BASE_URL } from '../main'
|
||||||
import { getToken, authState } from './auth'
|
import { getToken, authState } from './auth'
|
||||||
import { searchUsers, fetchFollowings, fetchAdmins } from './user'
|
import { searchUsers, fetchFollowings, fetchAdmins } from './user'
|
||||||
import { tiebaEmoji, TIEBA_EMOJI_CDN } from './tiebaEmoji'
|
import { tiebaEmoji } from './tiebaEmoji'
|
||||||
|
|
||||||
export function getEditorTheme() {
|
export function getEditorTheme() {
|
||||||
return document.documentElement.dataset.theme === 'dark' ? 'dark' : 'classic'
|
return document.documentElement.dataset.theme === 'dark' ? 'dark' : 'classic'
|
||||||
@@ -45,12 +45,9 @@ export function createVditor(editorId, options = {}) {
|
|||||||
theme: getEditorTheme(),
|
theme: getEditorTheme(),
|
||||||
preview: Object.assign({
|
preview: Object.assign({
|
||||||
theme: { current: getPreviewTheme() },
|
theme: { current: getPreviewTheme() },
|
||||||
customEmoji: tiebaEmoji,
|
|
||||||
emojiPath: TIEBA_EMOJI_CDN
|
|
||||||
}, preview),
|
}, preview),
|
||||||
hint: {
|
hint: {
|
||||||
emoji: tiebaEmoji,
|
emoji: tiebaEmoji,
|
||||||
emojiPath: TIEBA_EMOJI_CDN,
|
|
||||||
extend: [
|
extend: [
|
||||||
{
|
{
|
||||||
key: '@',
|
key: '@',
|
||||||
|
|||||||
Reference in New Issue
Block a user