@lukso/web-components 1.160.4 → 1.161.2

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.
Files changed (121) hide show
  1. package/dist/components/index.cjs +7 -5
  2. package/dist/components/index.js +5 -5
  3. package/dist/components/lukso-button/index.cjs +3 -3
  4. package/dist/components/lukso-button/index.js +3 -3
  5. package/dist/components/lukso-card/index.cjs +6 -6
  6. package/dist/components/lukso-card/index.js +6 -6
  7. package/dist/components/lukso-checkbox/index.cjs +3 -3
  8. package/dist/components/lukso-checkbox/index.js +3 -3
  9. package/dist/components/lukso-collapse/index.cjs +3 -3
  10. package/dist/components/lukso-collapse/index.js +3 -3
  11. package/dist/components/lukso-color-picker/index.cjs +5 -5
  12. package/dist/components/lukso-color-picker/index.js +5 -5
  13. package/dist/components/lukso-dropdown/index.cjs +4 -4
  14. package/dist/components/lukso-dropdown/index.js +4 -4
  15. package/dist/components/lukso-dropdown-option/index.cjs +2 -2
  16. package/dist/components/lukso-dropdown-option/index.js +2 -2
  17. package/dist/components/lukso-footer/index.cjs +3 -2
  18. package/dist/components/lukso-footer/index.d.ts.map +1 -1
  19. package/dist/components/lukso-footer/index.js +3 -2
  20. package/dist/components/lukso-icon/index.cjs +4 -4
  21. package/dist/components/lukso-icon/index.js +4 -4
  22. package/dist/components/lukso-image/index.cjs +4 -4
  23. package/dist/components/lukso-image/index.js +4 -4
  24. package/dist/components/lukso-input/index.cjs +4 -4
  25. package/dist/components/lukso-input/index.js +4 -4
  26. package/dist/components/lukso-markdown/index.cjs +13 -5
  27. package/dist/components/lukso-markdown/index.d.ts +1 -0
  28. package/dist/components/lukso-markdown/index.d.ts.map +1 -1
  29. package/dist/components/lukso-markdown/index.js +13 -5
  30. package/dist/components/lukso-markdown/lukso-markdown.stories.d.ts +2 -0
  31. package/dist/components/lukso-markdown/lukso-markdown.stories.d.ts.map +1 -1
  32. package/dist/components/lukso-markdown-editor/index.cjs +334 -255
  33. package/dist/components/lukso-markdown-editor/index.d.ts +9 -1
  34. package/dist/components/lukso-markdown-editor/index.d.ts.map +1 -1
  35. package/dist/components/lukso-markdown-editor/index.js +334 -255
  36. package/dist/components/lukso-markdown-editor/lukso-markdown-editor.stories.d.ts +6 -0
  37. package/dist/components/lukso-markdown-editor/lukso-markdown-editor.stories.d.ts.map +1 -1
  38. package/dist/components/lukso-modal/index.cjs +2 -2
  39. package/dist/components/lukso-modal/index.js +2 -2
  40. package/dist/components/lukso-navbar/index.cjs +3 -3
  41. package/dist/components/lukso-navbar/index.js +3 -3
  42. package/dist/components/lukso-pagination/index.cjs +3 -3
  43. package/dist/components/lukso-pagination/index.js +3 -3
  44. package/dist/components/lukso-profile/index.cjs +3 -3
  45. package/dist/components/lukso-profile/index.js +3 -3
  46. package/dist/components/lukso-progress/index.cjs +3 -3
  47. package/dist/components/lukso-progress/index.js +3 -3
  48. package/dist/components/lukso-radio/index.cjs +3 -3
  49. package/dist/components/lukso-radio/index.js +3 -3
  50. package/dist/components/lukso-radio-group/index.cjs +3 -3
  51. package/dist/components/lukso-radio-group/index.js +3 -3
  52. package/dist/components/lukso-sanitize/index.cjs +9 -1390
  53. package/dist/components/lukso-sanitize/index.d.ts +17 -1
  54. package/dist/components/lukso-sanitize/index.d.ts.map +1 -1
  55. package/dist/components/lukso-sanitize/index.js +4 -1396
  56. package/dist/components/lukso-sanitize/lukso-sanitize.stories.d.ts +17 -1
  57. package/dist/components/lukso-sanitize/lukso-sanitize.stories.d.ts.map +1 -1
  58. package/dist/components/lukso-search/index.cjs +6 -6
  59. package/dist/components/lukso-search/index.js +6 -6
  60. package/dist/components/lukso-select/index.cjs +6 -6
  61. package/dist/components/lukso-select/index.js +6 -6
  62. package/dist/components/lukso-share/index.cjs +2 -2
  63. package/dist/components/lukso-share/index.js +2 -2
  64. package/dist/components/lukso-switch/index.cjs +4 -4
  65. package/dist/components/lukso-switch/index.js +4 -4
  66. package/dist/components/lukso-tag/index.cjs +3 -3
  67. package/dist/components/lukso-tag/index.js +3 -3
  68. package/dist/components/lukso-terms/index.cjs +4 -4
  69. package/dist/components/lukso-terms/index.js +4 -4
  70. package/dist/components/lukso-textarea/index.cjs +4 -4
  71. package/dist/components/lukso-textarea/index.js +4 -4
  72. package/dist/components/lukso-tooltip/index.cjs +4 -4
  73. package/dist/components/lukso-tooltip/index.js +4 -4
  74. package/dist/components/lukso-username/index.cjs +4 -4
  75. package/dist/components/lukso-username/index.js +4 -4
  76. package/dist/components/lukso-wizard/index.cjs +2 -2
  77. package/dist/components/lukso-wizard/index.js +2 -2
  78. package/dist/{index-DNhzT2hA.cjs → index-BDC9pVk6.cjs} +2 -2
  79. package/dist/index-BFqOU6o6.cjs +50 -0
  80. package/dist/{index-NKnet_Ow.js → index-BJwLob67.js} +2 -2
  81. package/dist/{index-CKlH1beR.js → index-BOWftFAY.js} +1 -1
  82. package/dist/{index-CKjNXRek.cjs → index-C2uvRzO4.cjs} +3 -3
  83. package/dist/{index-C1JF-hTl.cjs → index-CEnG_x_7.cjs} +5 -5
  84. package/dist/index-CQq_Eyeu.js +41 -0
  85. package/dist/index-Chl2HHJ6.cjs +1408 -0
  86. package/dist/index-JvkSiEeQ.js +1404 -0
  87. package/dist/{index-C9Ins46B.cjs → index-Zriuvita.cjs} +1 -1
  88. package/dist/{index-BSwFyDEC.js → index-f-xajtU2.js} +3 -3
  89. package/dist/{index-CDUQ0-Uh.js → index-oQecUOlb.js} +5 -5
  90. package/dist/index.cjs +7 -5
  91. package/dist/index.js +5 -5
  92. package/dist/{property-Da9lvmME.js → property-CPkYmAYi.js} +1 -1
  93. package/dist/{property-dUn0JQiG.cjs → property-Cs8qVdri.cjs} +1 -1
  94. package/dist/shared/tailwind-element/index.cjs +1 -1
  95. package/dist/shared/tailwind-element/index.js +1 -1
  96. package/dist/{state-CD8hXUlY.cjs → state-Bh6EXopE.cjs} +1 -1
  97. package/dist/{state-CtpsBPdH.js → state-CtrTo6cC.js} +1 -1
  98. package/dist/{style-map-CDCcO0mt.js → style-map-BBz25umN.js} +1 -1
  99. package/dist/{style-map-nBexjTCa.cjs → style-map-DhbNG03r.cjs} +1 -1
  100. package/dist/tailwind-config.cjs +65 -0
  101. package/dist/tailwind-config.d.ts +85 -0
  102. package/dist/tailwind-config.d.ts.map +1 -1
  103. package/dist/tailwind-config.js +64 -1
  104. package/dist/{unsafe-html-DHNeIs-4.cjs → unsafe-html-Cb1yjpJn.cjs} +1 -1
  105. package/dist/{unsafe-html-Ci4jmi7b.js → unsafe-html-DTE5r2A7.js} +1 -1
  106. package/package.json +1 -1
  107. package/tailwind.config.cjs +208 -178
  108. package/tools/cn.cjs +1 -1
  109. package/tools/cn.js +1 -1
  110. package/tools/copy-assets.cjs +16 -16
  111. package/tools/copy-assets.js +2 -2
  112. package/tools/index.cjs +1 -1
  113. package/tools/index.js +1 -1
  114. package/tools/{tailwind-config-Ch2-b3Be.js → tailwind-config-DVTyRd7x.js} +64 -1
  115. package/tools/{tailwind-config-BIErjaAT.cjs → tailwind-config-DoMZEvsr.cjs} +65 -0
  116. package/tools/tailwind-config.cjs +3 -1
  117. package/tools/tailwind-config.d.ts +85 -0
  118. package/tools/tailwind-config.d.ts.map +1 -1
  119. package/tools/tailwind-config.js +1 -1
  120. package/dist/index-B5CXCi6j.js +0 -41
  121. package/dist/index-D4DEFira.cjs +0 -50
@@ -1,6 +1,6 @@
1
- import { T as TailwindStyledElement, E, x } from '../../index-B5CXCi6j.js';
2
- import { n, t } from '../../property-Da9lvmME.js';
3
- import { r } from '../../state-CtpsBPdH.js';
1
+ import { T as TailwindStyledElement, E, x } from '../../index-CQq_Eyeu.js';
2
+ import { n, t } from '../../property-CPkYmAYi.js';
3
+ import { r } from '../../state-CtrTo6cC.js';
4
4
  import { e } from '../../query-CHb9Ft_d.js';
5
5
  import { c as ce } from '../../index-B9iart53.js';
6
6
  import '../../tailwind-config.js';
@@ -10,7 +10,7 @@ import '../lukso-markdown/index.js';
10
10
  import '../lukso-switch/index.js';
11
11
  import '../lukso-button/index.js';
12
12
  import '../lukso-icon/index.js';
13
- import '../lukso-sanitize/index.js';
13
+ import '../../index-JvkSiEeQ.js';
14
14
  import '../lukso-dropdown/index.js';
15
15
  import '../lukso-dropdown-option/index.js';
16
16
  import '../lukso-tooltip/index.js';
@@ -201,6 +201,7 @@ var __decorateClass = (decorators, target, key, kind) => {
201
201
  };
202
202
  const DEFAULT_PREVIEW_BACKGROUND_COLOR = "#f9f9f9";
203
203
  const DEFAULT_PREVIEW_TEXT_COLOR = "#374151";
