New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

vditor

Package Overview
Dependencies
Maintainers
1
Versions
328
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vditor - npm Package Compare versions

Comparing version

to
3.3.4

dist/css/content-theme/light.css

26

CHANGELOG.md

@@ -69,6 +69,21 @@ ## Vditor change log

### v3.3.4 / 2020-06-xx
### v3.3.5 / 2020-07-xx
### v3.3.3 / 2020-06-23
### v3.3.4 / 2020-07-08
* [539](https://github.com/Vanessa219/vditor/pull/539) 即时渲染模式 setValue 后,没有及时渲染 Code 区域 `修复缺陷`
* [536](https://github.com/Vanessa219/vditor/issues/536) 文件上传检查后缀忽略大小写 `改进功能`
* [537](https://github.com/Vanessa219/vditor/issues/537) 添加 destroy 方法 `引入特新`
* [532](https://github.com/Vanessa219/vditor/issues/532) 中文输入过程中不应记录 UndoStack `修复缺陷`
* [519](https://github.com/Vanessa219/vditor/issues/519) 扩展 markdown 主题 `改进功能`
* [533](https://github.com/Vanessa219/vditor/issues/533) 中文字符串中间插入 \ 字符导致乱码 `修复缺陷`
* [528](https://github.com/Vanessa219/vditor/issues/528) wysiwyg & ir 列表中有两个代码块时的错误 `修复缺陷`
* [531](https://github.com/Vanessa219/vditor/issues/531) 移除 options.keymap `改进功能`
* [529](https://github.com/Vanessa219/vditor/issues/529) 移除格式化按钮 `改进功能`
* [526](https://github.com/Vanessa219/vditor/issues/526) 字符串中带有 \ 符号时,从 \ 后面,但不是行尾 Backspace 删除字符到达 \ 时处理异常 `修复缺陷`
* [517](https://github.com/Vanessa219/vditor/issues/517) Duplicate CSS(render.html) `修复缺陷`
* [522](https://github.com/Vanessa219/vditor/issues/522) 从 WPS Office 复制文本,粘贴异常 `修复缺陷`
* [524](https://github.com/Vanessa219/vditor/issues/524) no background-color change(dark mode-abcjs) `修复缺陷`
* [516](https://github.com/Vanessa219/vditor/issues/516) 高亮自动填写功能未生效问题 `修复缺陷`
* [355](https://github.com/Vanessa219/vditor/issues/355) 新增 VditorSVDOM 渲染器 `引入特新`
* [499](https://github.com/Vanessa219/vditor/issues/499) Chrome 浏览器,Up 方向键 光标位置移动异常 `修复缺陷`

@@ -96,2 +111,9 @@ * [514](https://github.com/Vanessa219/vditor/issues/514) 只读没有禁用场景菜单 `修复缺陷`

* 为 `setValue` 方法添加 `clearStack` 参数;新增 `clearStack` 方法
* 移除 `options.keymap`
* 移除工具栏上的格式化功能
* `setContentTheme` 参数修改为 `contentTheme: string, path: string`
* `options.preview.markdow.theme` 修改为 `options.preview.theme`
* `setTheme` 参数修改为 `theme: "dark" | "classic", contentTheme?: string, codeTheme?: string, contentThemePath?: string`
* 移除 `setSelection`
* 添加 `destory` 方法

@@ -98,0 +120,0 @@ ### v3.2.12 / 2020-06-07

6

dist/index.d.ts

@@ -12,3 +12,3 @@ /// <reference types="./types" />

/** 设置主题 */
setTheme(theme: "dark" | "classic", contentTheme?: string, codeTheme?: string): void;
setTheme(theme: "dark" | "classic", contentTheme?: string, codeTheme?: string, contentThemePath?: string): void;
/** 获取 Markdown 内容 */

@@ -26,4 +26,2 @@ getValue(): string;

enable(): void;
/** 选中从 start 开始到 end 结束的字符串,不支持 wysiwyg & ir 模式 */
setSelection(start: number, end: number): void;
/** 返回选中的字符串 */

@@ -64,3 +62,5 @@ getSelection(): string;

clearStack(): void;
/** 销毁编辑器 */
destroy(): void;
}
export default Vditor;

@@ -37,4 +37,4 @@ /// <reference types="./types" />

/** 设置内容主题 */
static setContentTheme: (contentTheme: string, cdn?: string) => void;
static setContentTheme: (contentTheme: string, path: string) => void;
}
export default Vditor;
/*!
* Vditor v3.3.3 - A markdown editor written in TypeScript.
* Vditor v3.3.4 - A markdown editor written in TypeScript.
*

@@ -27,2 +27,2 @@ * MIT License

*/
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Vditor=t():e.Vditor=t()}(window,(function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=26)}([function(e,t,n){"use strict";n.d(t,"b",(function(){return a})),n.d(t,"a",(function(){return c})),n.d(t,"e",(function(){return s})),n.d(t,"h",(function(){return l})),n.d(t,"c",(function(){return d})),n.d(t,"g",(function(){return u})),n.d(t,"f",(function(){return m})),n.d(t,"d",(function(){return f}));var r=n(2),i=n(1),o=n(3),a=function(e){var t;return getSelection().rangeCount>0&&(t=getSelection().getRangeAt(0),e.isEqualNode(t.startContainer)||e.contains(t.startContainer))||(e.focus(),(t=e.ownerDocument.createRange()).setStart(e,0),t.collapse(!0)),t},c=function(e){var t=window.getSelection().getRangeAt(0);if(!e.contains(t.startContainer)&&!Object(o.e)(t.startContainer,"vditor-panel--none"))return{left:0,top:0};var n,r=e.parentElement.getBoundingClientRect();if(0===t.getClientRects().length)if(3===t.startContainer.nodeType){var i=t.startContainer.parentElement;if(!(i&&i.getClientRects().length>0))return{left:0,top:0};n=i.getClientRects()[0]}else{var a=t.startContainer.children;if(a[t.startOffset]&&a[t.startOffset].getClientRects().length>0?n=a[t.startOffset].getClientRects()[0]:t.startContainer.childNodes.length>0?(t.selectNode(t.startContainer.childNodes[Math.max(0,t.startOffset-1)]),n=t.getClientRects()[0],t.collapse(!1)):n=t.startContainer.getClientRects()[0],!n){for(var c=t.startContainer.childNodes[t.startOffset];!c.getClientRects||c.getClientRects&&0===c.getClientRects().length;)c=c.parentElement;n=c.getClientRects()[0]}}else n=t.getClientRects()[0];return{left:n.left-r.left,top:n.top-r.top}},s=function(e,t){if(!t){if(0===getSelection().rangeCount)return!1;t=getSelection().getRangeAt(0)}var n=t.commonAncestorContainer;return e.isEqualNode(n)||e.contains(n)},l=function(e){var t=window.getSelection();t.removeAllRanges(),t.addRange(e)},d=function(e,t){var n={end:0,start:0};if(!t){if(0===getSelection().rangeCount)return n;t=window.getSelection().getRangeAt(0)}if(s(e,t)){var r=t.cloneRange();e.childNodes[0]&&e.childNodes[0].childNodes[0]?r.setStart(e.childNodes[0].childNodes[0],0):r.selectNodeContents(e),r.setEnd(t.startContainer,t.startOffset),n.start=r.toString().length,n.end=n.start+t.toString().length}return n},u=function(e,t,n){var r=0,i=0,o=n.childNodes[i],a=!1,c=!1;e=Math.max(0,e),t=Math.max(0,t);var s=n.ownerDocument.createRange();for(s.setStart(o||n,0),s.collapse(!0);!c&&o;){var d=r+o.textContent.length;if(!a&&e>=r&&e<=d&&(0===e?s.setStart(o,0):3===o.childNodes[0].nodeType?s.setStart(o.childNodes[0],e-r):o.nextSibling?s.setStartBefore(o.nextSibling):s.setStartAfter(o),a=!0,e===t)){c=!0;break}a&&t>=r&&t<=d&&(0===t?s.setEnd(o,0):3===o.childNodes[0].nodeType?s.setEnd(o.childNodes[0],t-r):o.nextSibling?s.setEndBefore(o.nextSibling):s.setEndAfter(o),c=!0),r=d,o=n.childNodes[++i]}return!c&&n.childNodes[i-1]&&s.setStartBefore(n.childNodes[i-1]),l(s),s},m=function(e,t){var n=e.querySelector("wbr");if(n){if(n.previousElementSibling)if(n.previousElementSibling.isSameNode(n.previousSibling)){if(n.previousElementSibling.lastChild)return t.setStartBefore(n),t.collapse(!0),l(t),!Object(i.c)()||"EM"!==n.previousElementSibling.tagName&&"STRONG"!==n.previousElementSibling.tagName&&"S"!==n.previousElementSibling.tagName||(t.insertNode(document.createTextNode(r.a.ZWSP)),t.collapse(!1)),void n.remove();t.setStartAfter(n.previousElementSibling)}else t.setStart(n.previousSibling,n.previousSibling.textContent.length);else n.previousSibling?t.setStart(n.previousSibling,n.previousSibling.textContent.length):n.nextSibling?3===n.nextSibling.nodeType?t.setStart(n.nextSibling,0):t.setStartBefore(n.nextSibling):t.setStart(n.parentElement,0);t.collapse(!0),n.remove(),l(t)}},f=function(e,t){var n=document.createElement("div");n.innerHTML=e;var r=n.querySelectorAll("p");1!==r.length||r[0].previousSibling||r[0].nextSibling||("wysiwyg"===t.currentMode&&t.wysiwyg.element.children.length>0||"ir"===t.currentMode&&t.ir.element.children.length>0)&&(e=r[0].innerHTML.trim());var i=document.createElement("template");i.innerHTML=e;var c=a(t[t.currentMode].element);""!==c.toString()&&"sv"!==t.currentMode&&(t[t.currentMode].preventInput=!0,document.execCommand("delete",!1,""));var s=Object(o.c)(c.startContainer);i.content.firstElementChild&&"0"===i.content.firstElementChild.getAttribute("data-block")&&s?s.insertAdjacentHTML("afterend",e):(c.insertNode(i.content.cloneNode(!0)),c.collapse(!1))}},function(e,t,n){"use strict";n.d(t,"f",(function(){return r})),n.d(t,"e",(function(){return i})),n.d(t,"a",(function(){return o})),n.d(t,"b",(function(){return a})),n.d(t,"d",(function(){return c})),n.d(t,"g",(function(){return s})),n.d(t,"c",(function(){return l}));var r=function(){return navigator.userAgent.indexOf("Safari")>-1&&-1===navigator.userAgent.indexOf("Chrome")},i=function(){return navigator.userAgent.toLowerCase().indexOf("firefox")>-1},o=function(){try{return"undefined"!=typeof localStorage}catch(e){return!1}},a=function(){return navigator.userAgent.indexOf("iPhone")>-1?"touchstart":"click"},c=function(e){return navigator.platform.toUpperCase().indexOf("MAC")>=0?!(!e.metaKey||e.ctrlKey):!(e.metaKey||!e.ctrlKey)},s=function(e){return/Mac/.test(navigator.platform)||"iPhone"===navigator.platform?(e=e.replace("ctrl","⌘").replace("shift","⇧").replace("alt","⌥")).indexOf("⇧")>-1&&(e=i()?e.replace(";",":").replace("=","+"):e.replace(":",";").replace("+","=").replace("_","-")):(e=e.replace("⌘","ctrl").replace("⇧","shift").replace("⌥","alt")).indexOf("shift")>-1&&(e=e.replace(";",":").replace("=","+")),e},l=function(){return/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor)}},function(e,t,n){"use strict";n.d(t,"b",(function(){return r})),n.d(t,"a",(function(){return i}));var r="3.3.3",i=function(){function e(){}return e.ZWSP="​",e.MOBILE_WIDTH=520,e.CLASS_MENU_DISABLED="vditor-menu--disabled",e.EDIT_TOOLBARS=["emoji","headings","bold","italic","strike","link","list","ordered-list","outdent","indent","check","line","quote","code","inline-code","insert-after","insert-before","upload","record","table"],e.CONTENT_THEME=["dark","light","wechat"],e.CODE_THEME=["abap","algol","algol_nu","arduino","autumn","borland","bw","colorful","dracula","emacs","friendly","fruity","github","igor","lovelace","manni","monokai","monokailight","murphy","native","paraiso-dark","paraiso-light","pastie","perldoc","pygments","rainbow_dash","rrt","solarized-dark","solarized-dark256","solarized-light","swapoff","tango","trac","vim","vs","xcode"],e.CODE_LANGUAGES=["mermaid","echarts","mindmap","abc","graphviz","apache","bash","cs","cpp","css","coffeescript","diff","xml","http","ini","json","java","javascript","js","makefile","markdown","nginx","objectivec","php","perl","properties","python","ruby","sql","shell","dart","erb","go","gradle","julia","kotlin","less","lua","matlab","rust","scss","typescript","ts","yaml"],e}()},function(e,t,n){"use strict";n.d(t,"g",(function(){return i})),n.d(t,"d",(function(){return o})),n.d(t,"c",(function(){return a})),n.d(t,"f",(function(){return c})),n.d(t,"e",(function(){return s})),n.d(t,"h",(function(){return l})),n.d(t,"b",(function(){return d})),n.d(t,"a",(function(){return u}));var r=n(6),i=function(e,t){for(var n=s(e,t),r=!1,i=!1;n&&!n.classList.contains("vditor-reset")&&!i;)(r=s(n.parentElement,t))?n=r:i=!0;return n||!1},o=function(e,t,n){if(!e)return!1;3===e.nodeType&&(e=e.parentElement);for(var r=e,i=!1;r&&!i&&!r.classList.contains("vditor-reset");)r.getAttribute(t)===n?i=!0:r=r.parentElement;return i&&r},a=function(e){if(!e)return!1;3===e.nodeType&&(e=e.parentElement);var t=e,n=!1,r=o(e,"data-block","0");if(r)return r;for(;t&&!n&&!t.classList.contains("vditor-reset");)"H1"===t.tagName||"H2"===t.tagName||"H3"===t.tagName||"H4"===t.tagName||"H5"===t.tagName||"H6"===t.tagName||"P"===t.tagName||"BLOCKQUOTE"===t.tagName||"OL"===t.tagName||"UL"===t.tagName?n=!0:t=t.parentElement;return n&&t},c=function(e,t){if(!e)return!1;3===e.nodeType&&(e=e.parentElement);for(var n=e,r=!1;n&&!r&&!n.classList.contains("vditor-reset");)n.nodeName===t?r=!0:n=n.parentElement;return r&&n},s=function(e,t){if(!e)return!1;3===e.nodeType&&(e=e.parentElement);for(var n=e,r=!1;n&&!r&&!n.classList.contains("vditor-reset");)n.classList.contains(t)?r=!0:n=n.parentElement;return r&&n},l=function(e,t){if(!e)return!1;3===e.nodeType&&(e=e.parentElement);var n=Object(r.b)(e,t),i=!1;n&&(i=Object(r.b)(n.parentElement,t));for(var o=!1;n&&!n.classList.contains("vditor-reset")&&!o;)i?(n=Object(r.b)(n.parentElement,t))&&(i=Object(r.b)(n.parentElement,t)):o=!0;return n||!1},d=function(e){var t=l(e,"UL"),n=l(e,"OL"),r=t;return n&&(!t||t&&n.contains(t))&&(r=n),r},u=function(e){for(;e&&e.lastChild;)e=e.lastChild;return e}},function(e,t,n){"use strict";n.d(t,"a",(function(){return r}));var r={en_US:{alignCenter:"Center",alignLeft:"Left",alignRight:"Right",alternateText:"Alternate text",bold:"Blod",both:"editor & preview",check:"Task List",code:"Code Block","code-theme":"Code Block Theme Preview",column:"Column",confirm:"Confirm","content-theme":"Content Theme Preview",copied:"Copied",copy:"Copy","delete-column":"Delete Row","delete-row":"Delete Column",devtools:"DevTools",down:"Down",downloadTip:"The browser does not support the download function",edit:"Edit","edit-mode":"Toggle Edit Mode",emoji:"Emoji",export:"Export",fileTypeError:"file type is error",footnoteRef:"Footnote Ref",format:"Format",fullscreen:"Toggle Fullscreen",generate:"Generating",headings:"Headings",help:"Help",imageURL:"image URL",indent:"Indent",info:"Info","inline-code":"Inline Code","insert-after":"Insert line after","insert-before":"Insert line Before","insert-column":"Insert Column","insert-row":"Insert Row",instantRendering:"Instant Rendering",italic:"Italic",language:"Language",line:"Line",link:"Link",linkRef:"Link Ref",list:"List",more:"More",nameEmpty:"Name is empty","ordered-list":"Order List",outdent:"Outdent",outline:"Outline",over:"over",performanceTip:"Real-time preview requires ${x}ms, you can close it",preview:"Preview",quote:"Quote",record:"Start Record/End Record","record-tip":"The device does not support recording",recording:"recording...",redo:"Redo",remove:"Remove",row:"Row",splitView:"Split View",strike:"Strike",table:"Table",textIsNotEmpty:"text(no empty)",tooltipText:"Tooltip text",undo:"Undo",up:"Up",update:"Update",upload:"Upload image or file",uploadError:"upload error",uploading:"uploading...",wysiwyg:"WYSIWYG"},ko_KR:{alignCenter:"가운데",alignLeft:"왼쪽",alignRight:"오른쪽",alternateText:"이미지 태그",bold:"굵게",both:"에디터 & 미리보기",check:"체크박스",code:"코드블럭삽입","code-theme":"코드블럭테마",column:"행",confirm:"확인","content-theme":"컨텐츠테마",copied:"복사완료",copy:"복사","delete-column":"열 삭제","delete-row":"행 삭제",devtools:"개발툴",down:"다운",downloadTip:"브라우저가 다운로드 기능을 지원하지 않습니다",edit:"수정","edit-mode":"편집모드",emoji:"이모지",export:"내보내기",fileTypeError:"지원하지않습니다.",footnoteRef:"각주참조",format:"형식",fullscreen:"전체화면",generate:"생성",headings:"제목크기",help:"도움말",imageURL:"이미지 URL",indent:"들여쓰기",info:"정보","inline-code":"인라인코드","insert-after":"블락 뒤로 입력","insert-before":"블락 앞으로 입력","insert-column":"열 삽입","insert-row":"행 삽입",instantRendering:"타이포라",italic:"기울임꼴",language:"언어",line:"문단나눔",link:"링크",linkRef:"링크 참조",list:"순서없는 목록",more:"더보기",nameEmpty:"이름이 비어있습니다.","ordered-list":"순서있는 목록",outdent:"내어쓰기",outline:"개요",over:"오버",performanceTip:"실시간 미리보기에는 ${x}ms가 필요하며 에디터/미리보기 버튼을 클릭하여 닫을 수 있습니다.",preview:"미리보기",quote:"인용단락",record:"녹음시작/녹음종료","record-tip":"녹음을 지원하지 않습니다.",recording:"녹음중...",redo:"되돌리기",remove:"삭제",row:"열",splitView:"마크다운",strike:"취소선",table:"표삽입",textIsNotEmpty:"텍스트(no empty)",tooltipText:"툴팁",undo:"취소하기",up:"위로",update:"업데이트",upload:"이미지 업로드하기",uploadError:"업로드 실패",uploading:"업로드중...",wysiwyg:"위지위그"},zh_CN:{alignCenter:"居中",alignLeft:"居左",alignRight:"居右",alternateText:"替代文本",bold:"粗体",both:"编辑 & 预览",check:"任务列表",code:"代码块","code-theme":"代码块主题预览",column:"列",confirm:"确定","content-theme":"内容主题预览",copied:"已复制",copy:"复制","delete-column":"删除列","delete-row":"删除行",devtools:"开发者工具",down:"下",downloadTip:"该浏览器不支持下载功能",edit:"编辑","edit-mode":"切换编辑模式",emoji:"表情",export:"导出",fileTypeError:"文件类型不允许上传",footnoteRef:"脚注标识",format:"格式化",fullscreen:"全屏切换",generate:"生成中",headings:"标题",help:"帮助",imageURL:"图片地址",indent:"列表缩进",info:"关于","inline-code":"行内代码","insert-after":"末尾插入行","insert-before":"起始插入行","insert-column":"插入列","insert-row":"插入行",instantRendering:"即时渲染",italic:"斜体",language:"语言",line:"分隔线",link:"链接",linkRef:"引用标识",list:"无序列表",more:"更多",nameEmpty:"文件名不能为空","ordered-list":"有序列表",outdent:"列表反向缩进",outline:"大纲",over:"超过",performanceTip:"实时预览需 ${x}ms,可点击编辑 & 预览按钮进行关闭",preview:"预览",quote:"引用",record:"开始录音/结束录音","record-tip":"该设备不支持录音功能",recording:"录音中...",redo:"重做",remove:"删除",row:"行",splitView:"分屏预览",strike:"删除线",table:"表格",textIsNotEmpty:"文本(不能为空)",tooltipText:"提示文本",undo:"撤销",up:"上",update:"更新",upload:"上传图片或文件",uploadError:"上传错误",uploading:"上传中...",wysiwyg:"所见即所得"}}},function(e,t,n){"use strict";n.d(t,"b",(function(){return r})),n.d(t,"a",(function(){return i}));var r=function(e,t){if(document.getElementById(t))return!1;var n=new XMLHttpRequest;n.open("GET",e,!1),n.setRequestHeader("Accept","text/javascript, application/javascript, application/ecmascript, application/x-ecmascript, */*; q=0.01"),n.send("");var r=document.createElement("script");r.type="text/javascript",r.text=n.responseText,r.id=t,document.head.appendChild(r)},i=function(e,t){return new Promise((function(n,r){if(document.getElementById(t))return n(),!1;var i=document.createElement("script");i.src=e,i.async=!0,document.head.appendChild(i),i.onload=function(){if(document.getElementById(t))return i.remove(),n(),!1;i.id=t,n()}}))}},function(e,t,n){"use strict";n.d(t,"b",(function(){return r})),n.d(t,"a",(function(){return i}));var r=function(e,t){if(!e)return!1;3===e.nodeType&&(e=e.parentElement);for(var n=e,r=!1;n&&!r&&!n.classList.contains("vditor-reset");)0===n.nodeName.indexOf(t)?r=!0:n=n.parentElement;return r&&n},i=function(e){var t=r(e,"H");return!(!t||2!==t.tagName.length||"HR"===t.tagName)&&t}},function(e,t,n){"use strict";n.d(t,"a",(function(){return r}));var r=function(e,t){if(!document.getElementById(t)){var n=document.createElement("link");n.id=t,n.rel="stylesheet",n.type="text/css",n.href=e,document.getElementsByTagName("head")[0].appendChild(n)}}},function(e,t,n){"use strict";n.d(t,"a",(function(){return r}));var r=function(e){return e.replace(/\u00a0/g," ")}},function(e,t,n){"use strict";n.d(t,"a",(function(){return o}));var r=n(2),i=n(7),o=function(e,t){if(void 0===t&&(t="https://cdn.jsdelivr.net/npm/vditor@"+r.b),r.a.CONTENT_THEME.includes(e)){var n=document.getElementById("vditorContentTheme"),o=t+"/dist/css/content-theme/"+e+".css";"light"!==e?n?n.href!==o&&(n.remove(),Object(i.a)(o,"vditorContentTheme")):Object(i.a)(o,"vditorContentTheme"):n&&n.remove()}}},function(e,t,n){"use strict";n.d(t,"a",(function(){return o}));var r=n(2),i=n(5),o=function(e,t){void 0===e&&(e=document),void 0===t&&(t="https://cdn.jsdelivr.net/npm/vditor@"+r.b);var n=e.querySelectorAll(".language-abc");n.length>0&&Object(i.a)(t+"/dist/js/abcjs/abcjs_basic.min.js","vditorAbcjsScript").then((function(){n.forEach((function(e){var t=document.createElement("div");t.style.backgroundColor="var(--preview-background-color)",e.parentNode.replaceChild(t,e),ABCJS.renderAbc(t,e.textContent.trim()),t.style.overflowX="auto"}))}))}},function(e,t,n){"use strict";n.d(t,"a",(function(){return o}));var r=n(2),i=n(5),o=function(e,t){void 0===e&&(e=document),void 0===t&&(t="https://cdn.jsdelivr.net/npm/vditor@"+r.b);var n=e.querySelectorAll(".language-echarts");n.length>0&&Object(i.a)(t+"/dist/js/echarts/echarts.min.js","vditorEchartsScript").then((function(){n.forEach((function(e){var t=e.innerText.trim();if(t)try{if("true"===e.getAttribute("data-processed"))return;var n=JSON.parse(t);echarts.init(e).setOption(n),e.setAttribute("data-processed","true")}catch(t){e.className="vditor-reset--error",e.innerHTML="echarts render error: <br>"+t}}))}))}},function(e,t,n){"use strict";n.d(t,"a",(function(){return c}));var r=n(25),i=n.n(r),o=n(4),a=n(8),c=function(e,t){void 0===t&&(t="zh_CN"),e.querySelectorAll("pre > code").forEach((function(n,r){if(!(n.classList.contains("language-mermaid")||n.classList.contains("language-echarts")||n.classList.contains("language-mindmap")||n.classList.contains("language-abc")||n.classList.contains("language-graphviz")||n.style.maxHeight.indexOf("px")>-1||e.classList.contains("vditor-preview")&&r>5)){var c=n.innerText;if(n.classList.contains("highlight-chroma")){var s=document.createElement("code");s.innerHTML=n.innerHTML,s.querySelectorAll(".highlight-ln").forEach((function(e){e.remove()})),c=s.innerText}var l=document.createElement("div");l.className="vditor-copy",l.innerHTML='<span aria-label="'+o.a[t].copy+"\"\nonmouseover=\"this.setAttribute('aria-label', '"+o.a[t].copy+"')\"\nclass=\"vditor-tooltipped vditor-tooltipped__w\"\nonclick=\"this.previousElementSibling.select();document.execCommand('copy');this.setAttribute('aria-label', '"+o.a[t].copied+"')\">"+i.a+"</span>";var d=document.createElement("textarea");d.value=Object(a.a)(c),l.insertAdjacentElement("afterbegin",d),n.before(l),n.style.maxHeight=window.outerHeight-40+"px"}}))}},function(e,t,n){"use strict";n.d(t,"a",(function(){return o}));var r=n(2),i=n(5),o=function(e,t){void 0===t&&(t="https://cdn.jsdelivr.net/npm/vditor@"+r.b);var n=e.querySelectorAll(".language-graphviz");0!==n.length&&Object(i.a)(t+"/dist/js/graphviz/viz.js","vditorGraphVizScript").then((function(){n.forEach((function(e){if("true"!==e.getAttribute("data-processed")){try{var t=new Blob(["importScripts('"+document.getElementById("vditorGraphVizScript").src.replace("viz.js","full.render.js")+"');"],{type:"application/javascript"}),n=(window.URL||window.webkitURL).createObjectURL(t),r=new Worker(n);new Viz({worker:r}).renderSVGElement(e.textContent).then((function(t){e.innerHTML=t.outerHTML})).catch((function(t){e.innerHTML="graphviz render error: <br>"+t,e.className="vditor-math vditor-reset--error"}))}catch(e){console.error("graphviz error",e)}e.setAttribute("data-processed","true")}}))}))}},function(e,t,n){"use strict";n.d(t,"a",(function(){return a}));var r=n(2),i=n(5),o=n(7),a=function(e,t,n){void 0===t&&(t=document),void 0===n&&(n="https://cdn.jsdelivr.net/npm/vditor@"+r.b);var a=e.style;r.a.CODE_THEME.includes(a)||(a="github");var c=document.getElementById("vditorHljsStyle"),s=n+"/dist/js/highlight.js/styles/"+a+".css";(c&&c.href!==s&&c.remove(),Object(o.a)(n+"/dist/js/highlight.js/styles/"+a+".css","vditorHljsStyle"),!1!==e.enable)&&(0!==t.querySelectorAll("pre > code").length&&Object(i.a)(n+"/dist/js/highlight.js/highlight.pack.js","vditorHljsScript").then((function(){t.querySelectorAll("pre > code").forEach((function(t){if(!t.parentElement.classList.contains("vditor-ir__marker--pre")&&!t.parentElement.classList.contains("vditor-wysiwyg__pre")&&!(t.classList.contains("language-mermaid")||t.classList.contains("language-echarts")||t.classList.contains("language-mindmap")||t.classList.contains("language-abc")||t.classList.contains("language-graphviz"))&&(hljs.highlightBlock(t),e.lineNumber)){t.classList.add("vditor-linenumber");var n=t.querySelector(".vditor-linenumber__temp");n||((n=document.createElement("div")).className="vditor-linenumber__temp",t.insertAdjacentElement("beforeend",n));var r=getComputedStyle(t).whiteSpace,i=!1;"pre-wrap"!==r&&"pre-line"!==r||(i=!0);var o="",a=t.textContent.split(/\r\n|\r|\n/g);a.pop(),a.map((function(e){var t="";i&&(n.textContent=e||"\n",t=' style="height:'+n.getBoundingClientRect().height+'px"'),o+="<span"+t+"></span>"})),n.style.display="none",o='<span class="vditor-linenumber__rows">'+o+"</span>",t.insertAdjacentHTML("beforeend",o)}}))})))}},function(e,t,n){"use strict";n.d(t,"a",(function(){return c}));var r=n(2),i=n(5),o=n(7),a=n(8),c=function(e,t){var n=e.querySelectorAll(".vditor-math");if(0!==n.length){var c={cdn:"https://cdn.jsdelivr.net/npm/vditor@"+r.b,math:{engine:"KaTeX",inlineDigit:!1,macros:{}}};t&&t.math&&(t.math=Object.assign({},c.math,t.math)),"KaTeX"===(t=Object.assign({},c,t)).math.engine?(Object(o.a)(t.cdn+"/dist/js/katex/katex.min.css","vditorKatexStyle"),Object(i.a)(t.cdn+"/dist/js/katex/katex.min.js","vditorKatexScript").then((function(){n.forEach((function(e){if(!e.getAttribute("data-math")){var t=Object(a.a)(e.textContent);e.setAttribute("data-math",t);try{e.innerHTML=katex.renderToString(t,{displayMode:"DIV"===e.tagName,output:"html"})}catch(t){e.innerHTML=t.message,e.className="vditor-math vditor-reset--error"}e.addEventListener("copy",(function(e){e.stopPropagation(),e.preventDefault();var t=e.currentTarget.closest(".vditor-math");e.clipboardData.setData("text/html",t.innerHTML),e.clipboardData.setData("text/plain",t.getAttribute("data-math"))}))}}))}))):"MathJax"===t.math.engine&&(window.MathJax||(window.MathJax={loader:{paths:{mathjax:t.cdn+"/dist/js/mathjax"}},tex:{macros:t.math.macros}}),Object(i.b)(t.cdn+"/dist/js/mathjax/tex-svg.js","vditorMathJaxScript"),setTimeout((function(){n.forEach((function(e){if(!e.getAttribute("data-math")){var t=Object(a.a)(e.textContent);e.setAttribute("data-math",t),window.MathJax.texReset();var n=window.MathJax.getMetricsFor(e);n.display="DIV"===e.tagName,window.MathJax.tex2svgPromise(t,n).then((function(t){e.innerHTML="",e.append(t),window.MathJax.startup.document.clear(),window.MathJax.startup.document.updateDocument();var n=e.querySelector("mjx-container").textContent.trim();""!==n&&(e.innerHTML=n,e.className="vditor-math vditor-reset--error")}))}}))})))}}},function(e,t,n){"use strict";n.d(t,"a",(function(){return o}));var r=n(2),i=n(5),o=function(e,t,n){void 0===t&&(t=".language-mermaid"),void 0===n&&(n="https://cdn.jsdelivr.net/npm/vditor@"+r.b),0!==e.querySelectorAll(t).length&&Object(i.a)(n+"/dist/js/mermaid/mermaid.min.js","vditorMermaidScript").then((function(){mermaid.init({noteMargin:10},t)}))}},function(e,t,n){"use strict";n.d(t,"a",(function(){return o}));var r=n(2),i=n(5),o=function(e,t){void 0===e&&(e=document),void 0===t&&(t="https://cdn.jsdelivr.net/npm/vditor@"+r.b);var n=e.querySelectorAll(".language-mindmap");n.length>0&&Object(i.a)(t+"/dist/js/echarts/echarts.min.js","vditorEchartsScript").then((function(){n.forEach((function(e){var t=e.getAttribute("data-code");if(t)try{if("true"===e.getAttribute("data-processed"))return;var n={series:[{data:[JSON.parse(decodeURIComponent(t))],initialTreeDepth:-1,itemStyle:{borderWidth:0,color:"#4285f4"},label:{backgroundColor:"#f6f8fa",borderColor:"#d1d5da",borderRadius:5,borderWidth:.5,color:"#586069",lineHeight:20,offset:[-5,0],padding:[0,5],position:"insideRight"},lineStyle:{color:"#d1d5da",width:1},roam:!0,symbol:function(e,t){var n;return(null===(n=null==t?void 0:t.data)||void 0===n?void 0:n.children)?"circle":"path://"},type:"tree"}],tooltip:{trigger:"item",triggerOn:"mousemove"}};echarts.init(e).setOption(n),e.setAttribute("data-processed","true")}catch(t){e.className="vditor-reset--error",e.innerHTML="mindmap render error: <br>"+t}}))}))}},function(e,t,n){"use strict";n.d(t,"a",(function(){return r}));var r=function(e){e&&e.querySelectorAll("a").forEach((function(e){var t=e.getAttribute("href");t&&(t.match(/^.+.(mp4|m4v|ogg|ogv|webm)$/)?function(e,t){e.insertAdjacentHTML("afterend",'<video controls="controls" src="'+t+'"></video>'),e.remove()}(e,t):t.match(/^.+.(mp3|wav|flac)$/)?function(e,t){e.insertAdjacentHTML("afterend",'<audio controls="controls" src="'+t+'"></audio>'),e.remove()}(e,t):function(e,t){var n=t.match(/\/\/(?:www\.)?(?:youtu\.be\/|youtube\.com\/(?:embed\/|v\/|watch\?v=|watch\?.+&v=))([\w|-]{11})(?:(?:[\?&]t=)(\S+))?/),r=t.match(/\/\/v\.youku\.com\/v_show\/id_(\w+)=*\.html/),i=t.match(/\/\/v\.qq\.com\/x\/cover\/.*\/([^\/]+)\.html\??.*/),o=t.match(/(?:www\.|\/\/)coub\.com\/view\/(\w+)/),a=t.match(/(?:www\.|\/\/)facebook\.com\/([^\/]+)\/videos\/([0-9]+)/),c=t.match(/.+dailymotion.com\/(video|hub)\/(\w+)\?/),s=t.match(/(?:www\.|\/\/)bilibili\.com\/video\/(\w+)/),l=t.match(/(?:www\.|\/\/)ted\.com\/talks\/(\w+)/);n&&11===n[1].length?(e.insertAdjacentHTML("afterend",'<iframe class="iframe__video" src="//www.youtube.com/embed/'+n[1]+(n[2]?"?start="+n[2]:"")+'"></iframe>'),e.remove()):r&&r[1]?(e.insertAdjacentHTML("afterend",'<iframe class="iframe__video" src="//player.youku.com/embed/'+r[1]+'"></iframe>'),e.remove()):i&&i[1]?(e.insertAdjacentHTML("afterend",'<iframe class="iframe__video" src="https://v.qq.com/txp/iframe/player.html?vid='+i[1]+'"></iframe>'),e.remove()):o&&o[1]?(e.insertAdjacentHTML("afterend",'<iframe class="iframe__video"\n src="//coub.com/embed/'+o[1]+'?muted=false&autostart=false&originalSize=true&startWithHD=true"></iframe>'),e.remove()):a&&a[0]?(e.insertAdjacentHTML("afterend",'<iframe class="iframe__video"\n src="https://www.facebook.com/plugins/video.php?href='+encodeURIComponent(a[0])+'"></iframe>'),e.remove()):c&&c[2]?(e.insertAdjacentHTML("afterend",'<iframe class="iframe__video"\n src="https://www.dailymotion.com/embed/video/'+c[2]+'"></iframe>'),e.remove()):s&&s[1]?(e.insertAdjacentHTML("afterend",'<iframe class="iframe__video"\n src="//player.bilibili.com/player.html?bvid='+s[1]+'"></iframe>'),e.remove()):l&&l[1]&&(e.insertAdjacentHTML("afterend",'<iframe class="iframe__video" src="//embed.ted.com/talks/'+l[1]+'"></iframe>'),e.remove())}(e,t))}))}},function(e,t,n){"use strict";n.d(t,"a",(function(){return o}));var r=n(2),i=n(7),o=function(e,t){void 0===t&&(t="https://cdn.jsdelivr.net/npm/vditor@"+r.b),r.a.CODE_THEME.includes(e)||(e="github");var n=document.getElementById("vditorHljsStyle"),o=t+"/dist/js/highlight.js/styles/"+e+".css";n?n.href!==o&&(n.remove(),Object(i.a)(o,"vditorHljsStyle")):Object(i.a)(o,"vditorHljsStyle")}},function(e,t){e.exports='<svg version=1.1 xmlns=http://www.w3.org/2000/svg width=32 height=32 viewBox="0 0 32 32"> <path d="M6 0v32l20-15.977-20-16.023z"></path> </svg> '},function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var r=n(6),i=function(e,t,n){var i="";Array.from(e.children).forEach((function(e,t){if(Object(r.a)(e)){var o=parseInt(e.tagName.substring(1),10),a=new Array(2*(o-1)).fill("&emsp;").join(""),c="";c=n&&"ir"===n.currentMode?e.textContent.substring(o+1).trim():e.textContent.trim();var s=e.id.lastIndexOf("_"),l=e.id.substring(0,-1===s?void 0:s);e.id=l+"_"+t,i+='<div data-id="'+e.id+'" class="vditor-outline__item">'+a+c+"</div>"}})),t.innerHTML=i,t.querySelectorAll(".vditor-outline__item").forEach((function(r){r.addEventListener("click",(function(i){var o=document.getElementById(r.getAttribute("data-id"));if(o){if(n)if("auto"===n.options.height){var a=o.offsetTop+n.element.offsetTop;n.options.toolbarConfig.pin||(a+=n.toolbar.element.offsetHeight),window.scrollTo(window.scrollX,a)}else n.element.offsetTop<window.scrollY&&window.scrollTo(window.scrollX,n.element.offsetTop),n.preview.element.contains(e)?e.parentElement.scrollTop=o.offsetTop:e.scrollTop=o.offsetTop;else window.scrollTo(window.scrollX,o.offsetTop);t.querySelectorAll(".vditor-outline__item").forEach((function(e){e.classList.remove("vditor-outline__item--current")})),r.classList.add("vditor-outline__item--current")}}))}))}},function(e,t,n){"use strict";n.d(t,"a",(function(){return r}));var r=function(e){var t=Lute.New();return t.PutEmojis(e.emojis),t.SetEmojiSite(e.emojiSite),t.SetHeadingAnchor(e.headingAnchor),t.SetInlineMathAllowDigitAfterOpenMarker(e.inlineMathDigit),t.SetAutoSpace(e.autoSpace),t.SetToC(e.toc),t.SetFootnotes(e.footnotes),t.SetChinesePunct(e.chinesePunct),t.SetFixTermTypo(e.fixTermTypo),t.SetVditorCodeBlockPreview(e.codeBlockPreview),t.SetSetext(e.setext),t.SetSanitize(e.sanitize),t.SetChineseParagraphBeginningSpace(e.paragraphBeginningSpace),t.SetRenderListStyle(e.listStyle),t.SetLinkBase(e.linkBase),e.lazyLoadImage&&t.SetImageLazyLoading(e.lazyLoadImage),t}},function(e,t){e.exports='<svg version=1.1 xmlns=http://www.w3.org/2000/svg width=32 height=32 viewBox="0 0 32 32"> <path d="M11 0h-6c-0.553 0-1 0.448-1 1v30c0 0.553 0.447 1 1 1h6c0.553 0 1-0.447 1-1v-30c0-0.552-0.447-1-1-1zM27 0h-6c-0.553 0-1 0.448-1 1v30c0 0.553 0.447 1 1 1h6c0.553 0 1-0.447 1-1v-30c0-0.552-0.447-1-1-1z"></path> </svg> '},,function(e,t){e.exports='<svg xmlns=http://www.w3.org/2000/svg viewBox="0 0 32 32" width=32px height=32px> <path d="M28.681 11.159c-0.694-0.947-1.662-2.053-2.724-3.116s-2.169-2.030-3.116-2.724c-1.612-1.182-2.393-1.319-2.841-1.319h-11.5c-1.379 0-2.5 1.121-2.5 2.5v23c0 1.378 1.121 2.5 2.5 2.5h19c1.378 0 2.5-1.122 2.5-2.5v-15.5c0-0.448-0.137-1.23-1.319-2.841zM24.543 9.457c0.959 0.959 1.712 1.825 2.268 2.543h-4.811v-4.811c0.718 0.556 1.584 1.309 2.543 2.268v0zM28 29.5c0 0.271-0.229 0.5-0.5 0.5h-19c-0.271 0-0.5-0.229-0.5-0.5v-23c0-0.271 0.229-0.5 0.5-0.5 0 0 11.499-0 11.5 0v7c0 0.552 0.448 1 1 1h7v15.5zM18.841 1.319c-1.612-1.182-2.393-1.319-2.841-1.319h-11.5c-1.378 0-2.5 1.121-2.5 2.5v23c0 1.207 0.86 2.217 2 2.45v-25.45c0-0.271 0.229-0.5 0.5-0.5h15.215c-0.301-0.248-0.595-0.477-0.873-0.681z"></path> </svg>'},function(e,t,n){"use strict";n.r(t);var r=n(10),i=n(11),o=n(12),a=n(13),c=n(14),s=function(e){void 0===e&&(e=document);var t=function(e){var t=document.createElement("img");t.src=e.getAttribute("data-src"),t.addEventListener("load",(function(){e.getAttribute("style")||e.getAttribute("class")||e.getAttribute("width")||e.getAttribute("height")||t.naturalHeight>t.naturalWidth&&t.naturalWidth/t.naturalHeight<document.querySelector(".vditor-reset").clientWidth/(window.innerHeight-40)&&t.naturalHeight>window.innerHeight-40&&(e.style.height=window.innerHeight-40+"px"),e.src=t.src})),e.removeAttribute("data-src")};if(!("IntersectionObserver"in window))return e.querySelectorAll("img").forEach((function(e){e.getAttribute("data-src")&&t(e)})),!1;window.vditorImageIntersectionObserver?(window.vditorImageIntersectionObserver.disconnect(),e.querySelectorAll("img").forEach((function(e){window.vditorImageIntersectionObserver.observe(e)}))):(window.vditorImageIntersectionObserver=new IntersectionObserver((function(e){e.forEach((function(e){(void 0===e.isIntersecting?0!==e.intersectionRatio:e.isIntersecting)&&e.target.getAttribute("data-src")&&t(e.target)}))})),e.querySelectorAll("img").forEach((function(e){window.vditorImageIntersectionObserver.observe(e)})))},l=n(15),d=n(18),u=n(16),m=n(17),f=n(21),p=n(2),h=n(9),g=n(5),v=n(22),b=n(23),w=n.n(b),y=n(20),S=n.n(y),j=n(0),x=function(e,t){if(void 0===t&&(t="zh_CN"),"undefined"!=typeof speechSynthesis&&"undefined"!=typeof SpeechSynthesisUtterance){var n=document.querySelector(".vditor-speech");if(!n){(n=document.createElement("div")).className="vditor-speech",document.body.insertAdjacentElement("beforeend",n);var r=function(){var e,n;return speechSynthesis.getVoices().forEach((function(r){r.lang===t.replace("_","-")&&(e=r),r.default&&(n=r)})),e||(e=n),e};void 0!==speechSynthesis.onvoiceschanged&&(speechSynthesis.onvoiceschanged=r);var i=r();n.onclick=function(){if("vditor-speech"===n.className){var e=new SpeechSynthesisUtterance(n.getAttribute("data-text"));e.voice=i,e.onend=function(){n.className="vditor-speech",speechSynthesis.cancel(),n.innerHTML=S.a},speechSynthesis.speak(e),n.className="vditor-speech vditor-speech--current",n.innerHTML=w.a}else speechSynthesis.speaking&&(speechSynthesis.paused?(speechSynthesis.resume(),n.innerHTML=w.a):(speechSynthesis.pause(),n.innerHTML=S.a));Object(j.h)(window.vditorSpeechRange)},document.body.addEventListener("click",(function(){""===getSelection().toString().trim()&&"block"===n.style.display&&(n.className="vditor-speech",speechSynthesis.cancel(),n.style.display="none")}))}e.addEventListener("mouseup",(function(e){var t=getSelection().toString().trim();if(speechSynthesis.cancel(),""!==getSelection().toString().trim()){window.vditorSpeechRange=getSelection().getRangeAt(0).cloneRange();var r=getSelection().getRangeAt(0).getBoundingClientRect();n.innerHTML=S.a,n.style.display="block",n.style.top=r.top+r.height+document.querySelector("html").scrollTop-20+"px",n.style.left=e.screenX+2+"px",n.setAttribute("data-text",t)}else"block"===n.style.display&&(n.className="vditor-speech",n.style.display="none")}))}},E=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,c)}s((r=r.apply(e,t||[])).next())}))},T=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},L=function(e){var t={anchor:0,cdn:"https://cdn.jsdelivr.net/npm/vditor@"+p.b,customEmoji:{},emojiPath:(e&&e.emojiPath||"https://cdn.jsdelivr.net/npm/vditor@"+p.b)+"/dist/images/emoji",hljs:{enable:!0,lineNumber:!1,style:"github"},lang:"zh_CN",markdown:{autoSpace:!1,chinesePunct:!1,codeBlockPreview:!0,fixTermTypo:!1,footnotes:!0,linkBase:"",listStyle:!1,paragraphBeginningSpace:!1,sanitize:!0,setext:!1,theme:"light",toc:!1},math:{engine:"KaTeX",inlineDigit:!1,macros:{}},speech:{enable:!1}};return(null==e?void 0:e.hljs)&&(e.hljs=Object.assign({},t.hljs,e.hljs)),(null==e?void 0:e.speech)&&(e.speech=Object.assign({},t.speech,e.speech)),(null==e?void 0:e.math)&&(e.math=Object.assign({},t.math,e.math)),(null==e?void 0:e.markdown)&&(e.markdown=Object.assign({},t.markdown,e.markdown)),Object.assign(t,e)},C=function(e,t){var n=L(t);return Object(g.a)(n.cdn+"/dist/js/lute/lute.min.js","vditorLuteScript").then((function(){var r=Object(v.a)({autoSpace:n.markdown.autoSpace,chinesePunct:n.markdown.chinesePunct,codeBlockPreview:n.markdown.codeBlockPreview,emojiSite:n.emojiPath,emojis:n.customEmoji,fixTermTypo:n.markdown.fixTermTypo,footnotes:n.markdown.footnotes,headingAnchor:0!==n.anchor,inlineMathDigit:n.math.inlineDigit,lazyLoadImage:n.lazyLoadImage,linkBase:n.markdown.linkBase,listStyle:n.markdown.listStyle,paragraphBeginningSpace:n.markdown.paragraphBeginningSpace,sanitize:n.markdown.sanitize,setext:n.markdown.setext,toc:n.markdown.toc});return(null==t?void 0:t.renderers)&&r.SetJSRenderers({renderers:{Md2HTML:t.renderers}}),r.Md2HTML(e)}))},A=function(e,t,n){return E(void 0,void 0,void 0,(function(){var f,p;return T(this,(function(g){switch(g.label){case 0:return f=L(n),[4,C(t,f)];case 1:return p=g.sent(),f.transform&&(p=f.transform(p)),e.innerHTML=p,e.classList.add("vditor-reset"),Object(h.a)(f.markdown.theme,f.cdn),1===f.anchor&&e.classList.add("vditor-reset--anchor"),Object(o.a)(e,f.lang),Object(c.a)(f.hljs,e,f.cdn),Object(l.a)(e,{cdn:f.cdn,math:f.math}),Object(u.a)(e,".language-mermaid",f.cdn),Object(a.a)(e,f.cdn),Object(i.a)(e,f.cdn),Object(m.a)(e,f.cdn),Object(r.a)(e,f.cdn),Object(d.a)(e),f.speech.enable&&x(e,f.lang),0!==f.anchor&&(v=f.anchor,document.querySelectorAll(".vditor-anchor").forEach((function(e){1===v&&e.classList.add("vditor-anchor--left"),e.onclick=function(){var t=e.getAttribute("href").substr(1),n=document.getElementById("vditorAnchor-"+t).offsetTop;document.querySelector("html").scrollTop=n}})),window.onhashchange=function(){var e=document.getElementById("vditorAnchor-"+decodeURIComponent(window.location.hash.substr(1)));e&&(document.querySelector("html").scrollTop=e.offsetTop)}),f.after&&f.after(),f.lazyLoadImage&&s(e),[2]}var v}))}))},O=n(19),k=function(){function e(){}return e.codeRender=o.a,e.graphvizRender=a.a,e.highlightRender=c.a,e.mathRender=l.a,e.mermaidRender=u.a,e.chartRender=i.a,e.abcRender=r.a,e.mindmapRender=m.a,e.outlineRender=f.a,e.mediaRender=d.a,e.speechRender=x,e.lazyLoadImageRender=s,e.md2html=C,e.preview=A,e.setCodeTheme=O.a,e.setContentTheme=h.a,e}();t.default=k}]).default}));
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Vditor=t():e.Vditor=t()}(window,(function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=26)}([function(e,t,n){"use strict";n.d(t,"g",(function(){return i})),n.d(t,"d",(function(){return o})),n.d(t,"c",(function(){return a})),n.d(t,"f",(function(){return c})),n.d(t,"e",(function(){return s})),n.d(t,"h",(function(){return l})),n.d(t,"b",(function(){return d})),n.d(t,"a",(function(){return u}));var r=n(6),i=function(e,t){for(var n=s(e,t),r=!1,i=!1;n&&!n.classList.contains("vditor-reset")&&!i;)(r=s(n.parentElement,t))?n=r:i=!0;return n||!1},o=function(e,t,n){if(!e)return!1;3===e.nodeType&&(e=e.parentElement);for(var r=e,i=!1;r&&!i&&!r.classList.contains("vditor-reset");)r.getAttribute(t)===n?i=!0:r=r.parentElement;return i&&r},a=function(e){if(!e)return!1;3===e.nodeType&&(e=e.parentElement);var t=e,n=!1,r=o(e,"data-block","0");if(r)return r;for(;t&&!n&&!t.classList.contains("vditor-reset");)"H1"===t.tagName||"H2"===t.tagName||"H3"===t.tagName||"H4"===t.tagName||"H5"===t.tagName||"H6"===t.tagName||"P"===t.tagName||"BLOCKQUOTE"===t.tagName||"OL"===t.tagName||"UL"===t.tagName?n=!0:t=t.parentElement;return n&&t},c=function(e,t){if(!e)return!1;3===e.nodeType&&(e=e.parentElement);for(var n=e,r=!1;n&&!r&&!n.classList.contains("vditor-reset");)n.nodeName===t?r=!0:n=n.parentElement;return r&&n},s=function(e,t){if(!e)return!1;3===e.nodeType&&(e=e.parentElement);for(var n=e,r=!1;n&&!r&&!n.classList.contains("vditor-reset");)n.classList.contains(t)?r=!0:n=n.parentElement;return r&&n},l=function(e,t){if(!e)return!1;3===e.nodeType&&(e=e.parentElement);var n=Object(r.b)(e,t),i=!1;n&&(i=Object(r.b)(n.parentElement,t));for(var o=!1;n&&!n.classList.contains("vditor-reset")&&!o;)i?(n=Object(r.b)(n.parentElement,t))&&(i=Object(r.b)(n.parentElement,t)):o=!0;return n||!1},d=function(e){var t=l(e,"UL"),n=l(e,"OL"),r=t;return n&&(!t||t&&n.contains(t))&&(r=n),r},u=function(e){for(;e&&e.lastChild;)e=e.lastChild;return e}},function(e,t,n){"use strict";n.d(t,"b",(function(){return a})),n.d(t,"a",(function(){return c})),n.d(t,"e",(function(){return s})),n.d(t,"h",(function(){return l})),n.d(t,"c",(function(){return d})),n.d(t,"g",(function(){return u})),n.d(t,"f",(function(){return f})),n.d(t,"d",(function(){return m}));var r=n(3),i=n(2),o=n(0),a=function(e){var t;return getSelection().rangeCount>0&&(t=getSelection().getRangeAt(0),e.isEqualNode(t.startContainer)||e.contains(t.startContainer))||(e.focus(),(t=e.ownerDocument.createRange()).setStart(e,0),t.collapse(!0)),t},c=function(e){var t=window.getSelection().getRangeAt(0);if(!e.contains(t.startContainer)&&!Object(o.e)(t.startContainer,"vditor-panel--none"))return{left:0,top:0};var n,r=e.parentElement.getBoundingClientRect();if(0===t.getClientRects().length)if(3===t.startContainer.nodeType){var i=t.startContainer.parentElement;if(!(i&&i.getClientRects().length>0))return{left:0,top:0};n=i.getClientRects()[0]}else{var a=t.startContainer.children;if(a[t.startOffset]&&a[t.startOffset].getClientRects().length>0)n=a[t.startOffset].getClientRects()[0];else if(t.startContainer.childNodes.length>0){var c=t.cloneRange();t.selectNode(t.startContainer.childNodes[Math.max(0,t.startOffset-1)]),n=t.getClientRects()[0],t.setEnd(c.endContainer,c.endOffset),t.setStart(c.startContainer,c.startOffset)}else n=t.startContainer.getClientRects()[0];if(!n){for(var s=t.startContainer.childNodes[t.startOffset];!s.getClientRects||s.getClientRects&&0===s.getClientRects().length;)s=s.parentElement;n=s.getClientRects()[0]}}else n=t.getClientRects()[0];return{left:n.left-r.left,top:n.top-r.top}},s=function(e,t){if(!t){if(0===getSelection().rangeCount)return!1;t=getSelection().getRangeAt(0)}var n=t.commonAncestorContainer;return e.isEqualNode(n)||e.contains(n)},l=function(e){var t=window.getSelection();t.removeAllRanges(),t.addRange(e)},d=function(e,t){var n={end:0,start:0};if(!t){if(0===getSelection().rangeCount)return n;t=window.getSelection().getRangeAt(0)}if(s(e,t)){var r=t.cloneRange();e.childNodes[0]&&e.childNodes[0].childNodes[0]?r.setStart(e.childNodes[0].childNodes[0],0):r.selectNodeContents(e),r.setEnd(t.startContainer,t.startOffset),n.start=r.toString().length,n.end=n.start+t.toString().length}return n},u=function(e,t,n){var r=0,i=0,o=n.childNodes[i],a=!1,c=!1;e=Math.max(0,e),t=Math.max(0,t);var s=n.ownerDocument.createRange();for(s.setStart(o||n,0),s.collapse(!0);!c&&o;){var d=r+o.textContent.length;if(!a&&e>=r&&e<=d&&(0===e?s.setStart(o,0):3===o.childNodes[0].nodeType?s.setStart(o.childNodes[0],e-r):o.nextSibling?s.setStartBefore(o.nextSibling):s.setStartAfter(o),a=!0,e===t)){c=!0;break}a&&t>=r&&t<=d&&(0===t?s.setEnd(o,0):3===o.childNodes[0].nodeType?s.setEnd(o.childNodes[0],t-r):o.nextSibling?s.setEndBefore(o.nextSibling):s.setEndAfter(o),c=!0),r=d,o=n.childNodes[++i]}return!c&&n.childNodes[i-1]&&s.setStartBefore(n.childNodes[i-1]),l(s),s},f=function(e,t){var n=e.querySelector("wbr");if(n){if(n.previousElementSibling)if(n.previousElementSibling.isSameNode(n.previousSibling)){if(n.previousElementSibling.lastChild)return t.setStartBefore(n),t.collapse(!0),l(t),!Object(i.c)()||"EM"!==n.previousElementSibling.tagName&&"STRONG"!==n.previousElementSibling.tagName&&"S"!==n.previousElementSibling.tagName||(t.insertNode(document.createTextNode(r.a.ZWSP)),t.collapse(!1)),void n.remove();t.setStartAfter(n.previousElementSibling)}else t.setStart(n.previousSibling,n.previousSibling.textContent.length);else n.previousSibling?t.setStart(n.previousSibling,n.previousSibling.textContent.length):n.nextSibling?3===n.nextSibling.nodeType?t.setStart(n.nextSibling,0):t.setStartBefore(n.nextSibling):t.setStart(n.parentElement,0);t.collapse(!0),n.remove(),l(t)}},m=function(e,t){var n=document.createElement("div");n.innerHTML=e;var r="sv"===t.currentMode?n.querySelectorAll('[data-type="p"]'):n.querySelectorAll("p");1===r.length&&!r[0].previousSibling&&!r[0].nextSibling&&t[t.currentMode].element.children.length>0&&("sv"===t.currentMode&&r[0].querySelectorAll('[data-type="newline"]').forEach((function(e){e.remove()})),e=r[0].innerHTML.trim());var i=document.createElement("template");i.innerHTML=e;var c=a(t[t.currentMode].element);""!==c.toString()&&(t[t.currentMode].preventInput=!0,document.execCommand("delete",!1,""));var s=Object(o.c)(c.startContainer);i.content.firstElementChild&&"0"===i.content.firstElementChild.getAttribute("data-block")&&s?s.insertAdjacentHTML("afterend",e):(c.insertNode(i.content.cloneNode(!0)),c.collapse(!1))}},function(e,t,n){"use strict";n.d(t,"f",(function(){return r})),n.d(t,"e",(function(){return i})),n.d(t,"a",(function(){return o})),n.d(t,"b",(function(){return a})),n.d(t,"d",(function(){return c})),n.d(t,"g",(function(){return s})),n.d(t,"c",(function(){return l}));var r=function(){return navigator.userAgent.indexOf("Safari")>-1&&-1===navigator.userAgent.indexOf("Chrome")},i=function(){return navigator.userAgent.toLowerCase().indexOf("firefox")>-1},o=function(){try{return"undefined"!=typeof localStorage}catch(e){return!1}},a=function(){return navigator.userAgent.indexOf("iPhone")>-1?"touchstart":"click"},c=function(e){return navigator.platform.toUpperCase().indexOf("MAC")>=0?!(!e.metaKey||e.ctrlKey):!(e.metaKey||!e.ctrlKey)},s=function(e){return/Mac/.test(navigator.platform)||"iPhone"===navigator.platform?(e=e.replace("ctrl","⌘").replace("shift","⇧").replace("alt","⌥")).indexOf("⇧")>-1&&(e=i()?e.replace(";",":").replace("=","+"):e.replace(":",";").replace("+","=").replace("_","-")):(e=e.replace("⌘","ctrl").replace("⇧","shift").replace("⌥","alt")).indexOf("shift")>-1&&(e=e.replace(";",":").replace("=","+")),e},l=function(){return/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor)}},function(e,t,n){"use strict";n.d(t,"b",(function(){return r})),n.d(t,"a",(function(){return i}));var r="3.3.4",i=function(){function e(){}return e.ZWSP="​",e.MOBILE_WIDTH=520,e.CLASS_MENU_DISABLED="vditor-menu--disabled",e.EDIT_TOOLBARS=["emoji","headings","bold","italic","strike","link","list","ordered-list","outdent","indent","check","line","quote","code","inline-code","insert-after","insert-before","upload","record","table"],e.CODE_THEME=["abap","algol","algol_nu","arduino","autumn","borland","bw","colorful","dracula","emacs","friendly","fruity","github","igor","lovelace","manni","monokai","monokailight","murphy","native","paraiso-dark","paraiso-light","pastie","perldoc","pygments","rainbow_dash","rrt","solarized-dark","solarized-dark256","solarized-light","swapoff","tango","trac","vim","vs","xcode"],e.CODE_LANGUAGES=["mermaid","echarts","mindmap","abc","graphviz","apache","bash","cs","cpp","css","coffeescript","diff","xml","http","ini","json","java","javascript","js","makefile","markdown","nginx","objectivec","php","perl","properties","python","ruby","sql","shell","dart","erb","go","gradle","julia","kotlin","less","lua","matlab","rust","scss","typescript","ts","yaml"],e.CDN="https://cdn.jsdelivr.net/npm/vditor@3.3.4",e.MARKDOWN_OPTIONS={autoSpace:!1,chinesePunct:!1,codeBlockPreview:!0,fixTermTypo:!1,footnotes:!0,linkBase:"",listStyle:!1,paragraphBeginningSpace:!1,sanitize:!0,setext:!1,toc:!1},e.HLJS_OPTIONS={enable:!0,lineNumber:!1,style:"github"},e.MATH_OPTIONS={engine:"KaTeX",inlineDigit:!1,macros:{}},e.THEME_OPTIONS={current:"light",list:{dark:"Dark",light:"Light",wechat:"WeChat"},path:e.CDN+"/dist/css/content-theme"},e}()},function(e,t,n){"use strict";n.d(t,"a",(function(){return r}));var r={en_US:{alignCenter:"Center",alignLeft:"Left",alignRight:"Right",alternateText:"Alternate text",bold:"Blod",both:"editor & preview",check:"Task List",code:"Code Block","code-theme":"Code Block Theme Preview",column:"Column",confirm:"Confirm","content-theme":"Content Theme Preview",copied:"Copied",copy:"Copy","delete-column":"Delete Row","delete-row":"Delete Column",devtools:"DevTools",down:"Down",downloadTip:"The browser does not support the download function",edit:"Edit","edit-mode":"Toggle Edit Mode",emoji:"Emoji",export:"Export",fileTypeError:"file type is error",footnoteRef:"Footnote Ref",fullscreen:"Toggle Fullscreen",generate:"Generating",headings:"Headings",help:"Help",imageURL:"image URL",indent:"Indent",info:"Info","inline-code":"Inline Code","insert-after":"Insert line after","insert-before":"Insert line Before","insert-column":"Insert Column","insert-row":"Insert Row",instantRendering:"Instant Rendering",italic:"Italic",language:"Language",line:"Line",link:"Link",linkRef:"Link Ref",list:"List",more:"More",nameEmpty:"Name is empty","ordered-list":"Order List",outdent:"Outdent",outline:"Outline",over:"over",performanceTip:"Real-time preview requires ${x}ms, you can close it",preview:"Preview",quote:"Quote",record:"Start Record/End Record","record-tip":"The device does not support recording",recording:"recording...",redo:"Redo",remove:"Remove",row:"Row",splitView:"Split View",strike:"Strike",table:"Table",textIsNotEmpty:"text(no empty)",tooltipText:"Tooltip text",undo:"Undo",up:"Up",update:"Update",upload:"Upload image or file",uploadError:"upload error",uploading:"uploading...",wysiwyg:"WYSIWYG"},ko_KR:{alignCenter:"가운데",alignLeft:"왼쪽",alignRight:"오른쪽",alternateText:"이미지 태그",bold:"굵게",both:"에디터 & 미리보기",check:"체크박스",code:"코드블럭삽입","code-theme":"코드블럭테마",column:"행",confirm:"확인","content-theme":"컨텐츠테마",copied:"복사완료",copy:"복사","delete-column":"열 삭제","delete-row":"행 삭제",devtools:"개발툴",down:"다운",downloadTip:"브라우저가 다운로드 기능을 지원하지 않습니다",edit:"수정","edit-mode":"편집모드",emoji:"이모지",export:"내보내기",fileTypeError:"지원하지않습니다.",footnoteRef:"각주참조",fullscreen:"전체화면",generate:"생성",headings:"제목크기",help:"도움말",imageURL:"이미지 URL",indent:"들여쓰기",info:"정보","inline-code":"인라인코드","insert-after":"블락 뒤로 입력","insert-before":"블락 앞으로 입력","insert-column":"열 삽입","insert-row":"행 삽입",instantRendering:"타이포라",italic:"기울임꼴",language:"언어",line:"문단나눔",link:"링크",linkRef:"링크 참조",list:"순서없는 목록",more:"더보기",nameEmpty:"이름이 비어있습니다.","ordered-list":"순서있는 목록",outdent:"내어쓰기",outline:"개요",over:"오버",performanceTip:"실시간 미리보기에는 ${x}ms가 필요하며 에디터/미리보기 버튼을 클릭하여 닫을 수 있습니다.",preview:"미리보기",quote:"인용단락",record:"녹음시작/녹음종료","record-tip":"녹음을 지원하지 않습니다.",recording:"녹음중...",redo:"되돌리기",remove:"삭제",row:"열",splitView:"마크다운",strike:"취소선",table:"표삽입",textIsNotEmpty:"텍스트(no empty)",tooltipText:"툴팁",undo:"취소하기",up:"위로",update:"업데이트",upload:"이미지 업로드하기",uploadError:"업로드 실패",uploading:"업로드중...",wysiwyg:"위지위그"},zh_CN:{alignCenter:"居中",alignLeft:"居左",alignRight:"居右",alternateText:"替代文本",bold:"粗体",both:"编辑 & 预览",check:"任务列表",code:"代码块","code-theme":"代码块主题预览",column:"列",confirm:"确定","content-theme":"内容主题预览",copied:"已复制",copy:"复制","delete-column":"删除列","delete-row":"删除行",devtools:"开发者工具",down:"下",downloadTip:"该浏览器不支持下载功能",edit:"编辑","edit-mode":"切换编辑模式",emoji:"表情",export:"导出",fileTypeError:"文件类型不允许上传",footnoteRef:"脚注标识",fullscreen:"全屏切换",generate:"生成中",headings:"标题",help:"帮助",imageURL:"图片地址",indent:"列表缩进",info:"关于","inline-code":"行内代码","insert-after":"末尾插入行","insert-before":"起始插入行","insert-column":"插入列","insert-row":"插入行",instantRendering:"即时渲染",italic:"斜体",language:"语言",line:"分隔线",link:"链接",linkRef:"引用标识",list:"无序列表",more:"更多",nameEmpty:"文件名不能为空","ordered-list":"有序列表",outdent:"列表反向缩进",outline:"大纲",over:"超过",performanceTip:"实时预览需 ${x}ms,可点击编辑 & 预览按钮进行关闭",preview:"预览",quote:"引用",record:"开始录音/结束录音","record-tip":"该设备不支持录音功能",recording:"录音中...",redo:"重做",remove:"删除",row:"行",splitView:"分屏预览",strike:"删除线",table:"表格",textIsNotEmpty:"文本(不能为空)",tooltipText:"提示文本",undo:"撤销",up:"上",update:"更新",upload:"上传图片或文件",uploadError:"上传错误",uploading:"上传中...",wysiwyg:"所见即所得"}}},function(e,t,n){"use strict";n.d(t,"b",(function(){return r})),n.d(t,"a",(function(){return i}));var r=function(e,t){if(document.getElementById(t))return!1;var n=new XMLHttpRequest;n.open("GET",e,!1),n.setRequestHeader("Accept","text/javascript, application/javascript, application/ecmascript, application/x-ecmascript, */*; q=0.01"),n.send("");var r=document.createElement("script");r.type="text/javascript",r.text=n.responseText,r.id=t,document.head.appendChild(r)},i=function(e,t){return new Promise((function(n,r){if(document.getElementById(t))return n(),!1;var i=document.createElement("script");i.src=e,i.async=!0,document.head.appendChild(i),i.onload=function(){if(document.getElementById(t))return i.remove(),n(),!1;i.id=t,n()}}))}},function(e,t,n){"use strict";n.d(t,"b",(function(){return r})),n.d(t,"a",(function(){return i}));var r=function(e,t){if(!e)return!1;3===e.nodeType&&(e=e.parentElement);for(var n=e,r=!1;n&&!r&&!n.classList.contains("vditor-reset");)0===n.nodeName.indexOf(t)?r=!0:n=n.parentElement;return r&&n},i=function(e){var t=r(e,"H");return!(!t||2!==t.tagName.length||"HR"===t.tagName)&&t}},function(e,t,n){"use strict";n.d(t,"a",(function(){return r}));var r=function(e,t){if(!document.getElementById(t)){var n=document.createElement("link");n.id=t,n.rel="stylesheet",n.type="text/css",n.href=e,document.getElementsByTagName("head")[0].appendChild(n)}}},function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var r=n(7),i=function(e,t){var n=document.getElementById("vditorContentTheme"),i=t+"/"+e+".css";n?n.href!==i&&(n.remove(),Object(r.a)(i,"vditorContentTheme")):Object(r.a)(i,"vditorContentTheme")}},function(e,t,n){"use strict";n.d(t,"a",(function(){return r}));var r=function(e){return e.replace(/\u00a0/g," ")}},function(e,t,n){"use strict";n.d(t,"a",(function(){return o}));var r=n(3),i=n(5),o=function(e,t){void 0===e&&(e=document),void 0===t&&(t=r.a.CDN);var n=e.querySelectorAll(".language-abc");n.length>0&&Object(i.a)(t+"/dist/js/abcjs/abcjs_basic.min.js","vditorAbcjsScript").then((function(){n.forEach((function(e){var t=document.createElement("div");t.className="language-abc",e.parentNode.replaceChild(t,e),ABCJS.renderAbc(t,e.textContent.trim()),t.style.overflowX="auto"}))}))}},function(e,t,n){"use strict";n.d(t,"a",(function(){return o}));var r=n(3),i=n(5),o=function(e,t){void 0===e&&(e=document),void 0===t&&(t=r.a.CDN);var n=e.querySelectorAll(".language-echarts");n.length>0&&Object(i.a)(t+"/dist/js/echarts/echarts.min.js","vditorEchartsScript").then((function(){n.forEach((function(e){var t=e.innerText.trim();if(t)try{if("true"===e.getAttribute("data-processed"))return;var n=JSON.parse(t);echarts.init(e).setOption(n),e.setAttribute("data-processed","true")}catch(t){e.className="vditor-reset--error",e.innerHTML="echarts render error: <br>"+t}}))}))}},function(e,t,n){"use strict";n.d(t,"a",(function(){return c}));var r=n(25),i=n.n(r),o=n(4),a=n(9),c=function(e,t){void 0===t&&(t="zh_CN"),e.querySelectorAll("pre > code").forEach((function(n,r){if(!(n.classList.contains("language-mermaid")||n.classList.contains("language-echarts")||n.classList.contains("language-mindmap")||n.classList.contains("language-abc")||n.classList.contains("language-graphviz")||n.style.maxHeight.indexOf("px")>-1||e.classList.contains("vditor-preview")&&r>5)){var c=n.innerText;if(n.classList.contains("highlight-chroma")){var s=document.createElement("code");s.innerHTML=n.innerHTML,s.querySelectorAll(".highlight-ln").forEach((function(e){e.remove()})),c=s.innerText}var l=document.createElement("div");l.className="vditor-copy",l.innerHTML='<span aria-label="'+o.a[t].copy+"\"\nonmouseover=\"this.setAttribute('aria-label', '"+o.a[t].copy+"')\"\nclass=\"vditor-tooltipped vditor-tooltipped__w\"\nonclick=\"this.previousElementSibling.select();document.execCommand('copy');this.setAttribute('aria-label', '"+o.a[t].copied+"')\">"+i.a+"</span>";var d=document.createElement("textarea");d.value=Object(a.a)(c),l.insertAdjacentElement("afterbegin",d),n.before(l),n.style.maxHeight=window.outerHeight-40+"px"}}))}},function(e,t,n){"use strict";n.d(t,"a",(function(){return o}));var r=n(3),i=n(5),o=function(e,t){void 0===t&&(t=r.a.CDN);var n=e.querySelectorAll(".language-graphviz");0!==n.length&&Object(i.a)(t+"/dist/js/graphviz/viz.js","vditorGraphVizScript").then((function(){n.forEach((function(e){if("true"!==e.getAttribute("data-processed")){try{var t=new Blob(["importScripts('"+document.getElementById("vditorGraphVizScript").src.replace("viz.js","full.render.js")+"');"],{type:"application/javascript"}),n=(window.URL||window.webkitURL).createObjectURL(t),r=new Worker(n);new Viz({worker:r}).renderSVGElement(e.textContent).then((function(t){e.innerHTML=t.outerHTML})).catch((function(t){e.innerHTML="graphviz render error: <br>"+t,e.className="vditor-math vditor-reset--error"}))}catch(e){console.error("graphviz error",e)}e.setAttribute("data-processed","true")}}))}))}},function(e,t,n){"use strict";n.d(t,"a",(function(){return a}));var r=n(3),i=n(5),o=n(7),a=function(e,t,n){void 0===t&&(t=document),void 0===n&&(n=r.a.CDN);var a=e.style;r.a.CODE_THEME.includes(a)||(a="github");var c=document.getElementById("vditorHljsStyle"),s=n+"/dist/js/highlight.js/styles/"+a+".css";(c&&c.href!==s&&c.remove(),Object(o.a)(n+"/dist/js/highlight.js/styles/"+a+".css","vditorHljsStyle"),!1!==e.enable)&&(0!==t.querySelectorAll("pre > code").length&&Object(i.a)(n+"/dist/js/highlight.js/highlight.pack.js","vditorHljsScript").then((function(){t.querySelectorAll("pre > code").forEach((function(t){if(!t.parentElement.classList.contains("vditor-ir__marker--pre")&&!t.parentElement.classList.contains("vditor-wysiwyg__pre")&&!(t.classList.contains("language-mermaid")||t.classList.contains("language-echarts")||t.classList.contains("language-mindmap")||t.classList.contains("language-abc")||t.classList.contains("language-graphviz"))&&(hljs.highlightBlock(t),e.lineNumber)){t.classList.add("vditor-linenumber");var n=t.querySelector(".vditor-linenumber__temp");n||((n=document.createElement("div")).className="vditor-linenumber__temp",t.insertAdjacentElement("beforeend",n));var r=getComputedStyle(t).whiteSpace,i=!1;"pre-wrap"!==r&&"pre-line"!==r||(i=!0);var o="",a=t.textContent.split(/\r\n|\r|\n/g);a.pop(),a.map((function(e){var t="";i&&(n.textContent=e||"\n",t=' style="height:'+n.getBoundingClientRect().height+'px"'),o+="<span"+t+"></span>"})),n.style.display="none",o='<span class="vditor-linenumber__rows">'+o+"</span>",t.insertAdjacentHTML("beforeend",o)}}))})))}},function(e,t,n){"use strict";n.d(t,"a",(function(){return c}));var r=n(3),i=n(5),o=n(7),a=n(9),c=function(e,t){var n=e.querySelectorAll(".vditor-math");if(0!==n.length){var c={cdn:r.a.CDN,math:{engine:"KaTeX",inlineDigit:!1,macros:{}}};t&&t.math&&(t.math=Object.assign({},c.math,t.math)),"KaTeX"===(t=Object.assign({},c,t)).math.engine?(Object(o.a)(t.cdn+"/dist/js/katex/katex.min.css","vditorKatexStyle"),Object(i.a)(t.cdn+"/dist/js/katex/katex.min.js","vditorKatexScript").then((function(){n.forEach((function(e){if(!e.getAttribute("data-math")){var t=Object(a.a)(e.textContent);e.setAttribute("data-math",t);try{e.innerHTML=katex.renderToString(t,{displayMode:"DIV"===e.tagName,output:"html"})}catch(t){e.innerHTML=t.message,e.className="vditor-math vditor-reset--error"}e.addEventListener("copy",(function(e){e.stopPropagation(),e.preventDefault();var t=e.currentTarget.closest(".vditor-math");e.clipboardData.setData("text/html",t.innerHTML),e.clipboardData.setData("text/plain",t.getAttribute("data-math"))}))}}))}))):"MathJax"===t.math.engine&&(window.MathJax||(window.MathJax={loader:{paths:{mathjax:t.cdn+"/dist/js/mathjax"}},tex:{macros:t.math.macros}}),Object(i.b)(t.cdn+"/dist/js/mathjax/tex-svg.js","vditorMathJaxScript"),setTimeout((function(){n.forEach((function(e){if(!e.getAttribute("data-math")){var t=Object(a.a)(e.textContent);e.setAttribute("data-math",t),window.MathJax.texReset();var n=window.MathJax.getMetricsFor(e);n.display="DIV"===e.tagName,window.MathJax.tex2svgPromise(t,n).then((function(t){e.innerHTML="",e.append(t),window.MathJax.startup.document.clear(),window.MathJax.startup.document.updateDocument();var n=e.querySelector("mjx-container").textContent.trim();""!==n&&(e.innerHTML=n,e.className="vditor-math vditor-reset--error")}))}}))})))}}},function(e,t,n){"use strict";n.d(t,"a",(function(){return o}));var r=n(3),i=n(5),o=function(e,t,n){void 0===t&&(t=".language-mermaid"),void 0===n&&(n=r.a.CDN),0!==e.querySelectorAll(t).length&&Object(i.a)(n+"/dist/js/mermaid/mermaid.min.js","vditorMermaidScript").then((function(){mermaid.init({noteMargin:10},t)}))}},function(e,t,n){"use strict";n.d(t,"a",(function(){return o}));var r=n(3),i=n(5),o=function(e,t){void 0===e&&(e=document),void 0===t&&(t=r.a.CDN);var n=e.querySelectorAll(".language-mindmap");n.length>0&&Object(i.a)(t+"/dist/js/echarts/echarts.min.js","vditorEchartsScript").then((function(){n.forEach((function(e){var t=e.getAttribute("data-code");if(t)try{if("true"===e.getAttribute("data-processed"))return;var n={series:[{data:[JSON.parse(decodeURIComponent(t))],initialTreeDepth:-1,itemStyle:{borderWidth:0,color:"#4285f4"},label:{backgroundColor:"#f6f8fa",borderColor:"#d1d5da",borderRadius:5,borderWidth:.5,color:"#586069",lineHeight:20,offset:[-5,0],padding:[0,5],position:"insideRight"},lineStyle:{color:"#d1d5da",width:1},roam:!0,symbol:function(e,t){var n;return(null===(n=null==t?void 0:t.data)||void 0===n?void 0:n.children)?"circle":"path://"},type:"tree"}],tooltip:{trigger:"item",triggerOn:"mousemove"}};echarts.init(e).setOption(n),e.setAttribute("data-processed","true")}catch(t){e.className="vditor-reset--error",e.innerHTML="mindmap render error: <br>"+t}}))}))}},function(e,t,n){"use strict";n.d(t,"a",(function(){return r}));var r=function(e){e&&e.querySelectorAll("a").forEach((function(e){var t=e.getAttribute("href");t&&(t.match(/^.+.(mp4|m4v|ogg|ogv|webm)$/)?function(e,t){e.insertAdjacentHTML("afterend",'<video controls="controls" src="'+t+'"></video>'),e.remove()}(e,t):t.match(/^.+.(mp3|wav|flac)$/)?function(e,t){e.insertAdjacentHTML("afterend",'<audio controls="controls" src="'+t+'"></audio>'),e.remove()}(e,t):function(e,t){var n=t.match(/\/\/(?:www\.)?(?:youtu\.be\/|youtube\.com\/(?:embed\/|v\/|watch\?v=|watch\?.+&v=))([\w|-]{11})(?:(?:[\?&]t=)(\S+))?/),r=t.match(/\/\/v\.youku\.com\/v_show\/id_(\w+)=*\.html/),i=t.match(/\/\/v\.qq\.com\/x\/cover\/.*\/([^\/]+)\.html\??.*/),o=t.match(/(?:www\.|\/\/)coub\.com\/view\/(\w+)/),a=t.match(/(?:www\.|\/\/)facebook\.com\/([^\/]+)\/videos\/([0-9]+)/),c=t.match(/.+dailymotion.com\/(video|hub)\/(\w+)\?/),s=t.match(/(?:www\.|\/\/)bilibili\.com\/video\/(\w+)/),l=t.match(/(?:www\.|\/\/)ted\.com\/talks\/(\w+)/);n&&11===n[1].length?(e.insertAdjacentHTML("afterend",'<iframe class="iframe__video" src="//www.youtube.com/embed/'+n[1]+(n[2]?"?start="+n[2]:"")+'"></iframe>'),e.remove()):r&&r[1]?(e.insertAdjacentHTML("afterend",'<iframe class="iframe__video" src="//player.youku.com/embed/'+r[1]+'"></iframe>'),e.remove()):i&&i[1]?(e.insertAdjacentHTML("afterend",'<iframe class="iframe__video" src="https://v.qq.com/txp/iframe/player.html?vid='+i[1]+'"></iframe>'),e.remove()):o&&o[1]?(e.insertAdjacentHTML("afterend",'<iframe class="iframe__video"\n src="//coub.com/embed/'+o[1]+'?muted=false&autostart=false&originalSize=true&startWithHD=true"></iframe>'),e.remove()):a&&a[0]?(e.insertAdjacentHTML("afterend",'<iframe class="iframe__video"\n src="https://www.facebook.com/plugins/video.php?href='+encodeURIComponent(a[0])+'"></iframe>'),e.remove()):c&&c[2]?(e.insertAdjacentHTML("afterend",'<iframe class="iframe__video"\n src="https://www.dailymotion.com/embed/video/'+c[2]+'"></iframe>'),e.remove()):s&&s[1]?(e.insertAdjacentHTML("afterend",'<iframe class="iframe__video"\n src="//player.bilibili.com/player.html?bvid='+s[1]+'"></iframe>'),e.remove()):l&&l[1]&&(e.insertAdjacentHTML("afterend",'<iframe class="iframe__video" src="//embed.ted.com/talks/'+l[1]+'"></iframe>'),e.remove())}(e,t))}))}},function(e,t,n){"use strict";n.d(t,"a",(function(){return o}));var r=n(3),i=n(7),o=function(e,t){void 0===t&&(t=r.a.CDN),r.a.CODE_THEME.includes(e)||(e="github");var n=document.getElementById("vditorHljsStyle"),o=t+"/dist/js/highlight.js/styles/"+e+".css";n?n.href!==o&&(n.remove(),Object(i.a)(o,"vditorHljsStyle")):Object(i.a)(o,"vditorHljsStyle")}},function(e,t){e.exports='<svg version=1.1 xmlns=http://www.w3.org/2000/svg width=32 height=32 viewBox="0 0 32 32"> <path d="M6 0v32l20-15.977-20-16.023z"></path> </svg> '},function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var r=n(6),i=function(e,t,n){var i="";Array.from(e.children).forEach((function(e,t){if(Object(r.a)(e)){var o=parseInt(e.tagName.substring(1),10),a=new Array(2*(o-1)).fill("&emsp;").join(""),c="";c=n&&"ir"===n.currentMode?e.textContent.substring(o+1).trim():e.textContent.trim();var s=e.id.lastIndexOf("_"),l=e.id.substring(0,-1===s?void 0:s);e.id=l+"_"+t,i+='<div data-id="'+e.id+'" class="vditor-outline__item">'+a+c+"</div>"}})),t.innerHTML=i,t.querySelectorAll(".vditor-outline__item").forEach((function(r){r.addEventListener("click",(function(i){var o=document.getElementById(r.getAttribute("data-id"));if(o){if(n)if("auto"===n.options.height){var a=o.offsetTop+n.element.offsetTop;n.options.toolbarConfig.pin||(a+=n.toolbar.element.offsetHeight),window.scrollTo(window.scrollX,a)}else n.element.offsetTop<window.scrollY&&window.scrollTo(window.scrollX,n.element.offsetTop),n.preview.element.contains(e)?e.parentElement.scrollTop=o.offsetTop:e.scrollTop=o.offsetTop;else window.scrollTo(window.scrollX,o.offsetTop);t.querySelectorAll(".vditor-outline__item").forEach((function(e){e.classList.remove("vditor-outline__item--current")})),r.classList.add("vditor-outline__item--current")}}))}))}},function(e,t,n){"use strict";n.d(t,"a",(function(){return r}));var r=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];for(var n={},i=function(e){for(var t in e)e.hasOwnProperty(t)&&("[object Object]"===Object.prototype.toString.call(e[t])?n[t]=r(n[t],e[t]):n[t]=e[t])},o=0;o<e.length;o++)i(e[o]);return n}},function(e,t,n){"use strict";n.d(t,"a",(function(){return r}));var r=function(e){var t=Lute.New();return t.PutEmojis(e.emojis),t.SetEmojiSite(e.emojiSite),t.SetHeadingAnchor(e.headingAnchor),t.SetInlineMathAllowDigitAfterOpenMarker(e.inlineMathDigit),t.SetAutoSpace(e.autoSpace),t.SetToC(e.toc),t.SetFootnotes(e.footnotes),t.SetChinesePunct(e.chinesePunct),t.SetFixTermTypo(e.fixTermTypo),t.SetVditorCodeBlockPreview(e.codeBlockPreview),t.SetSetext(e.setext),t.SetSanitize(e.sanitize),t.SetChineseParagraphBeginningSpace(e.paragraphBeginningSpace),t.SetRenderListStyle(e.listStyle),t.SetLinkBase(e.linkBase),e.lazyLoadImage&&t.SetImageLazyLoading(e.lazyLoadImage),t}},function(e,t){e.exports='<svg version=1.1 xmlns=http://www.w3.org/2000/svg width=32 height=32 viewBox="0 0 32 32"> <path d="M11 0h-6c-0.553 0-1 0.448-1 1v30c0 0.553 0.447 1 1 1h6c0.553 0 1-0.447 1-1v-30c0-0.552-0.447-1-1-1zM27 0h-6c-0.553 0-1 0.448-1 1v30c0 0.553 0.447 1 1 1h6c0.553 0 1-0.447 1-1v-30c0-0.552-0.447-1-1-1z"></path> </svg> '},function(e,t){e.exports='<svg xmlns=http://www.w3.org/2000/svg viewBox="0 0 32 32" width=32px height=32px> <path d="M28.681 11.159c-0.694-0.947-1.662-2.053-2.724-3.116s-2.169-2.030-3.116-2.724c-1.612-1.182-2.393-1.319-2.841-1.319h-11.5c-1.379 0-2.5 1.121-2.5 2.5v23c0 1.378 1.121 2.5 2.5 2.5h19c1.378 0 2.5-1.122 2.5-2.5v-15.5c0-0.448-0.137-1.23-1.319-2.841zM24.543 9.457c0.959 0.959 1.712 1.825 2.268 2.543h-4.811v-4.811c0.718 0.556 1.584 1.309 2.543 2.268v0zM28 29.5c0 0.271-0.229 0.5-0.5 0.5h-19c-0.271 0-0.5-0.229-0.5-0.5v-23c0-0.271 0.229-0.5 0.5-0.5 0 0 11.499-0 11.5 0v7c0 0.552 0.448 1 1 1h7v15.5zM18.841 1.319c-1.612-1.182-2.393-1.319-2.841-1.319h-11.5c-1.378 0-2.5 1.121-2.5 2.5v23c0 1.207 0.86 2.217 2 2.45v-25.45c0-0.271 0.229-0.5 0.5-0.5h15.215c-0.301-0.248-0.595-0.477-0.873-0.681z"></path> </svg>'},function(e,t,n){"use strict";n.r(t);var r=n(10),i=n(11),o=n(12),a=n(13),c=n(14),s=function(e){void 0===e&&(e=document);var t=function(e){var t=document.createElement("img");t.src=e.getAttribute("data-src"),t.addEventListener("load",(function(){e.getAttribute("style")||e.getAttribute("class")||e.getAttribute("width")||e.getAttribute("height")||t.naturalHeight>t.naturalWidth&&t.naturalWidth/t.naturalHeight<document.querySelector(".vditor-reset").clientWidth/(window.innerHeight-40)&&t.naturalHeight>window.innerHeight-40&&(e.style.height=window.innerHeight-40+"px"),e.src=t.src})),e.removeAttribute("data-src")};if(!("IntersectionObserver"in window))return e.querySelectorAll("img").forEach((function(e){e.getAttribute("data-src")&&t(e)})),!1;window.vditorImageIntersectionObserver?(window.vditorImageIntersectionObserver.disconnect(),e.querySelectorAll("img").forEach((function(e){window.vditorImageIntersectionObserver.observe(e)}))):(window.vditorImageIntersectionObserver=new IntersectionObserver((function(e){e.forEach((function(e){(void 0===e.isIntersecting?0!==e.intersectionRatio:e.isIntersecting)&&e.target.getAttribute("data-src")&&t(e.target)}))})),e.querySelectorAll("img").forEach((function(e){window.vditorImageIntersectionObserver.observe(e)})))},l=n(15),d=n(18),u=n(16),f=n(17),m=n(21),p=n(3),h=n(8),g=n(5),v=n(22),b=n(23),w=n(24),y=n.n(w),S=n(20),j=n.n(S),x=n(1),T=function(e,t){if(void 0===t&&(t="zh_CN"),"undefined"!=typeof speechSynthesis&&"undefined"!=typeof SpeechSynthesisUtterance){var n=document.querySelector(".vditor-speech");if(!n){(n=document.createElement("div")).className="vditor-speech",document.body.insertAdjacentElement("beforeend",n);var r=function(){var e,n;return speechSynthesis.getVoices().forEach((function(r){r.lang===t.replace("_","-")&&(e=r),r.default&&(n=r)})),e||(e=n),e};void 0!==speechSynthesis.onvoiceschanged&&(speechSynthesis.onvoiceschanged=r);var i=r();n.onclick=function(){if("vditor-speech"===n.className){var e=new SpeechSynthesisUtterance(n.getAttribute("data-text"));e.voice=i,e.onend=function(){n.className="vditor-speech",speechSynthesis.cancel(),n.innerHTML=j.a},speechSynthesis.speak(e),n.className="vditor-speech vditor-speech--current",n.innerHTML=y.a}else speechSynthesis.speaking&&(speechSynthesis.paused?(speechSynthesis.resume(),n.innerHTML=y.a):(speechSynthesis.pause(),n.innerHTML=j.a));Object(x.h)(window.vditorSpeechRange)},document.body.addEventListener("click",(function(){""===getSelection().toString().trim()&&"block"===n.style.display&&(n.className="vditor-speech",speechSynthesis.cancel(),n.style.display="none")}))}e.addEventListener("mouseup",(function(e){var t=getSelection().toString().trim();if(speechSynthesis.cancel(),""!==getSelection().toString().trim()){window.vditorSpeechRange=getSelection().getRangeAt(0).cloneRange();var r=getSelection().getRangeAt(0).getBoundingClientRect();n.innerHTML=j.a,n.style.display="block",n.style.top=r.top+r.height+document.querySelector("html").scrollTop-20+"px",n.style.left=e.screenX+2+"px",n.setAttribute("data-text",t)}else"block"===n.style.display&&(n.className="vditor-speech",n.style.display="none")}))}},E=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,c)}s((r=r.apply(e,t||[])).next())}))},C=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},L=function(e){var t={anchor:0,cdn:p.a.CDN,customEmoji:{},emojiPath:(e&&e.emojiPath||p.a.CDN)+"/dist/images/emoji",hljs:p.a.HLJS_OPTIONS,lang:"zh_CN",markdown:p.a.MARKDOWN_OPTIONS,math:p.a.MATH_OPTIONS,speech:{enable:!1},theme:p.a.THEME_OPTIONS};return Object(v.a)(t,e)},O=function(e,t){var n=L(t);return Object(g.a)(n.cdn+"/dist/js/lute/lute.min.js","vditorLuteScript").then((function(){var r=Object(b.a)({autoSpace:n.markdown.autoSpace,chinesePunct:n.markdown.chinesePunct,codeBlockPreview:n.markdown.codeBlockPreview,emojiSite:n.emojiPath,emojis:n.customEmoji,fixTermTypo:n.markdown.fixTermTypo,footnotes:n.markdown.footnotes,headingAnchor:0!==n.anchor,inlineMathDigit:n.math.inlineDigit,lazyLoadImage:n.lazyLoadImage,linkBase:n.markdown.linkBase,listStyle:n.markdown.listStyle,paragraphBeginningSpace:n.markdown.paragraphBeginningSpace,sanitize:n.markdown.sanitize,setext:n.markdown.setext,toc:n.markdown.toc});return(null==t?void 0:t.renderers)&&r.SetJSRenderers({renderers:{Md2HTML:t.renderers}}),r.Md2HTML(e)}))},A=function(e,t,n){return E(void 0,void 0,void 0,(function(){var m,p;return C(this,(function(g){switch(g.label){case 0:return m=L(n),[4,O(t,m)];case 1:return p=g.sent(),m.transform&&(p=m.transform(p)),e.innerHTML=p,e.classList.add("vditor-reset"),Object(h.a)(m.theme.current,m.theme.path),1===m.anchor&&e.classList.add("vditor-reset--anchor"),Object(o.a)(e,m.lang),Object(c.a)(m.hljs,e,m.cdn),Object(l.a)(e,{cdn:m.cdn,math:m.math}),Object(u.a)(e,".language-mermaid",m.cdn),Object(a.a)(e,m.cdn),Object(i.a)(e,m.cdn),Object(f.a)(e,m.cdn),Object(r.a)(e,m.cdn),Object(d.a)(e),m.speech.enable&&T(e,m.lang),0!==m.anchor&&(v=m.anchor,document.querySelectorAll(".vditor-anchor").forEach((function(e){1===v&&e.classList.add("vditor-anchor--left"),e.onclick=function(){var t=e.getAttribute("href").substr(1),n=document.getElementById("vditorAnchor-"+t).offsetTop;document.querySelector("html").scrollTop=n}})),window.onhashchange=function(){var e=document.getElementById("vditorAnchor-"+decodeURIComponent(window.location.hash.substr(1)));e&&(document.querySelector("html").scrollTop=e.offsetTop)}),m.after&&m.after(),m.lazyLoadImage&&s(e),[2]}var v}))}))},N=n(19),M=function(){function e(){}return e.codeRender=o.a,e.graphvizRender=a.a,e.highlightRender=c.a,e.mathRender=l.a,e.mermaidRender=u.a,e.chartRender=i.a,e.abcRender=r.a,e.mindmapRender=f.a,e.outlineRender=m.a,e.mediaRender=d.a,e.speechRender=T,e.lazyLoadImageRender=s,e.md2html=O,e.preview=A,e.setCodeTheme=N.a,e.setContentTheme=h.a,e}();t.default=M}]).default}));

