cm-md-editor 3.0.2 → 3.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/MdEditor.js +5 -0
package/package.json
CHANGED
package/src/MdEditor.js
CHANGED
|
@@ -99,6 +99,10 @@ export class MdEditor {
|
|
|
99
99
|
const button = document.createElement('button')
|
|
100
100
|
button.type = 'button'
|
|
101
101
|
button.title = btn.title
|
|
102
|
+
if (btn.name) {
|
|
103
|
+
button.dataset.name = btn.name
|
|
104
|
+
button.classList.add('mde-btn-' + btn.name)
|
|
105
|
+
}
|
|
102
106
|
button.style.cssText = 'background:none;border:none;border-radius:3px;cursor:pointer;padding:4px 6px;display:flex;align-items:center;justify-content:center;color:inherit;opacity:0.6;transition:opacity 0.15s,background 0.15s;'
|
|
103
107
|
if (btn.icon) {
|
|
104
108
|
button.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 16 16" fill="currentColor">${btn.icon}</svg>`
|
|
@@ -440,6 +444,7 @@ export class MdEditor {
|
|
|
440
444
|
|
|
441
445
|
insertTextAtCursor(text) {
|
|
442
446
|
// execCommand is deprecated, but without alternative to insert text and preserve the correct undo/redo stack
|
|
447
|
+
this.element.focus()
|
|
443
448
|
document.execCommand("insertText", false, text)
|
|
444
449
|
}
|
|
445
450
|
|