Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Vanessa219 authored and stevapple committed Apr 8, 2020
1 parent 82f1bb7 commit 7e7458a
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 7 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@

* [220](https://github.com/Vanessa219/vditor/issues/220) 软换行前进行删除,将会变为 p `修复缺陷`
* [221](https://github.com/Vanessa219/vditor/issues/221) 输入复选框时出现乱码 `修复缺陷`
* [222](https://github.com/Vanessa219/vditor/issues/222) The cursor does not enter when added in the middle of the list. `修复缺陷`
* [222](https://github.com/Vanessa219/vditor/issues/222) The cursor does not enter when added in the middle of the list `修复缺陷`
* [223](https://github.com/Vanessa219/vditor/issues/223) 下列 a 前输入 ``` b 会消失,且返回无光标 `修复缺陷`
* 文档更新
* 修改 `options.mode` 可选值为:'sv', 'wysiwyg', 'ir'
* toolbar 中的 wysiwyg 修改为 'edit-mode'
Expand Down
2 changes: 1 addition & 1 deletion demo/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import '../src/assets/scss/index.scss'
window.vditor = new Vditor('vditor', {
debugger: true,
typewriterMode: true,
// mode: 'ir',
mode: 'ir',
placeholder: 'placeholder',
preview: {
markdown: {
Expand Down
6 changes: 6 additions & 0 deletions src/assets/scss/_ir.scss
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@
}
}

&__link {
color: $blurColor;
text-decoration: underline;
}

.vditor-reset {
background-color: var(--panel-background-color);
margin: 0;
Expand Down Expand Up @@ -53,6 +58,7 @@
}
}

// block title
h1:before,
h2:before,
h3:before,
Expand Down
30 changes: 27 additions & 3 deletions src/ts/ir/input.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,36 @@
import {hasClosestBlock} from "../util/hasClosest";
import {log} from "../util/log";
import {setRangeByWbr} from "../wysiwyg/setRangeByWbr";
import {processAfterRender} from "./process";

export const input = (vditor: IVditor, range: Range) => {
range.insertNode(document.createElement("wbr"));
log("SpinVditorIRDOM", vditor.ir.element.innerHTML, "argument", vditor.options.debugger);
vditor.ir.element.innerHTML = vditor.lute.SpinVditorIRDOM(vditor.ir.element.innerHTML);
log("SpinVditorIRDOM", vditor.ir.element.innerHTML, "result", vditor.options.debugger);

let blockElement = hasClosestBlock(range.startContainer);

if (!blockElement) {
// 使用顶级块元素,应使用 innerHTML
blockElement = vditor.ir.element;
}

const isIRElement = blockElement.isEqualNode(vditor.ir.element);
let html = "";
if (!isIRElement) {
html = blockElement.outerHTML;
} else {
html = blockElement.innerHTML;
}

log("SpinVditorIRDOM", html, "argument", vditor.options.debugger);
html = vditor.lute.SpinVditorIRDOM(html);
log("SpinVditorIRDOM", html, "result", vditor.options.debugger);

if (isIRElement) {
blockElement.innerHTML = html;
} else {
blockElement.outerHTML = html;
}

setRangeByWbr(vditor.ir.element, range);
processAfterRender(vditor, {
enableAddUndoStack: true,
Expand Down
4 changes: 2 additions & 2 deletions src/ts/markdown/md2html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ export const loadLuteJs = (vditor: IVditor | string) => {
// cdn = vditor.options.cdn;
// }
// addScript(`${cdn}/dist/js/lute/lute.min.js`, "vditorLuteScript");
addScript(`/src/js/lute/lute.min.js`, "vditorLuteScript");
// addScript(`http://192.168.2.248:9090/lute.min.js?${new Date().getTime()}`, "vditorLuteScript");
// addScript(`/src/js/lute/lute.min.js`, "vditorLuteScript");
addScript(`http://192.168.2.248:9090/lute.min.js?${new Date().getTime()}`, "vditorLuteScript");

if (vditor && typeof vditor === "object" && !vditor.lute) {
vditor.lute = Lute.New();
Expand Down

0 comments on commit 7e7458a

Please sign in to comment.