提交 9c635990 编写于 作者: 璃白.'s avatar 璃白. 🌻

fix

上级 44c32ed7
......@@ -48,6 +48,7 @@
:rows="rows"
:html.sync="html"
:id="textareaId"
:ref="'md_textarea' + id"
@tab="$refs['md_header' + id].tab()"
@submit="submit"
v-else
......
......@@ -31,9 +31,6 @@ export default {
}
},
mounted() {
setTimeout(() => {
// this.resetMinHeight();
}, 0);
this.addClass();
},
updated() {
......@@ -46,39 +43,6 @@ export default {
if (!previewDom) return;
previewDom.className = "md_hljs";
}, 0);
},
transferMarkdown(val) {
marked.setOptions({
highlight: function(code, lang, callback) {
const html = require("highlight.js").highlightAuto(code).value;
return html;
}
});
const str = val + "";
// if (!str.trim()) return;
const html = marked(str);
this.$emit("update:html", html);
},
resetMinHeight() {
console.log("resetHeight");
const textEl = document.getElementById(this.id);
if (!textEl) return;
const height = textEl.offsetHeight;
console.log("编辑区高度", height);
this.htmlMinHeight = height;
}
},
watch: {
text: {
immediate: true,
handler: function(val) {
setTimeout(() => {
// this.resetMinHeight();
}, 0);
// this.transferMarkdown(val);
}
}
}
};
......
......@@ -88,11 +88,16 @@ export default {
document.addEventListener("mouseup", this.checkSelection);
},
mounted() {
setTimeout(() => {
this.resetMinHeight();
}, 0);
this.resetPreviewMinHeight();
},
watch: {
isFocus: {
handler: function(val) {
if (val) {
this.resetPreviewMinHeight();
}
}
},
text: {
immediate: true,
handler: function(val) {
......@@ -111,7 +116,7 @@ export default {
document.body.style.overflow = "auto";
}
setTimeout(() => {
this.reSizeHeight();
this.reSizeTextareaHeight();
}, 0);
}
},
......@@ -120,7 +125,7 @@ export default {
handler: function() {
setTimeout(() => {
if (!this.autoSize) return;
this.reSizeHeight();
this.reSizeTextareaHeight();
}, 0);
}
}
......@@ -139,15 +144,13 @@ export default {
}
},
methods: {
resetMinHeight() {
console.log("resetHeight");
const textEl = document.getElementById(this.id);
if (!textEl) return;
const height = textEl.offsetHeight;
console.log("编辑区高度", height);
this.$emit("update:htmlMinHeight", height);
// this.htmlMinHeight = height;
resetPreviewMinHeight() {
setTimeout(() => {
const textEl = document.getElementById(this.id);
if (!textEl) return;
const height = textEl.offsetHeight;
this.$emit("update:htmlMinHeight", height);
}, 0);
},
transferMarkdown(val) {
marked.setOptions({
......@@ -165,7 +168,7 @@ export default {
this.$emit("update:textLength", this.textContent.length);
this.emitText();
},
reSizeHeight() {
reSizeTextareaHeight() {
const textEl = document.getElementById(this.id);
if (!textEl) return;
const fontSize = getComputedStyle(textEl).getPropertyValue("font-size");
......
......@@ -205,10 +205,21 @@ export default {
const startStr = " ";
const endStr = "";
const originalText = this.text;
const selectionInfo = this.selectionInfo;
const cursorPoint = getPosition(this.id);
console.log(cursorPoint);
const selectionInfo = {
selectionStart: cursorPoint,
selectionEnd: cursorPoint
};
const newText = formatText(originalText, selectionInfo, startStr, endStr);
const len = newText.length - originalText.length;
// const len = 0;
this.$emit("update:selectionInfo", {
selectorId: "",
selectionStart: cursorPoint.selectionStart + len,
selectionEnd: cursorPoint.selectionEnd + len
});
this.updateText(newText, len);
},
setShowPreview(val) {
......@@ -222,8 +233,8 @@ export default {
this.$emit("update:selectionInfo", {
selectorId: "",
selectionStart: cursorPoint,
selectionEnd: cursorPoint
selectionStart: "",
selectionEnd: ""
});
console.log(cursorPoint);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册