Skip to content

Commit

Permalink
🎨
Browse files Browse the repository at this point in the history
  • Loading branch information
Vanessa219 committed Dec 3, 2024
1 parent cb7042f commit 97e8feb
Show file tree
Hide file tree
Showing 5 changed files with 8,818 additions and 70 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
charset = utf-8
charset = utf-8
2 changes: 1 addition & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"proseWrap": "preserve",
"quoteProps": "as-needed",
"requirePragma": false,
"semi": false,
"semi": true,
"singleQuote": false,
"tabWidth": 4,
"trailingComma": "es5",
Expand Down
132 changes: 66 additions & 66 deletions demo/index.js
Original file line number Diff line number Diff line change
@@ -1,69 +1,69 @@
import Vditor from '../src/index'
import '../src/assets/less/index.less'
import Vditor from "../src/index"
import "../src/assets/less/index.less"

// new VConsole()

let toolbar
if (window.innerWidth < 768) {
toolbar = [
'emoji',
'headings',
'bold',
'italic',
'strike',
'link',
'|',
'list',
'ordered-list',
'check',
'outdent',
'indent',
'|',
'quote',
'line',
'code',
'inline-code',
'insert-before',
'insert-after',
'|',
'upload',
'record',
'table',
'|',
'undo',
'redo',
'|',
'edit-mode',
'content-theme',
'code-theme',
'export',
"emoji",
"headings",
"bold",
"italic",
"strike",
"link",
"|",
"list",
"ordered-list",
"check",
"outdent",
"indent",
"|",
"quote",
"line",
"code",
"inline-code",
"insert-before",
"insert-after",
"|",
"upload",
"record",
"table",
"|",
"undo",
"redo",
"|",
"edit-mode",
"content-theme",
"code-theme",
"export",
{
name: 'more',
name: "more",
toolbar: [
'fullscreen',
'both',
'preview',
'info',
'help',
"fullscreen",
"both",
"preview",
"info",
"help",
],
}]
}
const initVditor = (language) => {
window.vditor = new Vditor('vditor', {
window.vditor = new Vditor("vditor", {
// _lutePath: `http://192.168.31.194:9090/lute.min.js?${new Date().getTime()}`,
_lutePath: 'src/js/lute/lute.min.js',
cdn: '',
_lutePath: "src/js/lute/lute.min.js",
cdn: "",
toolbar,
lang: language,
mode: 'wysiwyg',
mode: "wysiwyg",
height: window.innerHeight + 100,
outline: {
enable: true,
position: 'right',
position: "right",
},
debugger: true,
typewriterMode: true,
placeholder: 'Hello, Vditor!',
placeholder: "Hello, Vditor!",
preview: {
markdown: {
toc: true,
Expand All @@ -72,7 +72,7 @@ const initVditor = (language) => {
autoSpace: true,
},
math: {
engine: 'KaTeX',
engine: "KaTeX",
inlineDigit: true,
},
},
Expand All @@ -81,59 +81,59 @@ const initVditor = (language) => {
},
counter: {
enable: true,
type: 'text',
type: "text",
},
hint: {
emojiPath: 'https://cdn.jsdelivr.net/npm/[email protected]/dist/images/emoji',
emojiTail: '<a href="https://ld246.com/settings/function" target="_blank">设置常用表情</a>',
emojiPath: "https://cdn.jsdelivr.net/npm/[email protected]/dist/images/emoji",
emojiTail: "<a href=\"https://ld246.com/settings/function\" target=\"_blank\">设置常用表情</a>",
emoji: {
'sd': '💔',
'j': 'https://cdn.jsdelivr.net/npm/[email protected]/dist/images/emoji/j.png',
"sd": "💔",
"j": "https://cdn.jsdelivr.net/npm/[email protected]/dist/images/emoji/j.png",
},
parse: false,
extend: [
{
key: '@',
key: "@",
hint: (key) => {
console.log(key)
if ('vanessa'.indexOf(key.toLocaleLowerCase()) > -1) {
if ("vanessa".indexOf(key.toLocaleLowerCase()) > -1) {
return [
{
value: '@Vanessa',
html: '<img src="https://avatars0.githubusercontent.com/u/970828?s=60&v=4"/> Vanessa',
value: "@Vanessa",
html: "<img src=\"https://avatars0.githubusercontent.com/u/970828?s=60&v=4\"/> Vanessa",
}]
}
return []
},
},
{
key: '#',
key: "#",
hint: (key) => {
console.log(key)
if ('vditor'.indexOf(key.toLocaleLowerCase()) > -1) {
if ("vditor".indexOf(key.toLocaleLowerCase()) > -1) {
return [
{
value: '#Vditor',
html: '<span style="color: #999;">#Vditor</span> ♏ 一款浏览器端的 Markdown 编辑器,支持所见即所得(富文本)、即时渲染(类似 Typora)和分屏预览模式。',
value: "#Vditor",
html: "<span style=\"color: #999;\">#Vditor</span> ♏ 一款浏览器端的 Markdown 编辑器,支持所见即所得(富文本)、即时渲染(类似 Typora)和分屏预览模式。",
}]
}
return []
},
}],
},
tab: '\t',
tab: "\t",
upload: {
accept: 'image/*,.mp3, .wav, .rar',
token: 'test',
url: '/api/upload/editor',
linkToImgUrl: '/api/upload/fetch',
accept: "image/*,.mp3, .wav, .rar",
token: "test",
url: "/api/upload/editor",
linkToImgUrl: "/api/upload/fetch",
filename(name) {
return name.replace(/[^(a-zA-Z0-9\u4e00-\u9fa5\.)]/g, '').replace(/[\?\\/:|<>\*\[\]\(\)\$%\{\}@~]/g, '').replace('/\\s/g', '')
return name.replace(/[^(a-zA-Z0-9\u4e00-\u9fa5\.)]/g, "").replace(/[\?\\/:|<>\*\[\]\(\)\$%\{\}@~]/g, "").replace("/\\s/g", "")
},
},
})
}
initVditor('zh_CN')
initVditor("zh_CN")
window.setLang = (language) => {
window.vditor.destroy()
initVditor(language)
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"css-loader": "^5.2.4",
"eslint": "^9.12.0",
"eslint-plugin-jest": "^26.1.1",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-prettier": "5.2.1",
"file-loader": "^6.2.0",
"html-webpack-plugin": "^5.3.1",
"identity-obj-proxy": "^3.0.0",
Expand All @@ -45,7 +45,7 @@
"mini-css-extract-plugin": "^2.6.0",
"postcss": "^8.4.12",
"postcss-loader": "^5.2.0",
"prettier": "^2.5.1",
"prettier": "3.4.1",
"puppeteer": "^23.0.2",
"style-loader": "^1.3.0",
"terser-webpack-plugin": "^5.3.0",
Expand Down
Loading

0 comments on commit 97e8feb

Please sign in to comment.