You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
OneAuth/oaweb/components/editor/options.ts

209 lines
6.4 KiB
TypeScript

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

/*
* options.ts
* Copyright (C) 2023 veypi <i@veypi.com>
* 2023-10-07 20:21
* Distributed under terms of the MIT license.
*/
import { type CherryOptions } from 'cherry-markdown/types/cherry';
import '@/assets/css/editor.scss'
const basicConfig: CherryOptions = {
id: '',
value: '',
nameSpace: 'cherry',
themeSettings: {
// 主题列表,用于切换主题
themeList: [
{ className: 'dark', label: '黑' },
{ className: 'light', label: '白' },
{ className: 'orange', label: '橘里橘气' },
],
// 目前应用的主题
mainTheme: 'oa',
/** 代码块主题 */
codeBlockTheme: 'dark',
/** 行内代码主题,只有 red 和 black 两个主题 */
inlineCodeTheme: 'red',
/** 工具栏主题,只有 light 和 dark 两个主题,优先级低于 mainTheme */
toolbarTheme: 'dark',
},
externals: {
// echarts: window.echarts,
// katex: window.katex,
// MathJax: window.MathJax,
},
/** 预览区域跟随编辑器光标自动滚动 */
autoScrollByCursor: true,
forceAppend: false,
locale: 'zh_CN',
previewer: {
dom: false,
className: 'cherry-markdown',
// Whether to enable the editing ability of preview area (currently supports editing picture size and table content)
enablePreviewerBubble: true,
// 配置图片懒加载的逻辑
lazyLoadImg: {
// 加载图片时如果需要展示loaing图则配置loading图的地址
loadingImgPath: '',
// 同一时间最多有几个图片请求最大同时加载6张图片
maxNumPerTime: 1,
// 不进行懒加载处理的图片数量如果为0即所有图片都进行懒加载处理 如果设置为-1则所有图片都不进行懒加载处理
noLoadImgNum: 0,
// 首次自动加载几张图片不论图片是否滚动到视野内autoLoadImgNum = -1 表示会自动加载完所有图片
autoLoadImgNum: 3,
// 针对加载失败的图片 或 beforeLoadOneImgCallback 返回false 的图片最多尝试加载几次为了防止死循环最多5次。以图片的src为纬度统计重试次数
maxTryTimesPerSrc: 1,
// 加载一张图片之前的回调函数函数return false 会终止加载操作
beforeLoadOneImgCallback: (img: HTMLImageElement) => true,
// 加载一张图片失败之后的回调函数
failLoadOneImgCallback: (img: HTMLImageElement) => { },
// 加载一张图片之后的回调函数,如果图片加载失败,则不会回调该函数
afterLoadOneImgCallback: (img: HTMLImageElement) => { },
// 加载完所有图片后调用的回调函数
afterLoadAllImgCallback: () => { },
}
},
theme: [],
callback: {
afterChange: () => { },
/** 编辑器完成初次渲染后触发 */
afterInit: () => { },
/** img 标签挂载前触发,可用于懒加载等场景 */
beforeImageMounted: (srcProp: string, src: string) => {
return { srcProp: srcProp, src: src }
},
onClickPreview: () => { },
onCopyCode: (e: ClipboardEvent, code: string) => code,
changeString2Pinyin: (s: any) => s,
},
isPreviewOnly: false,
fileUpload: (f: any) => { console.log('upload file: ' + f) },
fileTypeLimitMap: {
video: "",
audio: "",
image: "",
word: "",
pdf: "",
file: "",
},
openai: false,
engine: {
global: {
urlProcessor(url: any, srcType: any) {
// console.log(`url-processor`, url, srcType);
return url;
},
},
syntax: {
autoLink: {
/** default open short link display */
enableShortLink: true,
/** default display 20 characters */
shortLinkLength: 20,
},
list: {
listNested: false, // The sibling list type becomes a child after conversion
indentSpace: 2, // Default 2 space indents
},
table: {
enableChart: false,
// chartRenderEngine: EChartsTableEngine,
// externals: ['echarts'],
},
inlineCode: {
theme: 'red',
},
codeBlock: {
wrap: true, // If it exceeds the length, whether to wrap the line. If false, the scroll bar will be displayed
lineNumber: true, // Default display line number
indentedCodeBlock: true,
},
fontEmphasis: {
allowWhitespace: false, // 是否允许首尾空格
},
strikethrough: {
needWhitespace: false, // 是否必须有前后空格
},
mathBlock: {
engine: 'MathJax', // katex或MathJax
src: 'https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-svg.js', // 如果使用MathJax plugins则需要使用该url通过script标签引入
// src: '/deps/mathjax/tex-svg.js',
plugins: true,
},
inlineMath: {
engine: 'MathJax', // katex或MathJax
},
emoji: {
useUnicode: false,
},
toc: {
/** By default, only one directory is rendered */
allowMultiToc: false,
},
header: {
/**
* Style of title
* - default Default style with anchor in front of title
* - autonumber There is a self incrementing sequence number anchor in front of the title
* - none Title has no anchor
*/
anchorStyle: 'autonumber',
},
// toc: {
// tocStyle: 'nested'
// }
// 'header': {
// strict: false
// }
},
},
toolbars: {
showToolbar: true,
theme: 'light',
toolbar: [
'bold',
'italic',
// {
// strikethrough: ['strikethrough', 'underline', 'sub', 'sup', 'ruby'],
// },
'size',
'|',
'color',
'header',
'|',
'drawIo',
'|',
'ol',
'ul',
'checklist',
'panel',
'justify',
'detail',
'|',
'formula',
{
insert: ['image', 'audio', 'video', 'link', 'hr', 'br', 'code', 'formula', 'toc', 'table', 'pdf', 'word', 'ruby'],
},
'graph',
'togglePreview',
'export',
// @ts-ignore
'saveMenu', 'backMenu'
],
// toolbarRight: [],
bubble: ['bold', 'italic', 'underline', 'strikethrough', 'sub', 'sup', 'quote', 'ruby', '|', 'size', 'color'], // array or false
// sidebar: false,
// float: false
customMenu: {
} as any,
},
drawioIframeUrl: '/cherry/drawio.html',
editor: {
defaultModel: 'edit&preview',
},
};
export default basicConfig