@aquera/nile-elements 0.1.67-beta-2.2 → 0.1.67-beta-2.4

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 (28) hide show
  1. package/demo/index.html +2 -2
  2. package/dist/index.js +151 -148
  3. package/dist/nile-rich-text-editor/nile-rich-text-editor.cjs.js +1 -1
  4. package/dist/nile-rich-text-editor/nile-rich-text-editor.cjs.js.map +1 -1
  5. package/dist/nile-rich-text-editor/nile-rich-text-editor.css.cjs.js +1 -1
  6. package/dist/nile-rich-text-editor/nile-rich-text-editor.css.cjs.js.map +1 -1
  7. package/dist/nile-rich-text-editor/nile-rich-text-editor.css.esm.js +120 -119
  8. package/dist/nile-rich-text-editor/nile-rich-text-editor.esm.js +1 -1
  9. package/dist/nile-rich-text-editor/nile-rte-select.cjs.js +1 -1
  10. package/dist/nile-rich-text-editor/nile-rte-select.cjs.js.map +1 -1
  11. package/dist/nile-rich-text-editor/nile-rte-select.esm.js +4 -2
  12. package/dist/nile-rich-text-editor/nile-rte-toolbar.cjs.js.map +1 -1
  13. package/dist/src/nile-rich-text-editor/nile-rich-text-editor.css.js +119 -118
  14. package/dist/src/nile-rich-text-editor/nile-rich-text-editor.css.js.map +1 -1
  15. package/dist/src/nile-rich-text-editor/nile-rich-text-editor.d.ts +4 -3
  16. package/dist/src/nile-rich-text-editor/nile-rich-text-editor.js +67 -31
  17. package/dist/src/nile-rich-text-editor/nile-rich-text-editor.js.map +1 -1
  18. package/dist/src/nile-rich-text-editor/nile-rte-select.js +5 -3
  19. package/dist/src/nile-rich-text-editor/nile-rte-select.js.map +1 -1
  20. package/dist/src/nile-rich-text-editor/nile-rte-toolbar.js +2 -2
  21. package/dist/src/nile-rich-text-editor/nile-rte-toolbar.js.map +1 -1
  22. package/dist/tsconfig.tsbuildinfo +1 -1
  23. package/package.json +1 -1
  24. package/src/nile-rich-text-editor/nile-rich-text-editor.css.ts +120 -119
  25. package/src/nile-rich-text-editor/nile-rich-text-editor.ts +87 -52
  26. package/src/nile-rich-text-editor/nile-rte-select.ts +5 -3
  27. package/src/nile-rich-text-editor/nile-rte-toolbar.ts +2 -2
  28. package/vscode-html-custom-data.json +8 -3
@@ -1,132 +1,133 @@
1
- // rte-styles.ts
1
+ // FILE: src/components/rte-styles.ts
2
2
  import { css } from 'lit';
