Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

![npm bundle size](https://img.shields.io/bundlephobia/min/@mycure/vue-wysiwyg?style=flat-square) ![npm](https://img.shields.io/npm/v/@mycure/vue-wysiwyg?style=flat-square) ![npm](https://img.shields.io/npm/dw/@mycure/vue-wysiwyg?style=flat-square)

A simple wysiwyg editor for Vue.js by [MYCURE Inc.](https://mycure.md)
A simple wysiwyg editor for Vue.js by [VorticeSoft](https://vorticesoft.com) based on works by [MYCURE Inc.](https://mycure.md)

## [GitBook Documentation](https://oss.mycure.md/v/vue-wysiwyg/)

Made with ❤️ by Joff Tiquez
Made with ❤️ by Joff Tiquez and Moisés Márquez
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/mc-wysiwyg.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
"@babel/plugin-proposal-export-default-from": "^7.7.4",
"@babel/plugin-transform-runtime": "^7.7.5",
"@babel/preset-env": "^7.7.5",
"@babel/preset-es2015": "^7.0.0-beta.53",
"@babel/runtime": "^7.7.5",
"@rollup/plugin-node-resolve": "^6.0.0",
"babel-minify": "^0.5.1",
"cross-env": "^6.0.3",
"jest": "^24.9.0",
"rimraf": "^3.0.0",
"rollup": "^1.27.9",
"postcss": "~8.4.28",
"rollup-plugin-babel": "^4.3.3",
"rollup-plugin-commonjs": "^10.1.0",
"rollup-plugin-postcss": "^2.0.3",
Expand All @@ -34,6 +34,6 @@
},
"dependencies": {
"package-lock-only": "0.0.4",
"vue-material-design-icons": "^4.4.0"
"vue-material-design-icons": "^5.2.0"
}
}
47 changes: 28 additions & 19 deletions src/McWysiwyg.vue
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
</div>
</div>
<div id="body" :style="{'height': `${height}px`}">
<div id="editor" contenteditable :style="{'min-height': `${height}px`}"></div>
<div :ref="'editor' + _uid" contenteditable @paste.stop.prevent="onPaste" :style="{'min-height': `${height}px`}"></div>
</div>
</div>
</div>
Expand Down Expand Up @@ -164,7 +164,7 @@ export default {
cols: 0
},
caratSelection: null,
savedPosition: null
savedPosition: null,
};
},
computed: {
Expand All @@ -185,8 +185,8 @@ export default {
handler (val) {
if (val) {
setTimeout(() => {
if (!document.getElementById('editor').innerHTML) {
document.getElementById('editor').innerHTML = val;
if (!this.$refs['editor' + this._uid].innerHTML) {
this.$refs['editor' + this._uid].innerHTML = val;
}
}, 100);
}
Expand Down Expand Up @@ -269,7 +269,7 @@ export default {
this.createTable();
},
createTable () {
document.getElementById('editor').focus();
this.$refs['editor' + this._uid].focus();
this.caratSelection.collapse(this.savedPosition[0], this.savedPosition[1]);
let table = `
<table width="100%" style="border-collapse: collapse; border: 1px solid lightgrey;">
Expand Down Expand Up @@ -303,13 +303,17 @@ export default {
document.execCommand(...args);
},
getValue () {
this.$emit('input', document.getElementById('editor').innerHTML);
}
this.$emit('input', this.$refs['editor' + this._uid].innerHTML);
},
onPaste(event){
const plainText = event.clipboardData.getData('text/plain')
this.exec('insertText', false, plainText)
},
},
mounted () {
let that = this;
this.$nextTick(() => {
document.getElementById('editor').addEventListener('input', function() {
this.$refs['editor' + this._uid].addEventListener('input', function() {
that.getValue();
}, false);
});
Expand Down Expand Up @@ -343,9 +347,12 @@ input:focus {
}

#toolbar {
min-height: 29px;
border-bottom: 1px solid lightgrey;
background-color: rgb(247, 247, 247);
border-bottom: 1px solid lightgrey;
background-color: #ebeef5;
display: flex;
justify-content: start;
padding: 0 0.6rem;
gap: 0.6rem;
}

#toolbar-options {
Expand All @@ -359,20 +366,22 @@ input:focus {
}

.toolbar-section {
float: left;
border-right: 1px solid lightgrey;
}

.wysiwyg-button {
height: 28px;
min-width: 30px;
background-color: transparent;
text-align: center;
padding: 2px;
height: 1.618rem;
width: 1.618rem;
background-color: transparent;
text-align: center;
padding: 2px;
border: 0;
cursor: pointer;
transition: .5s;
}

.wysiwyg-button:hover {
background-color: lightblue;
border-radius: 3px;
box-shadow: inset 0 0 0 .82rem #dcdfe6;
}

/* .wysiwyg-button-active {
Expand Down
Loading