@@ -0,1 +1,2 @@

/// <reference types="./types" />
declare const _VDITOR_VERSION: string;

@@ -8,5 +9,33 @@ export { _VDITOR_VERSION as VDITOR_VERSION };

static readonly EDIT_TOOLBARS: string[];
static readonly CONTENT_THEME: string[];
static readonly CODE_THEME: string[];
static readonly CODE_LANGUAGES: string[];
static readonly CDN: string;
static readonly MARKDOWN_OPTIONS: {
autoSpace: boolean;
chinesePunct: boolean;
codeBlockPreview: boolean;
fixTermTypo: boolean;
footnotes: boolean;
linkBase: string;
listStyle: boolean;
paragraphBeginningSpace: boolean;
sanitize: boolean;
setext: boolean;
toc: boolean;
};
static readonly HLJS_OPTIONS: {
enable: boolean;
lineNumber: boolean;
style: string;
};
static readonly MATH_OPTIONS: IMath;
static readonly THEME_OPTIONS: {
current: string;
list: {
dark: string;
light: string;
wechat: string;
};
path: string;
};
}

@@ -1,1 +0,1 @@

export declare const abcRender: (element?: HTMLElement | Document, cdn?: string) => void;
export declare const abcRender: (element?: (HTMLElement | Document), cdn?: string) => void;

