Style Manager: Custom Composite type : Give sample example for padding type. #5797
Unanswered
mkandanmk7
asked this question in
Q&A
Replies: 1 comment 1 reply
-
It's up to you to manage how to update the style based on your UI, eg. you can pass the style object to |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Could someone give me a comprehensive example of implementing the 'addType' function in a style manager for a custom composite property like Padding, because documentation typically focuses on single properties? Clear documentation for composite types is crucial for effectively understanding and utilizing this feature. Any insights or sample code shared would be greatly appreciated. Thanks!
editor.StyleManager.addType('my-custom-prop', {
// Create UI
create({ props, change }) {
const el = document.createElement('div');
el.innerHTML =
<input type="range" class="my-input" min="${props.min}" max="${props.max}"/>
;const inputEl = el.querySelector('.my-input');
inputEl.addEventListener('change', event => change({ event })); //
change
will trigger the emitinputEl.addEventListener('input', event => change({ event, partial: true }));
return el;
},
// Propagate UI changes up to the targets
emit({ props, updateStyle }, { event, partial }) {
const { value } = event.target;
updateStyle(
${value}px
, { partial });},
// Update UI (eg. when the target is changed)
update({ value, el }) {
el.querySelector('.my-input').value = parseInt(value, 10);
},
// Clean the memory from side effects if necessary (eg. global event listeners, etc.)
destroy() {
},
});
};
this code only in documentation. I expect composite type padding property style.
Beta Was this translation helpful? Give feedback.
All reactions