3
3
  export const styles = css `
4
-
5
-
6
- .editor {all: revert;}
7
-
8
- nile-rich-text-editor { position: relative; display: block; font-family: inherit; }
9
-
10
-
11
- nile-rte-toolbar-item > nile-button::part(base) {
12
-
13
- width:32px; height:32px; padding:0px 6px;
14
- border: none;
15
- }
16
-
17
- nile-rte-preview {
18
- white-space: normal;
19
- word-break: break-word;
20
- }
21
-
22
-
23
-
24
- .toolbar, nile-rte-toolbar {
25
-
26
- width:486px;
27
- display:flex; align-items:center; gap:6px; padding:8px;
28
- border:1px solid #e5e7eb; border-bottom:none; border-radius:8px 8px 0 0; background:#fff;
29
- }
30
-
31
- nile-rte-toolbar-item > button, .toolbar button, nile-rte-toolbar button {
32
- border:1px solid #e5e7eb; background:#fff; border-radius:6px;
33
- cursor:pointer;
34
- }
35
-
36
-
37
- /* Ensure clicks hit the button (not nested icon internals) */
38
- nile-rte-toolbar-item > button nile-icon { pointer-events:none; }
39
-
40
- nile-rte-toolbar-item > button.active { border-color:#2563eb; background:#eff6ff; }
41
- nile-rte-select select { height:32px; border:1px solid #e5e7eb; border-radius:6px; background:#fff; }
42
- nile-rte-color input[type="color"] { height:32px; width:36px; border:1px solid #e5e7eb; padding:0; border-radius:6px; background:#fff; }
43
- nile-rte-divider { width:1px; height:20px; background:#e5e7eb; display:inline-block; margin:0 4px; }
44
-
45
- .editor p { margin:1em 0; }
46
- .editor h1, .preview h1 { all: revert; font-size:2em, display: block;
47
- font-size: 2em;
48
- margin-top: 0.67em;
49
- margin-bottom: 0.67em;
50
- margin-left: 0;
51
- margin-right: 0;
52
- font-weight: bold; }
53
- .editor h2, .preview h2 { all: revert; display: block;
54
- font-size: 1.5em;
55
- margin-top: 0.83em;
56
- margin-bottom: 0.83em;
57
- margin-left: 0;
58
- margin-right: 0;
59
- font-weight: bold;}
60
- .editor h3 { font-size:1.17em }
61
- .editor h4 { font-size:1em }
62
- .editor h5 { font-size:0.83em }
63
- .editor h6 { font-size:0.67em }
64
-
65
- .editor { min-height:160px; max-width:478px; padding:12px; border:1px solid #e5e7eb; border-radius:0 0 8px 8px; background:#fff; outline:none;
66
- tab-size: 4;
67
- -moz-tab-size: 4;
68
- word-break: break-word;
69
- }
70
- nile-rte-preview { display:block; margin-top:10px; padding:10px; border:1px dashed #cbd5e1; border-radius:8px; background:#fafafa; max-width:478px; }
71
-
72
- .rte-color-trigger {
73
- display: inline-flex;
4
+ .editor { all: revert; }
5
+
6
+ nile-rich-text-editor {
7
+ position: relative;
8
+ display: block;
9
+ font-family: inherit;
10
+ }
11
+
12
+ /* --- Card 1: Toolbar + Editor --- */
13
+ .rte-container {
14
+ width: 100%;
15
+ border: 1px solid #e5e7eb;
16
+ border-radius: 8px;
17
+ background: #fff;
18
+ box-sizing: border-box;
19
+ }
20
+
21
+ /* Toolbar inside container */
22
+ .rte-container nile-rte-toolbar {
23
+ display: flex;
74
24
  align-items: center;
75
- justify-content: center;
76
- /* border: 1px solid var(--nile-color-border, #d9d9d9); */
77
- border-radius: 6px;
25
+ gap: 6px;
26
+ padding: 8px;
27
+ border-bottom: 1px solid #e5e7eb;
78
28
  background: #fff;
79
- cursor: pointer;
80
- border:none;
81
-
29
+ border-radius: 8px 8px 0 0;
82
30
 
83
- }
84
- nile-button.rte-color-trigger::part(base){
85
- width:32px; height:32px; padding:0px 6px;
86
- }
87
- .rte-color-trigger .glyph-stack {
88
- display: grid; /* stack vertically */
89
- grid-auto-rows: max-content;
90
- align-items: center;
91
- justify-items: center;
92
- line-height: 1;
31
+ width: 100%;
32
+ box-sizing: border-box;
93
33
  }
94
34
 
95
- .rte-color-trigger .glyph {
96
- font-size: 14px;
97
- line-height: 1;
98
- margin-bottom: 2px;
99
- }
100
35
 
101
- .rte-color-trigger .underline {
102
- width: 18px;
103
- height: 3px;
104
- border-radius: 2px;
105
- background: currentColor;
106
- }
107
-
108
-
109
- .rte-color-trigger .swatch-box {
110
- width: 18px;
111
- height: 16px;
112
- border-radius: 4px;
113
- border: 1px solid rgba(0,0,0,0.35);
114
- background: currentColor; /* overridden via JS */
115
- }
116
-
117
-
118
-
119
-
120
- nile-rte-toolbar-item > nile-button[data-active]::part(base) {
121
- background-color: var(--nile-colors-primary-400);
122
- }
123
-
124
- nile-rte-toolbar-item > nile-button[data-active]::part(base):hover {
125
- background-color: var(--nile-colors-primary-500);
36
+ .rte-container .editor {
37
+ min-height: 160px;
38
+ width: 100%;
39
+ padding: 12px;
40
+ background: #fff;
41
+ border-radius: 0 0 8px 8px;
42
+ outline: none;
43
+ tab-size: 4;
44
+ -moz-tab-size: 4;
45
+ word-break: break-word;
46
+ box-sizing: border-box;
47
+ border-radius: 8px;
48
+ }
49
+
50
+ /* --- Card 2: Preview --- */
51
+ /* Preview card */
52
+ nile-rte-preview {
53
+ display: block;
54
+ width: 100%;
55
+ margin-top: 16px;
56
+ padding: 12px;
57
+ border: 1px dashed #e5e7eb;
58
+ border-radius: 8px;
59
+ background: #fafafa;
60
+ box-sizing: border-box;
61
+ word-wrap: break-word;
126
62
  }
127
63
 
128
64
 
129
-
65
+ /* Toolbar button styling */
66
+ nile-rte-toolbar-item nile-button::part(base) {
67
+ width: 32px;
68
+ height: 32px;
69
+ padding: 0px 6px;
70
+ border: none;
71
+ }
72
+
73
+ nile-rte-toolbar-item > button,
74
+ nile-rte-toolbar button {
75
+ border: 1px solid #e5e7eb;
76
+ background: #fff;
77
+ border-radius: 6px;
78
+ cursor: pointer;
79
+ }
80
+
81
+ nile-rte-toolbar-item > button nile-icon { pointer-events: none; }
82
+
83
+ nile-rte-toolbar-item > button.active {
84
+ border-color: #2563eb;
85
+ background: #eff6ff;
86
+ }
87
+
88
+ /* Heading normalization */
89
+ .editor p { margin: 1em 0; }
90
+ .editor h1, .preview h1 {
91
+ font-size: 2em;
92
+ margin: 0.67em 0;
93
+ font-weight: bold;
94
+ }
95
+ .editor h2, .preview h2 {
96
+ font-size: 1.5em;
97
+ margin: 0.83em 0;
98
+ font-weight: bold;
99
+ }
100
+ .editor h3 { font-size: 1.17em; }
101
+ .editor h4 { font-size: 1em; }
102
+ .editor h5 { font-size: 0.83em; }
103
+ .editor h6 { font-size: 0.67em; }
104
+
105
+ /* Single-line variant */
106
+ .editor.single-line {
107
+ min-height: 50px;
108
+ max-height: 50px;
109
+ overflow-x: auto;
110
+ white-space: nowrap;
111
+ padding: 0px 12px 0px 12px;
112
+ scrollbar-width: none;
113
+ -ms-overflow-style: none;
114
+ }
115
+ nile-rte-preview.single-line {
116
+ min-height: 50px;
117
+ max-height: 50px;
118
+ padding: 0px 12px 0px 12px;
119
+ overflow-x: auto;
120
+ white-space: nowrap;
121
+ scrollbar-width: none;
122
+ -ms-overflow-style: none;
123
+ }
124
+ nile-rte-divider {
125
+ margin: 0 4px;
126
+ display: inline-block;
127
+ height: 24px;
128
+ width: 1px;
129
+ background: #E6E9EB;
130
+ }
130
131
  `;
131
132
  export default [styles];
132
133
  //# sourceMappingURL=nile-rich-text-editor.css.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"nile-rich-text-editor.css.js","sourceRoot":"","sources":["../../../src/nile-rich-text-editor/nile-rich-text-editor.css.ts"],"names":[],"mappings":"AAAA,gBAAgB;AAChB,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+HxB,CAAC;AAEF,eAAe,CAAC,MAAM,CAAC,CAAC","sourcesContent":["// rte-styles.ts\nimport { css } from 'lit';\n\nexport const styles = css`\n \n \n .editor {all: revert;}\n\n nile-rich-text-editor { position: relative; display: block; font-family: inherit; }\n\n \nnile-rte-toolbar-item > nile-button::part(base) {\n \n width:32px; height:32px; padding:0px 6px;\n border: none;\n}\n \nnile-rte-preview {\n white-space: normal;\n word-break: break-word;\n}\n\n\n\n .toolbar, nile-rte-toolbar {\n \n width:486px; \n display:flex; align-items:center; gap:6px; padding:8px; \n border:1px solid #e5e7eb; border-bottom:none; border-radius:8px 8px 0 0; background:#fff;\n }\n\n nile-rte-toolbar-item > button, .toolbar button, nile-rte-toolbar button {\n border:1px solid #e5e7eb; background:#fff; border-radius:6px;\n cursor:pointer;\n }\n\n \n /* Ensure clicks hit the button (not nested icon internals) */\n nile-rte-toolbar-item > button nile-icon { pointer-events:none; }\n\n nile-rte-toolbar-item > button.active { border-color:#2563eb; background:#eff6ff; }\n nile-rte-select select { height:32px; border:1px solid #e5e7eb; border-radius:6px; background:#fff; }\n nile-rte-color input[type=\"color\"] { height:32px; width:36px; border:1px solid #e5e7eb; padding:0; border-radius:6px; background:#fff; }\n nile-rte-divider { width:1px; height:20px; background:#e5e7eb; display:inline-block; margin:0 4px; }\n\n .editor p { margin:1em 0; }\n .editor h1, .preview h1 { all: revert; font-size:2em, display: block;\nfont-size: 2em;\nmargin-top: 0.67em;\nmargin-bottom: 0.67em;\nmargin-left: 0;\nmargin-right: 0;\nfont-weight: bold; }\n .editor h2, .preview h2 { all: revert;\tdisplay: block;\nfont-size: 1.5em;\nmargin-top: 0.83em;\nmargin-bottom: 0.83em;\nmargin-left: 0;\nmargin-right: 0;\nfont-weight: bold;}\n .editor h3 { font-size:1.17em }\n .editor h4 { font-size:1em }\n .editor h5 { font-size:0.83em }\n .editor h6 { font-size:0.67em }\n\n .editor { min-height:160px; max-width:478px; padding:12px; border:1px solid #e5e7eb; border-radius:0 0 8px 8px; background:#fff; outline:none; \n tab-size: 4; \n -moz-tab-size: 4; \n word-break: break-word; \n }\n nile-rte-preview { display:block; margin-top:10px; padding:10px; border:1px dashed #cbd5e1; border-radius:8px; background:#fafafa; max-width:478px; }\n\n .rte-color-trigger {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n /* border: 1px solid var(--nile-color-border, #d9d9d9); */\n border-radius: 6px;\n background: #fff;\n cursor: pointer;\n border:none;\n \n\n}\nnile-button.rte-color-trigger::part(base){\n width:32px; height:32px; padding:0px 6px;\n}\n.rte-color-trigger .glyph-stack {\n display: grid; /* stack vertically */\n grid-auto-rows: max-content; \n align-items: center;\n justify-items: center;\n line-height: 1;\n}\n\n.rte-color-trigger .glyph {\n font-size: 14px;\n line-height: 1;\n margin-bottom: 2px; \n}\n\n.rte-color-trigger .underline {\n width: 18px;\n height: 3px;\n border-radius: 2px;\n background: currentColor; \n}\n\n \n.rte-color-trigger .swatch-box {\n width: 18px;\n height: 16px;\n border-radius: 4px;\n border: 1px solid rgba(0,0,0,0.35);\n background: currentColor; /* overridden via JS */\n}\n\n \n\n \nnile-rte-toolbar-item > nile-button[data-active]::part(base) {\n background-color: var(--nile-colors-primary-400);\n}\n\nnile-rte-toolbar-item > nile-button[data-active]::part(base):hover {\n background-color: var(--nile-colors-primary-500); \n}\n\n\n\n`;\n\nexport default [styles];"]}