@@ -1,1 +0,1 @@

export declare const chartRender: (element?: HTMLElement | Document, cdn?: string) => void;
export declare const chartRender: (element?: (HTMLElement | Document), cdn?: string) => void;

@@ -1,1 +0,2 @@

export declare const codeRender: (element: HTMLElement, lang?: "en_US" | "ko_KR" | "zh_CN") => void;
/// <reference types="./types" />
export declare const codeRender: (element: HTMLElement, lang?: keyof II18n) => void;

@@ -6,2 +6,2 @@ declare global {

}
export declare const lazyLoadImageRender: (element?: HTMLElement | Document) => boolean;
export declare const lazyLoadImageRender: (element?: (HTMLElement | Document)) => boolean;

@@ -1,1 +0,1 @@

export declare const mindmapRender: (element?: HTMLElement | Document, cdn?: string) => void;
export declare const mindmapRender: (element?: (HTMLElement | Document), cdn?: string) => void;

@@ -0,1 +1,2 @@

/// <reference types="./types" />
declare global {

@@ -6,2 +7,2 @@ interface Window {

}
export declare const speechRender: (element: HTMLElement, lang?: "en_US" | "ko_KR" | "zh_CN") => void;
export declare const speechRender: (element: HTMLElement, lang?: keyof II18n) => void;
/// <reference types="./types" />
declare class Editor {
element: HTMLPreElement;
range: Range;
composingLock: boolean;
processTimeoutId: number;
hlToolbarTimeoutId: number;
preventInput: boolean;
constructor(vditor: IVditor);

@@ -6,0 +9,0 @@ private bindEvent;

/// <reference types="./types" />
export declare const inputEvent: (vditor: IVditor, options?: {
enableAddUndoStack: boolean;
enableHint: boolean;
enableInput: boolean;
}) => void;
export declare const inputEvent: (vditor: IVditor, event?: InputEvent) => void;
/// <reference types="./types" />
import { MenuItem } from "./MenuItem";
export declare const setEditMode: (vditor: IVditor, type: string, event: string | Event) => void;
export declare const setEditMode: (vditor: IVditor, type: string, event: Event | string) => void;
export declare class EditMode extends MenuItem {

@@ -5,0 +5,0 @@ element: HTMLElement;

@@ -1,1 +0,1 @@

export declare const setContentTheme: (contentTheme: string, cdn?: string) => void;
export declare const setContentTheme: (contentTheme: string, path: string) => void;
/// <reference types="./types" />
declare class Undo {
private undoStack;
private redoStack;
private stackSize;
private dmp;
private lastText;
private hasUndo;
private timeout;
private wysiwyg;
private ir;
private sv;
constructor();
clearStack(vditor: IVditor): void;
resetIcon(vditor: IVditor): void;
recordFirstPosition(vditor: IVditor): void;
undo(vditor: IVditor): void;
redo(vditor: IVditor): void;
recordFirstPosition(vditor: IVditor, event: KeyboardEvent): void;
addToUndoStack(vditor: IVditor): void;
private renderDiff;
private resetStack;
}
export { Undo };

@@ -8,3 +8,3 @@ /// <reference types="./types" />

}
declare const uploadFiles: (vditor: IVditor, files: DataTransferItemList | FileList | File[], element?: HTMLInputElement) => void;
declare const uploadFiles: (vditor: IVditor, files: FileList | DataTransferItemList | File[], element?: HTMLInputElement) => void;
export { Upload, uploadFiles };
/// <reference types="./types" />
export declare const focusEvent: (vditor: IVditor, editorElement: HTMLElement) => void;
export declare const blurEvent: (vditor: IVditor, editorElement: HTMLElement) => void;
export declare const dropEvent: (vditor: IVditor, editorElement: HTMLElement) => void;
export declare const scrollCenter: (vditor: IVditor) => void;
export declare const hotkeyEvent: (vditor: IVditor, editorElement: HTMLElement) => void;
export declare const selectEvent: (vditor: IVditor, editorElement: HTMLElement) => void;
/// <reference types="./types" />
export declare const fixGSKeyBackspace: (event: KeyboardEvent, vditor: IVditor) => boolean;
export declare const fixGSKeyBackspace: (event: KeyboardEvent, vditor: IVditor, startContainer: Node) => boolean;
export declare const fixCJKPosition: (range: Range, event: KeyboardEvent) => void;

@@ -18,6 +18,10 @@ export declare const fixCursorDownInlineMath: (range: Range, key: string) => void;

export declare const renderToc: (vditor: IVditor) => void;
export declare const execAfterRender: (vditor: IVditor) => void;
export declare const fixList: (range: Range, vditor: IVditor, pElement: false | HTMLElement, event: KeyboardEvent) => boolean;
export declare const execAfterRender: (vditor: IVditor, options?: {
enableAddUndoStack: boolean;
enableHint: boolean;
enableInput: boolean;
}) => void;
export declare const fixList: (range: Range, vditor: IVditor, pElement: HTMLElement | false, event: KeyboardEvent) => boolean;
export declare const fixTab: (vditor: IVditor, range: Range, event: KeyboardEvent) => boolean;
export declare const fixMarkdown: (event: KeyboardEvent, vditor: IVditor, pElement: false | HTMLElement, range: Range) => boolean;
export declare const fixMarkdown: (event: KeyboardEvent, vditor: IVditor, pElement: HTMLElement | false, range: Range) => boolean;
export declare const insertRow: (vditor: IVditor, range: Range, cellElement: HTMLElement) => void;

@@ -29,5 +33,5 @@ export declare const insertColumn: (vditor: IVditor, tableElement: HTMLTableElement, cellElement: HTMLElement) => void;

export declare const fixCodeBlock: (vditor: IVditor, event: KeyboardEvent, codeRenderElement: HTMLElement, range: Range) => boolean;
export declare const fixBlockquote: (vditor: IVditor, range: Range, event: KeyboardEvent, pElement: false | HTMLElement) => boolean;
export declare const fixBlockquote: (vditor: IVditor, range: Range, event: KeyboardEvent, pElement: HTMLElement | false) => boolean;
export declare const fixTask: (vditor: IVditor, range: Range, event: KeyboardEvent) => boolean;
export declare const fixDelete: (vditor: IVditor, range: Range, event: KeyboardEvent, pElement: false | HTMLElement) => boolean;
export declare const fixDelete: (vditor: IVditor, range: Range, event: KeyboardEvent, pElement: HTMLElement | false) => boolean;
export declare const fixHR: (range: Range) => void;

@@ -34,0 +38,0 @@ export declare const fixFirefoxArrowUpTable: (event: KeyboardEvent, blockElement: false | HTMLElement, range: Range) => boolean;

@@ -5,3 +5,2 @@ /// <reference types="./types" />

private defaultOptions;
private toolbarItem;
constructor(options: IOptions);

@@ -8,0 +7,0 @@ merge(): IOptions;

@@ -7,2 +7,6 @@ declare module "*.svg";

interface IObject {
[key: string]: string;
}
interface ILuteNode {

@@ -96,3 +100,3 @@ TokensStr: () => string;

interface ILuteOptions extends IMarkdownConfig {
emojis: { [key: string]: string };
emojis: IObject;
emojiSite: string;

@@ -109,2 +113,3 @@ headingAnchor: boolean;

Version: string;
Caret: string;

@@ -119,2 +124,3 @@ New(): ILute;

HTML2VditorIRDOM?: ILuteRender,
HTML2VditorSVDOM?: ILuteRender,
HTML2Md?: ILuteRender,

@@ -124,2 +130,3 @@ Md2HTML?: ILuteRender,

Md2VditorIRDOM?: ILuteRender,
Md2VditorSVDOM?: ILuteRender,
},

@@ -158,5 +165,5 @@ }): void;

PutEmojis(emojis: { [key: string]: string }): void;
PutEmojis(emojis: IObject): void;
GetEmojis(): { [key: string]: string };
GetEmojis(): IObject;

@@ -196,3 +203,3 @@ FormatMd(markdown: string): string;

// md 转换为 ir
Md2VditorIRDOM(html: string): string;
Md2VditorIRDOM(text: string): string;

@@ -202,3 +209,13 @@ // 获取 HTML

// 粘贴时将 html 转换为 sv
HTML2VditorIRDOM(html: string): string;
// sv 输入渲染
SpinVditorSVDOM(text: string): string;
// 粘贴时将 html 转换为 sv
HTML2VditorSVDOM(html: string): string;
// md 转换为 sv
Md2VditorSVDOM(text: string): string;
}

