This repository has been archived on 2023-08-30. You can view files and clone it, but cannot push or open issues/pull-requests.
bytedo
/
wcui
Archived
1
0
Fork 0

优化editor组件高度初始化

old
yutent 2022-02-24 10:22:38 +08:00
parent d79bb96b6b
commit 3d23648658
2 changed files with 14 additions and 14 deletions

View File

@ -1,8 +1,8 @@
<template>
<div class="neditor">
<div class="editor">
<section class="toolbar"></section>
<wc-scroll>
<div contenteditable="true" class="editor" spellcheck="false"></div>
<div contenteditable="true" class="typearea" spellcheck="false"></div>
</wc-scroll>
<div class="font-layer">
<span data-size="6">6号字体</span>
@ -75,7 +75,7 @@ a {
color: var(--color-teal-1);
}
.neditor {
.editor {
position: relative;
flex: 1;
display: flex;
@ -126,9 +126,10 @@ wc-scroll {
overflow: hidden;
flex: 1;
}
.editor {
.typearea {
width: 100%;
height: 100%;
min-height: 64px;
padding: 5px 8px;
outline: none;
@ -138,14 +139,14 @@ wc-scroll {
}
:host([disabled]) {
.neditor {
.editor {
cursor: not-allowed;
opacity: 0.6;
}
}
:host([readonly]) {
.neditor {
.editor {
cursor: default;
opacity: 0.8;
}
@ -373,7 +374,7 @@ export default class Editor {
get value() {
var html = this.__EDITOR__.innerHTML
if (~html.indexOf('<table>')) {
if (~html.indexOf('<table>') && !html.startsWith('<style>table')) {
html =
'<style>table{border-spacing:0;border-collapse:collapse;}table tr{background:#fff;}table thead tr{background:#f3f5fb;}table th,table td{padding:6px 12px;border:1px solid #dae1e9;}table th{font-weight: bold;}</style>' +
html
@ -449,6 +450,8 @@ export default class Editor {
})
}
this.__EDITOR__.style.cssText = `min-height:${this.clientHeight - 36}px;`
/* ------------------------------ */
// 工具栏点击事件

View File

@ -12,6 +12,9 @@ export default {
*/
nextTick: (function() {
let queue = []
let node = document.createTextNode('<!-- -->')
let bool = false
function callback() {
let n = queue.length
for (let i = 0; i < n; i++) {
@ -20,10 +23,8 @@ export default {
queue = queue.slice(n)
}
let node = document.createTextNode('<!-- -->')
new MutationObserver(callback).observe(node, { characterData: true })
let bool = false
return function(fn) {
queue.push(fn)
bool = !bool
@ -122,11 +123,7 @@ export default {
}
} else {
var target = ev.explicitOriginalTarget || ev.target
if (
dom === target ||
dom.contains(target) ||
(dom.root && dom.root.contains(target))
) {
if (dom === target || dom.contains(target) || (dom.root && dom.root.contains(target))) {
return
}
}