le-kit 0.1.3 → 0.1.5

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 (257) hide show
  1. package/dist/le-kit/assets/custom-elements.json +4305 -0
  2. package/dist/le-kit/index-Da-89pOc.js +4522 -0
  3. package/dist/le-kit/{index-D21JjI31.js.map → index-Da-89pOc.js.map} +1 -1
  4. package/dist/le-kit/index.esm.js +116 -2
  5. package/dist/le-kit/index.esm.js.map +1 -1
  6. package/dist/{esm → le-kit}/le-box.entry.js +3 -3
  7. package/dist/le-kit/le-button.entry.esm.js.map +1 -0
  8. package/dist/le-kit/le-button.entry.js +90 -0
  9. package/dist/{esm → le-kit}/le-card.entry.js +3 -3
  10. package/dist/le-kit/le-checkbox.entry.esm.js.map +1 -0
  11. package/dist/le-kit/le-checkbox.entry.js +59 -0
  12. package/dist/le-kit/le-component.entry.esm.js.map +1 -0
  13. package/dist/{collection/components/le-component/le-component.js → le-kit/le-component.entry.js} +19 -134
  14. package/dist/le-kit/le-kit.css +1010 -1
  15. package/dist/le-kit/le-kit.esm.js +48 -2
  16. package/dist/le-kit/le-kit.esm.js.map +1 -1
  17. package/dist/{esm → le-kit}/le-number-input.entry.js +5 -5
  18. package/dist/le-kit/le-popover.entry.esm.js.map +1 -0
  19. package/dist/{components/le-popover2.js → le-kit/le-popover.entry.js} +9 -45
  20. package/dist/{esm → le-kit}/le-popup.entry.js +6 -6
  21. package/dist/{esm → le-kit}/le-round-progress.entry.js +2 -2
  22. package/dist/le-kit/le-slot.entry.esm.js.map +1 -0
  23. package/dist/{collection/components/le-slot/le-slot.js → le-kit/le-slot.entry.js} +30 -279
  24. package/dist/{esm → le-kit}/le-stack.entry.js +3 -3
  25. package/dist/le-kit/le-string-input.entry.esm.js.map +1 -0
  26. package/dist/le-kit/le-string-input.entry.js +93 -0
  27. package/dist/{esm → le-kit}/le-text.entry.js +3 -3
  28. package/dist/{esm → le-kit}/le-turntable.entry.js +2 -2
  29. package/dist/{esm/utils-CJLZrrdC.js → le-kit/utils-FDOApZ53.js} +3 -3
  30. package/dist/le-kit/{utils-apol-Xc_.js.map → utils-FDOApZ53.js.map} +1 -1
  31. package/package.json +3 -54
  32. package/readme.md +2 -35
  33. package/dist/admin/index.d.ts +0 -23
  34. package/dist/admin/index.js +0 -74
  35. package/dist/admin/loader.js +0 -9
  36. package/dist/cjs/index-CO4npcak.js +0 -1796
  37. package/dist/cjs/index-CO4npcak.js.map +0 -1
  38. package/dist/cjs/index.cjs.js +0 -117
  39. package/dist/cjs/index.cjs.js.map +0 -1
  40. package/dist/cjs/le-box.cjs.entry.js +0 -184
  41. package/dist/cjs/le-box.entry.cjs.js.map +0 -1
  42. package/dist/cjs/le-button.le-checkbox.le-component.le-popover.le-slot.le-string-input.entry.cjs.js.map +0 -1
  43. package/dist/cjs/le-button_6.cjs.entry.js +0 -1199
  44. package/dist/cjs/le-card.cjs.entry.js +0 -29
  45. package/dist/cjs/le-card.entry.cjs.js.map +0 -1
  46. package/dist/cjs/le-kit.cjs.js +0 -25
  47. package/dist/cjs/le-kit.cjs.js.map +0 -1
  48. package/dist/cjs/le-number-input.cjs.entry.js +0 -202
  49. package/dist/cjs/le-number-input.entry.cjs.js.map +0 -1
  50. package/dist/cjs/le-popup.cjs.entry.js +0 -212
  51. package/dist/cjs/le-popup.entry.cjs.js.map +0 -1
  52. package/dist/cjs/le-round-progress.cjs.entry.js +0 -106
  53. package/dist/cjs/le-round-progress.entry.cjs.js.map +0 -1
  54. package/dist/cjs/le-stack.cjs.entry.js +0 -135
  55. package/dist/cjs/le-stack.entry.cjs.js.map +0 -1
  56. package/dist/cjs/le-text.cjs.entry.js +0 -335
  57. package/dist/cjs/le-text.entry.cjs.js.map +0 -1
  58. package/dist/cjs/le-turntable.cjs.entry.js +0 -139
  59. package/dist/cjs/le-turntable.entry.cjs.js.map +0 -1
  60. package/dist/cjs/loader.cjs.js +0 -13
  61. package/dist/cjs/loader.cjs.js.map +0 -1
  62. package/dist/cjs/utils-BeT0iyCQ.js +0 -152
  63. package/dist/cjs/utils-BeT0iyCQ.js.map +0 -1
  64. package/dist/collection/collection-manifest.json +0 -26
  65. package/dist/collection/components/le-box/le-box.default.css +0 -37
  66. package/dist/collection/components/le-box/le-box.js +0 -614
  67. package/dist/collection/components/le-box/le-box.js.map +0 -1
  68. package/dist/collection/components/le-button/le-button.default.css +0 -263
  69. package/dist/collection/components/le-button/le-button.js +0 -368
  70. package/dist/collection/components/le-button/le-button.js.map +0 -1
  71. package/dist/collection/components/le-card/le-card.default.css +0 -74
  72. package/dist/collection/components/le-card/le-card.js +0 -102
  73. package/dist/collection/components/le-card/le-card.js.map +0 -1
  74. package/dist/collection/components/le-checkbox/le-checkbox.css +0 -93
  75. package/dist/collection/components/le-checkbox/le-checkbox.js +0 -192
  76. package/dist/collection/components/le-checkbox/le-checkbox.js.map +0 -1
  77. package/dist/collection/components/le-component/le-component.css +0 -189
  78. package/dist/collection/components/le-component/le-component.js.map +0 -1
  79. package/dist/collection/components/le-number-input/le-number-input.css +0 -135
  80. package/dist/collection/components/le-number-input/le-number-input.js +0 -515
  81. package/dist/collection/components/le-number-input/le-number-input.js.map +0 -1
  82. package/dist/collection/components/le-popover/le-popover.css +0 -143
  83. package/dist/collection/components/le-popover/le-popover.js +0 -693
  84. package/dist/collection/components/le-popover/le-popover.js.map +0 -1
  85. package/dist/collection/components/le-popup/le-popup.api.js +0 -101
  86. package/dist/collection/components/le-popup/le-popup.api.js.map +0 -1
  87. package/dist/collection/components/le-popup/le-popup.css +0 -222
  88. package/dist/collection/components/le-popup/le-popup.js +0 -596
  89. package/dist/collection/components/le-popup/le-popup.js.map +0 -1
  90. package/dist/collection/components/le-round-progress/le-round-progress.css +0 -34
  91. package/dist/collection/components/le-round-progress/le-round-progress.js +0 -184
  92. package/dist/collection/components/le-round-progress/le-round-progress.js.map +0 -1
  93. package/dist/collection/components/le-slot/le-slot.default.css +0 -222
  94. package/dist/collection/components/le-slot/le-slot.js.map +0 -1
  95. package/dist/collection/components/le-stack/le-stack.default.css +0 -37
  96. package/dist/collection/components/le-stack/le-stack.js +0 -389
  97. package/dist/collection/components/le-stack/le-stack.js.map +0 -1
  98. package/dist/collection/components/le-string-input/le-string-input.css +0 -83
  99. package/dist/collection/components/le-string-input/le-string-input.js +0 -359
  100. package/dist/collection/components/le-string-input/le-string-input.js.map +0 -1
  101. package/dist/collection/components/le-text/le-text.default.css +0 -169
  102. package/dist/collection/components/le-text/le-text.js +0 -475
  103. package/dist/collection/components/le-text/le-text.js.map +0 -1
  104. package/dist/collection/components/le-turntable/le-turntable.css +0 -10
  105. package/dist/collection/components/le-turntable/le-turntable.js +0 -210
  106. package/dist/collection/components/le-turntable/le-turntable.js.map +0 -1
  107. package/dist/collection/global/app.js +0 -130
  108. package/dist/collection/global/app.js.map +0 -1
  109. package/dist/collection/index-admin.js +0 -27
  110. package/dist/collection/index-admin.js.map +0 -1
  111. package/dist/collection/index-core.js +0 -25
  112. package/dist/collection/index-core.js.map +0 -1
  113. package/dist/collection/index.js +0 -15
  114. package/dist/collection/index.js.map +0 -1
  115. package/dist/collection/types/blocks.js +0 -115
  116. package/dist/collection/types/blocks.js.map +0 -1
  117. package/dist/collection/types/options.js +0 -2
  118. package/dist/collection/types/options.js.map +0 -1
  119. package/dist/collection/utils/utils.js +0 -141
  120. package/dist/collection/utils/utils.js.map +0 -1
  121. package/dist/components/index.js +0 -127
  122. package/dist/components/index.js.map +0 -1
  123. package/dist/components/le-box.js +0 -256
  124. package/dist/components/le-box.js.map +0 -1
  125. package/dist/components/le-button.js +0 -9
  126. package/dist/components/le-button.js.map +0 -1
  127. package/dist/components/le-button2.js +0 -1408
  128. package/dist/components/le-button2.js.map +0 -1
  129. package/dist/components/le-card.js +0 -83
  130. package/dist/components/le-card.js.map +0 -1
  131. package/dist/components/le-checkbox.js +0 -9
  132. package/dist/components/le-checkbox.js.map +0 -1
  133. package/dist/components/le-component.js +0 -9
  134. package/dist/components/le-component.js.map +0 -1
  135. package/dist/components/le-number-input.js +0 -271
  136. package/dist/components/le-number-input.js.map +0 -1
  137. package/dist/components/le-popover.js +0 -9
  138. package/dist/components/le-popover.js.map +0 -1
  139. package/dist/components/le-popover2.js.map +0 -1
  140. package/dist/components/le-popup.js +0 -279
  141. package/dist/components/le-popup.js.map +0 -1
  142. package/dist/components/le-round-progress.js +0 -135
  143. package/dist/components/le-round-progress.js.map +0 -1
  144. package/dist/components/le-slot.js +0 -9
  145. package/dist/components/le-slot.js.map +0 -1
  146. package/dist/components/le-stack.js +0 -198
  147. package/dist/components/le-stack.js.map +0 -1
  148. package/dist/components/le-string-input.js +0 -9
  149. package/dist/components/le-string-input.js.map +0 -1
  150. package/dist/components/le-text.js +0 -398
  151. package/dist/components/le-text.js.map +0 -1
  152. package/dist/components/le-turntable.js +0 -164
  153. package/dist/components/le-turntable.js.map +0 -1
  154. package/dist/core/components/index.d.ts +0 -64
  155. package/dist/core/components/index.js +0 -125
  156. package/dist/core/components/index.js.map +0 -1
  157. package/dist/core/components/le-box.d.ts +0 -11
  158. package/dist/core/components/le-box.js +0 -246
  159. package/dist/core/components/le-box.js.map +0 -1
  160. package/dist/core/components/le-button.d.ts +0 -11
  161. package/dist/core/components/le-button.js +0 -9
  162. package/dist/core/components/le-button.js.map +0 -1
  163. package/dist/core/components/le-button2.js +0 -1358
  164. package/dist/core/components/le-button2.js.map +0 -1
  165. package/dist/core/components/le-card.d.ts +0 -11
  166. package/dist/core/components/le-card.js +0 -73
  167. package/dist/core/components/le-card.js.map +0 -1
  168. package/dist/core/components/le-checkbox.d.ts +0 -11
  169. package/dist/core/components/le-checkbox.js +0 -9
  170. package/dist/core/components/le-checkbox.js.map +0 -1
  171. package/dist/core/components/le-component.js.map +0 -1
  172. package/dist/core/components/le-number-input.d.ts +0 -11
  173. package/dist/core/components/le-number-input.js +0 -261
  174. package/dist/core/components/le-number-input.js.map +0 -1
  175. package/dist/core/components/le-popover.d.ts +0 -11
  176. package/dist/core/components/le-popover.js +0 -9
  177. package/dist/core/components/le-popover.js.map +0 -1
  178. package/dist/core/components/le-popover2.js +0 -382
  179. package/dist/core/components/le-popover2.js.map +0 -1
  180. package/dist/core/components/le-popup.d.ts +0 -11
  181. package/dist/core/components/le-popup.js +0 -269
  182. package/dist/core/components/le-popup.js.map +0 -1
  183. package/dist/core/components/le-round-progress.d.ts +0 -11
  184. package/dist/core/components/le-round-progress.js +0 -135
  185. package/dist/core/components/le-round-progress.js.map +0 -1
  186. package/dist/core/components/le-slot.js.map +0 -1
  187. package/dist/core/components/le-stack.d.ts +0 -11
  188. package/dist/core/components/le-stack.js +0 -188
  189. package/dist/core/components/le-stack.js.map +0 -1
  190. package/dist/core/components/le-string-input.d.ts +0 -11
  191. package/dist/core/components/le-string-input.js +0 -9
  192. package/dist/core/components/le-string-input.js.map +0 -1
  193. package/dist/core/components/le-text.d.ts +0 -11
  194. package/dist/core/components/le-text.js +0 -388
  195. package/dist/core/components/le-text.js.map +0 -1
  196. package/dist/core/components/le-turntable.d.ts +0 -11
  197. package/dist/core/components/le-turntable.js +0 -164
  198. package/dist/core/components/le-turntable.js.map +0 -1
  199. package/dist/core/index.d.ts +0 -21
  200. package/dist/core/index.js +0 -68
  201. package/dist/core/loader.js +0 -9
  202. package/dist/core/stencil-runtime.js +0 -1
  203. package/dist/docs.d.ts +0 -443
  204. package/dist/docs.json +0 -5185
  205. package/dist/esm/index-D71TXvJa.js +0 -1781
  206. package/dist/esm/index-D71TXvJa.js.map +0 -1
  207. package/dist/esm/index.js +0 -106
  208. package/dist/esm/index.js.map +0 -1
  209. package/dist/esm/le-box.entry.js.map +0 -1
  210. package/dist/esm/le-button.le-checkbox.le-component.le-popover.le-slot.le-string-input.entry.js.map +0 -1
  211. package/dist/esm/le-button_6.entry.js +0 -1192
  212. package/dist/esm/le-card.entry.js.map +0 -1
  213. package/dist/esm/le-kit.js +0 -21
  214. package/dist/esm/le-kit.js.map +0 -1
  215. package/dist/esm/le-number-input.entry.js.map +0 -1
  216. package/dist/esm/le-popup.entry.js.map +0 -1
  217. package/dist/esm/le-round-progress.entry.js.map +0 -1
  218. package/dist/esm/le-stack.entry.js.map +0 -1
  219. package/dist/esm/le-text.entry.js.map +0 -1
  220. package/dist/esm/le-turntable.entry.js.map +0 -1
  221. package/dist/esm/loader.js +0 -11
  222. package/dist/esm/loader.js.map +0 -1
  223. package/dist/esm/utils-CJLZrrdC.js.map +0 -1
  224. package/dist/index.cjs.js +0 -1
  225. package/dist/index.js +0 -1
  226. package/dist/le-kit/le-button.le-checkbox.le-component.le-popover.le-slot.le-string-input.entry.esm.js.map +0 -1
  227. package/dist/le-kit/p-024a764e.entry.js +0 -2
  228. package/dist/le-kit/p-024a764e.entry.js.map +0 -1
  229. package/dist/le-kit/p-073cf0b9.entry.js +0 -2
  230. package/dist/le-kit/p-073cf0b9.entry.js.map +0 -1
  231. package/dist/le-kit/p-0955b105.entry.js +0 -2
  232. package/dist/le-kit/p-0955b105.entry.js.map +0 -1
  233. package/dist/le-kit/p-18d79ee2.entry.js +0 -2
  234. package/dist/le-kit/p-18d79ee2.entry.js.map +0 -1
  235. package/dist/le-kit/p-4b1d3b6d.entry.js +0 -2
  236. package/dist/le-kit/p-4b1d3b6d.entry.js.map +0 -1
  237. package/dist/le-kit/p-79d179bd.entry.js +0 -2
  238. package/dist/le-kit/p-79d179bd.entry.js.map +0 -1
  239. package/dist/le-kit/p-D71TXvJa.js +0 -3
  240. package/dist/le-kit/p-D71TXvJa.js.map +0 -1
  241. package/dist/le-kit/p-c8a9288e.entry.js +0 -2
  242. package/dist/le-kit/p-c8a9288e.entry.js.map +0 -1
  243. package/dist/le-kit/p-cfc35bd3.entry.js +0 -2
  244. package/dist/le-kit/p-cfc35bd3.entry.js.map +0 -1
  245. package/dist/le-kit/p-d04da1f5.entry.js +0 -2
  246. package/dist/le-kit/p-d04da1f5.entry.js.map +0 -1
  247. package/dist/le-kit/p-qIai5-eB.js +0 -2
  248. package/dist/le-kit/p-qIai5-eB.js.map +0 -1
  249. package/dist/themes/base.css +0 -89
  250. package/dist/themes/dark.css +0 -100
  251. package/dist/themes/default.css +0 -108
  252. package/dist/themes/gradient.css +0 -100
  253. package/dist/themes/index.css +0 -413
  254. package/dist/themes/minimal.css +0 -100
  255. package/dist/themes/warm.css +0 -100
  256. package/dist/types/index-admin.d.ts +0 -29
  257. package/dist/types/index-core.d.ts +0 -27