@@ -211,12 +228,6 @@

interface II18nLang {
en_US: string;
ko_KR: string;
zh_CN: string;
}
interface II18n {
en_US: { [key: string]: string };
ko_KR: { [key: string]: string };
zh_CN: { [key: string]: string };
en_US: IObject;
ko_KR: IObject;
zh_CN: IObject;
}

@@ -228,2 +239,8 @@

interface IPreviewTheme {
current: string;
list?: IObject;
path: string;
}
/** @link https://hacpai.com/article/1549638745630#options-upload */

@@ -244,3 +261,3 @@ interface IUpload {

/** 请求头设置 */
headers?: { [key: string]: string };
headers?: IObject;
/** 额外请求参数 */

@@ -250,3 +267,3 @@ extraData?: { [key: string]: string | Blob };

/** 每次上传前都会重新设置请求头 */
setHeaders?(): { [key: string]: string };
setHeaders?(): IObject;

@@ -342,4 +359,2 @@ /** 上传成功回调 */

sanitize: boolean;
/** 内容主题。默认值:light */
theme?: string;
/** 链接前缀。默认值:'' */

@@ -367,2 +382,4 @@ linkBase?: string;

markdown?: IMarkdownConfig;
/** @link https://hacpai.com/article/1549638745630#options-preview-theme */
theme?: IPreviewTheme;

@@ -377,4 +394,4 @@ /** 预览回调 */

interface IPreviewOptions {
customEmoji?: { [key: string]: string };
lang?: (keyof II18nLang);
customEmoji?: IObject;
lang?: (keyof II18n);
lazyLoadImage?: string;

@@ -391,2 +408,3 @@ emojiPath?: string;

renderers?: ILuteRender;
theme?: IPreviewTheme;

@@ -410,3 +428,3 @@ transform?(html: string): string;

/** 默认表情,可从 [lute/emoji_map](https://github.com/88250/lute/blob/master/parse/emoji_map.go#L32) 中选取,也可自定义 */
emoji?: { [key: string]: string };
emoji?: IObject;
/** 表情图片地址。默认值: 'https://cdn.jsdelivr.net/npm/vditor@${VDITOR_VERSION}/dist/images/emoji' */

@@ -434,4 +452,2 @@ emojiPath?: string;

typewriterMode?: boolean;
/** @link https://hacpai.com/article/1549638745630#options-keymap */
keymap?: { [key: string]: string };
/** 编辑器总高度。默认值: 'auto' */

@@ -446,3 +462,3 @@ height?: number | string;

/** 多语言。默认值: 'zh_CN' */
lang?: (keyof II18nLang);
lang?: (keyof II18n);
/** @link https://hacpai.com/article/1549638745630#options-toolbar */

@@ -539,5 +555,2 @@ toolbar?: Array<string | IMenuItem>;

};
sv?: {
element: HTMLPreElement,
};
counter?: {

@@ -574,21 +587,5 @@ element: HTMLElement

addToUndoStack(vditor: IVditor): void
recordFirstPosition(vditor: IVditor): void,
recordFirstPosition(vditor: IVditor, event: KeyboardEvent): void,
resetIcon(vditor: IVditor): void,
};
wysiwygUndo?: {
clearStack(vditor: IVditor): void,
redo(vditor: IVditor): void
undo(vditor: IVditor): void
addToUndoStack(vditor: IVditor): void
recordFirstWbr(vditor: IVditor, event: KeyboardEvent): void,
resetIcon(vditor: IVditor): void,
};
irUndo?: {
clearStack(vditor: IVditor): void,
redo(vditor: IVditor): void
undo(vditor: IVditor): void
addToUndoStack(vditor: IVditor): void
recordFirstWbr(vditor: IVditor, event: KeyboardEvent): void,
resetIcon(vditor: IVditor): void,
};
wysiwyg?: {

@@ -609,2 +606,9 @@ element: HTMLPreElement,

};
sv?: {
element: HTMLPreElement,
processTimeoutId: number,
hlToolbarTimeoutId: number,
composingLock: boolean,
preventInput: boolean,
};
}
{
"name": "vditor",
"version": "3.3.3",
"version": "3.3.4",
"description": "♏ An In-browser Markdown editor, support WYSIWYG, Instant Rendering (Typora-like) and Split View modes.",

@@ -18,19 +18,20 @@ "author": "Vanessa <v@b3log.org> (http://vanessa.b3log.org)",

"dependencies": {
"diff-match-patch": "^1.0.4"
"diff-match-patch": "^1.0.5"
},
"types": "dist/index.d.ts",
"devDependencies": {
"@babel/core": "^7.8.7",
"@babel/preset-env": "^7.8.7",
"@babel/core": "^7.10.4",
"@babel/preset-env": "^7.10.4",
"@types/diff-match-patch": "^1.0.32",
"@types/jest": "^25.1.4",
"@types/puppeteer": "^2.0.1",
"autoprefixer": "^9.7.4",
"babel-loader": "^8.0.6",
"@types/jest": "^25.2.3",
"@types/puppeteer": "^2.1.1",
"autoprefixer": "^9.8.4",
"babel-loader": "^8.1.0",
"copy-webpack-plugin": "^5.1.1",
"css-loader": "^3.4.2",
"css-loader": "^3.6.0",
"file-loader": "^4.3.0",
"html-loader": "^0.5.5",
"html-webpack-plugin": "^3.2.0",
"jest": "^25.1.0",
"identity-obj-proxy": "^3.0.0",
"jest": "^25.5.4",
"mini-css-extract-plugin": "^0.8.2",

@@ -44,10 +45,10 @@ "node-sass": "^4.14.1",

"sass-loader": "^7.3.1",
"style-loader": "^1.1.3",
"ts-jest": "^25.4.0",
"ts-loader": "^6.2.1",
"style-loader": "^1.2.1",
"ts-jest": "^25.5.1",
"ts-loader": "^6.2.2",
"tslint": "^5.20.1",
"typescript": "^3.8.3",
"webpack": "^4.42.0",
"webpack-bundle-analyzer": "^3.6.1",
"webpack-cli": "^3.3.11",
"typescript": "^3.9.6",
"webpack": "^4.43.0",
"webpack-bundle-analyzer": "^3.8.0",
"webpack-cli": "^3.3.12",
"webpack-dev-server": "^3.11.0"

@@ -54,0 +55,0 @@ },

@@ -169,17 +169,18 @@ <p align="center">

* Toolbar, you can use name for shorthand: `toolbar: ['emoji', 'br', 'bold', '|', 'line']`. See default [src/ts/util/Options.ts](https://github.com/Vanessa219/vditor/blob/master/src/ts/util/Options.ts)
* name can be enumerated as: `emoji` , `headings` , `bold` , `italic` , `strike` , `|` , `line` , `quote` , `list` , `ordered-list` , `check` ,`outdent` ,`indent` , `code` , `inline-code`, `insert-after`, `insert-before`, `code-theme`, `content-theme`, `export`, `undo` , `redo` , `upload` , `link` , `table` , `record` , `edit-mode` , `both` , `preview` , `format` , `fullscreen` , `outline` , `devtools` , `info` , `help` , `br`
* name can be enumerated as: `emoji` , `headings` , `bold` , `italic` , `strike` , `|` , `line` , `quote` , `list` , `ordered-list` , `check` ,`outdent` ,`indent` , `code` , `inline-code`, `insert-after`, `insert-before`, `code-theme`, `content-theme`, `export`, `undo` , `redo` , `upload` , `link` , `table` , `record` , `edit-mode` , `both` , `preview` , `fullscreen` , `outline` , `devtools` , `info` , `help` , `br`
* When `name` is not in the enumeration, you can add a custom button in the following format:
```js
{
hotkey: '⌘-⇧-f',
name: 'format',
tipPosition: 'ne',
tip: 'format',
className: '',
icon: '<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="768" height="768" viewBox="0 0 768 768"><path d="M342 426v-84h426v84h-426zM342 256v-86h426v86h-426zM0 0h768v86h-768v-86zM342 598v-86h426v86h-426zM0 214l170 170-170 170v-340zM0 768v-86h768v86h-768z"></path></svg>',
click: () => {
alert('custom toolbar')
},
}
new Vditor('vditor', {
toolbar: [
{
hotkey: '⌘-⇧-S',
name: 'sponsor',
tipPosition: 's',
tip: '成为赞助者',
className: 'right',
icon: '<svg t="1589994565028" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2808" width="32" height="32"><path d="M506.6 423.6m-29.8 0a29.8 29.8 0 1 0 59.6 0 29.8 29.8 0 1 0-59.6 0Z" fill="#0F0F0F" p-id="2809"></path><path d="M717.8 114.5c-83.5 0-158.4 65.4-211.2 122-52.7-56.6-127.7-122-211.2-122-159.5 0-273.9 129.3-273.9 288.9C21.5 562.9 429.3 913 506.6 913s485.1-350.1 485.1-509.7c0.1-159.5-114.4-288.8-273.9-288.8z" fill="#FAFCFB" p-id="2810"></path><path d="M506.6 926c-22 0-61-20.1-116-59.6-51.5-37-109.9-86.4-164.6-139-65.4-63-217.5-220.6-217.5-324 0-81.4 28.6-157.1 80.6-213.1 53.2-57.2 126.4-88.8 206.3-88.8 40 0 81.8 14.1 124.2 41.9 28.1 18.4 56.6 42.8 86.9 74.2 30.3-31.5 58.9-55.8 86.9-74.2 42.5-27.8 84.3-41.9 124.2-41.9 79.9 0 153.2 31.5 206.3 88.8 52 56 80.6 131.7 80.6 213.1 0 103.4-152.1 261-217.5 324-54.6 52.6-113.1 102-164.6 139-54.8 39.5-93.8 59.6-115.8 59.6zM295.4 127.5c-72.6 0-139.1 28.6-187.3 80.4-47.5 51.2-73.7 120.6-73.7 195.4 0 64.8 78.3 178.9 209.6 305.3 53.8 51.8 111.2 100.3 161.7 136.6 56.1 40.4 88.9 54.8 100.9 54.8s44.7-14.4 100.9-54.8c50.5-36.3 108-84.9 161.7-136.6 131.2-126.4 209.6-240.5 209.6-305.3 0-74.9-26.2-144.2-73.7-195.4-48.2-51.9-114.7-80.4-187.3-80.4-61.8 0-127.8 38.5-201.7 117.9-2.5 2.6-5.9 4.1-9.5 4.1s-7.1-1.5-9.5-4.1C423.2 166 357.2 127.5 295.4 127.5z" fill="#141414" p-id="2811"></path><path d="M353.9 415.6m-33.8 0a33.8 33.8 0 1 0 67.6 0 33.8 33.8 0 1 0-67.6 0Z" fill="#0F0F0F" p-id="2812"></path><path d="M659.3 415.6m-33.8 0a33.8 33.8 0 1 0 67.6 0 33.8 33.8 0 1 0-67.6 0Z" fill="#0F0F0F" p-id="2813"></path><path d="M411.6 538.5c0 52.3 42.8 95 95 95 52.3 0 95-42.8 95-95v-31.7h-190v31.7z" fill="#5B5143" p-id="2814"></path><path d="M506.6 646.5c-59.6 0-108-48.5-108-108v-31.7c0-7.2 5.8-13 13-13h190.1c7.2 0 13 5.8 13 13v31.7c0 59.5-48.5 108-108.1 108z m-82-126.7v18.7c0 45.2 36.8 82 82 82s82-36.8 82-82v-18.7h-164z" fill="#141414" p-id="2815"></path><path d="M450.4 578.9a54.7 27.5 0 1 0 109.4 0 54.7 27.5 0 1 0-109.4 0Z" fill="#EA64F9" p-id="2816"></path><path d="M256 502.7a32.1 27.5 0 1 0 64.2 0 32.1 27.5 0 1 0-64.2 0Z" fill="#EFAFF9" p-id="2817"></path><path d="M703.3 502.7a32.1 27.5 0 1 0 64.2 0 32.1 27.5 0 1 0-64.2 0Z" fill="#EFAFF9" p-id="2818"></path></svg>',
click () {alert('捐赠地址:https://hacpai.com/sponsor')},
}],
})
```

@@ -193,3 +194,3 @@

| tipPosition | Prompt location: ne, nw | - |
| hotkey | Shortcut keys, support <kbd>⌘/ctrl-key</kbd> or <kbd>⌘/ctrl-⇧/shift-key</kbd> format configuration, do not support wysiwyg mode | - |
| hotkey | Shortcut keys, support <kbd>⌘/ctrl-key</kbd> or <kbd>⌘/ctrl-⇧/shift-key</kbd> format configuration | - |
| suffix | Insert the suffix in the editor | - |

@@ -235,2 +236,10 @@ | prefix | Insert the prefix in the editor | - |

#### options.preview.theme
| | Explanation | Default |
| - | - | - |
| current | current Markdown Theme | "light" |
| list | Choose Markdown Theme List | { dark: "Dark", light: "Light", wechat: "WeChat" } |
| path | CSS Path | `https://cdn.jsdelivr.net/npm/vditor@${VDITOR_VERSION}/dist/css/content-theme` |
#### options.preview.hljs

@@ -254,3 +263,2 @@

| codeBlockPreview |Whether to render code blocks in wysiwyg and ir modes | true |
| theme | Content Theme | 'light' |
| setext | Whether to parse the setext header | fa;se |

@@ -350,9 +358,2 @@ | paragraphBeginningSpace | Two spaces before the paragraph | false |

#### options.keymap
| | Explanation | Default |
| - | - | - |
| deleteLine | Delete the cursor line or selected line | '⌘-Backspace' |
| duplicate | Copy current line or selected content | '⌘-D' |
#### methods

@@ -369,3 +370,2 @@

| enable() | Unedit editor |
| setSelection(start: number, end: number) | Select the string from start to end and does not support wysiwyg mode |
| getSelection(): string | Returns the selected string |

@@ -385,4 +385,5 @@ | setValue(markdown: string, clearStack = false) | Set editor content |

| setPreviewMode(mode: "both" \| "editor") | Set preview mode |
| setTheme(theme: "dark" \| "classic", contentTheme?: string, codeTheme?: string) | Set theme |
| setTheme(theme: "dark" | "classic", contentTheme?: string, codeTheme?: string, contentThemePath?: string) | Set theme |
| getCurrentMode(): string | Get the editor's current editing mode |
| destroy() | Destroy the vditor |

@@ -444,3 +445,3 @@ #### static methods

| setCodeTheme (codeTheme: string, cdn = options.cdn) | update code theme |
| setContentTheme (contentTheme: string, cdn = options.cdn) | update content theme |
| setContentTheme (contentTheme: string, path: string) | update content theme |
| mindmapRender (element: (HTMLElement \| Document) = document, cdn = options.cdn) | Render mind map |

@@ -447,0 +448,0 @@

@@ -15,7 +15,5 @@ import VditorMethod from "./method";

import {Resize} from "./ts/resize/index";
import {formatRender} from "./ts/sv/formatRender";
import {getSelectText} from "./ts/sv/getSelectText";
import {html2md} from "./ts/sv/html2md";
import {Editor} from "./ts/sv/index";
import {insertText} from "./ts/sv/insertText";
import {inputEvent} from "./ts/sv/inputEvent";
import {processAfterRender as processSVAfterRender} from "./ts/sv/process";
import {Tip} from "./ts/tip";

@@ -31,8 +29,8 @@ import {Toolbar} from "./ts/toolbar/index";

import {Undo} from "./ts/undo";
import {IRUndo} from "./ts/undo/IRUndo";
import {WysiwygUndo} from "./ts/undo/WysiwygUndo";
import {Upload} from "./ts/upload/index";
import {addScript} from "./ts/util/addScript";
import {getSelectText} from "./ts/util/getSelectText";
import {Options} from "./ts/util/Options";
import {getCursorPosition, getEditorRange, setSelectionByPosition} from "./ts/util/selection";
import {processCodeRender} from "./ts/util/processCode";
import {getCursorPosition, getEditorRange} from "./ts/util/selection";
import {WYSIWYG} from "./ts/wysiwyg";

@@ -91,5 +89,3 @@ import {input} from "./ts/wysiwyg/input";

this.vditor.wysiwyg = new WYSIWYG(this.vditor);
this.vditor.wysiwygUndo = new WysiwygUndo();
this.vditor.ir = new IR(this.vditor);
this.vditor.irUndo = new IRUndo();
this.vditor.toolbar = new Toolbar(this.vditor);

@@ -142,8 +138,8 @@

/** 设置主题 */
public setTheme(theme: "dark" | "classic", contentTheme?: string, codeTheme?: string) {
public setTheme(theme: "dark" | "classic", contentTheme?: string, codeTheme?: string, contentThemePath?: string) {
this.vditor.options.theme = theme;
setTheme(this.vditor);
if (contentTheme) {
this.vditor.options.preview.markdown.theme = contentTheme;
setContentTheme(contentTheme, this.vditor.options.cdn);
this.vditor.options.preview.theme.current = contentTheme;
setContentTheme(contentTheme, contentThemePath || this.vditor.options.preview.theme.path);
}

@@ -201,15 +197,5 @@ if (codeTheme) {

this.vditor.undo.resetIcon(this.vditor);
this.vditor.wysiwygUndo.resetIcon(this.vditor);
this.vditor[this.vditor.currentMode].element.setAttribute("contenteditable", "true");
}
/** 选中从 start 开始到 end 结束的字符串,不支持 wysiwyg & ir 模式 */
public setSelection(start: number, end: number) {
if (this.vditor.currentMode !== "sv") {
console.error("所见即所得模式暂不支持该方法");
} else {
setSelectionByPosition(start, end, this.vditor.sv.element);
}
}
/** 返回选中的字符串 */

@@ -262,3 +248,3 @@ public getSelection() {

public html2md(value: string) {
return html2md(this.vditor, value);
return this.vditor.lute.HTML2Md(value);
}

@@ -286,7 +272,3 @@

}
if (this.vditor.currentMode === "sv") {
insertText(this.vditor, "", "", true);
} else {
document.execCommand("delete", false);
}
document.execCommand("delete", false);
}

@@ -296,7 +278,3 @@

public updateValue(value: string) {
if (this.vditor.currentMode === "sv") {
insertText(this.vditor, value, "", true);
} else {
document.execCommand("insertHTML", false, value);
}
document.execCommand("insertHTML", false, value);
}

@@ -306,7 +284,11 @@

public insertValue(value: string, render = true) {
const range = getEditorRange(this.vditor[this.vditor.currentMode].element);
range.collapse(true);
if (this.vditor.currentMode === "sv") {
insertText(this.vditor, value, "");
this.vditor.sv.preventInput = true;
document.execCommand("insertHTML", false, value);
if (render) {
inputEvent(this.vditor);
}
} else if (this.vditor.currentMode === "wysiwyg") {
const range = getEditorRange(this.vditor.wysiwyg.element);
range.collapse(true);
this.vditor.wysiwyg.preventInput = true;

@@ -318,4 +300,2 @@ document.execCommand("insertHTML", false, value);

} else if (this.vditor.currentMode === "ir") {
const range = getEditorRange(this.vditor.ir.element);
range.collapse(true);
this.vditor.ir.preventInput = true;

@@ -335,6 +315,4 @@ document.execCommand("insertHTML", false, value);

if (this.vditor.currentMode === "sv") {
formatRender(this.vditor, markdown, {
end: markdown.length,
start: markdown.length,
}, {
this.vditor.sv.element.innerHTML = this.vditor.lute.SpinVditorSVDOM(markdown);
processSVAfterRender(this.vditor, {
enableAddUndoStack: !clearStack,

@@ -352,2 +330,6 @@ enableHint: false,

this.vditor.ir.element.innerHTML = this.vditor.lute.Md2VditorIRDOM(markdown);
this.vditor.ir.element.querySelectorAll(".vditor-ir__preview[data-render='2']").forEach(
(item: HTMLElement) => {
processCodeRender(item, this.vditor);
});
processAfterRender(this.vditor, {

@@ -374,7 +356,13 @@ enableAddUndoStack: !clearStack,

this.vditor.undo.clearStack(this.vditor);
this.vditor.irUndo.clearStack(this.vditor);
this.vditor.wysiwygUndo.clearStack(this.vditor);
}
/** 销毁编辑器 */
public destroy() {
this.vditor.element.innerHTML = this.vditor.originalInnerHTML;
this.vditor.element.classList.remove("vditor");
this.vditor.element.removeAttribute("style");
this.clearCache();
}
}
export default Vditor;

@@ -12,54 +12,47 @@ declare const VDITOR_VERSION: string;

public static readonly EDIT_TOOLBARS: string[] = ["emoji", "headings", "bold", "italic", "strike", "link", "list",
"ordered-list", "outdent", "indent", "check", "line", "quote", "code", "inline-code", "insert-after", "insert-before", "upload", "record", "table"];
public static readonly CONTENT_THEME: string[] = ["dark", "light", "wechat"];
public static readonly CODE_THEME: string[] = ["abap", "algol", "algol_nu", "arduino", "autumn", "borland", "bw", "colorful", "dracula",
"emacs", "friendly", "fruity", "github", "igor", "lovelace", "manni", "monokai", "monokailight", "murphy",
"native", "paraiso-dark", "paraiso-light", "pastie", "perldoc", "pygments", "rainbow_dash", "rrt",
"solarized-dark", "solarized-dark256", "solarized-light", "swapoff", "tango", "trac", "vim", "vs", "xcode"];
public static readonly CODE_LANGUAGES: string[] = [
"mermaid",
"echarts",
"mindmap",
"abc",
"graphviz",
"apache",
"bash",
"cs",
"cpp",
"css",
"coffeescript",
"diff",
"xml",
"http",
"ini",
"json",
"java",
"javascript",
"js",
"makefile",
"markdown",
"nginx",
"objectivec",
"php",
"perl",
"properties",
"python",
"ruby",
"sql",
"shell",
"dart",
"erb",
"go",
"gradle",
"julia",
"kotlin",
"less",
"lua",
"matlab",
"rust",
"scss",
"typescript",
"ts",
"yaml",
];
"ordered-list", "outdent", "indent", "check", "line", "quote", "code", "inline-code", "insert-after",
"insert-before", "upload", "record", "table"];
public static readonly CODE_THEME: string[] = ["abap", "algol", "algol_nu", "arduino", "autumn", "borland", "bw",
"colorful", "dracula", "emacs", "friendly", "fruity", "github", "igor", "lovelace", "manni", "monokai",
"monokailight", "murphy", "native", "paraiso-dark", "paraiso-light", "pastie", "perldoc", "pygments",
"rainbow_dash", "rrt", "solarized-dark", "solarized-dark256", "solarized-light", "swapoff", "tango", "trac",
"vim", "vs", "xcode"];
public static readonly CODE_LANGUAGES: string[] = ["mermaid", "echarts", "mindmap", "abc", "graphviz", "apache",
"bash", "cs", "cpp", "css", "coffeescript", "diff", "xml", "http", "ini", "json", "java", "javascript", "js",
"makefile", "markdown", "nginx", "objectivec", "php", "perl", "properties", "python", "ruby", "sql", "shell",
"dart", "erb", "go", "gradle", "julia", "kotlin", "less", "lua", "matlab", "rust", "scss", "typescript", "ts",
"yaml"];
public static readonly CDN = `https://cdn.jsdelivr.net/npm/vditor@${VDITOR_VERSION}`;
public static readonly MARKDOWN_OPTIONS = {
autoSpace: false,
chinesePunct: false,
codeBlockPreview: true,
fixTermTypo: false,
footnotes: true,
linkBase: "",
listStyle: false,
paragraphBeginningSpace: false,
sanitize: true,
setext: false,
toc: false,
};
public static readonly HLJS_OPTIONS = {
enable: true,
lineNumber: false,
style: "github",
};
public static readonly MATH_OPTIONS: IMath = {
engine: "KaTeX",
inlineDigit: false,
macros: {},
};
public static readonly THEME_OPTIONS = {
current: "light",
list: {
dark: "Dark",
light: "Light",
wechat: "WeChat",
},
path: `${Constants.CDN}/dist/css/content-theme`,
};
}

@@ -39,3 +39,3 @@ import {i18n} from "../i18n";

markdown: {
theme: "${vditor.options.preview.markdown.theme}"
theme: "${vditor.options.preview.theme}"
},

@@ -64,3 +64,3 @@ hljs: {

const previewElement = document.getElementById('preview')
Vditor.setContentTheme('${vditor.options.preview.markdown.theme}', '${vditor.options.cdn}');
Vditor.setContentTheme('${vditor.options.preview.theme.current}', '${vditor.options.preview.theme.path}');
Vditor.codeRender(previewElement, '${vditor.options.lang}');

@@ -67,0 +67,0 @@ Vditor.highlightRender(${JSON.stringify(vditor.options.preview.hljs)}, previewElement, '${vditor.options.cdn}');

import {Constants} from "../constants";
import {processAfterRender} from "../ir/process";
import {getMarkdown} from "../markdown/getMarkdown";
import {formatRender} from "../sv/formatRender";
import {code160to32} from "../util/code160to32";

@@ -10,3 +8,3 @@ import {isCtrl} from "../util/compatibility";

import {processCodeRender} from "../util/processCode";
import {getCursorPosition, getSelectPosition, insertHTML, setSelectionFocus} from "../util/selection";
import {getCursorPosition, insertHTML, setSelectionFocus} from "../util/selection";

@@ -29,11 +27,5 @@ export class Hint {

}
const position = getSelectPosition(vditor[vditor.currentMode].element);
let currentLineValue: string;
if (vditor.currentMode !== "sv") {
const range = getSelection().getRangeAt(0);
currentLineValue = range.startContainer.textContent.substring(0, range.startOffset) || "";
} else {
currentLineValue = getMarkdown(vditor)
.substring(0, position.end).split("\n").slice(-1).pop();
}
const range = getSelection().getRangeAt(0);
currentLineValue = range.startContainer.textContent.substring(0, range.startOffset) || "";

@@ -140,64 +132,54 @@ let key = this.getKey(currentLineValue, ":");

if (vditor.currentMode !== "sv") {
if (vditor.currentMode === "ir") {
const preBeforeElement = hasClosestByAttribute(range.startContainer, "data-type", "code-block-info");
if (preBeforeElement) {
preBeforeElement.textContent = Constants.ZWSP + value.trimRight();
range.selectNodeContents(preBeforeElement);
range.collapse(false);
processAfterRender(vditor);
preBeforeElement.parentElement.querySelectorAll("code").forEach((item) => {
item.className = "language-" + value.trimRight();
});
processCodeRender(preBeforeElement.parentElement.querySelector(".vditor-ir__preview"), vditor);
this.recentLanguage = value.trimRight();
return;
}
}
if (vditor.currentMode === "wysiwyg" && range.startContainer.nodeType !== 3 &&
(range.startContainer as HTMLElement).firstElementChild.classList.contains("vditor-input")) {
const inputElement = (range.startContainer as HTMLElement).firstElementChild as HTMLInputElement;
inputElement.value = value.trimRight();
range.selectNodeContents(inputElement);
// 代码提示
if (vditor.currentMode === "ir") {
const preBeforeElement = hasClosestByAttribute(range.startContainer, "data-type", "code-block-info");
if (preBeforeElement) {
preBeforeElement.textContent = Constants.ZWSP + value.trimRight();
range.selectNodeContents(preBeforeElement);
range.collapse(false);
inputElement.dispatchEvent(new CustomEvent("input"));
processAfterRender(vditor);
preBeforeElement.parentElement.querySelectorAll("code").forEach((item) => {
item.className = "language-" + value.trimRight();
});
processCodeRender(preBeforeElement.parentElement.querySelector(".vditor-ir__preview"), vditor);
this.recentLanguage = value.trimRight();
return;
}
range.setStart(range.startContainer, range.startContainer.textContent.lastIndexOf(splitChar));
range.deleteContents();
if (value.indexOf(":") > -1) {
insertHTML(vditor.lute.SpinVditorDOM(value), vditor);
range.insertNode(document.createTextNode(" "));
} else {
range.insertNode(document.createTextNode(value));
}
}
if (vditor.currentMode === "wysiwyg" && range.startContainer.nodeType !== 3 &&
(range.startContainer as HTMLElement).firstElementChild.classList.contains("vditor-input")) {
const inputElement = (range.startContainer as HTMLElement).firstElementChild as HTMLInputElement;
inputElement.value = value.trimRight();
range.selectNodeContents(inputElement);
range.collapse(false);
setSelectionFocus(range);
inputElement.dispatchEvent(new CustomEvent("input"));
this.recentLanguage = value.trimRight();
return;
}
if (vditor.currentMode === "wysiwyg") {
const preElement = hasClosestByClassName(range.startContainer, "vditor-wysiwyg__block");
if (preElement && preElement.lastElementChild.classList.contains("vditor-wysiwyg__preview")) {
preElement.lastElementChild.innerHTML = preElement.firstElementChild.innerHTML;
processCodeRender(preElement.lastElementChild as HTMLElement, vditor);
}
} else {
const preElement = hasClosestByClassName(range.startContainer, "vditor-ir__marker--pre");
if (preElement && preElement.nextElementSibling.classList.contains("vditor-ir__preview")) {
preElement.nextElementSibling.innerHTML = preElement.innerHTML;
processCodeRender(preElement.nextElementSibling as HTMLElement, vditor);
}
}
execAfterRender(vditor);
range.setStart(range.startContainer, range.startContainer.textContent.lastIndexOf(splitChar));
range.deleteContents();
if (value.indexOf(":") > -1 && vditor.currentMode !== "sv") {
insertHTML(vditor.lute.SpinVditorDOM(value), vditor);
range.insertNode(document.createTextNode(" "));
} else {
const position = getSelectPosition(vditor.sv.element, range);
const text = getMarkdown(vditor);
const preText = text.substring(0, text.substring(0, position.start).lastIndexOf(splitChar));
formatRender(vditor, preText + value + text.substring(position.start),
{
end: (preText + value).length,
start: (preText + value).length,
});
range.insertNode(document.createTextNode(value));
}
range.collapse(false);
setSelectionFocus(range);
if (vditor.currentMode === "wysiwyg") {
const preElement = hasClosestByClassName(range.startContainer, "vditor-wysiwyg__block");
if (preElement && preElement.lastElementChild.classList.contains("vditor-wysiwyg__preview")) {
preElement.lastElementChild.innerHTML = preElement.firstElementChild.innerHTML;
processCodeRender(preElement.lastElementChild as HTMLElement, vditor);
}
} else if (vditor.currentMode === "ir") {
const preElement = hasClosestByClassName(range.startContainer, "vditor-ir__marker--pre");
if (preElement && preElement.nextElementSibling.classList.contains("vditor-ir__preview")) {
preElement.nextElementSibling.innerHTML = preElement.innerHTML;
processCodeRender(preElement.nextElementSibling as HTMLElement, vditor);
}
}
execAfterRender(vditor);
}

@@ -204,0 +186,0 @@

@@ -28,3 +28,2 @@ export const i18n: II18n = {

"footnoteRef": "Footnote Ref",
"format": "Format",
"fullscreen": "Toggle Fullscreen",

@@ -103,3 +102,2 @@ "generate": "Generating",

"footnoteRef": "각주참조",
"format": "형식",
"fullscreen": "전체화면",

@@ -178,3 +176,2 @@ "generate": "생성",

"footnoteRef": "脚注标识",
"format": "格式化",
"fullscreen": "全屏切换",

@@ -181,0 +178,0 @@ "generate": "生成中",

import {Constants} from "../constants";
import {uploadFiles} from "../upload";
import {isCtrl, isFirefox} from "../util/compatibility";
import {blurEvent, focusEvent, hotkeyEvent, scrollCenter, selectEvent} from "../util/editorCommonEvent";
import {blurEvent, dropEvent, focusEvent, hotkeyEvent, scrollCenter, selectEvent} from "../util/editorCommonEvent";
import {paste} from "../util/fixBrowserBehavior";

@@ -12,3 +11,3 @@ import {hasClosestByClassName} from "../util/hasClosest";

import {expandMarker} from "./expandMarker";
import {highlightToolbar} from "./highlightToolbar";
import {highlightToolbarIR} from "./highlightToolbarIR";
import {input} from "./input";

@@ -35,4 +34,2 @@ import {processAfterRender, processHint} from "./process";

document.execCommand("DefaultParagraphSeparator", false, "p");
focusEvent(vditor, this.element);

@@ -42,2 +39,3 @@ blurEvent(vditor, this.element);

selectEvent(vditor, this.element);
dropEvent(vditor, this.element);
}

@@ -69,16 +67,2 @@

if (vditor.options.upload.url || vditor.options.upload.handler) {
this.element.addEventListener("drop",
(event: CustomEvent & { dataTransfer?: DataTransfer, target: HTMLElement }) => {
if (event.dataTransfer.types[0] !== "Files") {
return;
}
const files = event.dataTransfer.items;
if (files.length > 0) {
uploadFiles(vditor, files);
}
event.preventDefault();
});
}
this.element.addEventListener("compositionstart", (event: InputEvent) => {

@@ -89,3 +73,6 @@ this.composingLock = true;

this.element.addEventListener("compositionend", (event: InputEvent) => {
input(vditor, getSelection().getRangeAt(0).cloneRange());
if (!isFirefox()) {
input(vditor, getSelection().getRangeAt(0).cloneRange());
}
this.composingLock = false;
});

@@ -152,3 +139,3 @@

expandMarker(range, vditor);
highlightToolbar(vditor);
highlightToolbarIR(vditor);
});

@@ -163,3 +150,3 @@

}
highlightToolbar(vditor);
highlightToolbarIR(vditor);
if ((event.key === "Backspace" || event.key === "Delete") &&

@@ -166,0 +153,0 @@ vditor.ir.element.innerHTML !== "" && vditor.ir.element.childNodes.length === 1 &&

@@ -145,3 +145,2 @@ import {isHeadingMD, isHrMD, renderToc} from "../util/fixBrowserBehavior";

}
// 添加链接引用

@@ -148,0 +147,0 @@ const allLinkRefDefsElement = vditor.ir.element.querySelector("[data-type='link-ref-defs-block']");

import {Constants} from "../constants";
import {getMarkdown} from "../markdown/getMarkdown";
import {accessLocalStorage, isSafari} from "../util/compatibility";
import {accessLocalStorage} from "../util/compatibility";
import {listToggle, renderToc} from "../util/fixBrowserBehavior";
import {hasClosestBlock, hasClosestByAttribute, hasClosestByClassName, hasClosestByMatchTag} from "../util/hasClosest";
import {getEditorRange, getSelectPosition, setRangeByWbr, setSelectionFocus} from "../util/selection";
import {highlightToolbar} from "./highlightToolbar";
import {highlightToolbarIR} from "./highlightToolbarIR";

@@ -47,4 +47,3 @@ export const processHint = (vditor: IVditor) => {

vditor.ir.processTimeoutId = window.setTimeout(() => {
if (vditor.ir.composingLock && isSafari()) {
// safari 中文输入遇到 addToUndoStack 会影响下一次的中文输入
if (vditor.ir.composingLock) {
return;

@@ -73,3 +72,3 @@ }

if (options.enableAddUndoStack) {
vditor.irUndo.addToUndoStack(vditor);
vditor.undo.addToUndoStack(vditor);
}

@@ -80,3 +79,3 @@ }, 800);

export const processHeading = (vditor: IVditor, value: string) => {
const range = getSelection().getRangeAt(0);
const range = getEditorRange(vditor.ir.element);
const headingElement = hasClosestBlock(range.startContainer) || range.startContainer as HTMLElement;

@@ -93,3 +92,3 @@ if (headingElement) {

}
highlightToolbar(vditor);
highlightToolbarIR(vditor);
renderToc(vditor);

@@ -200,3 +199,3 @@ }

processAfterRender(vditor);
highlightToolbar(vditor);
highlightToolbarIR(vditor);
};

@@ -31,12 +31,12 @@ import {hidePanel} from "../toolbar/setToolbar";

if (event.key.indexOf("Arrow") === -1) {
vditor.irUndo.recordFirstWbr(vditor, event);
vditor.undo.recordFirstPosition(vditor, event);
}
if (!fixGSKeyBackspace(event, vditor)) {
const range = getEditorRange(vditor.ir.element);
const startContainer = range.startContainer;
if (!fixGSKeyBackspace(event, vditor, startContainer)) {
return false;
}
const range = getEditorRange(vditor.ir.element);
const startContainer = range.startContainer;
fixCJKPosition(range, event);

@@ -88,3 +88,2 @@

}
// 代码块

@@ -91,0 +90,0 @@ const preRenderElement = hasClosestByClassName(startContainer, "vditor-ir__marker--pre");

@@ -1,2 +0,2 @@

import {VDITOR_VERSION} from "../constants";
import {Constants} from "../constants";
import {addScript} from "../util/addScript";

@@ -8,4 +8,3 @@

export const abcRender = (element: (HTMLElement | Document) = document,
cdn = `https://cdn.jsdelivr.net/npm/vditor@${VDITOR_VERSION}`) => {
export const abcRender = (element: (HTMLElement | Document) = document, cdn = Constants.CDN) => {
const abcElements = element.querySelectorAll(".language-abc");

@@ -16,3 +15,3 @@ if (abcElements.length > 0) {

const divElement = document.createElement("div");
divElement.style.backgroundColor = "var(--preview-background-color)";
divElement.className = "language-abc";
e.parentNode.replaceChild(divElement, e);

@@ -19,0 +18,0 @@ ABCJS.renderAbc(divElement, e.textContent.trim());

@@ -1,2 +0,2 @@

import {VDITOR_VERSION} from "../constants";
import {Constants} from "../constants";
import {addScript} from "../util/addScript";

@@ -8,4 +8,3 @@

export const chartRender = (element: (HTMLElement | Document) = document,
cdn = `https://cdn.jsdelivr.net/npm/vditor@${VDITOR_VERSION}`) => {
export const chartRender = (element: (HTMLElement | Document) = document, cdn = Constants.CDN) => {
const echartsElements = element.querySelectorAll(".language-echarts");

@@ -12,0 +11,0 @@ if (echartsElements.length > 0) {

@@ -5,6 +5,6 @@ import copySVG from "../../assets/icons/copy.svg";

export const codeRender = (element: HTMLElement, lang: (keyof II18nLang) = "zh_CN") => {
export const codeRender = (element: HTMLElement, lang: keyof II18n = "zh_CN") => {
element.querySelectorAll("pre > code").forEach((e: HTMLElement, index: number) => {
if (e.classList.contains("language-mermaid") || e.classList.contains("language-echarts") ||
e.classList.contains("language-mindmap") || e.classList.contains("language-abc") ||
e.classList.contains("language-mindmap") || e.classList.contains("language-abc") ||
e.classList.contains("language-graphviz")) {

@@ -11,0 +11,0 @@ return;

@@ -5,3 +5,2 @@ import {code160to32} from "../util/code160to32";

if (vditor.currentMode === "sv") {
// last char must be a `\n`.
return code160to32(`${vditor.sv.element.textContent}\n`.replace(/\n\n$/, "\n"));

@@ -8,0 +7,0 @@ } else if (vditor.currentMode === "wysiwyg") {

@@ -1,2 +0,2 @@

import {VDITOR_VERSION} from "../constants";
import {Constants} from "../constants";
import {addScript} from "../util/addScript";

@@ -10,3 +10,3 @@

export const graphvizRender = (element: HTMLElement, cdn = `https://cdn.jsdelivr.net/npm/vditor@${VDITOR_VERSION}`) => {
export const graphvizRender = (element: HTMLElement, cdn = Constants.CDN) => {
const graphvizElements = element.querySelectorAll(".language-graphviz");

@@ -13,0 +13,0 @@

@@ -1,2 +0,2 @@

import {Constants, VDITOR_VERSION} from "../constants";
import {Constants} from "../constants";
import {addScript} from "../util/addScript";

@@ -10,3 +10,3 @@ import {addStyle} from "../util/addStyle";

export const highlightRender = (hljsOption?: IHljs, element: HTMLElement | Document = document,
cdn = `https://cdn.jsdelivr.net/npm/vditor@${VDITOR_VERSION}`) => {
cdn = Constants.CDN) => {
let style = hljsOption.style;

@@ -13,0 +13,0 @@ if (!Constants.CODE_THEME.includes(style)) {

@@ -1,2 +0,2 @@

import {VDITOR_VERSION} from "../constants";
import {Constants} from "../constants";
import {addScript, addScriptSync} from "../util/addScript";

@@ -27,3 +27,3 @@ import {addStyle} from "../util/addStyle";

const defaultOptions = {
cdn: `https://cdn.jsdelivr.net/npm/vditor@${VDITOR_VERSION}`,
cdn: Constants.CDN,
math: {

@@ -30,0 +30,0 @@ engine: "KaTeX",

@@ -1,2 +0,2 @@

import {VDITOR_VERSION} from "../constants";
import {Constants} from "../constants";
import {addScript} from "../util/addScript";

@@ -9,3 +9,3 @@

export const mermaidRender = (element: HTMLElement, className = ".language-mermaid",
cdn = `https://cdn.jsdelivr.net/npm/vditor@${VDITOR_VERSION}`) => {
cdn = Constants.CDN) => {
if (element.querySelectorAll(className).length === 0) {

@@ -12,0 +12,0 @@ return;

@@ -1,2 +0,2 @@

import {VDITOR_VERSION} from "../constants";
import {Constants} from "../constants";
import {addScript} from "../util/addScript";

@@ -8,4 +8,3 @@

export const mindmapRender = (element: (HTMLElement | Document) = document,
cdn = `https://cdn.jsdelivr.net/npm/vditor@${VDITOR_VERSION}`) => {
export const mindmapRender = (element: (HTMLElement | Document) = document, cdn = Constants.CDN) => {
const mindmapElements = element.querySelectorAll(".language-mindmap");

@@ -12,0 +11,0 @@ if (mindmapElements.length > 0) {

@@ -1,4 +0,5 @@

import {VDITOR_VERSION} from "../constants";
import {Constants} from "../constants";
import {setContentTheme} from "../ui/setContentTheme";
import {addScript} from "../util/addScript";
import {merge} from "../util/merge";
import {abcRender} from "./abcRender";

@@ -19,50 +20,17 @@ import {anchorRender} from "./anchorRender";

const mergeOptions = (options?: IPreviewOptions) => {
const defaultOption = {
const defaultOption: IPreviewOptions = {
anchor: 0,
cdn: `https://cdn.jsdelivr.net/npm/vditor@${VDITOR_VERSION}`,
cdn: Constants.CDN,
customEmoji: {},
emojiPath: `${(options && options.emojiPath) ||
`https://cdn.jsdelivr.net/npm/vditor@${VDITOR_VERSION}`}/dist/images/emoji`,
hljs: {
enable: true,
lineNumber: false,
style: "github",
},
emojiPath: `${(options && options.emojiPath) || Constants.CDN}/dist/images/emoji`,
hljs: Constants.HLJS_OPTIONS,
lang: "zh_CN",
markdown: {
autoSpace: false,
chinesePunct: false,
codeBlockPreview: true,
fixTermTypo: false,
footnotes: true,
linkBase: "",
listStyle: false,
paragraphBeginningSpace: false,
sanitize: true,
setext: false,
theme: "light",
toc: false,
},
math: {
engine: "KaTeX",
inlineDigit: false,
macros: {},
},
markdown: Constants.MARKDOWN_OPTIONS,
math: Constants.MATH_OPTIONS,
speech: {
enable: false,
},
theme: Constants.THEME_OPTIONS,
};
if (options?.hljs) {
options.hljs = Object.assign({}, defaultOption.hljs, options.hljs);
}
if (options?.speech) {
options.speech = Object.assign({}, defaultOption.speech, options.speech);
}
if (options?.math) {
options.math = Object.assign({}, defaultOption.math, options.math);
}
if (options?.markdown) {
options.markdown = Object.assign({}, defaultOption.markdown, options.markdown);
}
return Object.assign(defaultOption, options);
return merge(defaultOption, options);
};

@@ -110,3 +78,3 @@

previewElement.classList.add("vditor-reset");
setContentTheme(mergedOptions.markdown.theme, mergedOptions.cdn);
setContentTheme(mergedOptions.theme.current, mergedOptions.theme.path);
if (mergedOptions.anchor === 1) {

@@ -113,0 +81,0 @@ previewElement.classList.add("vditor-reset--anchor");

@@ -10,3 +10,3 @@ import pauseSVG from "../../assets/icons/pause.svg";

}
export const speechRender = (element: HTMLElement, lang: (keyof II18nLang) = "zh_CN") => {
export const speechRender = (element: HTMLElement, lang: keyof II18n = "zh_CN") => {
if (typeof speechSynthesis === "undefined" || typeof SpeechSynthesisUtterance === "undefined") {

@@ -13,0 +13,0 @@ return;

@@ -1,17 +0,18 @@

import {getMarkdown} from "../markdown/getMarkdown";
import {uploadFiles} from "../upload/index";
import {isCtrl} from "../util/compatibility";
import {focusEvent, hotkeyEvent, scrollCenter, selectEvent} from "../util/editorCommonEvent";
import {getSelectText} from "./getSelectText";
import {html2md} from "./html2md";
import {isCtrl, isFirefox} from "../util/compatibility";
import {blurEvent, dropEvent, focusEvent, hotkeyEvent, selectEvent} from "../util/editorCommonEvent";
import {paste} from "../util/fixBrowserBehavior";
import {getSelectText} from "../util/getSelectText";
import {highlightToolbarSV} from "./highlightToolbarSV";
import {inputEvent} from "./inputEvent";
import {insertText} from "./insertText";
class Editor {
public element: HTMLPreElement;
public range: Range;
public composingLock: boolean = false;
public processTimeoutId: number;
public hlToolbarTimeoutId: number;
public preventInput: boolean;
constructor(vditor: IVditor) {
this.element = document.createElement("pre");
this.element.className = "vditor-textarea";
this.element.className = "vditor-sv vditor-reset";
this.element.setAttribute("placeholder", vditor.options.placeholder);

@@ -24,4 +25,6 @@ this.element.setAttribute("contenteditable", "true");

focusEvent(vditor, this.element);
blurEvent(vditor, this.element);
hotkeyEvent(vditor, this.element);
selectEvent(vditor, this.element);
dropEvent(vditor, this.element);
}

@@ -36,30 +39,10 @@

this.element.addEventListener("keypress", (event: KeyboardEvent) => {
if (!isCtrl(event) && event.key === "Enter") {
insertText(vditor, "\n", "", true);
scrollCenter(vditor);
event.preventDefault();
}
});
this.element.addEventListener("input", () => {
inputEvent(vditor, {
enableAddUndoStack: true,
enableHint: true,
enableInput: true,
this.element.addEventListener("paste", (event: ClipboardEvent & { target: HTMLElement }) => {
paste(vditor, event, {
pasteCode: (code: string) => {
document.execCommand("insertHTML", false, code);
},
});
// 选中多行后输入任意字符,br 后无 \n
this.element.querySelectorAll("br").forEach((br) => {
if (!br.nextElementSibling) {
br.insertAdjacentHTML("afterend", '<span style="display: none">\n</span>');
}
});
});
this.element.addEventListener("blur", () => {
if (vditor.options.blur) {
vditor.options.blur(getMarkdown(vditor));
}
});
this.element.addEventListener("scroll", () => {

@@ -82,59 +65,43 @@ if (vditor.preview.element.style.display !== "block") {

if (vditor.options.upload.url || vditor.options.upload.handler) {
this.element.addEventListener("drop", (event: CustomEvent & { dataTransfer?: DataTransfer }) => {
if (event.dataTransfer.types[0] !== "Files") {
insertText(vditor, getSelection().toString(), "", false);
event.preventDefault();
return;
}
const files = event.dataTransfer.items;
if (files.length === 0) {
return;
}
uploadFiles(vditor, files);
event.preventDefault();
});
}
this.element.addEventListener("compositionstart", (event: InputEvent) => {
this.composingLock = true;
});
this.element.addEventListener("paste", (event: ClipboardEvent) => {
const textHTML = event.clipboardData.getData("text/html");
const textPlain = event.clipboardData.getData("text/plain");
event.stopPropagation();
event.preventDefault();
if (textHTML.trim() !== "") {
if (textHTML.replace(/<(|\/)(html|body|meta)[^>]*?>/ig, "").trim() ===
`<a href="${textPlain}">${textPlain}</a>` ||
textHTML.replace(/<(|\/)(html|body|meta)[^>]*?>/ig, "").trim() ===
`<!--StartFragment--><a href="${textPlain}">${textPlain}</a><!--EndFragment-->`) {
// https://github.com/b3log/vditor/issues/37
} else {
const tempElement = document.createElement("div");
tempElement.innerHTML = textHTML;
tempElement.querySelectorAll("[style]").forEach((e) => {
e.removeAttribute("style");
});
tempElement.querySelectorAll(".vditor-copy").forEach((e) => {
e.remove();
});
tempElement.querySelectorAll(".vditor-anchor").forEach((e) => {
e.remove();
});
const mdValue = html2md(vditor, tempElement.innerHTML, textPlain).trimRight();
insertText(vditor, mdValue, "", true);
return;
}
} else if (textPlain.trim() !== "" && event.clipboardData.files.length === 0) {
// https://github.com/b3log/vditor/issues/67
} else if (event.clipboardData.files.length > 0) {
// upload file
if (!(vditor.options.upload.url || vditor.options.upload.handler)) {
return;
}
// NOTE: not work in Safari.
// maybe the browser considered local filesystem as the same domain as the pasted data
uploadFiles(vditor, event.clipboardData.files);
this.element.addEventListener("compositionend", (event: InputEvent) => {
if (!isFirefox()) {
inputEvent(vditor, event);
}
this.composingLock = false;
});
this.element.addEventListener("input", (event: InputEvent) => {
if (this.composingLock) {
return;
}
insertText(vditor, textPlain, "", true);
if (this.preventInput) {
this.preventInput = false;
return;
}
inputEvent(vditor, event);
});
this.element.addEventListener("click", (event: InputEvent) => {
highlightToolbarSV(vditor);
});
this.element.addEventListener("keyup", (event) => {
if (event.isComposing || isCtrl(event)) {
return;
}
highlightToolbarSV(vditor);
if ((event.key === "Backspace" || event.key === "Delete") &&
vditor.sv.element.innerHTML !== "" && vditor.sv.element.childNodes.length === 1 &&
vditor.sv.element.firstElementChild && vditor.sv.element.firstElementChild.tagName === "DIV"
&& vditor.sv.element.firstElementChild.childElementCount === 2
&& (vditor.sv.element.firstElementChild.textContent === "" || vditor.sv.element.textContent === "\n")) {
// 为空时显示 placeholder
vditor.sv.element.innerHTML = "";
return;
}
});
}

@@ -141,0 +108,0 @@ }

@@ -1,33 +0,169 @@

import {getMarkdown} from "../markdown/getMarkdown";
import {accessLocalStorage} from "../util/compatibility";
import {scrollCenter} from "../util/editorCommonEvent";
import {hasClosestByAttribute} from "../util/hasClosest";
import {log} from "../util/log";
import {getSelectPosition, setRangeByWbr} from "../util/selection";
import {processAfterRender} from "./process";
export const inputEvent = (vditor: IVditor, options = {
enableAddUndoStack: true,
enableHint: false,
enableInput: true,
}) => {
const text = getMarkdown(vditor);
if (vditor.options.counter.enable) {
vditor.counter.render(vditor, text);
export const inputEvent = (vditor: IVditor, event?: InputEvent) => {
const range = getSelection().getRangeAt(0).cloneRange();
let blockElement = hasClosestByAttribute(range.startContainer, "data-block", "0");
// 不调用 lute 解析
if (blockElement && event && (event.inputType === "deleteContentBackward" || event.data === " ")) {
// 开始可以输入空格
const startOffset = getSelectPosition(blockElement, range).start;
let startSpace = true;
for (let i = startOffset - 1;
// 软换行后有空格
i > blockElement.textContent.substr(0, startOffset).lastIndexOf("\n"); i--) {
if (blockElement.textContent.charAt(i) !== " " &&
// 多个 tab 前删除不形成代码块 https://github.com/Vanessa219/vditor/issues/162 1
blockElement.textContent.charAt(i) !== "\t") {
startSpace = false;
break;
}
}
if (startOffset === 0) {
startSpace = false;
}
if (startSpace) {
processAfterRender(vditor);
return;
}
// list item marker 删除或空格
const listElement = hasClosestByAttribute(range.startContainer, "data-type", "li");
if (listElement) {
if (event.data === " " &&
(hasClosestByAttribute(range.startContainer, "data-type", "li-marker") ||
hasClosestByAttribute(range.startContainer, "data-type", "task-marker"))) {
processAfterRender(vditor);
return;
}
const liMarkerElement = listElement.querySelector('[data-type="li-marker"]');
if (event.inputType === "deleteContentBackward" && getSelectPosition(listElement, range).start <=
listElement.getAttribute("data-space").length +
(liMarkerElement ? liMarkerElement.textContent.length : 0) +
(listElement.querySelector('[data-type="task-marker"]') ? 4 : 0)
) {
processAfterRender(vditor);
return;
}
}
// heading marker 删除或空格
const headingElement = hasClosestByAttribute(range.startContainer, "data-type", "heading-marker");
if (headingElement && (event.data === " " || event.inputType === "deleteContentBackward")) {
processAfterRender(vditor);
return;
}
// blockquote marker 删除或空格
const blockquoteElement = hasClosestByAttribute(range.startContainer, "data-type", "blockquote-marker");
if (blockquoteElement && (event.data === " " || event.inputType === "deleteContentBackward")) {
processAfterRender(vditor);
return;
}
// block code marker 删除
const blockCodeElement =
hasClosestByAttribute(range.startContainer, "data-type", "code-block");
if (blockCodeElement && event.inputType === "deleteContentBackward") {
const startIndex = getSelectPosition(blockElement, range).start;
if (startIndex <= 2 || startIndex === blockCodeElement.textContent.length - 1) {
if (blockElement.querySelectorAll(".vditor-sv__marker").length === 1) {
blockElement.querySelector(".vditor-sv__marker").remove();
}
processAfterRender(vditor);
return;
}
}
}
if (typeof vditor.options.input === "function" && options.enableInput) {
vditor.options.input(text, vditor.preview.element);
if (blockElement && blockElement.textContent.trimRight() === "$$") {
// 内联数学公式
processAfterRender(vditor);
return;
}
if (options.enableHint) {
vditor.hint.render(vditor);
if (!blockElement) {
blockElement = vditor.sv.element;
}
if (vditor.options.cache.enable && accessLocalStorage()) {
localStorage.setItem(vditor.options.cache.id, text);
if (vditor.options.cache.after) {
vditor.options.cache.after(text);
const footnotesElement = hasClosestByAttribute(range.startContainer, "data-type", "footnotes-block");
if (footnotesElement) {
// 修改脚注
blockElement = footnotesElement;
}
if (blockElement.getAttribute("data-type") === "link-ref-defs-block") {
// 修改链接引用
blockElement = vditor.sv.element;
}
if (hasClosestByAttribute(range.startContainer, "data-type", "footnotes-link")) {
// 修改脚注角标
blockElement = vditor.sv.element;
}
// 添加光标位置
if (blockElement.textContent.indexOf(Lute.Caret) === -1) {
// 点击工具栏会插入 Caret
range.insertNode(document.createTextNode(Lute.Caret));
}
// 清除浏览器自带的样式
blockElement.querySelectorAll("[style]").forEach((item) => { // 不可前置,否则会影响 newline 的样式
item.removeAttribute("style");
});
blockElement.querySelectorAll("font").forEach((item) => { // 不可前置,否则会影响光标的位置
item.outerHTML = item.innerHTML;
});
let html = blockElement.textContent;
if (event?.inputType === "insertParagraph" && blockElement.previousElementSibling
&& blockElement.previousElementSibling.textContent.trim() !== "") {
// 在粗体中换行
html = blockElement.previousElementSibling.outerHTML + html;
blockElement.previousElementSibling.remove();
}
const isSVElement = blockElement.isEqualNode(vditor.sv.element);
if (isSVElement) {
html = blockElement.textContent;
} else {
if (blockElement.previousElementSibling) {
html = blockElement.previousElementSibling.textContent + html;
blockElement.previousElementSibling.remove();
}
if (blockElement.nextElementSibling) {
html = html + blockElement.nextElementSibling.textContent;
blockElement.nextElementSibling.remove();
}
// 添加链接引用
const allLinkRefDefsElement = vditor.sv.element.querySelector("[data-type='link-ref-defs-block']");
if (allLinkRefDefsElement && !blockElement.isEqualNode(allLinkRefDefsElement)) {
html += allLinkRefDefsElement.textContent;
allLinkRefDefsElement.remove();
}
// 添加脚注
const allFootnoteElement = vditor.sv.element.querySelector("[data-type='footnotes-block']");
if (allFootnoteElement && !blockElement.isEqualNode(allFootnoteElement)) {
html += allFootnoteElement.textContent;
allFootnoteElement.remove();
}
}
vditor.preview.render(vditor);
if (options.enableAddUndoStack) {
vditor.undo.addToUndoStack(vditor);
log("SpinVditorSVDOM", html, "argument", vditor.options.debugger);
html = vditor.lute.SpinVditorSVDOM(html);
log("SpinVditorSVDOM", html, "result", vditor.options.debugger);
if (isSVElement) {
blockElement.innerHTML = html;
} else {
blockElement.outerHTML = html;
const allLinkRefDefsElement = vditor.sv.element.querySelector("[data-type='link-ref-defs-block']");
if (allLinkRefDefsElement) {
vditor.sv.element.insertAdjacentElement("beforeend", allLinkRefDefsElement);
}
const allFootnoteElement = vditor.sv.element.querySelector("[data-type='footnotes-block']");
if (allFootnoteElement) {
vditor.sv.element.insertAdjacentElement("beforeend", allFootnoteElement);
}
}
setRangeByWbr(vditor.sv.element, range);
if (vditor.devtools) {
vditor.devtools.renderEchart(vditor);
}
scrollCenter(vditor);
processAfterRender(vditor, {
enableAddUndoStack: true,
enableHint: true,
enableInput: true,
});
};

@@ -1,96 +0,127 @@

import {getMarkdown} from "../markdown/getMarkdown";
import {isCtrl} from "../util/compatibility";
import {matchHotKey} from "../util/hotKey";
import {getSelectPosition} from "../util/selection";
import {formatRender} from "./formatRender";
import {getCurrentLinePosition} from "./getCurrentLinePosition";
import {insertText} from "./insertText";
import {fixTab} from "../util/fixBrowserBehavior";
import {hasClosestByAttribute} from "../util/hasClosest";
import {getEditorRange, getSelectPosition} from "../util/selection";
import {inputEvent} from "./inputEvent";
export const processKeydown = (vditor: IVditor, event: KeyboardEvent) => {
vditor.undo.recordFirstPosition(vditor);
vditor.sv.composingLock = event.isComposing;
if (event.isComposing) {
return false;
}
if (event.key.indexOf("Arrow") === -1) {
vditor.undo.recordFirstPosition(vditor, event);
}
// 仅处理以下快捷键操作
if (event.key !== "Enter" && event.key !== "Tab" && event.key !== "Backspace" && event.key.indexOf("Arrow") === -1
&& !isCtrl(event) && event.key !== "Escape") {
return false;
}
const range = getEditorRange(vditor.sv.element);
const startContainer = range.startContainer;
const editorElement = vditor.sv.element;
const position = getSelectPosition(editorElement);
const text = getMarkdown(vditor);
// tab and shift + tab
if (vditor.options.tab && event.key === "Tab") {
event.preventDefault();
event.stopPropagation();
// blockquote
const blockquoteLineElement = hasClosestByAttribute(startContainer, "data-type", "blockquote-line");
if (blockquoteLineElement) {
const startIndex = getSelectPosition(blockquoteLineElement, range).start;
if (event.key === "Enter" && !isCtrl(event) && !event.altKey) {
if (startIndex === 2 && blockquoteLineElement.firstElementChild) {
// 在 marker 中换行,删除 marker 标记
blockquoteLineElement.firstElementChild.remove();
event.preventDefault();
return true;
} else if (blockquoteLineElement.textContent.trim() !== "") {
// 换行应延续 >
range.insertNode(document.createTextNode("\n>"));
range.collapse(false);
inputEvent(vditor);
event.preventDefault();
return true;
}
}
// 光标在每一行的第一个字符后删除
if (event.key === "Backspace" && !isCtrl(event) && !event.altKey && !event.shiftKey && startIndex === 1) {
range.setStart(startContainer, 0);
range.extractContents();
if (blockquoteLineElement.firstElementChild.textContent === "") {
blockquoteLineElement.firstElementChild.remove();
}
event.preventDefault();
return true;
}
}
const selectLinePosition = getCurrentLinePosition(position, text);
const selectLineList = text.substring(selectLinePosition.start, selectLinePosition.end - 1).split("\n");
if (event.shiftKey) {
let shiftCount = 0;
let startIsShift = false;
const selectionShiftResult = selectLineList.map((value, index) => {
let shiftLineValue = value;
if (value.indexOf(vditor.options.tab) === 0) {
if (index === 0) {
startIsShift = true;
}
shiftCount++;
shiftLineValue = value.replace(vditor.options.tab, "");
// list item
const listElement = hasClosestByAttribute(startContainer, "data-type", "li");
if (listElement) {
const markerElement = listElement.querySelector('[data-type="li-marker"]');
const startIndex = getSelectPosition(listElement, range).start;
const space = listElement.getAttribute("data-space");
// 回车
if (event.key === "Enter" && !isCtrl(event) && !event.altKey) {
const isTask = listElement.querySelector('[data-type="task-marker"]');
if (markerElement && startIndex ===
markerElement.textContent.length + space.length + (isTask ? 4 : 0)) {
// 清空列表标记符
if (space === "") {
markerElement.remove();
} else {
markerElement.previousElementSibling.remove();
inputEvent(vditor);
}
return shiftLineValue;
}).join("\n");
formatRender(vditor, text.substring(0, selectLinePosition.start) +
selectionShiftResult + text.substring(selectLinePosition.end - 1),
{
end: position.end - shiftCount * vditor.options.tab.length,
start: position.start - (startIsShift ? vditor.options.tab.length : 0),
});
if (isTask) {
listElement.querySelectorAll('[data-type="task-marker"]').forEach((item: HTMLElement) => {
item.remove();
});
}
} else {
// 添加标记符号
let newMarker = "\n";
if (markerElement) {
newMarker += space + markerElement.textContent;
}
if (isTask) {
newMarker += " [ ] ";
}
range.insertNode(document.createTextNode(newMarker));
range.collapse(false);
inputEvent(vditor);
}
event.preventDefault();
return true;
}
if (position.start === position.end) {
insertText(vditor, vditor.options.tab, "");
// 光标在每一行的第一个字符后删除
if (event.key === "Backspace" && !isCtrl(event) && !event.altKey && !event.shiftKey) {
const firstElement = hasClosestByAttribute(startContainer, "data-type", "li-marker") ||
hasClosestByAttribute(startContainer, "data-type", "li-space");
if (firstElement && startIndex === 1) {
range.setStart(startContainer, 0);
range.extractContents();
if (firstElement.textContent === "") {
firstElement.remove();
}
event.preventDefault();
return true;
}
}
// 第一个 marker 后 tab 进行缩进
if (event.key === "Tab" && markerElement && startIndex === markerElement.textContent.length + space.length) {
markerElement.insertAdjacentHTML("beforebegin",
`<span data-type="li-space">${markerElement.textContent.replace(/\S/g, " ")}</span>`);
inputEvent(vditor);
event.preventDefault();
return true;
}
const selectionResult = selectLineList.map((value) => {
return vditor.options.tab + value;
}).join("\n");
formatRender(vditor, text.substring(0, selectLinePosition.start) + selectionResult +
text.substring(selectLinePosition.end - 1),
{
end: position.end + selectLineList.length * vditor.options.tab.length,
start: position.start + vditor.options.tab.length,
});
return true;
}
// delete
if (!isCtrl(event) && !event.shiftKey && event.keyCode === 8) {
if (position.start !== position.end) {
insertText(vditor, "", "", true);
} else {
// delete emoji
const emojiMatch = text.substring(0, position.start).match(/([\u{1F300}-\u{1F5FF}][\u{2000}-\u{206F}][\u{2700}-\u{27BF}]|([\u{1F900}-\u{1F9FF}]|[\u{1F300}-\u{1F5FF}]|[\u{1F680}-\u{1F6FF}]|[\u{1F600}-\u{1F64F}])[\u{2000}-\u{206F}][\u{2600}-\u{26FF}]|[\u{1F300}-\u{1F5FF}]|[\u{1F100}-\u{1F1FF}]|[\u{1F600}-\u{1F64F}]|[\u{1F680}-\u{1F6FF}]|[\u{1F200}-\u{1F2FF}]|[\u{1F900}-\u{1F9FF}]|[\u{1F000}-\u{1F02F}]|[\u{FE00}-\u{FE0F}]|[\u{1F0A0}-\u{1F0FF}]|[\u{0000}-\u{007F}][\u{20D0}-\u{20FF}]|[\u{0000}-\u{007F}][\u{FE00}-\u{FE0F}][\u{20D0}-\u{20FF}])$/u);
const deleteChar = emojiMatch ? emojiMatch[0].length : 1;
formatRender(vditor,
text.substring(0, position.start - deleteChar) + text.substring(position.start),
{
end: position.start - deleteChar,
start: position.start - deleteChar,
}, {
enableAddUndoStack: true,
enableHint: true,
enableInput: true,
});
}
event.preventDefault();
event.stopPropagation();
// tab
if (fixTab(vditor, range, event)) {
return true;
}
// hotkey command + delete
if (vditor.options.keymap.deleteLine && matchHotKey(vditor.options.keymap.deleteLine, event)) {
const linePosition = getCurrentLinePosition(position, text);
const deletedText = text.substring(0, linePosition.start) + text.substring(linePosition.end);
const startIndex = Math.min(deletedText.length, position.start);
formatRender(vditor, deletedText, {
end: startIndex,
start: startIndex,
});
// 回车,除 list item 外
if (event.key === "Enter" && !isCtrl(event) && !event.altKey) {
// 添加 \n
range.insertNode(document.createTextNode("\n"));
range.collapse(false);
event.preventDefault();

@@ -100,27 +131,27 @@ return true;

// hotkey command + d
if (vditor.options.keymap.duplicate && matchHotKey(vditor.options.keymap.duplicate, event)) {
let lineText = text.substring(position.start, position.end);
if (position.start === position.end) {
const linePosition = getCurrentLinePosition(position, text);
lineText = text.substring(linePosition.start, linePosition.end);
formatRender(vditor,
text.substring(0, linePosition.end) + lineText + text.substring(linePosition.end),
{
end: position.end + lineText.length,
start: position.start + lineText.length,
});
} else {
formatRender(vditor,
text.substring(0, position.end) + lineText + text.substring(position.end),
{
end: position.end + lineText.length,
start: position.start + lineText.length,
});
// 删除后光标前有 newline 的处理
const blockElement = hasClosestByAttribute(startContainer, "data-block", "0");
if (blockElement && event.key === "Backspace" && !isCtrl(event) && !event.altKey && !event.shiftKey) {
const startIndex = getSelectPosition(blockElement, range).start;
// 光标在每一行的开始位置
if (startIndex === 0 && blockElement.previousElementSibling &&
blockElement.previousElementSibling.lastElementChild.getAttribute("data-type") === "newline") {
blockElement.previousElementSibling.lastElementChild.remove();
if (blockElement.textContent.trim() !== "") {
inputEvent(vditor);
}
event.preventDefault();
return true;
}
event.preventDefault();
return true;
// 光标在每一行的第一个字符后, list item、blockquote line 处理在上方
const textElement = hasClosestByAttribute(startContainer, "data-type", "text");
if (textElement && range.startOffset === 1 && textElement.previousElementSibling &&
textElement.previousElementSibling.getAttribute("data-type") === "newline") {
range.setStart(startContainer, 0);
range.extractContents();
event.preventDefault();
return true;
}
}
return false;
};

@@ -1,2 +0,1 @@

import {Constants} from "../constants";
import {setContentTheme} from "../ui/setContentTheme";

@@ -18,4 +17,4 @@ import {getEventName} from "../util/compatibility";

let innerHTML = "";
Constants.CONTENT_THEME.forEach((theme) => {
innerHTML += `<button>${theme}</button>`;
Object.keys(vditor.options.preview.theme.list).forEach((key) => {
innerHTML += `<button data-type="${key}">${vditor.options.preview.theme.list[key]}</button>`;
});

@@ -27,4 +26,4 @@ panelElement.innerHTML =

hidePanel(vditor, ["subToolbar"]);
vditor.options.preview.markdown.theme = event.target.textContent;
setContentTheme(event.target.textContent, vditor.options.cdn);
vditor.options.preview.theme.current = event.target.getAttribute("data-type");
setContentTheme(vditor.options.preview.theme.current, vditor.options.preview.theme.path);
event.preventDefault();

@@ -31,0 +30,0 @@ event.stopPropagation();

import {Constants} from "../constants";
import {i18n} from "../i18n";
import {highlightToolbar as IRHighlightToolbar} from "../ir/highlightToolbar";
import {processAfterRender} from "../ir/process";
import {getMarkdown} from "../markdown/getMarkdown";
import {formatRender} from "../sv/formatRender";
import {processAfterRender as processSVAfterRender} from "../sv/process";
import {setPadding, setTypewriterPosition} from "../ui/initUI";
import {getEventName, updateHotkeyTip} from "../util/compatibility";
import {highlightToolbar} from "../util/highlightToolbar";
import {processCodeRender} from "../util/processCode";
import {highlightToolbar} from "../wysiwyg/highlightToolbar";
import {renderDomByMd} from "../wysiwyg/renderDomByMd";

@@ -48,5 +47,4 @@ import {MenuItem} from "./MenuItem";

if (type === "ir") {
hideToolbar(vditor.toolbar.elements, ["format", "both"]);
hideToolbar(vditor.toolbar.elements, ["both"]);
showToolbar(vditor.toolbar.elements, ["outdent", "indent", "outline", "insert-before", "insert-after"]);
vditor.irUndo.resetIcon(vditor);
vditor.sv.element.style.display = "none";

@@ -69,12 +67,5 @@ vditor.wysiwyg.element.parentElement.style.display = "none";

});
if (typeof event !== "string") {
// 初始化不 focus
vditor.ir.element.focus();
IRHighlightToolbar(vditor);
}
} else if (type === "wysiwyg") {
hideToolbar(vditor.toolbar.elements, ["format", "both"]);
hideToolbar(vditor.toolbar.elements, ["both"]);
showToolbar(vditor.toolbar.elements, ["outdent", "indent", "outline", "insert-before", "insert-after"]);
vditor.wysiwygUndo.resetIcon(vditor);
vditor.sv.element.style.display = "none";

@@ -92,13 +83,6 @@ vditor.wysiwyg.element.parentElement.style.display = "block";

});
if (typeof event !== "string") {
// 初始化不 focus
vditor.wysiwyg.element.focus();
highlightToolbar(vditor);
}
vditor.wysiwyg.popover.style.display = "none";
} else if (type === "sv") {
showToolbar(vditor.toolbar.elements, ["format", "both"]);
showToolbar(vditor.toolbar.elements, ["both"]);
hideToolbar(vditor.toolbar.elements, ["outdent", "indent", "outline", "insert-before", "insert-after"]);
vditor.undo.resetIcon(vditor);
vditor.wysiwyg.element.parentElement.style.display = "none";

@@ -112,3 +96,4 @@ vditor.ir.element.parentElement.style.display = "none";

vditor.currentMode = "sv";
formatRender(vditor, markdownText, undefined, {
vditor.sv.element.innerHTML = vditor.lute.SpinVditorSVDOM(markdownText);
processSVAfterRender(vditor, {
enableAddUndoStack: true,

@@ -118,8 +103,10 @@ enableHint: false,

});
if (typeof event !== "string") {
// 初始化不 focus
vditor.sv.element.focus();
}
setPadding(vditor);
}
vditor.undo.resetIcon(vditor);
if (typeof event !== "string") {
// 初始化不 focus
vditor[vditor.currentMode].element.focus();
highlightToolbar(vditor);
}
if (typeof event === "string") {

@@ -126,0 +113,0 @@ vditor.outline.render(vditor);

@@ -1,3 +0,3 @@

import {insertText} from "../sv/insertText";
import {getEventName} from "../util/compatibility";
import {execAfterRender} from "../util/fixBrowserBehavior";
import {getEditorRange, insertHTML, setSelectionFocus} from "../util/selection";

@@ -46,27 +46,21 @@ import {MenuItem} from "./MenuItem";

const value = element.getAttribute("data-value");
if (vditor.currentMode === "sv") {
insertText(vditor, value, "", true);
const range = getEditorRange(vditor[vditor.currentMode].element);
let html = value;
if (vditor.currentMode === "wysiwyg") {
html = vditor.lute.SpinVditorDOM(value);
} else if (vditor.currentMode === "ir") {
html = vditor.lute.SpinVditorIRDOM(value);
}
if (value.indexOf(":") > -1 && vditor.currentMode !== "sv") {
const tempElement = document.createElement("div");
tempElement.innerHTML = html;
html = tempElement.firstElementChild.firstElementChild.outerHTML + " ";
insertHTML(html, vditor);
} else {
let range;
let html = "";
if (vditor.currentMode === "wysiwyg") {
range = getEditorRange(vditor.wysiwyg.element);
html = vditor.lute.SpinVditorDOM(value);
} else if (vditor.currentMode === "ir") {
range = getEditorRange(vditor.ir.element);
html = vditor.lute.SpinVditorIRDOM(value);
}
if (value.indexOf(":") > -1) {
const tempElement = document.createElement("div");
tempElement.innerHTML = html;
html = tempElement.firstElementChild.firstElementChild.outerHTML + " ";
insertHTML(html, vditor);
} else {
range.insertNode(document.createTextNode(value));
}
range.collapse(false);
setSelectionFocus(range);
range.insertNode(document.createTextNode(value));
}
range.collapse(false);
setSelectionFocus(range);
panelElement.style.display = "none";
execAfterRender(vditor);
});

@@ -73,0 +67,0 @@ element.addEventListener("mouseover", (event: Event) => {

import {Constants} from "../constants";
import {processHeading} from "../ir/process";
import {insertText} from "../sv/insertText";
import {processHeading as processHeadingSV} from "../sv/process";
import {getEventName, updateHotkeyTip} from "../util/compatibility";

@@ -38,16 +38,15 @@ import {afterRenderEvent} from "../wysiwyg/afterRenderEvent";

actionBtn.blur();
if (vditor.currentMode === "wysiwyg" && actionBtn.classList.contains("vditor-menu--current")) {
removeHeading(vditor);
afterRenderEvent(vditor);
if (actionBtn.classList.contains("vditor-menu--current")) {
if (vditor.currentMode === "wysiwyg") {
removeHeading(vditor);
afterRenderEvent(vditor);
} else if (vditor.currentMode === "ir") {
processHeading(vditor, "");
} else {
processHeadingSV(vditor, "");
}
actionBtn.classList.remove("vditor-menu--current");
} else if (vditor.currentMode === "ir" && actionBtn.classList.contains("vditor-menu--current")) {
processHeading(vditor, "");
actionBtn.classList.remove("vditor-menu--current");
} else {
if (panelElement.style.display === "block") {
panelElement.style.display = "none";
} else {
hidePanel(vditor, ["subToolbar"]);
panelElement.style.display = "block";
}
hidePanel(vditor, ["subToolbar"]);
panelElement.style.display = "block";
}

@@ -62,10 +61,8 @@ });

afterRenderEvent(vditor);
actionBtn.classList.add("vditor-menu--current");
} else if (vditor.currentMode === "ir") {
processHeading(vditor, (event.target as HTMLElement).getAttribute("data-value"));
actionBtn.classList.add("vditor-menu--current");
} else {
insertText(vditor, (event.target as HTMLElement).getAttribute("data-value"), "",
false, true);
processHeadingSV(vditor, (event.target as HTMLElement).getAttribute("data-value"));
}
actionBtn.classList.add("vditor-menu--current");
panelElement.style.display = "none";

@@ -72,0 +69,0 @@ });

@@ -13,3 +13,2 @@ import {getEventName} from "../util/compatibility";

import {Export} from "./Export";
import {Format} from "./Format";
import {Fullscreen} from "./Fullscreen";

@@ -131,5 +130,2 @@ import {Headings} from "./Headings";

break;
case "format":
menuItemObj = new Format(vditor, menuItem);
break;
case "edit-mode":

@@ -136,0 +132,0 @@ menuItemObj = new EditMode(vditor, menuItem);

import {Constants} from "../constants";
import {i18n} from "../i18n/index";
import {processToolbar} from "../ir/process";
import {insertText} from "../sv/insertText";
import {processToolbar as processToolbarSV} from "../sv/process";
import {getEventName} from "../util/compatibility";

@@ -51,4 +51,4 @@ import {updateHotkeyTip} from "../util/compatibility";

} else {
insertText(vditor, menuItem.prefix || "", menuItem.suffix || "",
false, true);
processToolbarSV(vditor, this.element.children[0],
menuItem.prefix || "", menuItem.suffix || "");
}

@@ -55,0 +55,0 @@ });

@@ -21,3 +21,3 @@ import {Constants} from "../constants";

const toolbars = Constants.EDIT_TOOLBARS.concat(["both", "format", "edit-mode", "devtools"]);
const toolbars = Constants.EDIT_TOOLBARS.concat(["both", "edit-mode", "devtools"]);
if (btnElement.classList.contains("vditor-menu--current")) {

@@ -24,0 +24,0 @@ btnElement.classList.remove("vditor-menu--current");

@@ -5,4 +5,4 @@ import {Constants} from "../constants";

import {getEventName} from "../util/compatibility";
import {RecordMedia} from "../util/RecordMedia";
import {MenuItem} from "./MenuItem";
import {RecordMedia} from "./RecordMedia";

@@ -9,0 +9,0 @@ export class Record extends MenuItem {

@@ -15,11 +15,5 @@ import {Constants} from "../constants";

}
if (vditor.currentMode === "sv") {
vditor.undo.redo(vditor);
} else if (vditor.currentMode === "wysiwyg") {
vditor.wysiwygUndo.redo(vditor);
} else if (vditor.currentMode === "ir") {
vditor.irUndo.redo(vditor);
}
vditor.undo.redo(vditor);
});
}
}

@@ -15,11 +15,5 @@ import {Constants} from "../constants";

}
if (vditor.currentMode === "sv") {
vditor.undo.undo(vditor);
} else if (vditor.currentMode === "wysiwyg") {
vditor.wysiwygUndo.undo(vditor);
} else if (vditor.currentMode === "ir") {
vditor.irUndo.undo(vditor);
}
vditor.undo.undo(vditor);
});
}
}
import {Constants} from "../constants";
import {html2md} from "../sv/html2md";
import {setEditMode} from "../toolbar/EditMode";

@@ -18,3 +17,3 @@ import {accessLocalStorage} from "../util/compatibility";

setTheme(vditor);
setContentTheme(vditor.options.preview.markdown.theme, vditor.options.cdn);
setContentTheme(vditor.options.preview.theme.current, vditor.options.preview.theme.path);
if (typeof vditor.options.height === "number") {

@@ -73,2 +72,4 @@ vditor.element.style.height = vditor.options.height + "px";

document.execCommand("DefaultParagraphSeparator", false, "p");
if (navigator.userAgent.indexOf("iPhone") > -1 && typeof window.visualViewport !== "undefined") {

@@ -152,3 +153,3 @@ // https://github.com/Vanessa219/vditor/issues/379

} else if (vditor.originalInnerHTML) {
initValue = html2md(vditor, vditor.originalInnerHTML);
initValue = vditor.lute.HTML2Md(vditor.originalInnerHTML);
} else if (!vditor.options.cache.enable) {

@@ -155,0 +156,0 @@ initValue = "";

@@ -1,6 +0,5 @@

import {Constants, VDITOR_VERSION} from "../constants";
import {Constants} from "../constants";
import {addStyle} from "../util/addStyle";
export const setCodeTheme = (codeTheme: string,
cdn = `https://cdn.jsdelivr.net/npm/vditor@${VDITOR_VERSION}`) => {
export const setCodeTheme = (codeTheme: string, cdn = Constants.CDN) => {
if (!Constants.CODE_THEME.includes(codeTheme)) {

@@ -7,0 +6,0 @@ codeTheme = "github";

@@ -1,23 +0,12 @@

import {Constants, VDITOR_VERSION} from "../constants";
import {addStyle} from "../util/addStyle";
export const setContentTheme = (contentTheme: string,
cdn = `https://cdn.jsdelivr.net/npm/vditor@${VDITOR_VERSION}`) => {
if (!Constants.CONTENT_THEME.includes(contentTheme)) {
return;
}
export const setContentTheme = (contentTheme: string, path: string) => {
const vditorContentTheme = document.getElementById("vditorContentTheme") as HTMLLinkElement;
const href = `${cdn}/dist/css/content-theme/${contentTheme}.css`;
if (contentTheme === "light") {
if (vditorContentTheme) {
vditorContentTheme.remove();
}
return;
}
const cssPath = `${path}/${contentTheme}.css`;
if (!vditorContentTheme) {
addStyle(href, "vditorContentTheme");
} else if (vditorContentTheme.href !== href) {
addStyle(cssPath, "vditorContentTheme");
} else if (vditorContentTheme.href !== cssPath) {
vditorContentTheme.remove();
addStyle(href, "vditorContentTheme");
addStyle(cssPath, "vditorContentTheme");
}
};
import DiffMatchPatch, {diff_match_patch, patch_obj} from "diff-match-patch";
import {getMarkdown} from "../markdown/getMarkdown";
import {formatRender} from "../sv/formatRender";
import {disableToolbar} from "../toolbar/setToolbar";
import {enableToolbar} from "../toolbar/setToolbar";
import {disableToolbar, enableToolbar} from "../toolbar/setToolbar";
import {isFirefox, isSafari} from "../util/compatibility";
import {scrollCenter} from "../util/editorCommonEvent";
import {getSelectPosition} from "../util/selection";
import {execAfterRender} from "../util/fixBrowserBehavior";
import {highlightToolbar} from "../util/highlightToolbar";
import {processCodeRender} from "../util/processCode";
import {setRangeByWbr, setSelectionFocus} from "../util/selection";
interface IUndo {
hasUndo: boolean;
lastText: string;
redoStack: patch_obj[][];
undoStack: patch_obj[][];
}
class Undo {
private undoStack: Array<{ patchList: patch_obj[], end: number }>;
private redoStack: Array<{ patchList: patch_obj[], end: number }>;
private stackSize = 50;
private dmp: diff_match_patch;
private lastText: string;
private hasUndo: boolean;
private timeout: number;
private wysiwyg: IUndo;
private ir: IUndo;
private sv: IUndo;
constructor() {
this.redoStack = [];
this.undoStack = [];
this.resetStack();
// @ts-ignore
this.dmp = new DiffMatchPatch();
this.lastText = "";
this.hasUndo = false;
}
public clearStack(vditor: IVditor) {
this.redoStack = [];
this.undoStack = [];
this.lastText = "";
this.hasUndo = false;
this.resetStack();
this.resetIcon(vditor);

@@ -39,3 +39,4 @@ }

}
if (this.undoStack.length > 1) {
if (this[vditor.currentMode].undoStack.length > 1) {
enableToolbar(vditor.toolbar.elements, ["undo"]);

@@ -46,3 +47,3 @@ } else {

if (this.redoStack.length !== 0) {
if (this[vditor.currentMode].redoStack.length !== 0) {
enableToolbar(vditor.toolbar.elements, ["redo"]);

@@ -54,67 +55,130 @@ } else {

public recordFirstPosition(vditor: IVditor) {
if (this.undoStack.length === 1) {
this.undoStack[0].end = getSelectPosition(vditor.sv.element).end;
}
}
public undo(vditor: IVditor) {
if (vditor.sv.element.getAttribute("contenteditable") === "false") {
if (vditor[vditor.currentMode].element.getAttribute("contenteditable") === "false") {
return;
}
if (this.undoStack.length < 2) {
if (this[vditor.currentMode].undoStack.length < 2) {
return;
}
const state = this.undoStack.pop();
if (!state || !state.patchList) {
const state = this[vditor.currentMode].undoStack.pop();
if (!state) {
return;
}
this.redoStack.push(state);
this[vditor.currentMode].redoStack.push(state);
this.renderDiff(state, vditor);
this.hasUndo = true;
this[vditor.currentMode].hasUndo = true;
}
public redo(vditor: IVditor) {
if (vditor.sv.element.getAttribute("contenteditable") === "false") {
if (vditor[vditor.currentMode].element.getAttribute("contenteditable") === "false") {
return;
}
const state = this.redoStack.pop();
if (!state || !state.patchList) {
const state = this[vditor.currentMode].redoStack.pop();
if (!state) {
return;
}
this.undoStack.push(state);
this[vditor.currentMode].undoStack.push(state);
this.renderDiff(state, vditor, true);
}
public recordFirstPosition(vditor: IVditor, event: KeyboardEvent) {
if (getSelection().rangeCount === 0) {
return;
}
if (this[vditor.currentMode].undoStack.length !== 1 || this[vditor.currentMode].undoStack[0].length === 0) {
return;
}
if (isFirefox() && event.key === "Backspace") {
// Firefox 第一次删除无效
return;
}
if (isSafari()) {
// Safari keydown 在 input 之后,不需要重复记录历史
return;
}
if (vditor.currentMode === "sv") {
const caretElement = document.createElement("span");
caretElement.className = "wbr";
caretElement.textContent = Lute.Caret;
getSelection().getRangeAt(0).insertNode(caretElement);
} else {
getSelection().getRangeAt(0).insertNode(document.createElement("wbr"));
}
if (vditor.currentMode === "wysiwyg") {
this[vditor.currentMode].undoStack[0][0].diffs[0][1] =
vditor.lute.SpinVditorDOM(vditor[vditor.currentMode].element.innerHTML);
} else if (vditor.currentMode === "ir") {
this[vditor.currentMode].undoStack[0][0].diffs[0][1] =
vditor.lute.SpinVditorIRDOM(vditor[vditor.currentMode].element.innerHTML);
} else {
this[vditor.currentMode].undoStack[0][0].diffs[0][1] =
vditor.lute.SpinVditorSVDOM(vditor[vditor.currentMode].element.textContent);
}
this[vditor.currentMode].lastText = this[vditor.currentMode].undoStack[0][0].diffs[0][1];
const wbrElement =
vditor[vditor.currentMode].element.querySelector(vditor.currentMode === "sv" ? ".wbr" : "wbr");
if (wbrElement) {
wbrElement.remove();
}
// 不能添加 setSelectionFocus(cloneRange); 否则 windows chrome 首次输入会烂
}
public addToUndoStack(vditor: IVditor) {
clearTimeout(this.timeout);
this.timeout = window.setTimeout(() => {
const text = getMarkdown(vditor);
const diff = this.dmp.diff_main(text, this.lastText, true);
const patchList = this.dmp.patch_make(text, this.lastText, diff);
if (patchList.length === 0) {
return;
// afterRenderEvent.ts 已经 debounce
let cloneRange: Range;
if (getSelection().rangeCount !== 0 && !vditor[vditor.currentMode].element.querySelector("wbr")) {
const range = getSelection().getRangeAt(0);
if (vditor[vditor.currentMode].element.contains(range.startContainer)) {
cloneRange = range.cloneRange();
if (vditor.currentMode === "sv") {
const caretElement = document.createElement("span");
caretElement.className = "wbr";
caretElement.textContent = Lute.Caret;
range.insertNode(caretElement);
} else {
range.insertNode(document.createElement("wbr"));
}
}
this.lastText = text;
this.undoStack.push({patchList, end: getSelectPosition(vditor.sv.element).end});
if (this.undoStack.length > this.stackSize) {
this.undoStack.shift();
}
if (this.hasUndo) {
this.redoStack = [];
this.hasUndo = false;
disableToolbar(vditor.toolbar.elements, ["redo"]);
}
}
let text;
if (vditor.currentMode === "wysiwyg") {
text = vditor.lute.SpinVditorDOM(vditor[vditor.currentMode].element.innerHTML);
} else if (vditor.currentMode === "ir") {
text = vditor.lute.SpinVditorIRDOM(vditor[vditor.currentMode].element.innerHTML);
} else {
text = vditor.lute.SpinVditorSVDOM(vditor[vditor.currentMode].element.textContent);
}
const wbrElement =
vditor[vditor.currentMode].element.querySelector(vditor.currentMode === "sv" ? ".wbr" : "wbr");
if (wbrElement) {
wbrElement.remove();
}
if (cloneRange) {
setSelectionFocus(cloneRange);
}
const diff = this.dmp.diff_main(text, this[vditor.currentMode].lastText, true);
const patchList = this.dmp.patch_make(text, this[vditor.currentMode].lastText, diff);
if (patchList.length === 0 && this[vditor.currentMode].undoStack.length > 0) {
return;
}
this[vditor.currentMode].lastText = text;
this[vditor.currentMode].undoStack.push(patchList);
if (this[vditor.currentMode].undoStack.length > this.stackSize) {
this[vditor.currentMode].undoStack.shift();
}
if (this[vditor.currentMode].hasUndo) {
this[vditor.currentMode].redoStack = [];
this[vditor.currentMode].hasUndo = false;
disableToolbar(vditor.toolbar.elements, ["redo"]);
}
if (this.undoStack.length > 1) {
enableToolbar(vditor.toolbar.elements, ["undo"]);
}
}, 500);
if (this[vditor.currentMode].undoStack.length > 1) {
enableToolbar(vditor.toolbar.elements, ["undo"]);
}
}
private renderDiff(state: { patchList: patch_obj[], end: number }, vditor: IVditor, isRedo: boolean = false) {
private renderDiff(state: patch_obj[], vditor: IVditor, isRedo: boolean = false) {
let text;
let positoin;
if (isRedo) {
const redoPatchList = this.dmp.patch_deepCopy(state.patchList).reverse();
const redoPatchList = this.dmp.patch_deepCopy(state).reverse();
redoPatchList.forEach((patch) => {

@@ -125,20 +189,28 @@ patch.diffs.forEach((diff) => {

});
text = this.dmp.patch_apply(redoPatchList, this.lastText)[0];
positoin = {
end: state.end,
start: state.end,
};
text = this.dmp.patch_apply(redoPatchList, this[vditor.currentMode].lastText)[0];
} else {
text = this.dmp.patch_apply(state.patchList, this.lastText)[0];
if (this.undoStack[this.undoStack.length - 1]) {
positoin = {
end: this.undoStack[this.undoStack.length - 1].end,
start: this.undoStack[this.undoStack.length - 1].end,
};
}
text = this.dmp.patch_apply(state, this[vditor.currentMode].lastText)[0];
}
this.lastText = text;
this[vditor.currentMode].lastText = text;
vditor[vditor.currentMode].element.innerHTML = text;
if (vditor.currentMode !== "sv") {
vditor[vditor.currentMode].element.querySelectorAll(`.vditor-${vditor.currentMode}__preview[data-render='2']`)
.forEach((blockElement: HTMLElement) => {
processCodeRender(blockElement, vditor);
});
}
formatRender(vditor, text, positoin, {
if (!vditor[vditor.currentMode].element.querySelector("wbr")) {
// Safari 第一次输入没有光标,需手动定位到结尾
const range = getSelection().getRangeAt(0);
range.setEndBefore(vditor[vditor.currentMode].element);
range.collapse(false);
} else {
setRangeByWbr(
vditor[vditor.currentMode].element, vditor[vditor.currentMode].element.ownerDocument.createRange());
scrollCenter(vditor);
}
execAfterRender(vditor, {
enableAddUndoStack: false,

@@ -148,6 +220,5 @@ enableHint: false,

});
highlightToolbar(vditor);
scrollCenter(vditor);
if (this.undoStack.length > 1) {
if (this[vditor.currentMode].undoStack.length > 1) {
enableToolbar(vditor.toolbar.elements, ["undo"]);

@@ -158,3 +229,3 @@ } else {

if (this.redoStack.length !== 0) {
if (this[vditor.currentMode].redoStack.length !== 0) {
enableToolbar(vditor.toolbar.elements, ["redo"]);

@@ -165,4 +236,25 @@ } else {

}
private resetStack() {
this.ir = {
hasUndo: false,
lastText: "",
redoStack: [],
undoStack: [],
};
this.sv = {
hasUndo: false,
lastText: "",
redoStack: [],
undoStack: [],
};
this.wysiwyg = {
hasUndo: false,
lastText: "",
redoStack: [],
undoStack: [],
};
}
}
export {Undo};
import {i18n} from "../i18n/index";
import {insertText} from "../sv/insertText";
import {getEditorRange, setSelectionFocus} from "../util/selection";

@@ -24,3 +23,3 @@ import {getElement} from "./getElement";

let uploadingStr = "";
const lang: (keyof II18nLang) = vditor.options.lang;
const lang: keyof II18n = vditor.options.lang;

@@ -46,14 +45,14 @@ for (let iMax = files.length, i = 0; i < iMax; i++) {

if (vditor.options.upload.accept) {
let isAccept = false;
vditor.options.upload.accept.split(",").forEach((item) => {
const isAccept = vditor.options.upload.accept.split(",").some((item) => {
const type = item.trim();
if (type.indexOf(".") === 0) {
if (fileExt === type) {
isAccept = true;
if (fileExt.toLowerCase() === type.toLowerCase()) {
return true;
}
} else {
if (file.type.split("/")[0] === type.split("/")[0]) {
isAccept = true;
return true;
}
}
return false;
});

@@ -140,7 +139,3 @@

setSelectionFocus(vditor.upload.range);
if (vditor.currentMode !== "sv") {
document.execCommand("insertHTML", false, succFileText);
} else {
insertText(vditor, succFileText, "", true);
}
document.execCommand("insertHTML", false, succFileText);
vditor.upload.range = getSelection().getRangeAt(0).cloneRange();

@@ -147,0 +142,0 @@ };

import {processHeading} from "../ir/process";
import {processKeydown as irProcessKeydown} from "../ir/processKeydown";
import {getMarkdown} from "../markdown/getMarkdown";
import {getSelectText} from "../sv/getSelectText";
import {insertText} from "../sv/insertText";
import {processHeading as processHeadingSV} from "../sv/process";
import {processKeydown as mdProcessKeydown} from "../sv/processKeydown";
import {setEditMode} from "../toolbar/EditMode";
import {hidePanel} from "../toolbar/setToolbar";
import {uploadFiles} from "../upload";
import {getCursorPosition} from "../util/selection";

@@ -14,2 +14,3 @@ import {afterRenderEvent} from "../wysiwyg/afterRenderEvent";

import {getEventName, isCtrl} from "./compatibility";
import {getSelectText} from "./getSelectText";
import {hasClosestByMatchTag} from "./hasClosest";

@@ -35,2 +36,18 @@ import {matchHotKey} from "./hotKey";

export const dropEvent = (vditor: IVditor, editorElement: HTMLElement) => {
if (vditor.options.upload.url || vditor.options.upload.handler) {
editorElement.addEventListener("drop",
(event: CustomEvent & { dataTransfer?: DataTransfer, target: HTMLElement }) => {
if (event.dataTransfer.types[0] !== "Files") {
return;
}
const files = event.dataTransfer.items;
if (files.length > 0) {
uploadFiles(vditor, files);
}
event.preventDefault();
});
}
};
export const scrollCenter = (vditor: IVditor) => {

@@ -79,33 +96,13 @@ if (!vditor.options.typewriterMode) {

// undo
if (matchHotKey("⌘-Z", event)) {
if (vditor.currentMode === "sv" && !vditor.toolbar.elements.undo) {
vditor.undo.undo(vditor);
event.preventDefault();
return;
} else if (vditor.currentMode === "wysiwyg" && !vditor.toolbar.elements.undo) {
vditor.wysiwygUndo.undo(vditor);
event.preventDefault();
return;
} else if (vditor.currentMode === "ir") {
vditor.irUndo.undo(vditor);
event.preventDefault();
return;
}
if (matchHotKey("⌘-Z", event) && !vditor.toolbar.elements.undo) {
vditor.undo.undo(vditor);
event.preventDefault();
return;
}
// redo
if (matchHotKey("⌘-Y", event)) {
if (vditor.currentMode === "sv" && !vditor.toolbar.elements.redo) {
vditor.undo.redo(vditor);
event.preventDefault();
return;
} else if (vditor.currentMode === "wysiwyg" && !vditor.toolbar.elements.redo) {
vditor.wysiwygUndo.redo(vditor);
event.preventDefault();
return;
} else if (vditor.currentMode === "ir") {
vditor.irUndo.redo(vditor);
event.preventDefault();
return;
}
if (matchHotKey("⌘-Y", event) && !vditor.toolbar.elements.redo) {
vditor.undo.redo(vditor);
event.preventDefault();
return;
}

@@ -135,5 +132,3 @@

} else if (vditor.currentMode === "sv") {
insertText(vditor,
"#".repeat(parseInt(event.code.replace("Digit", ""), 10)) + " ",
"", false, true);
processHeadingSV(vditor, "#".repeat(parseInt(event.code.replace("Digit", ""), 10)) + " ");
} else if (vditor.currentMode === "ir") {

@@ -140,0 +135,0 @@ processHeading(vditor, "#".repeat(parseInt(event.code.replace("Digit", ""), 10)) + " ");

import {Constants} from "../constants";
import {highlightToolbar as highlightToolbarIR} from "../ir/highlightToolbar";
import {input as IRInput} from "../ir/input";
import {processAfterRender} from "../ir/process";
import {processAfterRender as processSVAfterRender} from "../sv/process";
import {uploadFiles} from "../upload";

@@ -9,3 +9,2 @@ import {setHeaders} from "../upload/setHeaders";

import {afterRenderEvent} from "../wysiwyg/afterRenderEvent";
import {highlightToolbar} from "../wysiwyg/highlightToolbar";
import {input} from "../wysiwyg/input";

@@ -23,2 +22,3 @@ import {isCtrl, isFirefox} from "./compatibility";

import {hasClosestByHeadings} from "./hasClosestByHeadings";
import {highlightToolbar} from "./highlightToolbar";
import {matchHotKey} from "./hotKey";

@@ -34,6 +34,10 @@ import {

// https://github.com/Vanessa219/vditor/issues/508 软键盘无法删除空块
export const fixGSKeyBackspace = (event: KeyboardEvent, vditor: IVditor) => {
export const fixGSKeyBackspace = (event: KeyboardEvent, vditor: IVditor, startContainer: Node) => {
if (event.keyCode === 229 && event.code === "" && event.key === "Unidentified" && vditor.currentMode !== "sv") {
vditor[vditor.currentMode].composingLock = true;
return false;
const blockElement = hasClosestBlock(startContainer);
// 移动端的标点符号都显示为 299,因此需限定为空删除的条件
if (blockElement && blockElement.textContent.trim() === "") {
vditor[vditor.currentMode].composingLock = true;
return false;
}
}

@@ -78,7 +82,3 @@ return true;

setRangeByWbr(vditor[vditor.currentMode].element, range);
if (vditor.currentMode === "ir") {
highlightToolbarIR(vditor);
} else {
highlightToolbar(vditor);
}
highlightToolbar(vditor);
execAfterRender(vditor);

@@ -275,5 +275,3 @@ }

execAfterRender(vditor);
if (vditor.currentMode === "wysiwyg") {
highlightToolbar(vditor);
}
highlightToolbar(vditor);
} else {

@@ -333,5 +331,3 @@ vditor[vditor.currentMode].element.focus();

execAfterRender(vditor);
if (vditor.currentMode === "wysiwyg") {
highlightToolbar(vditor);
}
highlightToolbar(vditor);
} else {

@@ -437,7 +433,13 @@ vditor[vditor.currentMode].element.focus();

export const execAfterRender = (vditor: IVditor) => {
export const execAfterRender = (vditor: IVditor, options = {
enableAddUndoStack: true,
enableHint: false,
enableInput: true,
}) => {
if (vditor.currentMode === "wysiwyg") {
afterRenderEvent(vditor);
afterRenderEvent(vditor, options);
} else if (vditor.currentMode === "ir") {
processAfterRender(vditor);
processAfterRender(vditor, options);
} else if (vditor.currentMode === "sv") {
processSVAfterRender(vditor, options);
}

@@ -457,3 +459,3 @@ };

}
range.insertNode(document.createTextNode("\n"));
range.insertNode(document.createTextNode("\n\n"));
range.collapse(false);

@@ -672,5 +674,3 @@ execAfterRender(vditor);

tableElement.remove();
if (vditor.currentMode === "wysiwyg") {
highlightToolbar(vditor);
}
highlightToolbar(vditor);
break;

@@ -983,3 +983,4 @@ }

let isEmpty = false;
if (pElement.innerHTML.replace(Constants.ZWSP, "") === "\n") {
if (pElement.innerHTML.replace(Constants.ZWSP, "") === "\n" ||
pElement.innerHTML.replace(Constants.ZWSP, "") === "") {
// 空 P

@@ -1204,9 +1205,11 @@ isEmpty = true;

HTML2VditorIRDOM?: ILuteRender,
HTML2VditorSVDOM?: ILuteRender,
Md2VditorDOM?: ILuteRender,
Md2VditorIRDOM?: ILuteRender,
Md2VditorSVDOM?: ILuteRender,
} = {};
const renderLinkDest: ILuteRenderCallback = (node) => {
const src = node.TokensStr();
if (node.__internal_object__.Parent.Type === 34 && src
&& src.indexOf("file://") === -1 && vditor.options.upload.linkToImgUrl) {
if (node.__internal_object__.Parent.Type === 34 && src && src.indexOf("file://") === -1 &&
vditor.options.upload.linkToImgUrl) {
const xhr = new XMLHttpRequest();

@@ -1224,8 +1227,17 @@ xhr.open("POST", vditor.options.upload.linkToImgUrl);

const original = responseJSON.data.originalURL;
const imgElement: HTMLImageElement =
vditor[vditor.currentMode].element.querySelector(`img[src="${original}"]`);
imgElement.src = responseJSON.data.url;
if (vditor.currentMode === "ir") {
imgElement.previousElementSibling.previousElementSibling.innerHTML =
responseJSON.data.url;
if (vditor.currentMode === "sv") {
vditor.sv.element.querySelectorAll('[data-type="image"] .vditor-sv__marker--link')
.forEach((item: HTMLElement) => {
if (item.textContent === original) {
item.textContent = responseJSON.data.url;
}
});
} else {
const imgElement: HTMLImageElement =
vditor[vditor.currentMode].element.querySelector(`img[src="${original}"]`);
imgElement.src = responseJSON.data.url;
if (vditor.currentMode === "ir") {
imgElement.previousElementSibling.previousElementSibling.innerHTML =
responseJSON.data.url;
}
}

@@ -1242,4 +1254,6 @@ execAfterRender(vditor);

return [`<span class="vditor-ir__marker vditor-ir__marker--link">${src}</span>`, Lute.WalkStop];
} else if (vditor.currentMode === "wysiwyg") {
return ["", Lute.WalkStop];
} else {
return ["", Lute.WalkStop];
return [`<span class="vditor-sv__marker--link">${src}</span>`, Lute.WalkStop];
}

@@ -1264,18 +1278,25 @@ };

const code = processPasteCode(textHTML, textPlain, vditor.currentMode);
const codeElement = hasClosestByMatchTag(event.target, "CODE");
const codeElement = vditor.currentMode === "sv" ?
hasClosestByAttribute(event.target, "data-type", "code-block") :
hasClosestByMatchTag(event.target, "CODE");
if (codeElement) {
// 粘贴在代码位置
const position = getSelectPosition(event.target);
if (codeElement.parentElement.tagName !== "PRE") {
// https://github.com/Vanessa219/vditor/issues/463
textPlain += Constants.ZWSP;
if (vditor.currentMode === "sv") {
document.execCommand("insertHTML", false, textPlain);
} else {
const position = getSelectPosition(event.target);
if (codeElement.parentElement.tagName !== "PRE") {
// https://github.com/Vanessa219/vditor/issues/463
textPlain += Constants.ZWSP;
}
codeElement.textContent = codeElement.textContent.substring(0, position.start)
+ textPlain + codeElement.textContent.substring(position.end);
setSelectionByPosition(position.start + textPlain.length, position.start + textPlain.length,
codeElement.parentElement);
if (codeElement.parentElement?.nextElementSibling.classList
.contains(`vditor-${vditor.currentMode}__preview`)) {
codeElement.parentElement.nextElementSibling.innerHTML = codeElement.outerHTML;
processCodeRender(codeElement.parentElement.nextElementSibling as HTMLElement, vditor);
}
}
codeElement.textContent = codeElement.textContent.substring(0, position.start)
+ textPlain + codeElement.textContent.substring(position.end);
setSelectionByPosition(position.start + textPlain.length, position.start + textPlain.length,
codeElement.parentElement);
if (codeElement.parentElement?.nextElementSibling.classList.contains(`vditor-${vditor.currentMode}__preview`)) {
codeElement.parentElement.nextElementSibling.innerHTML = codeElement.outerHTML;
processCodeRender(codeElement.parentElement.nextElementSibling as HTMLElement, vditor);
}
} else if (code) {

@@ -1297,6 +1318,10 @@ callback.pasteCode(code);

insertHTML(vditor.lute.HTML2VditorIRDOM(tempElement.innerHTML), vditor);
} else {
} else if (vditor.currentMode === "wysiwyg") {
renderers.HTML2VditorDOM = {renderLinkDest};
vditor.lute.SetJSRenderers({renderers});
insertHTML(vditor.lute.HTML2VditorDOM(tempElement.innerHTML), vditor);
} else {
renderers.HTML2VditorSVDOM = {renderLinkDest};
vditor.lute.SetJSRenderers({renderers});
insertHTML(vditor.lute.HTML2VditorSVDOM(tempElement.innerHTML), vditor);
}

@@ -1311,6 +1336,10 @@ vditor.outline.render(vditor);

insertHTML(vditor.lute.Md2VditorIRDOM(textPlain), vditor);
} else {
} else if (vditor.currentMode === "wysiwyg") {
renderers.Md2VditorDOM = {renderLinkDest};
vditor.lute.SetJSRenderers({renderers});
insertHTML(vditor.lute.Md2VditorDOM(textPlain), vditor);
} else {
renderers.Md2VditorSVDOM = {renderLinkDest};
vditor.lute.SetJSRenderers({renderers});
insertHTML(vditor.lute.Md2VditorSVDOM(textPlain), vditor);
}

@@ -1320,7 +1349,9 @@ vditor.outline.render(vditor);

}
vditor[vditor.currentMode].element.querySelectorAll(`.vditor-${vditor.currentMode}__preview[data-render='2']`)
.forEach((item: HTMLElement) => {
processCodeRender(item, vditor);
});
if (vditor.currentMode !== "sv") {
vditor[vditor.currentMode].element.querySelectorAll(`.vditor-${vditor.currentMode}__preview[data-render='2']`)
.forEach((item: HTMLElement) => {
processCodeRender(item, vditor);
});
}
execAfterRender(vditor);
};

@@ -25,3 +25,2 @@ import insertAfterSVG from "../../assets/icons/after.svg";

import orderedListVG from "../../assets/icons/ordered-list.svg";
import formatSVG from "../../assets/icons/outdent.svg";
import outdentSVG from "../../assets/icons/outdent.svg";

@@ -37,3 +36,4 @@ import previewSVG from "../../assets/icons/preview.svg";

import uploadSVG from "../../assets/icons/upload.svg";
import {VDITOR_VERSION} from "../constants";
import {Constants} from "../constants";
import {merge} from "./merge";

@@ -47,3 +47,3 @@ export class Options {

},
cdn: `https://cdn.jsdelivr.net/npm/vditor@${VDITOR_VERSION}`,
cdn: Constants.CDN,
classes: {

@@ -70,8 +70,4 @@ preview: "",

},
emojiPath: `https://cdn.jsdelivr.net/npm/vditor@${VDITOR_VERSION}/dist/images/emoji`,
emojiPath: `${Constants.CDN}/dist/images/emoji`,
},
keymap: {
deleteLine: "⌘-Backspace",
duplicate: "⌘-D",
},
lang: "zh_CN",

@@ -83,27 +79,8 @@ mode: "wysiwyg",

delay: 1000,
hljs: {
enable: true,
lineNumber: false,
style: "github",
},
markdown: {
autoSpace: false,
chinesePunct: false,
codeBlockPreview: true,
fixTermTypo: false,
footnotes: true,
linkBase: "",
listStyle: false,
sanitize: true,
setext: false,
theme: "light",
toc: false,
},
math: {
engine: "KaTeX",
inlineDigit: false,
macros: {},
},
hljs: Constants.HLJS_OPTIONS,
markdown: Constants.MARKDOWN_OPTIONS,
math: Constants.MATH_OPTIONS,
maxWidth: 800,
mode: "both",
theme: Constants.THEME_OPTIONS,
},

@@ -154,3 +131,2 @@ resize: {

"preview",
"format",
"devtools",

@@ -178,198 +154,2 @@ "info",

private toolbarItem = [{
icon: exportSVG,
name: "export",
tipPosition: "ne",
}, {
hotkey: "⌘-E",
icon: emojiSVG,
name: "emoji",
tipPosition: "ne",
}, {
hotkey: "⌘-H",
icon: headingsSVG,
name: "headings",
tipPosition: "ne",
}, {
hotkey: "⌘-B",
icon: boldSVG,
name: "bold",
prefix: "**",
suffix: "**",
tipPosition: "ne",
}, {
hotkey: "⌘-I",
icon: italicSVG,
name: "italic",
prefix: "*",
suffix: "*",
tipPosition: "ne",
}, {
hotkey: "⌘-S",
icon: strikekSVG,
name: "strike",
prefix: "~~",
suffix: "~~",
tipPosition: "ne",
}, {
hotkey: "⌘-K",
icon: linkSVG,
name: "link",
prefix: "[",
suffix: "](https://)",
tipPosition: "n",
}, {
name: "|",
}, {
hotkey: "⌘-L",
icon: listSVG,
name: "list",
prefix: "* ",
tipPosition: "n",
}, {
hotkey: "⌘-O",
icon: orderedListVG,
name: "ordered-list",
prefix: "1. ",
tipPosition: "n",
}, {
hotkey: "⌘-J",
icon: checkSVG,
name: "check",
prefix: "* [ ] ",
tipPosition: "n",
}, {
hotkey: "⌘-⇧-I",
icon: outdentSVG,
name: "outdent",
tipPosition: "n",
}, {
hotkey: "⌘-⇧-O",
icon: indentSVG,
name: "indent",
tipPosition: "n",
}, {
name: "|",
}, {
hotkey: "⌘-;",
icon: quoteSVG,
name: "quote",
prefix: "> ",
tipPosition: "n",
}, {
hotkey: "⌘-⇧-H",
icon: lineSVG,
name: "line",
prefix: "---",
tipPosition: "n",
}, {
hotkey: "⌘-U",
icon: codeSVG,
name: "code",
prefix: "```\n",
suffix: "\n```",
tipPosition: "n",
}, {
hotkey: "⌘-G",
icon: inlineCodeSVG,
name: "inline-code",
prefix: "`",
suffix: "`",
tipPosition: "n",
}, {
hotkey: "⌘-⇧-B",
icon: insertBeforeSVG,
name: "insert-before",
tipPosition: "n",
}, {
hotkey: "⌘-⇧-E",
icon: insertAfterSVG,
name: "insert-after",
tipPosition: "n",
}, {
name: "|",
}, {
icon: uploadSVG,
name: "upload",
tipPosition: "n",
}, {
icon: recordSVG,
name: "record",
tipPosition: "n",
}, {
hotkey: "⌘-M",
icon: tableSVG,
name: "table",
prefix: "| col1",
suffix: " | col2 | col3 |\n| --- | --- | --- |\n| | | |\n| | | |",
tipPosition: "n",
}, {
name: "|",
}, {
hotkey: "⌘-Z",
icon: undoSVG,
name: "undo",
tipPosition: "nw",
}, {
hotkey: "⌘-Y",
icon: redoSVG,
name: "redo",
tipPosition: "nw",
}, {
name: "|",
}, {
icon: moreSVG,
name: "more",
tipPosition: "e",
}, {
hotkey: "⌘-'",
icon: fullscreenSVG,
name: "fullscreen",
tipPosition: "nw",
}, {
icon: editSVG,
name: "edit-mode",
tipPosition: "nw",
}, {
hotkey: "⌘-P",
icon: bothSVG,
name: "both",
tipPosition: "nw",
}, {
icon: previewSVG,
name: "preview",
tipPosition: "nw",
}, {
hotkey: "⌘-⇧-F",
icon: formatSVG,
name: "format",
tipPosition: "nw",
}, {
icon: outlinerSVG,
name: "outline",
tipPosition: "nw",
}, {
icon: contentThemeSVG,
name: "content-theme",
tipPosition: "nw",
}, {
icon: codeThemeSVG,
name: "code-theme",
tipPosition: "nw",
}, {
icon: bugSVG,
name: "devtools",
tipPosition: "nw",
}, {
icon: infoSVG,
name: "info",
tipPosition: "nw",
}, {
icon: helpSVG,
name: "help",
tipPosition: "nw",
}, {
name: "br",
}];
constructor(options: IOptions) {

@@ -381,51 +161,2 @@ this.options = options;

if (this.options) {
if (this.options.upload) {
this.options.upload = Object.assign({}, this.defaultOptions.upload, this.options.upload);
}
if (this.options.cache) {
this.options.cache = Object.assign({}, this.defaultOptions.cache, this.options.cache);
}
if (this.options.classes) {
this.options.classes = Object.assign({}, this.defaultOptions.classes, this.options.classes);
}
if (this.options.keymap) {
this.options.keymap = Object.assign({}, this.defaultOptions.keymap, this.options.keymap);
}
if (this.options.preview) {
if (this.options.preview.hljs) {
this.options.preview.hljs =
Object.assign({}, this.defaultOptions.preview.hljs, this.options.preview.hljs);
}
if (this.options.preview.math) {
this.options.preview.math =
Object.assign({}, this.defaultOptions.preview.math, this.options.preview.math);
}
if (this.options.preview.markdown) {
this.options.preview.markdown =
Object.assign({}, this.defaultOptions.preview.markdown, this.options.preview.markdown);
}
this.options.preview = Object.assign({}, this.defaultOptions.preview, this.options.preview);
}
if (this.options.hint) {
this.options.hint = Object.assign({}, this.defaultOptions.hint, this.options.hint);
}
if (this.options.resize) {
this.options.resize = Object.assign({}, this.defaultOptions.resize, this.options.resize);
}
if (this.options.counter) {
this.options.counter = Object.assign({}, this.defaultOptions.counter, this.options.counter);
}
if (this.options.toolbarConfig) {
this.options.toolbarConfig =
Object.assign({}, this.defaultOptions.toolbarConfig, this.options.toolbarConfig);
}
if (this.options.toolbar) {

@@ -436,5 +167,11 @@ this.options.toolbar = this.mergeToolbar(this.options.toolbar);

}
if (this.options.preview?.theme?.list) {
this.defaultOptions.preview.theme.list = this.options.preview.theme.list;
}
if (this.options.hint?.emoji) {
this.defaultOptions.hint.emoji = this.options.hint.emoji;
}
}
const mergedOptions = Object.assign({}, this.defaultOptions, this.options);
const mergedOptions = merge(this.defaultOptions, this.options);

@@ -449,6 +186,196 @@ if (mergedOptions.cache.enable && !mergedOptions.cache.id) {

private mergeToolbar(toolbar: Array<string | IMenuItem>) {
const toolbarItem = [{
icon: exportSVG,
name: "export",
tipPosition: "ne",
}, {
hotkey: "⌘-E",
icon: emojiSVG,
name: "emoji",
tipPosition: "ne",
}, {
hotkey: "⌘-H",
icon: headingsSVG,
name: "headings",
tipPosition: "ne",
}, {
hotkey: "⌘-B",
icon: boldSVG,
name: "bold",
prefix: "**",
suffix: "**",
tipPosition: "ne",
}, {
hotkey: "⌘-I",
icon: italicSVG,
name: "italic",
prefix: "*",
suffix: "*",
tipPosition: "ne",
}, {
hotkey: "⌘-S",
icon: strikekSVG,
name: "strike",
prefix: "~~",
suffix: "~~",
tipPosition: "ne",
}, {
hotkey: "⌘-K",
icon: linkSVG,
name: "link",
prefix: "[",
suffix: "](https://)",
tipPosition: "n",
}, {
name: "|",
}, {
hotkey: "⌘-L",
icon: listSVG,
name: "list",
prefix: "* ",
tipPosition: "n",
}, {
hotkey: "⌘-O",
icon: orderedListVG,
name: "ordered-list",
prefix: "1. ",
tipPosition: "n",
}, {
hotkey: "⌘-J",
icon: checkSVG,
name: "check",
prefix: "* [ ] ",
tipPosition: "n",
}, {
hotkey: "⌘-⇧-I",
icon: outdentSVG,
name: "outdent",
tipPosition: "n",
}, {
hotkey: "⌘-⇧-O",
icon: indentSVG,
name: "indent",
tipPosition: "n",
}, {
name: "|",
}, {
hotkey: "⌘-;",
icon: quoteSVG,
name: "quote",
prefix: "> ",
tipPosition: "n",
}, {
hotkey: "⌘-⇧-H",
icon: lineSVG,
name: "line",
prefix: "---",
tipPosition: "n",
}, {
hotkey: "⌘-U",
icon: codeSVG,
name: "code",
prefix: "```\n",
suffix: "\n```",
tipPosition: "n",
}, {
hotkey: "⌘-G",
icon: inlineCodeSVG,
name: "inline-code",
prefix: "`",
suffix: "`",
tipPosition: "n",
}, {
hotkey: "⌘-⇧-B",
icon: insertBeforeSVG,
name: "insert-before",
tipPosition: "n",
}, {
hotkey: "⌘-⇧-E",
icon: insertAfterSVG,
name: "insert-after",
tipPosition: "n",
}, {
name: "|",
}, {
icon: uploadSVG,
name: "upload",
tipPosition: "n",
}, {
icon: recordSVG,
name: "record",
tipPosition: "n",
}, {
hotkey: "⌘-M",
icon: tableSVG,
name: "table",
prefix: "| col1",
suffix: " | col2 | col3 |\n| --- | --- | --- |\n| | | |\n| | | |",
tipPosition: "n",
}, {
name: "|",
}, {
hotkey: "⌘-Z",
icon: undoSVG,
name: "undo",
tipPosition: "nw",
}, {
hotkey: "⌘-Y",
icon: redoSVG,
name: "redo",
tipPosition: "nw",
}, {
name: "|",
}, {
icon: moreSVG,
name: "more",
tipPosition: "e",
}, {
hotkey: "⌘-'",
icon: fullscreenSVG,
name: "fullscreen",
tipPosition: "nw",
}, {
icon: editSVG,
name: "edit-mode",
tipPosition: "nw",
}, {
hotkey: "⌘-P",
icon: bothSVG,
name: "both",
tipPosition: "nw",
}, {
icon: previewSVG,
name: "preview",
tipPosition: "nw",
}, {
icon: outlinerSVG,
name: "outline",
tipPosition: "nw",
}, {
icon: contentThemeSVG,
name: "content-theme",
tipPosition: "nw",
}, {
icon: codeThemeSVG,
name: "code-theme",
tipPosition: "nw",
}, {
icon: bugSVG,
name: "devtools",
tipPosition: "nw",
}, {
icon: infoSVG,
name: "info",
tipPosition: "nw",
}, {
icon: helpSVG,
name: "help",
tipPosition: "nw",
}, {
name: "br",
}];
const toolbarResult: IMenuItem[] = [];
toolbar.forEach((menuItem: IMenuItem) => {
let currentMenuItem = menuItem;
this.toolbarItem.forEach((defaultMenuItem: IMenuItem) => {
toolbarItem.forEach((defaultMenuItem: IMenuItem) => {
if (typeof menuItem === "string" && defaultMenuItem.name === menuItem) {

@@ -455,0 +382,0 @@ currentMenuItem = defaultMenuItem;

@@ -22,3 +22,3 @@ import {abcRender} from "../markdown/abcRender";

&& pres[0].className !== "vditor-wysiwyg"
&& pres[0].className !== "vditor-textarea") {
&& pres[0].className !== "vditor-sv") {
// IDE

@@ -25,0 +25,0 @@ isCode = true;

@@ -50,5 +50,7 @@ import {Constants} from "../constants";

// in table or code block
const cloneRange = range.cloneRange();
range.selectNode(range.startContainer.childNodes[Math.max(0, range.startOffset - 1)]);
cursorRect = range.getClientRects()[0];
range.collapse(false);
range.setEnd(cloneRange.endContainer, cloneRange.endOffset);
range.setStart(cloneRange.startContainer, cloneRange.startOffset);
} else {

@@ -237,9 +239,14 @@ cursorRect = (range.startContainer as HTMLElement).getClientRects()[0];

tempElement.innerHTML = html;
const pElements = tempElement.querySelectorAll("p");
if (pElements.length === 1 && !pElements[0].previousSibling && !pElements[0].nextSibling) {
if ((vditor.currentMode === "wysiwyg" && vditor.wysiwyg.element.children.length > 0) ||
(vditor.currentMode === "ir" && vditor.ir.element.children.length > 0)) {
// empty and past
html = pElements[0].innerHTML.trim();
const tempBlockElement = vditor.currentMode === "sv" ?
tempElement.querySelectorAll('[data-type="p"]') :
tempElement.querySelectorAll("p");
if (tempBlockElement.length === 1 && !tempBlockElement[0].previousSibling && !tempBlockElement[0].nextSibling &&
vditor[vditor.currentMode].element.children.length > 0) {
// empty and past
if (vditor.currentMode === "sv") {
tempBlockElement[0].querySelectorAll('[data-type="newline"]').forEach((item: HTMLElement) => {
item.remove();
});
}
html = tempBlockElement[0].innerHTML.trim();
}

@@ -251,3 +258,3 @@

const range = getEditorRange(vditor[vditor.currentMode].element);
if (range.toString() !== "" && vditor.currentMode !== "sv") {
if (range.toString() !== "") {
vditor[vditor.currentMode].preventInput = true;

@@ -254,0 +261,0 @@ document.execCommand("delete", false, "");

import {getMarkdown} from "../markdown/getMarkdown";
import {accessLocalStorage, isSafari} from "../util/compatibility";
import {accessLocalStorage} from "../util/compatibility";

@@ -14,4 +14,3 @@ export const afterRenderEvent = (vditor: IVditor, options = {

vditor.wysiwyg.afterRenderTimeoutId = window.setTimeout(() => {
if (vditor.wysiwyg.composingLock && isSafari()) {
// safari 中文输入遇到 addToUndoStack 会影响下一次的中文输入
if (vditor.wysiwyg.composingLock) {
return;

@@ -40,5 +39,5 @@ }

if (options.enableAddUndoStack) {
vditor.wysiwygUndo.addToUndoStack(vditor);
vditor.undo.addToUndoStack(vditor);
}
}, 800);
};
import {Constants} from "../constants";
import {hidePanel} from "../toolbar/setToolbar";
import {uploadFiles} from "../upload";
import {isCtrl, isFirefox} from "../util/compatibility";
import {blurEvent, focusEvent, hotkeyEvent, scrollCenter, selectEvent} from "../util/editorCommonEvent";
import {blurEvent, dropEvent, focusEvent, hotkeyEvent, scrollCenter, selectEvent} from "../util/editorCommonEvent";
import {isHeadingMD, isHrMD, paste, renderToc} from "../util/fixBrowserBehavior";

@@ -18,3 +17,3 @@ import {

import {afterRenderEvent} from "./afterRenderEvent";
import {genImagePopover, highlightToolbar} from "./highlightToolbar";
import {genImagePopover, highlightToolbarWYSIWYG} from "./highlightToolbarWYSIWYG";
import {getRenderElementNextNode, modifyPre} from "./inlineTag";

@@ -46,4 +45,2 @@ import {input} from "./input";

document.execCommand("DefaultParagraphSeparator", false, "p");
focusEvent(vditor, this.element);

@@ -53,19 +50,6 @@ blurEvent(vditor, this.element);

selectEvent(vditor, this.element);
dropEvent(vditor, this.element);
}
private bindEvent(vditor: IVditor) {
if (vditor.options.upload.url || vditor.options.upload.handler) {
this.element.addEventListener("drop",
(event: CustomEvent & { dataTransfer?: DataTransfer, target: HTMLElement }) => {
if (event.dataTransfer.types[0] !== "Files") {
return;
}
const files = event.dataTransfer.items;
if (files.length > 0) {
uploadFiles(vditor, files);
}
event.preventDefault();
});
}
window.addEventListener("scroll", () => {

@@ -174,3 +158,6 @@ hidePanel(vditor, ["hint"]);

}
input(vditor, getSelection().getRangeAt(0).cloneRange(), event);
if (!isFirefox()) {
input(vditor, getSelection().getRangeAt(0).cloneRange(), event);
}
this.composingLock = false;
});

@@ -273,3 +260,3 @@

highlightToolbar(vditor);
highlightToolbarWYSIWYG(vditor);

@@ -314,3 +301,3 @@ // 点击后光标落于预览区,需展开代码块

highlightToolbar(vditor);
highlightToolbarWYSIWYG(vditor);

@@ -317,0 +304,0 @@ if (event.key !== "ArrowDown" && event.key !== "ArrowRight" && event.key !== "Backspace"

@@ -117,6 +117,7 @@ import {isToC, renderToc} from "../util/fixBrowserBehavior";

if (html === '<p data-block="0">```<wbr></p>' && vditor.hint.recentLanguage) {
html = '<p data-block="0">```<wbr></p>'.replace("```", "```" + vditor.hint.recentLanguage);
}
log("SpinVditorDOM", html, "argument", vditor.options.debugger);
html = vditor.lute.SpinVditorDOM(html);
log("SpinVditorDOM", html, "result", vditor.options.debugger);

@@ -123,0 +124,0 @@

@@ -37,12 +37,12 @@ import {Constants} from "../constants";

if (event.key.indexOf("Arrow") === -1) {
vditor.wysiwygUndo.recordFirstWbr(vditor, event);
vditor.undo.recordFirstPosition(vditor, event);
}
if (!fixGSKeyBackspace(event, vditor)) {
const range = getEditorRange(vditor.wysiwyg.element);
const startContainer = range.startContainer;
if (!fixGSKeyBackspace(event, vditor, startContainer)) {
return false;
}
const range = getEditorRange(vditor.wysiwyg.element);
const startContainer = range.startContainer;
fixCJKPosition(range, event);

@@ -49,0 +49,0 @@

@@ -8,3 +8,3 @@ import {Constants} from "../constants";

import {afterRenderEvent} from "./afterRenderEvent";
import {genAPopover, highlightToolbar} from "./highlightToolbar";
import {genAPopover, highlightToolbarWYSIWYG} from "./highlightToolbarWYSIWYG";
import {getNextHTML, getPreviousHTML, splitElement} from "./inlineTag";

@@ -319,3 +319,3 @@

if (useHighlight) {
highlightToolbar(vditor);
highlightToolbarWYSIWYG(vditor);
}

@@ -322,0 +322,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet