Skip to content

Commit

Permalink
fix(plugin_katex): fix event issue causing katex integration failure (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
qwqcode committed May 30, 2024
1 parent a0b0a33 commit ca6f8ed
Show file tree
Hide file tree
Showing 15 changed files with 159 additions and 148 deletions.
3 changes: 3 additions & 0 deletions docs/docs/.vitepress/theme/Artalk.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import { watch, nextTick, ref, onMounted, onUnmounted } from 'vue'
import { useData, useRouter } from 'vitepress'
import Artalk from 'artalk'
import { ArtalkKatexPlugin } from '@artalk/plugin-katex'
import 'artalk/dist/Artalk.css'
const el = ref<HTMLElement | null>(null)
Expand Down Expand Up @@ -36,6 +37,8 @@ onUnmounted(() => {
})
function initArtalk(conf: any) {
Artalk.use(ArtalkKatexPlugin)
artalk = Artalk.init({
el: el.value,
emoticons: '/assets/emoticons/default.json',
Expand Down
1 change: 1 addition & 0 deletions docs/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"vitepress": "1.1.4"
},
"dependencies": {
"@artalk/plugin-katex": "^0.1.7",
"vue": "^3.4.26"
}
}
36 changes: 36 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions ui/artalk-sidebar/src/pages/settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ function save() {
border-bottom: 1px solid var(--at-color-border);
outline: none;
background: transparent;
-webkit-appearance: none;
border-radius: 0;
&:focus {
border-bottom-color: var(--at-color-main);
Expand Down
6 changes: 4 additions & 2 deletions ui/artalk/src/plugins/markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ import type { ArtalkPlugin } from '@/types'
import * as marked from '@/lib/marked'

export const Markdown: ArtalkPlugin = (ctx) => {
ctx.watchConf(['markedReplacers', 'imgLazyLoad', 'markedOptions'], (conf) => {
ctx.watchConf(['imgLazyLoad', 'markedOptions'], (conf) => {
marked.initMarked({
markedOptions: ctx.getConf().markedOptions,
imgLazyLoad: ctx.getConf().imgLazyLoad,
})
})

if (conf.markedReplacers) marked.setReplacers(conf.markedReplacers)
ctx.watchConf(['markedReplacers'], (conf) => {
conf.markedReplacers && marked.setReplacers(conf.markedReplacers)
})
}
10 changes: 1 addition & 9 deletions ui/plugin-auth/artalk-plugin-shim.d.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1 @@
import type { ArtalkPlugin } from 'artalk'

export {}

declare global {
interface Window {
ArtalkPlugins?: { [name: string]: ArtalkPlugin }
}
}
/// <reference types="@artalk/plugin-kit/client" />
10 changes: 3 additions & 7 deletions ui/plugin-auth/main.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* @refresh reload */
import './style.scss'
import Artalk, { ArtalkPlugin } from 'artalk'
import { ArtalkPlugin } from 'artalk'
import { DialogMain } from './DialogMain'
import { createLayer } from './lib/layer'
import { RenderEditorUser } from './EditorUser'
Expand Down Expand Up @@ -56,13 +56,9 @@ export const ArtalkAuthPlugin: ArtalkPlugin = (ctx) => {
})
}

if ((window as any)?.Artalk) {
;(window as any).Artalk.use(ArtalkAuthPlugin)
} else if (Artalk) {
Artalk.use(ArtalkAuthPlugin)
}

// Mount plugin to browser window global
if (window) {
!window.ArtalkPlugins && (window.ArtalkPlugins = {})
window.ArtalkPlugins.Auth = ArtalkAuthPlugin
window.Artalk?.use(ArtalkAuthPlugin)
}
1 change: 1 addition & 0 deletions ui/plugin-auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"solid-js": "^1.8.17"
},
"devDependencies": {
"@artalk/plugin-kit": "workspace:^",
"vite-plugin-css-injected-by-js": "^3.5.1",
"vite-plugin-solid": "^2.10.2"
}
Expand Down
2 changes: 1 addition & 1 deletion ui/plugin-katex/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# @artalk/plugin-katex

食用方法参考[官方文档](https://artalk.js.org/guide/frontend/latex.html)
使用方法参考[官方文档](https://artalk.js.org/guide/frontend/latex.html)
28 changes: 0 additions & 28 deletions ui/plugin-katex/index.html

This file was deleted.

79 changes: 0 additions & 79 deletions ui/plugin-katex/main.ts

This file was deleted.

23 changes: 21 additions & 2 deletions ui/plugin-katex/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
{
"name": "@artalk/plugin-katex",
"version": "0.1.6",
"version": "0.1.7",
"minAppVersion": "2.8.6",
"license": "MIT",
"description": "The katex plugin for artalk",
"type": "module",
"main": "./dist/artalk-plugin-katex.js",
"module": "./dist/artalk-plugin-katex.es.js",
"module": "./dist/artalk-plugin-katex.mjs",
"types": "./dist/artalk-plugin-katex.d.ts",
"files": [
"dist"
],
"scripts": {
"dev": "vite",
"build": "vite build",
Expand All @@ -17,6 +23,19 @@
"katex": "^0.16.10"
},
"devDependencies": {
"@artalk/plugin-kit": "workspace:^",
"@types/katex": "0.16.7"
},
"exports": {
".": {
"require": {
"types": "./dist/artalk-plugin-katex.d.cts",
"default": "./dist/artalk-plugin-katex.cjs"
},
"default": {
"types": "./dist/artalk-plugin-katex.d.ts",
"default": "./dist/artalk-plugin-katex.mjs"
}
}
}
}
Loading

0 comments on commit ca6f8ed

Please sign in to comment.