markupeditor 0.9.15 → 0.9.16

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.
@@ -25206,8 +25206,6 @@ class MarkupEditorElement extends HTMLElement {
25206
25206
  // Apply toolbar appearance CSS custom properties if an appearance section is present
25207
25207
  const appearance = this.editor.config?.toolbar?.appearance;
25208
25208
  if (appearance) {
25209
- const canMatchMedia = typeof window.matchMedia === 'function';
25210
- const isDark = canMatchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
25211
25209
  const colorPairs = {
25212
25210
  accentColor: '--Markup-accent-color',
25213
25211
  toolbarBg: '--Markup-toolbar-bg',
@@ -25219,16 +25217,25 @@ class MarkupEditorElement extends HTMLElement {
25219
25217
  buttonSize: '--Markup-button-size',
25220
25218
  buttonFontSize: '--Markup-button-font-size',
25221
25219
  };
25222
- for (const [field, varName] of Object.entries(colorPairs)) {
25223
- if (appearance[field] != null) {
25224
- this.style.setProperty(varName, isDark ? appearance[field].dark : appearance[field].light);
25220
+ const applyColors = (isDark) => {
25221
+ for (const [field, varName] of Object.entries(colorPairs)) {
25222
+ if (appearance[field] != null) {
25223
+ this.style.setProperty(varName, isDark ? appearance[field].dark : appearance[field].light);
25224
+ }
25225
25225
  }
25226
- }
25226
+ };
25227
25227
  for (const [field, varName] of Object.entries(singleValues)) {
25228
25228
  if (appearance[field] != null) {
25229
25229
  this.style.setProperty(varName, appearance[field]);
25230
25230
  }
25231
25231
  }
25232
+ if (typeof window.matchMedia === 'function') {
25233
+ const mq = window.matchMedia('(prefers-color-scheme: dark)');
25234
+ applyColors(mq.matches);
25235
+ mq.addEventListener('change', (e) => applyColors(e.matches));
25236
+ } else {
25237
+ applyColors(false);
25238
+ }
25232
25239
  }
25233
25240
 
25234
25241
  // Prepend and/or append any augmentations
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "markupeditor",
3
- "version": "0.9.15",
3
+ "version": "0.9.16",
4
4
  "description": "A web component and API for WYSIWYG HTML editing.",
5
5
  "keywords": [
6
6
  "wysiwyg",