204
+ const ACCESSIBILITY_CHECK_DELAY = 1e3;
204
205
  let LuksoMarkdownEditor = class extends TailwindStyledElement(style) {
205
206
  constructor() {
206
207
  super(...arguments);
@@ -220,6 +221,18 @@ let LuksoMarkdownEditor = class extends TailwindStyledElement(style) {
220
221
  this.placeholder = "";
221
222
  this.previewBackgroundColor = DEFAULT_PREVIEW_BACKGROUND_COLOR;
222
223
  this.previewTextColor = DEFAULT_PREVIEW_TEXT_COLOR;
224
+ this.stripHtmlTags = false;
225
+ this.tools = void 0;
226
+ this.toolsState = [];
227
+ this.defaultTools = [
228
+ "heading",
229
+ "bold",
230
+ "italic",
231
+ "list",
232
+ "link",
233
+ "alignment",
234
+ "color"
235
+ ];
223
236
  this.savedSelectionForPreview = null;
224
237
  this.isHeadingDropdownOpen = false;
225
238
  this.isColorDropdownOpen = false;
@@ -256,7 +269,6 @@ let LuksoMarkdownEditor = class extends TailwindStyledElement(style) {
256
269
  this.accessibilityViolations = [];
257
270
  this.hasAccessibilityViolations = false;
258
271
  this.accessibilityCheckTimeout = null;
259
- this.ACCESSIBILITY_CHECK_DELAY = 1e3;
260
272
  this.handleOutsideClick = (event) => {
261
273
  const target = event.target;
262
274
  const isInsideThisComponent = this.contains(target) || this.shadowRoot?.contains(target);
@@ -528,7 +540,25 @@ let LuksoMarkdownEditor = class extends TailwindStyledElement(style) {
528
540
  this.accessibilityCheckTimeout = window.setTimeout(() => {
529
541
  this.performAccessibilityCheck();
530
542
  this.accessibilityCheckTimeout = null;
531
- }, this.ACCESSIBILITY_CHECK_DELAY);
543
+ }, ACCESSIBILITY_CHECK_DELAY);
544
+ }
545
+ /**
546
+ * Clean up empty color spans from the value.
547
+ * This removes spans like <span style="color: #xxx"></span> with no content.
548
+ */
549
+ cleanupEmptyColorSpans() {
550
+ const emptyColorSpanRegex = /<span style="color: [^"]+"><\/span>/g;
551
+ const cleanedValue = this.value.replace(emptyColorSpanRegex, "");
552
+ if (cleanedValue !== this.value) {
553
+ this.value = cleanedValue;
554
+ const textarea = this.textareaEl?.shadowRoot?.querySelector("textarea");
555
+ if (textarea) {
556
+ const currentPos = textarea.selectionStart ?? 0;
557
+ textarea.value = cleanedValue;
558
+ const newPos = Math.min(currentPos, cleanedValue.length);
559
+ textarea.setSelectionRange(newPos, newPos);
560
+ }
561
+ }
532
562
  }
533
563
  /**
534
564
  * Unified helper that ensures both active format state and change events are properly
@@ -538,6 +568,7 @@ let LuksoMarkdownEditor = class extends TailwindStyledElement(style) {
538
568
  * @param event - Optional event that triggered the change
539
569
  */
540
570
  emitChangeAndRefresh(event) {
571
+ this.cleanupEmptyColorSpans();
541
572
  this.updateActiveFormats();
542
573
  this.dispatchChange(event);
543
574
  this.scheduleAccessibilityCheck();
@@ -827,9 +858,27 @@ let LuksoMarkdownEditor = class extends TailwindStyledElement(style) {
827
858
  }
828
859
  this.value = before + transformed + after;
829
860
  textarea.value = before + transformed + after;
830
- const cursorPosition = before.length + transformed.length;
861
+ let selStart;
862
+ let selEnd;
863
+ if (alignment === "left" || existingMatch && existingMatch[1] === alignment || this.getNestedAlignment(selected) === alignment) {
864
+ selStart = before.length;
865
+ selEnd = before.length + transformed.length;
866
+ } else {
867
+ const openTagMatch = transformed.match(
868
+ /<div style="text-align: (center|right);">([^<]*)<\/div>/
869
+ );
870
+ if (openTagMatch) {
871
+ const innerContent = openTagMatch[2];
872
+ const tagStart = transformed.indexOf(">") + 1;
873
+ selStart = before.length + tagStart;
874
+ selEnd = selStart + innerContent.length;
875
+ } else {
876
+ selStart = before.length;
877
+ selEnd = before.length + transformed.length;
878
+ }
879
+ }
831
880
  requestAnimationFrame(() => {
832
- textarea.setSelectionRange(cursorPosition, cursorPosition);
881
+ textarea.setSelectionRange(selStart, selEnd);
833
882
  this.emitChangeAndRefresh();
834
883
  });
835
884
  });
@@ -1327,7 +1376,7 @@ let LuksoMarkdownEditor = class extends TailwindStyledElement(style) {
1327
1376
  this.value = before + wrapped + after;
1328
1377
  textarea.value = before + wrapped + after;
1329
1378
  const selStart = before.length + newColorTagOpen.length;
1330
- const selEnd = selStart + (selected ? selected.length : 4);
1379
+ const selEnd = selStart + (selected ? selected.length : 0);
1331
1380
  requestAnimationFrame(() => {
1332
1381
  textarea.setSelectionRange(selStart, selEnd);
1333
1382
  this.emitChangeAndRefresh();
@@ -2132,126 +2181,127 @@ ${indent}${nextNumber}. `;
2132
2181
  toolbarTemplate() {
2133
2182
  return x`
2134
2183
  <div class="flex items-center gap-1">
2135
- <div class=${cn(this.styles().headingMenu())}>
2136
- <!-- Heading -->
2137
- <lukso-tooltip text="Heading options" placement="top">
2138
- <lukso-button
2139
- id=${this.headingTriggerId}
2140
- @click=${(e) => {
2184
+ <!-- Heading -->
2185
+ ${this.toolsState.includes("heading") ? x`<div class=${cn(this.styles().headingMenu())}>
2186
+ <lukso-tooltip text="Heading options" placement="top">
2187
+ <lukso-button
2188
+ id=${this.headingTriggerId}
2189
+ @click=${(e) => {
2141
2190
  e.stopPropagation();
2142
2191
  this.isColorDropdownOpen = false;
2143
2192
  this.isListDropdownOpen = false;
2144
2193
  this.isAlignmentDropdownOpen = false;
2145
2194
  this.isHeadingDropdownOpen = !this.isHeadingDropdownOpen;
2146
2195
  }}
2147
- aria-expanded=${this.isHeadingDropdownOpen ? "true" : "false"}
2148
- aria-label="Heading options"
2149
- variant="secondary"
2150
- size="small"
2151
- custom-class=${this.toolbarButton({
2196
+ aria-expanded=${this.isHeadingDropdownOpen ? "true" : "false"}
2197
+ aria-label="Heading options"
2198
+ variant="secondary"
2199
+ size="small"
2200
+ custom-class=${this.toolbarButton({
2152
2201
  active: this.getActiveHeadingLevel() > 0
2153
2202
  })}
2154
- is-icon
2155
- >
2156
- <lukso-icon
2157
- name="smallcaps"
2158
- size="small"
2159
- pack="vuesax"
2160
- variant="linear"
2161
- ></lukso-icon>
2162
- </lukso-button>
2163
- </lukso-tooltip>
2164
- <lukso-dropdown
2165
- id="headingDropdown"
2166
- trigger-id=""
2167
- size="medium"
2168
- ?is-open=${this.isHeadingDropdownOpen}
2169
- >
2170
- <lukso-dropdown-option
2171
- ?is-selected=${this.getActiveHeadingLevel() === 0}
2172
- @click=${(e) => {
2203
+ is-icon
2204
+ >
2205
+ <lukso-icon
2206
+ name="smallcaps"
2207
+ size="small"
2208
+ pack="vuesax"
2209
+ variant="linear"
2210
+ ></lukso-icon>
2211
+ </lukso-button>
2212
+ </lukso-tooltip>
2213
+ <lukso-dropdown
2214
+ id="headingDropdown"
2215
+ trigger-id=""
2216
+ size="medium"
2217
+ ?is-open=${this.isHeadingDropdownOpen}
2218
+ >
2219
+ <lukso-dropdown-option
2220
+ ?is-selected=${this.getActiveHeadingLevel() === 0}
2221
+ @click=${(e) => {
2173
2222
  e.stopPropagation();
2174
2223
  this.restoreFocusAndSelection();
2175
2224
  this.applyHeading(0);
2176
2225
  this.isHeadingDropdownOpen = false;
2177
2226
  }}
2178
- size="medium"
2179
- >
2180
- Normal text
2181
- </lukso-dropdown-option>
2182
- <lukso-dropdown-option
2183
- ?is-selected=${this.getActiveHeadingLevel() === 1}
2184
- @click=${(e) => {
2227
+ size="medium"
2228
+ >
2229
+ Normal text
2230
+ </lukso-dropdown-option>
2231
+ <lukso-dropdown-option
2232
+ ?is-selected=${this.getActiveHeadingLevel() === 1}
2233
+ @click=${(e) => {
2185
2234
  e.stopPropagation();
2186
2235
  this.restoreFocusAndSelection();
2187
2236
  this.applyHeading(1);
2188
2237
  this.isHeadingDropdownOpen = false;
2189
2238
  }}
2190
- size="medium"
2191
- >
2192
- Heading 1
2193
- </lukso-dropdown-option>
2194
- <lukso-dropdown-option
2195
- ?is-selected=${this.getActiveHeadingLevel() === 2}
2196
- @click=${(e) => {
2239
+ size="medium"
2240
+ >
2241
+ Heading 1
2242
+ </lukso-dropdown-option>
2243
+ <lukso-dropdown-option
2244
+ ?is-selected=${this.getActiveHeadingLevel() === 2}
2245
+ @click=${(e) => {
2197
2246
  e.stopPropagation();
2198
2247
  this.restoreFocusAndSelection();
2199
2248
  this.applyHeading(2);
2200
2249
  this.isHeadingDropdownOpen = false;
2201
2250
  }}
2202
- size="medium"
2203
- >
2204
- Heading 2
2205
- </lukso-dropdown-option>
2206
- <lukso-dropdown-option
2207
- ?is-selected=${this.getActiveHeadingLevel() === 3}
2208
- @click=${(e) => {
2251
+ size="medium"
2252
+ >
2253
+ Heading 2
2254
+ </lukso-dropdown-option>
2255
+ <lukso-dropdown-option
2256
+ ?is-selected=${this.getActiveHeadingLevel() === 3}
2257
+ @click=${(e) => {
2209
2258
  e.stopPropagation();
2210
2259
  this.restoreFocusAndSelection();
2211
2260
  this.applyHeading(3);
2212
2261
  this.isHeadingDropdownOpen = false;
2213
2262
  }}
2214
- size="medium"
2215
- >
2216
- Heading 3
2217
- </lukso-dropdown-option>
2218
- <lukso-dropdown-option
2219
- ?is-selected=${this.getActiveHeadingLevel() === 4}
2220
- @click=${(e) => {
2263
+ size="medium"
2264
+ >
2265
+ Heading 3
2266
+ </lukso-dropdown-option>
2267
+ <lukso-dropdown-option
2268
+ ?is-selected=${this.getActiveHeadingLevel() === 4}
2269
+ @click=${(e) => {
2221
2270
  e.stopPropagation();
2222
2271
  this.restoreFocusAndSelection();
2223
2272
  this.applyHeading(4);
2224
2273
  this.isHeadingDropdownOpen = false;
2225
2274
  }}
2226
- size="medium"
2227
- >
2228
- Heading 4
2229
- </lukso-dropdown-option>
2230
- </lukso-dropdown>
2231
- </div>
2275
+ size="medium"
2276
+ >
2277
+ Heading 4
2278
+ </lukso-dropdown-option>
2279
+ </lukso-dropdown>
2280
+ </div>` : E}
2232
2281
 
2233
2282
  <!-- Bold -->
2234
- ${this.buttonTemplate(
2283
+ ${this.toolsState.includes("bold") ? this.buttonTemplate(
2235
2284
  "text-bold",
2236
2285
  () => this.toggleWrap("**"),
2237
2286
  "Bold",
2238
2287
  this.activeFormats.bold
2239
- )}
2288
+ ) : E}
2240
2289
 
2241
2290
  <!-- Italic -->
2242
- ${this.buttonTemplate(
2291
+ ${this.toolsState.includes("italic") ? this.buttonTemplate(
2243
2292
  "text-italic",
2244
2293
  () => this.toggleWrap("*"),
2245
2294
  "Italic",
2246
2295
  this.activeFormats.italic
2247
- )}
2296
+ ) : E}
2248
2297
 
2249
2298
  <!-- List -->
2250
- <div class=${this.styles().listMenu()}>
2251
- <lukso-tooltip text="List options" placement="top">
2252
- <lukso-button
2253
- id=${this.listTriggerId}
2254
- @click=${(e) => {
2299
+ ${this.toolsState.includes("list") ? x`
2300
+ <div class=${this.styles().listMenu()}>
2301
+ <lukso-tooltip text="List options" placement="top">
2302
+ <lukso-button
2303
+ id=${this.listTriggerId}
2304
+ @click=${(e) => {
2255
2305
  e.stopPropagation();
2256
2306
  this.restoreFocusAndSelection();
2257
2307
  this.isHeadingDropdownOpen = false;
@@ -2259,82 +2309,84 @@ ${indent}${nextNumber}. `;
2259
2309
  this.isAlignmentDropdownOpen = false;
2260
2310
  this.isListDropdownOpen = !this.isListDropdownOpen;
2261
2311
  }}
2262
- aria-expanded=${this.isListDropdownOpen ? "true" : "false"}
2263
- aria-label="List options"
2264
- variant="secondary"
2265
- size="small"
2266
- custom-class=${this.toolbarButton({
2312
+ aria-expanded=${this.isListDropdownOpen ? "true" : "false"}
2313
+ aria-label="List options"
2314
+ variant="secondary"
2315
+ size="small"
2316
+ custom-class=${this.toolbarButton({
2267
2317
  active: this.activeFormats.unorderedList || this.activeFormats.orderedList
2268
2318
  })}
2269
- is-icon
2270
- >
2271
- <lukso-icon
2272
- name="task"
2273
- size="small"
2274
- pack="vuesax"
2275
- variant="linear"
2276
- ></lukso-icon>
2277
- </lukso-button>
2278
- </lukso-tooltip>
2279
- <lukso-dropdown
2280
- id="listDropdown"
2281
- trigger-id=""
2282
- size="medium"
2283
- ?is-open=${this.isListDropdownOpen}
2284
- >
2285
- <lukso-dropdown-option
2286
- ?is-selected=${this.getActiveListType() === "none"}
2287
- @click=${(e) => {
2319
+ is-icon
2320
+ >
2321
+ <lukso-icon
2322
+ name="task"
2323
+ size="small"
2324
+ pack="vuesax"
2325
+ variant="linear"
2326
+ ></lukso-icon>
2327
+ </lukso-button>
2328
+ </lukso-tooltip>
2329
+ <lukso-dropdown
2330
+ id="listDropdown"
2331
+ trigger-id=""
2332
+ size="medium"
2333
+ ?is-open=${this.isListDropdownOpen}
2334
+ >
2335
+ <lukso-dropdown-option
2336
+ ?is-selected=${this.getActiveListType() === "none"}
2337
+ @click=${(e) => {
2288
2338
  e.stopPropagation();
2289
2339
  this.restoreFocusAndSelection();
2290
2340
  this.applyList("none");
2291
2341
  this.isListDropdownOpen = false;
2292
2342
  }}
2293
- size="medium"
2294
- >
2295
- No list
2296
- </lukso-dropdown-option>
2297
- <lukso-dropdown-option
2298
- ?is-selected=${this.getActiveListType() === "unordered"}
2299
- @click=${(e) => {
2343
+ size="medium"
2344
+ >
2345
+ No list
2346
+ </lukso-dropdown-option>
2347
+ <lukso-dropdown-option
2348
+ ?is-selected=${this.getActiveListType() === "unordered"}
2349
+ @click=${(e) => {
2300
2350
  e.stopPropagation();
2301
2351
  this.restoreFocusAndSelection();
2302
2352
  this.applyList("unordered");
2303
2353
  this.isListDropdownOpen = false;
2304
2354
  }}
2305
- size="medium"
2306
- >
2307
- Unordered
2308
- </lukso-dropdown-option>
2309
- <lukso-dropdown-option
2310
- ?is-selected=${this.getActiveListType() === "ordered"}
2311
- @click=${(e) => {
2355
+ size="medium"
2356
+ >
2357
+ Unordered
2358
+ </lukso-dropdown-option>
2359
+ <lukso-dropdown-option
2360
+ ?is-selected=${this.getActiveListType() === "ordered"}
2361
+ @click=${(e) => {
2312
2362
  e.stopPropagation();
2313
2363
  this.restoreFocusAndSelection();
2314
2364
  this.applyList("ordered");
2315
2365
  this.isListDropdownOpen = false;
2316
2366
  }}
2317
- size="medium"
2318
- >
2319
- Ordered
2320
- </lukso-dropdown-option>
2321
- </lukso-dropdown>
2322
- </div>
2367
+ size="medium"
2368
+ >
2369
+ Ordered
2370
+ </lukso-dropdown-option>
2371
+ </lukso-dropdown>
2372
+ </div>
2373
+ ` : E}
2323
2374
 
2324
2375
  <!-- Link -->
2325
- ${this.buttonTemplate(
2376
+ ${this.toolsState.includes("link") ? this.buttonTemplate(
2326
2377
  "link",
2327
2378
  () => this.insertLink(),
2328
2379
  "Link",
2329
2380
  this.activeFormats.link
2330
- )}
2381
+ ) : E}
2331
2382
 
2332
2383
  <!-- Text Alignment -->
2333
- <div class=${this.styles().alignmentMenu()}>
2334
- <lukso-tooltip text="Text alignment" placement="top">
2335
- <lukso-button
2336
- id=${this.alignmentTriggerId}
2337
- @click=${(e) => {
2384
+ ${this.toolsState.includes("alignment") ? x`
2385
+ <div class=${this.styles().alignmentMenu()}>
2386
+ <lukso-tooltip text="Text alignment" placement="top">
2387
+ <lukso-button
2388
+ id=${this.alignmentTriggerId}
2389
+ @click=${(e) => {
2338
2390
  e.stopPropagation();
2339
2391
  this.restoreFocusAndSelection();
2340
2392
  this.isHeadingDropdownOpen = false;
@@ -2342,101 +2394,103 @@ ${indent}${nextNumber}. `;
2342
2394
  this.isListDropdownOpen = false;
2343
2395
  this.isAlignmentDropdownOpen = !this.isAlignmentDropdownOpen;
2344
2396
  }}
2345
- aria-expanded=${this.isAlignmentDropdownOpen ? "true" : "false"}
2346
- aria-label="Text alignment"
2347
- variant="secondary"
2348
- size="small"
2349
- custom-class=${this.toolbarButton({
2397
+ aria-expanded=${this.isAlignmentDropdownOpen ? "true" : "false"}
2398
+ aria-label="Text alignment"
2399
+ variant="secondary"
2400
+ size="small"
2401
+ custom-class=${this.toolbarButton({
2350
2402
  active: this.activeFormats.alignment !== "left"
2351
2403
  })}
2352
- is-icon
2353
- >
2354
- <lukso-icon
2355
- name=${this.getAlignmentIcon()}
2356
- size="small"
2357
- pack="vuesax"
2358
- variant="linear"
2359
- ></lukso-icon>
2360
- </lukso-button>
2361
- </lukso-tooltip>
2362
- <lukso-dropdown
2363
- id="alignmentDropdown"
2364
- trigger-id=""
2365
- size="medium"
2366
- ?is-open=${this.isAlignmentDropdownOpen}
2367
- >
2368
- <lukso-dropdown-option
2369
- ?is-selected=${this.activeFormats.alignment === "left"}
2370
- @click=${(e) => {
2404
+ is-icon
2405
+ >
2406
+ <lukso-icon
2407
+ name=${this.getAlignmentIcon()}
2408
+ size="small"
2409
+ pack="vuesax"
2410
+ variant="linear"
2411
+ ></lukso-icon>
2412
+ </lukso-button>
2413
+ </lukso-tooltip>
2414
+ <lukso-dropdown
2415
+ id="alignmentDropdown"
2416
+ trigger-id=""
2417
+ size="medium"
2418
+ ?is-open=${this.isAlignmentDropdownOpen}
2419
+ >
2420
+ <lukso-dropdown-option
2421
+ ?is-selected=${this.activeFormats.alignment === "left"}
2422
+ @click=${(e) => {
2371
2423
  e.stopPropagation();
2372
2424
  this.restoreFocusAndSelection();
2373
2425
  this.applyAlignment("left");
2374
2426
  this.isAlignmentDropdownOpen = false;
2375
2427
  }}
2376
- size="medium"
2377
- aria-label="Align left"
2378
- >
2379
- <div style="display: flex; align-items: center; gap: 8px;">
2380
- <lukso-icon
2381
- name="textalign-left"
2382
- size="small"
2383
- pack="vuesax"
2384
- variant="linear"
2385
- ></lukso-icon>
2386
- Left
2387
- </div>
2388
- </lukso-dropdown-option>
2389
- <lukso-dropdown-option
2390
- ?is-selected=${this.activeFormats.alignment === "center"}
2391
- @click=${(e) => {
2428
+ size="medium"
2429
+ aria-label="Align left"
2430
+ >
2431
+ <div style="display: flex; align-items: center; gap: 8px;">
2432
+ <lukso-icon
2433
+ name="textalign-left"
2434
+ size="small"
2435
+ pack="vuesax"
2436
+ variant="linear"
2437
+ ></lukso-icon>
2438
+ Left
2439
+ </div>
2440
+ </lukso-dropdown-option>
2441
+ <lukso-dropdown-option
2442
+ ?is-selected=${this.activeFormats.alignment === "center"}
2443
+ @click=${(e) => {
2392
2444
  e.stopPropagation();
2393
2445
  this.restoreFocusAndSelection();
2394
2446
  this.applyAlignment("center");
2395
2447
  this.isAlignmentDropdownOpen = false;
2396
2448
  }}
2397
- size="medium"
2398
- aria-label="Align center"
2399
- >
2400
- <div style="display: flex; align-items: center; gap: 8px;">
2401
- <lukso-icon
2402
- name="textalign-center"
2403
- size="small"
2404
- pack="vuesax"
2405
- variant="linear"
2406
- ></lukso-icon>
2407
- Center
2408
- </div>
2409
- </lukso-dropdown-option>
2410
- <lukso-dropdown-option
2411
- ?is-selected=${this.activeFormats.alignment === "right"}
2412
- @click=${(e) => {
2449
+ size="medium"
2450
+ aria-label="Align center"
2451
+ >
2452
+ <div style="display: flex; align-items: center; gap: 8px;">
2453
+ <lukso-icon
2454
+ name="textalign-center"
2455
+ size="small"
2456
+ pack="vuesax"
2457
+ variant="linear"
2458
+ ></lukso-icon>
2459
+ Center
2460
+ </div>
2461
+ </lukso-dropdown-option>
2462
+ <lukso-dropdown-option
2463
+ ?is-selected=${this.activeFormats.alignment === "right"}
2464
+ @click=${(e) => {
2413
2465
  e.stopPropagation();
2414
2466
  this.restoreFocusAndSelection();
2415
2467
  this.applyAlignment("right");
2416
2468
  this.isAlignmentDropdownOpen = false;
2417
2469
  }}
2418
- size="medium"
2419
- aria-label="Align right"
2420
- >
2421
- <div style="display: flex; align-items: center; gap: 8px;">
2422
- <lukso-icon
2423
- name="textalign-right"
2424
- size="small"
2425
- pack="vuesax"
2426
- variant="linear"
2427
- ></lukso-icon>
2428
- Right
2470
+ size="medium"
2471
+ aria-label="Align right"
2472
+ >
2473
+ <div style="display: flex; align-items: center; gap: 8px;">
2474
+ <lukso-icon
2475
+ name="textalign-right"
2476
+ size="small"
2477
+ pack="vuesax"
2478
+ variant="linear"
2479
+ ></lukso-icon>
2480
+ Right
2481
+ </div>
2482
+ </lukso-dropdown-option>
2483
+ </lukso-dropdown>
2429
2484
  </div>
2430
- </lukso-dropdown-option>
2431
- </lukso-dropdown>
2432
- </div>
2485
+ ` : E}
2433
2486
 
2434
2487
  <!-- Color -->
2435
- <div class=${this.styles().colorMenu()}>
2436
- <lukso-tooltip text="Text color" placement="top">
2437
- <lukso-button
2438
- id=${this.colorTriggerId}
2439
- @click=${(e) => {
2488
+ ${this.toolsState.includes("color") ? x`
2489
+ <div class=${this.styles().colorMenu()}>
2490
+ <lukso-tooltip text="Text color" placement="top">
2491
+ <lukso-button
2492
+ id=${this.colorTriggerId}
2493
+ @click=${(e) => {
2440
2494
  e.stopPropagation();
2441
2495
  this.restoreFocusAndSelection();
2442
2496
  this.isHeadingDropdownOpen = false;
@@ -2453,66 +2507,70 @@ ${indent}${nextNumber}. `;
2453
2507
  }
2454
2508
  this.isColorDropdownOpen = !this.isColorDropdownOpen;
2455
2509
  }}
2456
- aria-expanded=${this.isColorDropdownOpen ? "true" : "false"}
2457
- aria-pressed=${this.activeFormats.color ? "true" : "false"}
2458
- aria-label="Text color"
2459
- variant="secondary"
2460
- size="small"
2461
- custom-class=${this.toolbarButton({
2510
+ aria-expanded=${this.isColorDropdownOpen ? "true" : "false"}
2511
+ aria-pressed=${this.activeFormats.color ? "true" : "false"}
2512
+ aria-label="Text color"
2513
+ variant="secondary"
2514
+ size="small"
2515
+ custom-class=${this.toolbarButton({
2462
2516
  active: this.activeFormats.color
2463
2517
  })}
2464
- is-icon
2465
- >
2466
- <div
2467
- class="size-4 rounded-full"
2468
- style="background-color: ${this.activeFormats.activeColor};"
2469
- ></div>
2470
- </lukso-button>
2471
- </lukso-tooltip>
2472
- <lukso-dropdown
2473
- id="colorDropdown"
2474
- trigger-id=""
2475
- size="medium"
2476
- max-height="300"
2477
- ?is-open=${this.isColorDropdownOpen}
2478
- >
2479
- <div class="grid grid-cols-8 gap-2 p-2 w-[260px]">
2480
- <div class="col-span-8 mb-2 flex items-center justify-between">
2481
- <span class="text-xs text-neutral-60">Text Color</span>
2482
- ${this.activeFormats.color ? x`<button
2483
- class="text-xs text-neutral-60 hover:text-neutral-20 underline"
2484
- @click=${(e) => {
2518
+ is-icon
2519
+ >
2520
+ <div
2521
+ class="size-4 rounded-full"
2522
+ style="background-color: ${this.activeFormats.activeColor};"
2523
+ ></div>
2524
+ </lukso-button>
2525
+ </lukso-tooltip>
2526
+ <lukso-dropdown
2527
+ id="colorDropdown"
2528
+ trigger-id=""
2529
+ size="medium"
2530
+ max-height="300"
2531
+ ?is-open=${this.isColorDropdownOpen}
2532
+ >
2533
+ <div class="grid grid-cols-8 gap-2 p-2 w-[260px]">
2534
+ <div
2535
+ class="col-span-8 mb-2 flex items-center justify-between"
2536
+ >
2537
+ <span class="text-xs text-neutral-60">Text Color</span>
2538
+ ${this.activeFormats.color ? x`<button
2539
+ class="text-xs text-neutral-60 hover:text-neutral-20 underline"
2540
+ @click=${(e) => {
2485
2541
  e.stopPropagation();
2486
2542
  this.clearColor();
2487
2543
  this.isColorDropdownOpen = false;
2488
2544
  }}
2489
- type="button"
2490
- aria-label="Clear color"
2491
- >
2492
- Clear
2493
- </button>` : E}
2494
- </div>
2495
- ${this.colorSamples.map(
2545
+ type="button"
2546
+ aria-label="Clear color"
2547
+ >
2548
+ Clear
2549
+ </button>` : E}
2550
+ </div>
2551
+ ${this.colorSamples.map(
2496
2552
  (color) => x`
2497
- <button
2498
- class="w-6 h-6 rounded-4 border transition-all ${this.activeFormats.activeColor === color ? "border-neutral-20 ring-2 ring-purple-51" : "border-neutral-90 hover:border-neutral-60"}"
2499
- style="background-color: ${color}"
2500
- title=${color}
2501
- aria-pressed=${this.activeFormats.activeColor === color ? "true" : "false"}
2502
- aria-label="Color ${color}"
2503
- @click=${(e) => {
2553
+ <button
2554
+ class="w-6 h-6 rounded-4 border transition-all ${this.activeFormats.activeColor === color ? "border-neutral-20 ring-2 ring-purple-51" : "border-neutral-90 hover:border-neutral-60"}"
2555
+ style="background-color: ${color}"
2556
+ title=${color}
2557
+ aria-pressed=${this.activeFormats.activeColor === color ? "true" : "false"}
2558
+ aria-label="Color ${color}"
2559
+ @click=${(e) => {
2504
2560
  e.stopPropagation();
2505
2561
  this.selectColor(color);
2506
2562
  this.isColorDropdownOpen = false;
2507
2563
  }}
2508
- ></button>
2509
- `
2564
+ ></button>
2565
+ `
2510
2566
  )}
2511
- </div>
2512
- </lukso-dropdown>
2513
- </div>
2567
+ </div>
2568
+ </lukso-dropdown>
2569
+ </div>
2570
+ ` : E}
2514
2571
 
2515
- <div class=${this.styles().divider()}></div>
2572
+ <!-- Divider -->
2573
+ ${this.toolsState.length > 0 ? x`<div class=${this.styles().divider()}></div>` : E}
2516
2574
  </div>
2517
2575
  `;
2518
2576
  }
@@ -2557,6 +2615,17 @@ ${indent}${nextNumber}. `;
2557
2615
  if (!this.previewTextColor) {
2558
2616
  this.previewTextColor = DEFAULT_PREVIEW_TEXT_COLOR;
2559
2617
  }
2618
+ this.toolsState = this.defaultTools;
2619
+ try {
2620
+ if (this.tools) {
2621
+ this.toolsState = JSON.parse(this.tools);
2622
+ }
2623
+ } catch (error) {
2624
+ console.warn(
2625
+ "Invalid JSON for tools property in lukso-markdown-editor. Using default tools.",
2626
+ error
2627
+ );
2628
+ }
2560
2629
  return x`
2561
2630
  <div class=${wrapper()}>
2562
2631
  ${this.labelTemplate()} ${this.descriptionTemplate()}
@@ -2596,6 +2665,7 @@ ${indent}${nextNumber}. `;
2596
2665
  >
2597
2666
  <lukso-markdown
2598
2667
  value=${this.value}
2668
+ ?strip-html-tags=${this.stripHtmlTags}
2599
2669
  custom-style=${`color: ${this.previewTextColor};`}
2600
2670
  ></lukso-markdown>
2601
2671
  ${this.accessibilityIndicatorTemplate()}
@@ -2658,6 +2728,15 @@ __decorateClass([
2658
2728
  __decorateClass([
2659
2729
  n({ type: String, attribute: "preview-text-color", reflect: true })
2660
2730
  ], LuksoMarkdownEditor.prototype, "previewTextColor", 2);
2731
+ __decorateClass([
2732
+ n({ type: Boolean, attribute: "strip-html-tags" })
2733
+ ], LuksoMarkdownEditor.prototype, "stripHtmlTags", 2);
2734
+ __decorateClass([
2735
+ n({ type: String })
2736
+ ], LuksoMarkdownEditor.prototype, "tools", 2);
2737
+ __decorateClass([
2738
+ r()
2739
+ ], LuksoMarkdownEditor.prototype, "toolsState", 2);
2661
2740
  __decorateClass([
2662
2741
  r()
2663
2742
  ], LuksoMarkdownEditor.prototype, "savedSelectionForPreview", 2);