BUG: v0.16.27 - Style/ID disappear when nested span
Question
Version: 0.16.27
Are you able to reproduce the bug from the demo?
[ ] Yes [ ] No [X] Video but no demo
What is the expected behavior?
Add as many nested span elements as necessary and preserve their style/ID.
What is the current behavior?
From two nested span elements, style/ID of parent span elements disappear.
Are you able to attach screenshots, screencasts or a live demo?
[X] Yes (attach) [ ] No
TextEditor.vue
// ...
methods: {
onButtonClick (action, value = '') {
try {
const selected = this.editor.getSelected()
const rte = selected.view.activeRte
let style = `${action}:${value};`
switch (action) {
case 'showCustomizationPanel':
this.customizationPanel = value
break
case 'text-align':
this.mergeComponentStyle(selected, {
[action]: value
})
break
case 'font-size':
case 'line-height':
style += (action === 'font-size') ? 'line-height:100%;' : ''
rte.insertHTML(
`<span style="${style}">${rte.selection()}</span>`
)
break
default:
rte.exec(action, value)
}
} catch (error) {
this.showError(error, 'onButtonClick()')
}
},
/**
* Defines default style on the added component
* @see {@link https://grapesjs.com/docs/api/component.html#getstyle|Get style}
* @param {object} component
* @returns {void}
*/
setDefaultStyle (component) {
const {
'font-family': fontFamily = '',
'font-size': fontSize = ''
} = component.getStyle()
if (!fontFamily) {
this.mergeComponentStyle(component, {
'font-family': this.font.familyPartner[this.partnerId] || this.font.familyDefault
})
}
if (!fontSize) {
this.mergeComponentStyle(component, {
'font-size': this.font.sizePartner[this.partnerId] || this.font.sizeDefault,
'line-height': '100%'
})
}
},
/**
* Merges GrapesJS component style
* @see {@link https://grapesjs.com/docs/api/component.html#getstyle|Get style}
* @see {@link https://grapesjs.com/docs/api/component.html#setstyle|Set style}
* @param {object} component
* @param {object} style
* @returns {void}
*/
mergeComponentStyle (component, style) {
component.setStyle({
...component.getStyle(),
...style
})
}
}
// ...
Answers (1)
Hi Benjamin, the bug was already fixed (when you report a bug, ensure to have the latest version)
Related Questions and Answers
Continue research with similar issue discussions.
Issue #3443
BUG: backbone-undo/underscore security advisory
Version: v0.17.3 Are you able to reproduce the bug from the demo?[x] Yes[ ] No What is the expected behavior? See below What is the current...
Issue #3272
BUG: id are added to <img/> on double click on it
Version: 0.16.37 Are you able to reproduce the bug from the demo? [X] Yes [ ] No What is the expected behavior? It's about the GrapesJS-mjm...
Issue #2921
BUG: Autosave not working on style manager when classes are disabled
Version: 0.16.18 Are you able to reproduce the bug from the demo? [x ] Yes: https://jsfiddle.net/ju1a0onx/ What is the expected behavior? A...
Issue #3125
BUG: linear-gradient CSS does weird things to background-image
Version: 0.16.27 Are you able to reproduce the bug from the demo? [x] Yes [ ] No What is the expected behavior? When adding background-imag...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.