@@ -1,475 +0,0 @@
1
- import { h, Host } from "@stencil/core";
2
- import { observeModeChanges } from "../../utils/utils";
3
- /**
4
- * A text component with rich text editing capabilities in admin mode.
5
- *
6
- * `le-text` renders semantic text elements (headings, paragraphs, code, quotes)
7
- * and provides a Notion-like rich text editor in admin mode with formatting
8
- * toolbar for bold, italic, links, and paragraph type selection.
9
- *
10
- * @slot - Default slot for text content
11
- *
12
- * @cssprop --le-text-color - Text color
13
- * @cssprop --le-text-font-size - Font size
14
- * @cssprop --le-text-line-height - Line height
15
- * @cssprop --le-text-font-weight - Font weight
16
- *
17
- * @csspart text - The text container element
18
- *
19
- * @cmsEditable true
20
- * @cmsCategory Content
21
- */
22
- export class LeText {
23
- el;
24
- /**
25
- * The semantic variant/type of text element
26
- * @allowedValues p | h1 | h2 | h3 | h4 | h5 | h6 | code | quote | label | small
27
- */
28
- variant = 'p';
29
- /**
30
- * Text alignment
31
- * @allowedValues left | center | right | justify
32
- */
33
- align = 'left';
34
- /**
35
- * Text color (CSS value or theme token)
36
- */
37
- color;
38
- /**
39
- * Whether the text should truncate with ellipsis
40
- */
41
- truncate = false;
42
- /**
43
- * Maximum number of lines before truncating (requires truncate=true)
44
- */
45
- maxLines;
46
- /**
47
- * Internal state to track admin mode
48
- */
49
- adminMode = false;
50
- /**
51
- * The HTML content being edited
52
- */
53
- content = '';
54
- /**
55
- * Whether the editor is focused (shows toolbar)
56
- */
57
- isFocused = false;
58
- /**
59
- * Current selection state for toolbar button highlighting
60
- */
61
- selectionState = {
62
- isBold: false,
63
- isItalic: false,
64
- isUnderline: false,
65
- isStrikethrough: false,
66
- isLink: false,
67
- blockType: 'p',
68
- };
69
- /**
70
- * Reference to the contenteditable element
71
- */
72
- editorRef;
73
- /**
74
- * Reference to the slot element
75
- */
76
- slotRef;
77
- disconnectModeObserver;
78
- connectedCallback() {
79
- this.disconnectModeObserver = observeModeChanges(this.el, (mode) => {
80
- const wasAdmin = this.adminMode;
81
- this.adminMode = mode === 'admin';
82
- if (this.adminMode && !wasAdmin) {
83
- // Entering admin mode - read content from slot
84
- requestAnimationFrame(() => this.readSlottedContent());
85
- }
86
- else if (!this.adminMode && wasAdmin) {
87
- // Leaving admin mode - sync content back to slot
88
- this.syncContentToSlot();
89
- }
90
- });
91
- }
92
- disconnectedCallback() {
93
- this.disconnectModeObserver?.();
94
- }
95
- onVariantChange() {
96
- // When variant changes in admin mode, update the content wrapper
97
- if (this.adminMode && this.editorRef) {
98
- this.syncContentToSlot();
99
- }
100
- }
101
- /**
102
- * Read content from slotted elements
103
- */
104
- readSlottedContent() {
105
- if (!this.slotRef)
106
- return;
107
- const assignedNodes = this.slotRef.assignedNodes({ flatten: true });
108
- // Collect all content from assigned nodes
109
- let html = '';
110
- assignedNodes.forEach(node => {
111
- if (node.nodeType === Node.TEXT_NODE) {
112
- html += node.textContent;
113
- }
114
- else if (node.nodeType === Node.ELEMENT_NODE) {
115
- html += node.innerHTML || node.textContent;
116
- }
117
- });
118
- this.content = html.trim();
119
- }
120
- /**
121
- * Sync edited content back to the slot
122
- */
123
- syncContentToSlot() {
124
- if (!this.editorRef)
125
- return;
126
- const newContent = this.editorRef.innerHTML;
127
- // Update the light DOM content
128
- // We need to update the actual slotted content
129
- const slot = this.slotRef;
130
- if (slot) {
131
- const assignedNodes = slot.assignedNodes({ flatten: true });
132
- if (assignedNodes.length > 0) {
133
- const firstNode = assignedNodes[0];
134
- if (firstNode.nodeType === Node.ELEMENT_NODE) {
135
- firstNode.innerHTML = newContent;
136
- }
137
- else if (firstNode.nodeType === Node.TEXT_NODE) {
138
- // Replace text node with the new content
139
- const parent = firstNode.parentNode;
140
- if (parent) {
141
- // Create a temporary element to parse HTML
142
- const temp = document.createElement('span');
143
- temp.innerHTML = newContent;
144
- // Replace the text node
145
- parent.replaceChild(temp, firstNode);
146
- // Unwrap the span if it only contains text
147
- if (temp.childNodes.length === 1 && temp.firstChild?.nodeType === Node.TEXT_NODE) {
148
- parent.replaceChild(temp.firstChild, temp);
149
- }
150
- }
151
- }
152
- }
153
- else {
154
- // No assigned nodes, set innerHTML on the host's light DOM
155
- this.el.innerHTML = newContent;
156
- }
157
- }
158
- }
159
- /**
160
- * Handle input in the contenteditable
161
- */
162
- handleInput = () => {
163
- if (this.editorRef) {
164
- this.content = this.editorRef.innerHTML;
165
- this.updateSelectionState();
166
- }
167
- };
168
- /**
169
- * Handle focus on the editor
170
- */
171
- handleFocus = () => {
172
- this.isFocused = true;
173
- this.updateSelectionState();
174
- };
175
- /**
176
- * Handle blur on the editor
177
- */
178
- handleBlur = (e) => {
179
- // Check if focus moved to toolbar
180
- const relatedTarget = e.relatedTarget;
181
- const toolbar = this.el.shadowRoot?.querySelector('.le-text-toolbar');
182
- if (toolbar?.contains(relatedTarget)) {
183
- // Focus moved to toolbar, keep it open
184
- return;
185
- }
186
- // Small delay to allow toolbar clicks to register
187
- setTimeout(() => {
188
- if (!this.el.shadowRoot?.activeElement) {
189
- this.isFocused = false;
190
- this.syncContentToSlot();
191
- }
192
- }, 150);
193
- };
194
- /**
195
- * Handle selection change to update toolbar state
196
- */
197
- handleSelectionChange = () => {
198
- this.updateSelectionState();
199
- };
200
- /**
201
- * Update the selection state for toolbar highlighting
202
- */
203
- updateSelectionState() {
204
- const selection = window.getSelection();
205
- if (!selection || selection.rangeCount === 0)
206
- return;
207
- this.selectionState = {
208
- isBold: document.queryCommandState('bold'),
209
- isItalic: document.queryCommandState('italic'),
210
- isUnderline: document.queryCommandState('underline'),
211
- isStrikethrough: document.queryCommandState('strikeThrough'),
212
- isLink: this.isSelectionInLink(selection),
213
- blockType: this.variant,
214
- };
215
- }
216
- /**
217
- * Check if current selection is within a link
218
- */
219
- isSelectionInLink(selection) {
220
- if (!selection.anchorNode)
221
- return false;
222
- let node = selection.anchorNode;
223
- while (node && node !== this.editorRef) {
224
- if (node.nodeName === 'A')
225
- return true;
226
- node = node.parentNode;
227
- }
228
- return false;
229
- }
230
- /**
231
- * Execute a formatting command
232
- */
233
- execCommand(command, value) {
234
- // Focus the editor first
235
- this.editorRef?.focus();
236
- // Execute the command
237
- document.execCommand(command, false, value);
238
- // Update state
239
- this.handleInput();
240
- this.updateSelectionState();
241
- }
242
- /**
243
- * Toggle bold formatting
244
- */
245
- toggleBold = (e) => {
246
- e.preventDefault();
247
- this.execCommand('bold');
248
- };
249
- /**
250
- * Toggle italic formatting
251
- */
252
- toggleItalic = (e) => {
253
- e.preventDefault();
254
- this.execCommand('italic');
255
- };
256
- /**
257
- * Toggle underline formatting
258
- */
259
- toggleUnderline = (e) => {
260
- e.preventDefault();
261
- this.execCommand('underline');
262
- };
263
- /**
264
- * Toggle strikethrough formatting
265
- */
266
- toggleStrikethrough = (e) => {
267
- e.preventDefault();
268
- this.execCommand('strikeThrough');
269
- };
270
- /**
271
- * Add or edit a link
272
- */
273
- toggleLink = (e) => {
274
- e.preventDefault();
275
- if (this.selectionState.isLink) {
276
- // Remove link
277
- this.execCommand('unlink');
278
- }
279
- else {
280
- // Add link
281
- const url = prompt('Enter URL:', 'https://');
282
- if (url) {
283
- this.execCommand('createLink', url);
284
- }
285
- }
286
- };
287
- /**
288
- * Change the block type/variant
289
- */
290
- changeVariant = (e) => {
291
- const select = e.target;
292
- this.variant = select.value;
293
- };
294
- /**
295
- * Render the formatting toolbar
296
- */
297
- renderToolbar() {
298
- return (h("div", { class: "le-text-toolbar" }, h("select", { class: "le-text-toolbar-select", onChange: this.changeVariant, onMouseDown: (e) => e.preventDefault() }, h("option", { value: "p", selected: this.variant === 'p' }, "Paragraph"), h("option", { value: "h1", selected: this.variant === 'h1' }, "Heading 1"), h("option", { value: "h2", selected: this.variant === 'h2' }, "Heading 2"), h("option", { value: "h3", selected: this.variant === 'h3' }, "Heading 3"), h("option", { value: "h4", selected: this.variant === 'h4' }, "Heading 4"), h("option", { value: "h5", selected: this.variant === 'h5' }, "Heading 5"), h("option", { value: "h6", selected: this.variant === 'h6' }, "Heading 6"), h("option", { value: "quote", selected: this.variant === 'quote' }, "Quote"), h("option", { value: "code", selected: this.variant === 'code' }, "Code"), h("option", { value: "label", selected: this.variant === 'label' }, "Label"), h("option", { value: "small", selected: this.variant === 'small' }, "Small")), h("div", { class: "le-text-toolbar-divider" }), h("button", { type: "button", class: { 'le-text-toolbar-btn': true, 'active': this.selectionState.isBold }, onMouseDown: this.toggleBold, title: "Bold (Ctrl+B)" }, h("strong", null, "B")), h("button", { type: "button", class: { 'le-text-toolbar-btn': true, 'active': this.selectionState.isItalic }, onMouseDown: this.toggleItalic, title: "Italic (Ctrl+I)" }, h("em", null, "I")), h("button", { type: "button", class: { 'le-text-toolbar-btn': true, 'active': this.selectionState.isUnderline }, onMouseDown: this.toggleUnderline, title: "Underline (Ctrl+U)" }, h("span", { style: { textDecoration: 'underline' } }, "U")), h("button", { type: "button", class: { 'le-text-toolbar-btn': true, 'active': this.selectionState.isStrikethrough }, onMouseDown: this.toggleStrikethrough, title: "Strikethrough" }, h("span", { style: { textDecoration: 'line-through' } }, "S")), h("div", { class: "le-text-toolbar-divider" }), h("button", { type: "button", class: { 'le-text-toolbar-btn': true, 'active': this.selectionState.isLink }, onMouseDown: this.toggleLink, title: this.selectionState.isLink ? 'Remove link' : 'Add link' }, "\uD83D\uDD17")));
299
- }
300
- /**
301
- * Get the semantic tag for the current variant
302
- */
303
- getTag() {
304
- switch (this.variant) {
305
- case 'quote':
306
- return 'blockquote';
307
- case 'code':
308
- return 'pre';
309
- case 'label':
310
- return 'label';
311
- case 'small':
312
- return 'small';
313
- default:
314
- return this.variant; // h1-h6, p
315
- }
316
- }
317
- render() {
318
- const Tag = this.getTag();
319
- const textStyle = {};
320
- if (this.color) {
321
- textStyle.color = this.color;
322
- }
323
- if (this.align) {
324
- textStyle.textAlign = this.align;
325
- }
326
- const textClass = {
327
- 'le-text': true,
328
- [`variant-${this.variant}`]: true,
329
- 'truncate': this.truncate,
330
- [`max-lines-${this.maxLines}`]: this.truncate && this.maxLines,
331
- };
332
- // Admin mode - show rich text editor
333
- if (this.adminMode) {
334
- return (h(Host, { class: "admin-mode" }, h("le-component", { component: "le-text" }, h("div", { class: "le-text-editor-wrapper" }, this.isFocused && this.renderToolbar(), h(Tag, { class: textClass, part: "text", style: textStyle }, h("div", { ref: (el) => this.editorRef = el, class: "le-text-editor", contentEditable: true, onInput: this.handleInput, onFocus: this.handleFocus, onBlur: this.handleBlur, onKeyUp: this.handleSelectionChange, onMouseUp: this.handleSelectionChange, innerHTML: this.content })), h("div", { class: "hidden-slot" }, h("slot", { ref: (el) => this.slotRef = el, onSlotchange: () => this.readSlottedContent() }))))));
335
- }
336
- // Default mode - render semantic element with slotted content
337
- return (h(Host, null, h(Tag, { class: textClass, part: "text", style: textStyle }, h("slot", { ref: (el) => this.slotRef = el }))));
338
- }
339
- static get is() { return "le-text"; }
340
- static get encapsulation() { return "shadow"; }
341
- static get originalStyleUrls() {
342
- return {
343
- "$": ["le-text.default.css"]
344
- };
345
- }
346
- static get styleUrls() {
347
- return {
348
- "$": ["le-text.default.css"]
349
- };
350
- }
351
- static get properties() {
352
- return {
353
- "variant": {
354
- "type": "string",
355
- "mutable": true,
356
- "complexType": {
357
- "original": "'p' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'code' | 'quote' | 'label' | 'small'",
358
- "resolved": "\"code\" | \"h1\" | \"h2\" | \"h3\" | \"h4\" | \"h5\" | \"h6\" | \"label\" | \"p\" | \"quote\" | \"small\"",
359
- "references": {}
360
- },
361
- "required": false,
362
- "optional": false,
363
- "docs": {
364
- "tags": [{
365
- "name": "allowedValues",
366
- "text": "p | h1 | h2 | h3 | h4 | h5 | h6 | code | quote | label | small"
367
- }],
368
- "text": "The semantic variant/type of text element"
369
- },
370
- "getter": false,
371
- "setter": false,
372
- "reflect": true,
373
- "attribute": "variant",
374
- "defaultValue": "'p'"
375
- },
376
- "align": {
377
- "type": "string",
378
- "mutable": false,
379
- "complexType": {
380
- "original": "'left' | 'center' | 'right' | 'justify'",
381
- "resolved": "\"center\" | \"justify\" | \"left\" | \"right\"",
382
- "references": {}
383
- },
384
- "required": false,
385
- "optional": false,
386
- "docs": {
387
- "tags": [{
388
- "name": "allowedValues",
389
- "text": "left | center | right | justify"
390
- }],
391
- "text": "Text alignment"
392
- },
393
- "getter": false,
394
- "setter": false,
395
- "reflect": true,
396
- "attribute": "align",
397
- "defaultValue": "'left'"
398
- },
399
- "color": {
400
- "type": "string",
401
- "mutable": false,
402
- "complexType": {
403
- "original": "string",
404
- "resolved": "string",
405
- "references": {}
406
- },
407
- "required": false,
408
- "optional": true,
409
- "docs": {
410
- "tags": [],
411
- "text": "Text color (CSS value or theme token)"
412
- },
413
- "getter": false,
414
- "setter": false,
415
- "reflect": false,
416
- "attribute": "color"
417
- },
418
- "truncate": {
419
- "type": "boolean",
420
- "mutable": false,
421
- "complexType": {
422
- "original": "boolean",
423
- "resolved": "boolean",
424
- "references": {}
425
- },
426
- "required": false,
427
- "optional": false,
428
- "docs": {
429
- "tags": [],
430
- "text": "Whether the text should truncate with ellipsis"
431
- },
432
- "getter": false,
433
- "setter": false,
434
- "reflect": false,
435
- "attribute": "truncate",
436
- "defaultValue": "false"
437
- },
438
- "maxLines": {
439
- "type": "number",
440
- "mutable": false,
441
- "complexType": {
442
- "original": "number",
443
- "resolved": "number",
444
- "references": {}
445
- },
446
- "required": false,
447
- "optional": true,
448
- "docs": {
449
- "tags": [],
450
- "text": "Maximum number of lines before truncating (requires truncate=true)"
451
- },
452
- "getter": false,
453
- "setter": false,
454
- "reflect": false,
455
- "attribute": "max-lines"
456
- }
457
- };
458
- }
459
- static get states() {
460
- return {
461
- "adminMode": {},
462
- "content": {},
463
- "isFocused": {},
464
- "selectionState": {}
465
- };
466
- }
467
- static get elementRef() { return "el"; }
468
- static get watchers() {
469
- return [{
470
- "propName": "variant",
471
- "methodName": "onVariantChange"
472
- }];
473
- }
474
- }
475
- //# sourceMappingURL=le-text.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"le-text.js","sourceRoot":"","sources":["../../../src/components/le-text/le-text.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAChF,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAEvD;;;;;;;;;;;;;;;;;;GAkBG;AAMH,MAAM,OAAO,MAAM;IACN,EAAE,CAAc;IAE3B;;;OAGG;IACqC,OAAO,GAAyF,GAAG,CAAC;IAE5I;;;OAGG;IACsB,KAAK,GAA4C,MAAM,CAAC;IAEjF;;OAEG;IACK,KAAK,CAAU;IAEvB;;OAEG;IACK,QAAQ,GAAY,KAAK,CAAC;IAElC;;OAEG;IACK,QAAQ,CAAU;IAE1B;;OAEG;IACc,SAAS,GAAY,KAAK,CAAC;IAE5C;;OAEG;IACc,OAAO,GAAW,EAAE,CAAC;IAEtC;;OAEG;IACc,SAAS,GAAY,KAAK,CAAC;IAE5C;;OAEG;IACc,cAAc,GAAmB;QAChD,MAAM,EAAE,KAAK;QACb,QAAQ,EAAE,KAAK;QACf,WAAW,EAAE,KAAK;QAClB,eAAe,EAAE,KAAK;QACtB,MAAM,EAAE,KAAK;QACb,SAAS,EAAE,GAAG;KACf,CAAC;IAEF;;OAEG;IACK,SAAS,CAAkB;IAEnC;;OAEG;IACK,OAAO,CAAmB;IAE1B,sBAAsB,CAAc;IAE5C,iBAAiB;QACf,IAAI,CAAC,sBAAsB,GAAG,kBAAkB,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,IAAI,EAAE,EAAE;YACjE,MAAM,QAAQ,GAAG,IA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,GAAG,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,GAAG,EAAE,EAChC,KAAK,EAAC,gBAAgB,EACtB,eAAe,EAAE,IAAI,EACrB,OAAO,EAAE,IAAI,CAAC,WAAW,EACzB,OAAO,EAAE,IAAI,CAAC,WAAW,EACzB,MAAM,EAAE,IAAI,CAAC,UAAU,EACvB,OAAO,EAAE,IAAI,CAAC,qBAAqB,EACnC,SAAS,EAAE,IAAI,CAAC,qBAAqB,EACrC,SAAS,EAAE,IAAI,CAAC,OAAO,GAClB,CACH;wBAEN,WAAK,KAAK,EAAC,aAAa;4BACtB,YACE,GAAG,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,GAAG,EAAqB,EACjD,YAAY,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,kBAAkB,EAAE,GACvC,CACJ,CACF,CACO,CACV,CACR,CAAC;QACJ,CAAC;QAED,8DAA8D;QAC9D,OAAO,CACL,EAAC,IAAI;YACH,EAAC,GAAG,IACF,KAAK,EAAE,SAAS,EAChB,IAAI,EAAC,MAAM,EACX,KAAK,EAAE,SAAS;gBAEhB,YAAM,GAAG,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,GAAG,EAAqB,GAAS,CAC5D,CACD,CACR,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Prop, State, h, Host, Element, Watch } from '@stencil/core';\nimport { observeModeChanges } from '../../utils/utils';\n\n/**\n * A text component with rich text editing capabilities in admin mode.\n *\n * `le-text` renders semantic text elements (headings, paragraphs, code, quotes)\n * and provides a Notion-like rich text editor in admin mode with formatting\n * toolbar for bold, italic, links, and paragraph type selection.\n *\n * @slot - Default slot for text content\n *\n * @cssprop --le-text-color - Text color\n * @cssprop --le-text-font-size - Font size\n * @cssprop --le-text-line-height - Line height\n * @cssprop --le-text-font-weight - Font weight\n *\n * @csspart text - The text container element\n *\n * @cmsEditable true\n * @cmsCategory Content\n */\n@Component({\n tag: 'le-text',\n styleUrl: 'le-text.default.css',\n shadow: true,\n})\nexport class LeText {\n @Element() el: HTMLElement;\n\n /**\n * The semantic variant/type of text element\n * @allowedValues p | h1 | h2 | h3 | h4 | h5 | h6 | code | quote | label | small\n */\n @Prop({ mutable: true, reflect: true }) variant: 'p' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'code' | 'quote' | 'label' | 'small' = 'p';\n\n /**\n * Text alignment\n * @allowedValues left | center | right | justify\n */\n @Prop({ reflect: true }) align: 'left' | 'center' | 'right' | 'justify' = 'left';\n\n /**\n * Text color (CSS value or theme token)\n */\n @Prop() color?: string;\n\n /**\n * Whether the text should truncate with ellipsis\n */\n @Prop() truncate: boolean = false;\n\n /**\n * Maximum number of lines before truncating (requires truncate=true)\n */\n @Prop() maxLines?: number;\n\n /**\n * Internal state to track admin mode\n */\n @State() private adminMode: boolean = false;\n\n /**\n * The HTML content being edited\n */\n @State() private content: string = '';\n\n /**\n * Whether the editor is focused (shows toolbar)\n */\n @State() private isFocused: boolean = false;\n\n /**\n * Current selection state for toolbar button highlighting\n */\n @State() private selectionState: SelectionState = {\n isBold: false,\n isItalic: false,\n isUnderline: false,\n isStrikethrough: false,\n isLink: false,\n blockType: 'p',\n };\n\n /**\n * Reference to the contenteditable element\n */\n private editorRef?: HTMLDivElement;\n\n /**\n * Reference to the slot element\n */\n private slotRef?: HTMLSlotElement;\n\n private disconnectModeObserver?: () => void;\n\n connectedCallback() {\n this.disconnectModeObserver = observeModeChanges(this.el, (mode) => {\n const wasAdmin = this.adminMode;\n this.adminMode = mode === 'admin';\n \n if (this.adminMode && !wasAdmin) {\n // Entering admin mode - read content from slot\n requestAnimationFrame(() => this.readSlottedContent());\n } else if (!this.adminMode && wasAdmin) {\n // Leaving admin mode - sync content back to slot\n this.syncContentToSlot();\n }\n });\n }\n\n disconnectedCallback() {\n this.disconnectModeObserver?.();\n }\n\n @Watch('variant')\n onVariantChange() {\n // When variant changes in admin mode, update the content wrapper\n if (this.adminMode && this.editorRef) {\n this.syncContentToSlot();\n }\n }\n\n /**\n * Read content from slotted elements\n */\n private readSlottedContent() {\n if (!this.slotRef) return;\n \n const assignedNodes = this.slotRef.assignedNodes({ flatten: true });\n \n // Collect all content from assigned nodes\n let html = '';\n assignedNodes.forEach(node => {\n if (node.nodeType === Node.TEXT_NODE) {\n html += node.textContent;\n } else if (node.nodeType === Node.ELEMENT_NODE) {\n html += (node as Element).innerHTML || node.textContent;\n }\n });\n \n this.content = html.trim();\n }\n\n /**\n * Sync edited content back to the slot\n */\n private syncContentToSlot() {\n if (!this.editorRef) return;\n \n const newContent = this.editorRef.innerHTML;\n \n // Update the light DOM content\n // We need to update the actual slotted content\n const slot = this.slotRef;\n if (slot) {\n const assignedNodes = slot.assignedNodes({ flatten: true });\n if (assignedNodes.length > 0) {\n const firstNode = assignedNodes[0];\n if (firstNode.nodeType === Node.ELEMENT_NODE) {\n (firstNode as Element).innerHTML = newContent;\n } else if (firstNode.nodeType === Node.TEXT_NODE) {\n // Replace text node with the new content\n const parent = firstNode.parentNode;\n if (parent) {\n // Create a temporary element to parse HTML\n const temp = document.createElement('span');\n temp.innerHTML = newContent;\n // Replace the text node\n parent.replaceChild(temp, firstNode);\n // Unwrap the span if it only contains text\n if (temp.childNodes.length === 1 && temp.firstChild?.nodeType === Node.TEXT_NODE) {\n parent.replaceChild(temp.firstChild, temp);\n }\n }\n }\n } else {\n // No assigned nodes, set innerHTML on the host's light DOM\n this.el.innerHTML = newContent;\n }\n }\n }\n\n /**\n * Handle input in the contenteditable\n */\n private handleInput = () => {\n if (this.editorRef) {\n this.content = this.editorRef.innerHTML;\n this.updateSelectionState();\n }\n };\n\n /**\n * Handle focus on the editor\n */\n private handleFocus = () => {\n this.isFocused = true;\n this.updateSelectionState();\n };\n\n /**\n * Handle blur on the editor\n */\n private handleBlur = (e: FocusEvent) => {\n // Check if focus moved to toolbar\n const relatedTarget = e.relatedTarget as HTMLElement;\n const toolbar = this.el.shadowRoot?.querySelector('.le-text-toolbar');\n \n if (toolbar?.contains(relatedTarget)) {\n // Focus moved to toolbar, keep it open\n return;\n }\n \n // Small delay to allow toolbar clicks to register\n setTimeout(() => {\n if (!this.el.shadowRoot?.activeElement) {\n this.isFocused = false;\n this.syncContentToSlot();\n }\n }, 150);\n };\n\n /**\n * Handle selection change to update toolbar state\n */\n private handleSelectionChange = () => {\n this.updateSelectionState();\n };\n\n /**\n * Update the selection state for toolbar highlighting\n */\n private updateSelectionState() {\n const selection = window.getSelection();\n if (!selection || selection.rangeCount === 0) return;\n\n this.selectionState = {\n isBold: document.queryCommandState('bold'),\n isItalic: document.queryCommandState('italic'),\n isUnderline: document.queryCommandState('underline'),\n isStrikethrough: document.queryCommandState('strikeThrough'),\n isLink: this.isSelectionInLink(selection),\n blockType: this.variant,\n };\n }\n\n /**\n * Check if current selection is within a link\n */\n private isSelectionInLink(selection: Selection): boolean {\n if (!selection.anchorNode) return false;\n \n let node: Node | null = selection.anchorNode;\n while (node && node !== this.editorRef) {\n if (node.nodeName === 'A') return true;\n node = node.parentNode;\n }\n return false;\n }\n\n /**\n * Execute a formatting command\n */\n private execCommand(command: string, value?: string) {\n // Focus the editor first\n this.editorRef?.focus();\n \n // Execute the command\n document.execCommand(command, false, value);\n \n // Update state\n this.handleInput();\n this.updateSelectionState();\n }\n\n /**\n * Toggle bold formatting\n */\n private toggleBold = (e: Event) => {\n e.preventDefault();\n this.execCommand('bold');\n };\n\n /**\n * Toggle italic formatting\n */\n private toggleItalic = (e: Event) => {\n e.preventDefault();\n this.execCommand('italic');\n };\n\n /**\n * Toggle underline formatting\n */\n private toggleUnderline = (e: Event) => {\n e.preventDefault();\n this.execCommand('underline');\n };\n\n /**\n * Toggle strikethrough formatting\n */\n private toggleStrikethrough = (e: Event) => {\n e.preventDefault();\n this.execCommand('strikeThrough');\n };\n\n /**\n * Add or edit a link\n */\n private toggleLink = (e: Event) => {\n e.preventDefault();\n \n if (this.selectionState.isLink) {\n // Remove link\n this.execCommand('unlink');\n } else {\n // Add link\n const url = prompt('Enter URL:', 'https://');\n if (url) {\n this.execCommand('createLink', url);\n }\n }\n };\n\n /**\n * Change the block type/variant\n */\n private changeVariant = (e: Event) => {\n const select = e.target as HTMLSelectElement;\n this.variant = select.value as typeof this.variant;\n };\n\n /**\n * Render the formatting toolbar\n */\n private renderToolbar() {\n return (\n <div class=\"le-text-toolbar\">\n <select \n class=\"le-text-toolbar-select\"\n onChange={this.changeVariant}\n onMouseDown={(e) => e.preventDefault()}\n >\n <option value=\"p\" selected={this.variant === 'p'}>Paragraph</option>\n <option value=\"h1\" selected={this.variant === 'h1'}>Heading 1</option>\n <option value=\"h2\" selected={this.variant === 'h2'}>Heading 2</option>\n <option value=\"h3\" selected={this.variant === 'h3'}>Heading 3</option>\n <option value=\"h4\" selected={this.variant === 'h4'}>Heading 4</option>\n <option value=\"h5\" selected={this.variant === 'h5'}>Heading 5</option>\n <option value=\"h6\" selected={this.variant === 'h6'}>Heading 6</option>\n <option value=\"quote\" selected={this.variant === 'quote'}>Quote</option>\n <option value=\"code\" selected={this.variant === 'code'}>Code</option>\n <option value=\"label\" selected={this.variant === 'label'}>Label</option>\n <option value=\"small\" selected={this.variant === 'small'}>Small</option>\n </select>\n \n <div class=\"le-text-toolbar-divider\"></div>\n \n <button\n type=\"button\"\n class={{ 'le-text-toolbar-btn': true, 'active': this.selectionState.isBold }}\n onMouseDown={this.toggleBold}\n title=\"Bold (Ctrl+B)\"\n >\n <strong>B</strong>\n </button>\n \n <button\n type=\"button\"\n class={{ 'le-text-toolbar-btn': true, 'active': this.selectionState.isItalic }}\n onMouseDown={this.toggleItalic}\n title=\"Italic (Ctrl+I)\"\n >\n <em>I</em>\n </button>\n \n <button\n type=\"button\"\n class={{ 'le-text-toolbar-btn': true, 'active': this.selectionState.isUnderline }}\n onMouseDown={this.toggleUnderline}\n title=\"Underline (Ctrl+U)\"\n >\n <span style={{ textDecoration: 'underline' }}>U</span>\n </button>\n \n <button\n type=\"button\"\n class={{ 'le-text-toolbar-btn': true, 'active': this.selectionState.isStrikethrough }}\n onMouseDown={this.toggleStrikethrough}\n title=\"Strikethrough\"\n >\n <span style={{ textDecoration: 'line-through' }}>S</span>\n </button>\n \n <div class=\"le-text-toolbar-divider\"></div>\n \n <button\n type=\"button\"\n class={{ 'le-text-toolbar-btn': true, 'active': this.selectionState.isLink }}\n onMouseDown={this.toggleLink}\n title={this.selectionState.isLink ? 'Remove link' : 'Add link'}\n >\n 🔗\n </button>\n </div>\n );\n }\n\n /**\n * Get the semantic tag for the current variant\n */\n private getTag(): string {\n switch (this.variant) {\n case 'quote':\n return 'blockquote';\n case 'code':\n return 'pre';\n case 'label':\n return 'label';\n case 'small':\n return 'small';\n default:\n return this.variant; // h1-h6, p\n }\n }\n\n render() {\n const Tag = this.getTag();\n \n const textStyle: { [key: string]: string } = {};\n if (this.color) {\n textStyle.color = this.color;\n }\n if (this.align) {\n textStyle.textAlign = this.align;\n }\n\n const textClass = {\n 'le-text': true,\n [`variant-${this.variant}`]: true,\n 'truncate': this.truncate,\n [`max-lines-${this.maxLines}`]: this.truncate && this.maxLines,\n };\n\n // Admin mode - show rich text editor\n if (this.adminMode) {\n return (\n <Host class=\"admin-mode\">\n <le-component component=\"le-text\">\n <div class=\"le-text-editor-wrapper\">\n {this.isFocused && this.renderToolbar()}\n <Tag \n class={textClass}\n part=\"text\"\n style={textStyle}\n >\n <div\n ref={(el) => this.editorRef = el}\n class=\"le-text-editor\"\n contentEditable={true}\n onInput={this.handleInput}\n onFocus={this.handleFocus}\n onBlur={this.handleBlur}\n onKeyUp={this.handleSelectionChange}\n onMouseUp={this.handleSelectionChange}\n innerHTML={this.content}\n ></div>\n </Tag>\n {/* Hidden slot to receive light DOM content */}\n <div class=\"hidden-slot\">\n <slot \n ref={(el) => this.slotRef = el as HTMLSlotElement}\n onSlotchange={() => this.readSlottedContent()}\n ></slot>\n </div>\n </div>\n </le-component>\n </Host>\n );\n }\n\n // Default mode - render semantic element with slotted content\n return (\n <Host>\n <Tag \n class={textClass}\n part=\"text\"\n style={textStyle}\n >\n <slot ref={(el) => this.slotRef = el as HTMLSlotElement}></slot>\n </Tag>\n </Host>\n );\n }\n}\n\n/**\n * Selection state for toolbar\n */\ninterface SelectionState {\n isBold: boolean;\n isItalic: boolean;\n isUnderline: boolean;\n isStrikethrough: boolean;\n isLink: boolean;\n blockType: string;\n}\n"]}
@@ -1,10 +0,0 @@
1
- :host {
2
- display: block;
3
- cursor: grab;
4
- }
5
-
6
- div.turntable {
7
- width: 100%;
8
- height: 100%;
9
- padding: 1px;
10
- }