mirror of
https://github.com/doocs/md.git
synced 2024-11-24 19:10:34 +08:00
fix: update insertForm component
This commit is contained in:
parent
47847aabc4
commit
214f4ba3ae
@ -51,80 +51,76 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import config from "../../assets/scripts/config";
|
import config from "../../assets/scripts/config";
|
||||||
import { mapState, mapMutations } from "vuex";
|
import {
|
||||||
export default {
|
mapState,
|
||||||
props: {
|
mapMutations
|
||||||
dialogFormVisible: {
|
} from "vuex";
|
||||||
type: Boolean,
|
export default {
|
||||||
default: false
|
props: {
|
||||||
}
|
dialogFormVisible: {
|
||||||
},
|
type: Boolean,
|
||||||
data() {
|
default: false
|
||||||
return {
|
}
|
||||||
config: config,
|
},
|
||||||
rowNum: 1,
|
data() {
|
||||||
colNum: 1,
|
return {
|
||||||
tableData: {}
|
config: config,
|
||||||
};
|
rowNum: 1,
|
||||||
},
|
colNum: 1,
|
||||||
computed: {
|
tableData: {}
|
||||||
btnType() {
|
};
|
||||||
return !this.nightMode ? "success" : "default";
|
},
|
||||||
},
|
computed: {
|
||||||
...mapState({
|
btnType() {
|
||||||
nightMode: state => state.nightMode,
|
return !this.nightMode ? "success" : "default";
|
||||||
editor: state => state.editor
|
},
|
||||||
})
|
...mapState({
|
||||||
},
|
nightMode: state => state.nightMode,
|
||||||
methods: {
|
editor: state => state.editor
|
||||||
// 插入表格
|
})
|
||||||
insertTable() {
|
},
|
||||||
const cursor = this.editor.getCursor();
|
methods: {
|
||||||
const rows = this.rowNum;
|
// 插入表格
|
||||||
const cols = this.colNum;
|
insertTable() {
|
||||||
|
const cursor = this.editor.getCursor();
|
||||||
|
const rows = this.rowNum;
|
||||||
|
const cols = this.colNum;
|
||||||
|
|
||||||
let table = "";
|
let table = "";
|
||||||
let currRow = [];
|
let currRow = [];
|
||||||
for (let i = 0; i < rows + 2; ++i) {
|
for (let i = 0; i < rows + 2; ++i) {
|
||||||
table += "|";
|
table += "|\t";
|
||||||
currRow = [];
|
currRow = [];
|
||||||
for (let j = 0; j < cols; ++j) {
|
for (let j = 0; j < cols; ++j) {
|
||||||
let rowIdx = i;
|
const rowIdx = i > 1 ? i - 1 : i;
|
||||||
if (i > 1) {
|
i === 1 ?
|
||||||
rowIdx = i - 1;
|
currRow.push("---\t") :
|
||||||
}
|
currRow.push(this.tableData[`k_${rowIdx}_${j}`] || "");
|
||||||
|
}
|
||||||
i === 1
|
table += currRow.join("\t|\t");
|
||||||
? currRow.push("---")
|
table += "\t|\n";
|
||||||
: currRow.push(
|
}
|
||||||
this.tableData[`k_${rowIdx}_${j}`]
|
this.tableData = {};
|
||||||
? this.tableData[`k_${rowIdx}_${j}`]
|
this.rowNum = 1;
|
||||||
: ""
|
this.colNum = 1;
|
||||||
);
|
this.editor.replaceSelection(`\n${table}\n`, "end");
|
||||||
|
this.$emit("close");
|
||||||
|
this.editorRefresh();
|
||||||
|
},
|
||||||
|
...mapMutations(["editorRefresh"]),
|
||||||
|
handleChange(val, type) {}
|
||||||
}
|
}
|
||||||
table += currRow.join("|");
|
};
|
||||||
table += "|\n";
|
|
||||||
}
|
|
||||||
this.tableData = {};
|
|
||||||
this.rowNum = 1;
|
|
||||||
this.colNum = 1;
|
|
||||||
this.editor.replaceSelection(`\n${table}\n`, "end");
|
|
||||||
this.$emit("close");
|
|
||||||
this.editorRefresh();
|
|
||||||
},
|
|
||||||
...mapMutations(["editorRefresh"]),
|
|
||||||
handleChange(val, type) {}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="less">
|
<style lang="less">
|
||||||
.tb-options {
|
.tb-options {
|
||||||
margin-bottom: 20px;
|
margin-bottom: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.head-style .el-input__inner {
|
.head-style .el-input__inner {
|
||||||
background-color: #f2f2f2;
|
background-color: #f2f2f2;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
Loading…
Reference in New Issue
Block a user