1
+ {"version":3,"file":"nile-rich-text-editor.css.js","sourceRoot":"","sources":["../../../src/nile-rich-text-editor/nile-rich-text-editor.css.ts"],"names":[],"mappings":"AAAA,qCAAqC;AACrC,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgIxB,CAAC;AAEF,eAAe,CAAC,MAAM,CAAC,CAAC","sourcesContent":["// FILE: src/components/rte-styles.ts\nimport { css } from 'lit';\n\nexport const styles = css`\n .editor { all: revert; }\n\n nile-rich-text-editor {\n position: relative;\n display: block;\n font-family: inherit;\n }\n\n /* --- Card 1: Toolbar + Editor --- */\n .rte-container {\n width: 100%;\n border: 1px solid #e5e7eb;\n border-radius: 8px;\n background: #fff;\n box-sizing: border-box;\n }\n\n /* Toolbar inside container */\n.rte-container nile-rte-toolbar {\n display: flex;\n align-items: center;\n gap: 6px;\n padding: 8px;\n border-bottom: 1px solid #e5e7eb;\n background: #fff;\n border-radius: 8px 8px 0 0;\n\n width: 100%; \n box-sizing: border-box; \n}\n\n\n .rte-container .editor {\n min-height: 160px;\n width: 100%;\n padding: 12px;\n background: #fff;\n border-radius: 0 0 8px 8px;\n outline: none;\n tab-size: 4;\n -moz-tab-size: 4;\n word-break: break-word;\n box-sizing: border-box;\n border-radius: 8px;\n }\n\n /* --- Card 2: Preview --- */\n /* Preview card */\nnile-rte-preview {\n display: block;\n width: 100%;\n margin-top: 16px; \n padding: 12px;\n border: 1px dashed #e5e7eb;\n border-radius: 8px;\n background: #fafafa;\n box-sizing: border-box;\n word-wrap: break-word;\n}\n\n\n /* Toolbar button styling */\n nile-rte-toolbar-item nile-button::part(base) {\n width: 32px;\n height: 32px;\n padding: 0px 6px;\n border: none;\n }\n\n nile-rte-toolbar-item > button,\n nile-rte-toolbar button {\n border: 1px solid #e5e7eb;\n background: #fff;\n border-radius: 6px;\n cursor: pointer;\n }\n\n nile-rte-toolbar-item > button nile-icon { pointer-events: none; }\n\n nile-rte-toolbar-item > button.active {\n border-color: #2563eb;\n background: #eff6ff;\n }\n\n /* Heading normalization */\n .editor p { margin: 1em 0; }\n .editor h1, .preview h1 {\n font-size: 2em;\n margin: 0.67em 0;\n font-weight: bold;\n }\n .editor h2, .preview h2 {\n font-size: 1.5em;\n margin: 0.83em 0;\n font-weight: bold;\n }\n .editor h3 { font-size: 1.17em; }\n .editor h4 { font-size: 1em; }\n .editor h5 { font-size: 0.83em; }\n .editor h6 { font-size: 0.67em; }\n\n /* Single-line variant */\n .editor.single-line {\n min-height: 50px;\n max-height: 50px;\n overflow-x: auto;\n white-space: nowrap;\n padding: 0px 12px 0px 12px;\n scrollbar-width: none;\n -ms-overflow-style: none;\n }\n nile-rte-preview.single-line {\n min-height: 50px;\n max-height: 50px;\n padding: 0px 12px 0px 12px;\n overflow-x: auto;\n white-space: nowrap;\n scrollbar-width: none;\n -ms-overflow-style: none;\n }\n nile-rte-divider { \n margin: 0 4px;\n display: inline-block;\n height: 24px;\n width: 1px;\n background: #E6E9EB;\n }\n`;\n\nexport default [styles];\n"]}
@@ -13,10 +13,8 @@ type MentionsConfig = Record<string, {
13
13
  }[]>;
14
14
  export declare class NileRichTextEditor extends LitElement {
15
15
  protected createRenderRoot(): this;
16
- protected shouldUpdate(): boolean;
17
- /** Initial HTML content */
18
16
  value: string;
19
- /** Optional mentions config (can also be on <nile-rte-mentions mentions="...">) */
17
+ singleLineEditor: boolean;
20
18
  mentions: MentionsConfig;
21
19
  private content;
22
20
  private editorEl;
@@ -30,11 +28,14 @@ export declare class NileRichTextEditor extends LitElement {
30
28
  private bgColorInput;
31
29
  private colorSwatchEl;
32
30
  private bgSwatchEl;
31
+ private containerEl;
33
32
  private mentionsEl;
34
33
  private injectCss;
35
34
  connectedCallback(): void;
35
+ private ensureStructure;
36
36
  private updateContentWithMention;
37
37
  disconnectedCallback(): void;
38
+ protected updated(changed: Map<string, any>): void;
38
39
  private ensureEditor;
39
40
  private unwrapMention;
40
41
  private scrubBrokenMentions;
@@ -12,10 +12,6 @@ import './nile-rte-mentions';
12
12
  import './nile-rte-link';
13
13
  import { closestBlock, nearestElement, rgbToHex, toggleInlineTag, setBlockTag, setAlignment, setFontFamily, setForeColor, setBackColor, } from './utils';
14
14
  import { styles } from './nile-rich-text-editor.css';
15
- /**
16
- * Map commands → default icon names from your <nile-icon> set.
17
- * Adjust values to match the real names you have.
18
- */
19
15
  const DEFAULT_ICONS = {
20
16
  bold: 'format_bold',
21
17
  italic: 'format_italic',
@@ -32,16 +28,14 @@ const DEFAULT_ICONS = {
32
28
  let NileRichTextEditor = class NileRichTextEditor extends LitElement {
33
29
  constructor() {
34
30
  super(...arguments);
35
- /** Initial HTML content */
31
+ // protected shouldUpdate() { return false; }
36
32
  this.value = '';
37
- /** Optional mentions config (can also be on <nile-rte-mentions mentions="...">) */
33
+ this.singleLineEditor = false;
38
34
  this.mentions = {};
39
- // ----- internal state (no Lit render) -----
40
35
  this.content = '';
41
36
  this.previewEl = null;
42
37
  this.toolbarEl = null;
43
38
  this.lastRange = null;
44
- // map for button active reflections
45
39
  this.buttonMap = new Map();
46
40
  this.headingSelect = null;
47
41
  this.fontSelect = null;
@@ -49,9 +43,23 @@ let NileRichTextEditor = class NileRichTextEditor extends LitElement {
49
43
  this.bgColorInput = null;
50
44
  this.colorSwatchEl = null;
51
45
  this.bgSwatchEl = null;
52
- // Mentions controller (child)
46
+ this.containerEl = null;
53
47
  this.mentionsEl = null;
54
48
  this.onEditorKeydown = (e) => {
49
+ if (this.singleLineEditor && e.key === 'Enter' && e.shiftKey) {
50
+ e.preventDefault();
51
+ return;
52
+ }
53
+ if (e.ctrlKey && e.key.toLowerCase() === 'i') {
54
+ e.preventDefault();
55
+ toggleInlineTag(this.editorEl, 'em');
56
+ this.updateContent();
57
+ this.updateToolbarState();
58
+ }
59
+ if (this.singleLineEditor && e.key === 'Enter') {
60
+ e.preventDefault();
61
+ return;
62
+ }
55
63
  if (e.key !== 'Tab')
56
64
  return;
57
65
  e.preventDefault();
@@ -104,7 +112,6 @@ let NileRichTextEditor = class NileRichTextEditor extends LitElement {
104
112
  };
105
113
  }
106
114
  createRenderRoot() { return this; }
107
- shouldUpdate() { return false; }
108
115
  injectCss(cssText) {
109
116
  if (this.querySelector('style[data-rte-style]'))
110
117
  return;
@@ -116,9 +123,7 @@ let NileRichTextEditor = class NileRichTextEditor extends LitElement {
116
123
  connectedCallback() {
117
124
  super.connectedCallback();
118
125
  this.injectCss(styles.cssText);
119
- this.toolbarEl = this.querySelector('nile-rte-toolbar');
120
- this.previewEl = this.querySelector('nile-rte-preview');
121
- this.ensureEditor();
126
+ this.ensureStructure();
122
127
  if (this.value && !this.editorEl.innerHTML.trim()) {
123
128
  this.editorEl.innerHTML = this.value;
124
129
  }
@@ -133,11 +138,35 @@ let NileRichTextEditor = class NileRichTextEditor extends LitElement {
133
138
  this.wireEditor();
134
139
  this.updateToolbarState();
135
140
  this.syncPreview();
136
- document.addEventListener('selectionchange', this.onSelectionChange, true);
137
- if (this.mentionsEl) {
138
- this.mentionsEl.addEventListener('mention-selected', (e) => {
139
- this.updateContentWithMention(e.detail);
140
- });
141
+ }
142
+ ensureStructure() {
143
+ this.toolbarEl = this.querySelector('nile-rte-toolbar');
144
+ this.previewEl = this.querySelector('nile-rte-preview');
145
+ // container for toolbar + editor
146
+ this.containerEl = this.querySelector('.rte-container');
147
+ if (!this.containerEl) {
148
+ this.containerEl = document.createElement('div');
149
+ this.containerEl.className = 'rte-container';
150
+ this.appendChild(this.containerEl);
151
+ }
152
+ // ensure editor
153
+ this.ensureEditor();
154
+ // put toolbar + editor inside container
155
+ if (this.toolbarEl && this.toolbarEl.parentElement !== this.containerEl) {
156
+ this.containerEl.appendChild(this.toolbarEl);
157
+ }
158
+ if (this.editorEl.parentElement !== this.containerEl) {
159
+ this.containerEl.appendChild(this.editorEl);
160
+ }
161
+ // 👉 move preview OUTSIDE container, right after it
162
+ if (this.previewEl) {
163
+ if (this.previewEl.parentElement !== this) {
164
+ this.appendChild(this.previewEl);
165
+ }
166
+ // ensure preview is placed AFTER container
167
+ if (this.previewEl.previousElementSibling !== this.containerEl) {
168
+ this.insertBefore(this.previewEl, this.containerEl.nextSibling);
169
+ }
141
170
  }
142
171
  }
143
172
  updateContentWithMention(mentionDetail) {
@@ -158,27 +187,27 @@ let NileRichTextEditor = class NileRichTextEditor extends LitElement {
158
187
  }
159
188
  super.disconnectedCallback();
160
189
  }
190
+ updated(changed) {
191
+ if (changed.has('singleLineEditor')) {
192
+ if (this.editorEl) {
193
+ this.editorEl.classList.toggle('single-line', this.singleLineEditor);
194
+ }
195
+ if (this.previewEl) {
196
+ this.previewEl.classList.toggle('single-line', this.singleLineEditor);
197
+ }
198
+ }
199
+ }
161
200
  ensureEditor() {
162
201
  this.editorEl = this.querySelector('.editor');
163
202
  if (!this.editorEl) {
164
203
  const editor = document.createElement('article');
165
204
  editor.className = 'editor';
166
205
  editor.setAttribute('contenteditable', 'true');
167
- if (this.toolbarEl?.nextSibling) {
168
- this.insertBefore(editor, this.toolbarEl.nextSibling);
169
- }
170
- else if (this.previewEl) {
171
- this.insertBefore(editor, this.previewEl);
172
- }
173
- else {
174
- this.appendChild(editor);
175
- }
176
206
  this.editorEl = editor;
177
207
  }
178
208
  if (!this.editorEl.innerHTML.trim()) {
179
209
  this.editorEl.innerHTML = '<p><br></p>';
180
210
  }
181
- this.ensureAtLeastOneParagraph();
182
211
  }
183
212
  unwrapMention(span, preserveText = true) {
184
213
  const parent = span.parentNode;
@@ -277,9 +306,13 @@ let NileRichTextEditor = class NileRichTextEditor extends LitElement {
277
306
  btn.innerHTML = child.innerHTML;
278
307
  child.innerHTML = '';
279
308
  }
280
- // Mount it
281
- if (!btn.isConnected)
282
- child.appendChild(btn);
309
+ // Mount button inside tooltip
310
+ if (!btn.isConnected) {
311
+ const tooltip = document.createElement('nile-tooltip');
312
+ tooltip.setAttribute('content', label);
313
+ tooltip.appendChild(btn);
314
+ child.appendChild(tooltip);
315
+ }
283
316
  // Interactions
284
317
  btn.setAttribute('aria-label', label);
285
318
  btn.addEventListener('mousedown', e => e.preventDefault());
@@ -621,6 +654,9 @@ let NileRichTextEditor = class NileRichTextEditor extends LitElement {
621
654
  __decorate([
622
655
  property({ type: String })
623
656
  ], NileRichTextEditor.prototype, "value", void 0);
657
+ __decorate([
658
+ property({ type: Boolean, attribute: 'singlelineeditor' })
659
+ ], NileRichTextEditor.prototype, "singleLineEditor", void 0);
624
660
  __decorate([
625
661
  property({
626
662
  attribute: 'mentions',