@libs-ui/components-preview-text-data 0.2.357-4 → 0.2.357-41

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.
@@ -2,15 +2,19 @@ import * as i0 from '@angular/core';
2
2
  import { signal, inject, DestroyRef, computed, input, model, output, viewChild, effect, Component, ChangeDetectionStrategy } from '@angular/core';
3
3
  import { linter, lintGutter } from '@codemirror/lint';
4
4
  import { EditorState, Transaction, Compartment, Prec } from '@codemirror/state';
5
- import { EditorView, lineNumbers } from '@codemirror/view';
5
+ import { runScopeHandlers, EditorView, lineNumbers } from '@codemirror/view';
6
6
  import { LibsUiComponentsButtonsButtonComponent } from '@libs-ui/components-buttons-button';
7
7
  import { LibsUiComponentsDropdownComponent } from '@libs-ui/components-dropdown';
8
8
  import { LibsUiNotificationService } from '@libs-ui/services-notification';
9
+ import * as i1 from '@ngx-translate/core';
10
+ import { TranslateService, TranslateModule } from '@ngx-translate/core';
11
+ import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
9
12
  import { basicSetup } from 'codemirror6';
10
13
  import { returnListObject } from '@libs-ui/services-http-request';
11
14
  import { UtilsHttpParamsRequest, get } from '@libs-ui/utils';
12
- import { syntaxTree } from '@codemirror/language';
15
+ import { syntaxTree, ensureSyntaxTree } from '@codemirror/language';
13
16
  import { autocompletion } from '@codemirror/autocomplete';
17
+ import { getSearchQuery, findPrevious, findNext, selectMatches, closeSearchPanel, replaceNext, replaceAll, setSearchQuery, SearchQuery, search } from '@codemirror/search';
14
18
 
15
19
  /**
16
20
  * Danh sách các ngôn ngữ được hỗ trợ
@@ -154,6 +158,35 @@ const DEFAULT_SECURITY_PATTERNS = [
154
158
  /document\.write\s*\(/i,
155
159
  /window\.location\s*=/i,
156
160
  ];
161
+ /**
162
+ * Bộ pattern chặn mặc định cho ô soạn **SQL** — dùng với `[forbiddenPatterns]`.
163
+ *
164
+ * 🔴 `DEFAULT_SECURITY_PATTERNS` ở trên CHỈ chặn API JavaScript (`eval`, `fetch`, `localStorage`…)
165
+ * nên không dùng được cho SQL. Bộ này chặn câu lệnh GHI và truy vấn siêu dữ liệu, dành cho các màn
166
+ * chỉ cho phép đọc (BI, dashboard, báo cáo).
167
+ *
168
+ * 🔴 Đây là lớp THUẬN TIỆN cho người dùng — báo sớm ngay khi gõ sai loại câu lệnh, KHÔNG phải lớp
169
+ * bảo mật: người dùng vẫn gọi API trực tiếp được. Backend BẮT BUỘC tự kiểm lại.
170
+ *
171
+ * Màn thật sự cần chạy câu lệnh ghi thì tự truyền bộ pattern riêng, hoặc lọc bớt bộ này:
172
+ * `DEFAULT_SQL_FORBIDDEN_PATTERNS.filter((p) => !String(p).includes('delete'))`.
173
+ */
174
+ const DEFAULT_SQL_FORBIDDEN_PATTERNS = [
175
+ // Câu lệnh đổi lược đồ.
176
+ /\b(drop|truncate|alter|create)\b/i,
177
+ // Câu lệnh ghi dữ liệu.
178
+ /\b(delete|update|insert)\b/i,
179
+ // Câu lệnh đổi quyền.
180
+ /\b(grant|revoke)\b/i,
181
+ // Ghi kết quả ra tệp trên máy chủ cơ sở dữ liệu.
182
+ /\binto\s+outfile\b/i,
183
+ // Đọc siêu dữ liệu — lộ toàn bộ danh sách bảng/cột của hệ thống.
184
+ /\binformation_schema\b/i,
185
+ // Bảng/hàm hệ thống của PostgreSQL.
186
+ /\bpg_[a-z_]+\b/i,
187
+ // Dấu chấm phẩy rồi còn nội dung phía sau ⇒ nối thêm câu lệnh thứ hai.
188
+ /;\s*\S/,
189
+ ];
157
190
  /**
158
191
  * Các key của AST node KHÔNG phải node con (metadata vị trí, comment...) — bỏ qua khi duyệt.
159
192
  */
@@ -564,13 +597,30 @@ const buildSqlErrorMessage = (doc, node) => {
564
597
  return 'Missing closing ")"';
565
598
  return `Unexpected end of SQL after "${prevToken}"`;
566
599
  };
600
+ /**
601
+ * Lỗi Lezer rơi đúng vào dấu `_` MỞ ĐẦU một tên (`b._id`, `_id`) — báo oan.
602
+ *
603
+ * 🔴 `@codemirror/lang-sql` 6.10 chỉ nhận chữ/số làm ký tự đầu tên (`isAlpha` bỏ `_`), nên tên hợp lệ
604
+ * như `b._id` bị vẽ chấm đỏ (người dùng chỉ ra 30/09/2026). `_` đứng SAU chữ/số là giữa tên, không đụng.
605
+ */
606
+ const isUnderscoreIdentifierStart = (doc, pos) => pos < doc.length && doc.sliceString(pos, pos + 1) === '_' && !/\w/.test(pos > 0 ? doc.sliceString(pos - 1, pos) : '');
607
+ /**
608
+ * Đoạn chữ NGAY TẠI vị trí lỗi khớp một mẫu token do ỨNG DỤNG tự thay trước khi chạy (vd `$sqlCard.ma_dn` của mobio-web)
609
+ * — báo oan, bỏ qua. Mẫu do nơi dùng truyền vào qua input `syntaxIgnoreTokens`: thư viện không biết token của dự án nào.
610
+ */
611
+ const isIgnoredTokenAt = (doc, pos, patterns) => {
612
+ if (!patterns.length || pos >= doc.length)
613
+ return false;
614
+ const text = doc.sliceString(pos, Math.min(doc.length, pos + 200));
615
+ return patterns.some((pattern) => new RegExp(`^(?:${pattern.source})`, pattern.flags.replace(/[gy]/g, '')).test(text));
616
+ };
567
617
  /** Phát hiện lỗi cú pháp SQL từ error node của syntaxTree (Lezer). */
568
- const computeSqlDiagnostics = (view) => {
618
+ const computeSqlDiagnostics = (view, ignoreTokens = []) => {
569
619
  const diagnostics = [];
570
620
  const doc = view.state.doc;
571
621
  syntaxTree(view.state).iterate({
572
622
  enter: (node) => {
573
- if (!node.type.isError)
623
+ if (!node.type.isError || isUnderscoreIdentifierStart(doc, node.from) || isIgnoredTokenAt(doc, node.from, ignoreTokens))
574
624
  return;
575
625
  diagnostics.push({ from: Math.max(0, node.from - 1), to: node.from, severity: 'error', message: buildSqlErrorMessage(doc, node) });
576
626
  },
@@ -635,15 +685,20 @@ const computePythonDiagnostics = (view) => {
635
685
  */
636
686
  const buildCompletionExtension = (items) => {
637
687
  const completionSource = (context) => {
638
- const dotMatch = context.matchBefore(/\w+\.\w*/);
688
+ // Cho phép path nhiều cấp (a.b.c.) — [\w.]+ bắt trọn chuỗi trước con trỏ.
689
+ const dotMatch = context.matchBefore(/[\w.]+\.\w*/);
639
690
  if (dotMatch) {
640
- const dotPos = dotMatch.text.indexOf('.');
641
- const objectName = dotMatch.text.slice(0, dotPos);
642
- const parent = items.find((i) => i.label === objectName);
643
- if (parent?.properties?.length) {
691
+ const segments = dotMatch.text.split('.');
692
+ const partial = segments[segments.length - 1]; // phần đang gõ dở sau dấu '.' cuối
693
+ const pathSegments = segments.slice(0, -1); // các cấp đã hoàn tất
694
+ let current = items.find((item) => item.label === pathSegments[0]);
695
+ for (let level = 1; level < pathSegments.length && current; level++) {
696
+ current = current.properties?.find((property) => property.label === pathSegments[level]);
697
+ }
698
+ if (current?.properties?.length) {
644
699
  return {
645
- from: dotMatch.from + dotPos + 1,
646
- options: parent.properties.map((p) => ({ label: p.label, type: p.type ?? 'property', detail: p.detail ?? '', info: p.info ?? '' })),
700
+ from: context.pos - partial.length,
701
+ options: current.properties.map((p) => ({ label: p.label, type: p.type ?? 'property', detail: p.detail ?? '', info: p.info ?? '' })),
647
702
  };
648
703
  }
649
704
  }
@@ -666,60 +721,257 @@ const toGlobalRegex = (pattern) => {
666
721
  }
667
722
  return new RegExp(escapeRegex(pattern), 'gi');
668
723
  };
724
+ /** Thời gian tối đa (ms) chờ parser dựng xong cây cú pháp của văn bản vừa dán. */
725
+ const pasteParseTimeout = 200;
669
726
  /**
670
- * Extension bảo mật gồm 2 layer:
671
- * 1. Linter: highlight đỏ tại đúng vị trí match (bỏ qua match trong comment) + gọi `emitViolations`.
672
- * 2. Transaction filter: chặn paste nếu nội dung paste chứa pattern cấm.
727
+ * Tìm mọi vị trí khớp pattern cấm, BỎ QUA match nằm trọn trong comment.
728
+ *
729
+ * Dùng chung cho linter và bộ chặn dán: trước đây bộ chặn dán kiểm cả comment nên một chú thích
730
+ * kiểu `-- 1 dòng / KH; KH …` khớp `/;\s*\S/` là cả lần dán bị huỷ im lặng, trong khi linter lại
731
+ * không gạch đỏ chỗ nào — người dùng không có cách nào biết vì sao dán không được.
732
+ *
733
+ * `fullParse`: ép parser dựng hết cây trước khi dò comment. Bộ chặn dán cần cờ này vì state mới
734
+ * vừa tạo chưa được parse — thiếu nó thì comment ở cuối văn bản dài không được nhận ra.
673
735
  */
674
- const buildForbiddenExtension = (patterns, emitViolations) => {
675
- const forbiddenLinter = linter((view) => {
676
- const diagnostics = [];
677
- const violations = [];
678
- const text = view.state.doc.toString();
679
- const commentRanges = [];
680
- syntaxTree(view.state).iterate({
681
- enter: (node) => {
682
- if (node.type.name.toLowerCase().includes('comment')) {
683
- commentRanges.push({ from: node.from, to: node.to });
684
- }
685
- },
686
- });
687
- const isInComment = (from, to) => commentRanges.some((r) => from >= r.from && to <= r.to);
688
- for (const pattern of patterns) {
689
- const re = toGlobalRegex(pattern);
690
- re.lastIndex = 0;
691
- let match;
692
- while ((match = re.exec(text)) !== null) {
693
- const from = match.index;
694
- const to = from + match[0].length;
695
- if (isInComment(from, to))
696
- continue;
697
- const line = view.state.doc.lineAt(from).number;
698
- const patternLabel = pattern instanceof RegExp ? pattern.source : pattern;
699
- diagnostics.push({ from, to, severity: 'error', message: `Mã bị cấm: "${match[0]}" — vi phạm chính sách bảo mật` });
700
- violations.push({ from, to, line, pattern: patternLabel, matched: match[0] });
736
+ const findForbiddenMatches = (state, patterns, fullParse = false) => {
737
+ const text = state.doc.toString();
738
+ const tree = (fullParse ? ensureSyntaxTree(state, state.doc.length, pasteParseTimeout) : null) ?? syntaxTree(state);
739
+ const commentRanges = [];
740
+ tree.iterate({
741
+ enter: (node) => {
742
+ if (node.type.name.toLowerCase().includes('comment')) {
743
+ commentRanges.push({ from: node.from, to: node.to });
701
744
  }
745
+ },
746
+ });
747
+ const violations = [];
748
+ for (const pattern of patterns) {
749
+ const re = toGlobalRegex(pattern);
750
+ re.lastIndex = 0;
751
+ let match;
752
+ while ((match = re.exec(text)) !== null) {
753
+ const from = match.index;
754
+ const to = from + match[0].length;
755
+ // Regex khớp chuỗi rỗng thì exec đứng yên tại chỗ — nhích lên để không lặp vô hạn, và bỏ qua
756
+ // vì match rỗng không chỉ ra đoạn mã nào để cấm.
757
+ if (!match[0].length) {
758
+ re.lastIndex++;
759
+ continue;
760
+ }
761
+ if (commentRanges.some((r) => from >= r.from && to <= r.to))
762
+ continue;
763
+ const patternLabel = pattern instanceof RegExp ? pattern.source : pattern;
764
+ violations.push({ from, to, line: state.doc.lineAt(from).number, pattern: patternLabel, matched: match[0] });
702
765
  }
766
+ }
767
+ return violations;
768
+ };
769
+ /**
770
+ * Extension bảo mật gồm 2 layer, cùng bỏ qua match nằm trong comment:
771
+ * 1. Linter: highlight đỏ tại đúng vị trí match + gọi `emitViolations`.
772
+ * 2. Transaction filter: chặn paste nếu văn bản sau khi dán có match cấm ngoài comment.
773
+ */
774
+ const buildForbiddenExtension = (patterns, emitViolations) => {
775
+ const forbiddenLinter = linter((view) => {
776
+ const violations = findForbiddenMatches(view.state, patterns);
703
777
  emitViolations(violations);
704
- return diagnostics;
778
+ return violations.map((item) => ({ from: item.from, to: item.to, severity: 'error', message: `Mã bị cấm: "${item.matched}" — vi phạm chính sách bảo mật` }));
705
779
  });
706
780
  const pasteFilter = EditorState.transactionFilter.of((tr) => {
707
781
  if (!tr.docChanged)
708
782
  return tr;
709
783
  if (!tr.annotation(Transaction.userEvent)?.startsWith('input.paste'))
710
784
  return tr;
711
- const newText = tr.newDoc.toString();
712
- for (const pattern of patterns) {
713
- const re = toGlobalRegex(pattern);
714
- re.lastIndex = 0;
715
- if (re.test(newText))
716
- return [];
717
- }
718
- return tr;
785
+ return findForbiddenMatches(tr.state, patterns, true).length ? [] : tr;
719
786
  });
720
787
  return [forbiddenLinter, pasteFilter];
721
788
  };
722
789
 
790
+ /** Đếm tối đa bấy nhiêu chỗ khớp — câu lệnh rất dài mà đếm hết thì mỗi phím gõ đều khựng. */
791
+ const searchCountLimit = 999;
792
+ const searchToggles = [
793
+ { name: 'case', label: 'Aa', phrase: 'match case' },
794
+ { name: 'word', label: 'ab', phrase: 'by word' },
795
+ { name: 're', label: '.*', phrase: 'regexp' },
796
+ ];
797
+ const createElement = (tag, className, attributes = {}) => {
798
+ const element = document.createElement(tag);
799
+ element.className = className;
800
+ Object.entries(attributes).forEach(([key, value]) => element.setAttribute(key, value));
801
+ return element;
802
+ };
803
+ /** Vị trí chỗ khớp đang chọn / tổng số chỗ khớp — `current` = 0 khi con trỏ chưa đứng trên chỗ khớp nào. */
804
+ const countMatches = (state, query) => {
805
+ if (!query.valid) {
806
+ return { current: 0, total: 0 };
807
+ }
808
+ const { from, to } = state.selection.main;
809
+ const cursor = query.getCursor(state);
810
+ let total = 0;
811
+ let current = 0;
812
+ for (let next = cursor.next(); !next.done && total < searchCountLimit; next = cursor.next()) {
813
+ total++;
814
+ if (next.value.from === from && next.value.to === to) {
815
+ current = total;
816
+ }
817
+ }
818
+ return { current, total };
819
+ };
820
+ /**
821
+ * Khung tìm/thay thế (Ctrl + F) dựng lại thay khung mặc định của `@codemirror/search`.
822
+ *
823
+ * 🔴 Khung mặc định xếp ô, nút và ô tích nối đuôi nhau bằng `<br>` — rộng thì hàng Thay dính lên hàng Tìm, hẹp thì
824
+ * ô tích chen vào giữa, CSS không sắp nổi (người dùng chỉ ra 30/09/2026). Tự dựng DOM để bố cục cố định hai hàng.
825
+ * Chữ lấy qua `state.phrase` — nơi dùng cấp bản dịch bằng `EditorState.phrases`.
826
+ */
827
+ class LibsUiSearchPanel {
828
+ view;
829
+ dom;
830
+ top = false;
831
+ query;
832
+ searchField;
833
+ replaceField;
834
+ countLabel;
835
+ toggleButtons = new Map();
836
+ navigateButtons = [];
837
+ constructor(view) {
838
+ this.view = view;
839
+ const phrase = (text) => view.state.phrase(text);
840
+ this.query = getSearchQuery(view.state);
841
+ this.dom = createElement('div', 'libs-ui-cm-search');
842
+ this.dom.addEventListener('keydown', (event) => this.handlerKeydown(event));
843
+ // Lưới 2 hàng kiểu Sublime: [nhãn] [ô nhập giãn hết] [nút] [nút] [✕] — hai hàng thẳng cột tuyệt đối.
844
+ // Hàng 1: Tìm — trong ô có số kết quả · ↑ ↓ · Aa ab .*; nút "Tìm tiếp" · "Chọn tất cả".
845
+ // Hàng 2: Thay — nút "Thay" · "Thay tất cả". Ô chỉ đọc thì không có hàng 2.
846
+ const searchBox = createElement('div', 'libs-ui-cm-search-field', { 'data-area': 'find-field' });
847
+ this.searchField = this.createInput('search', phrase('Find'), this.query.search);
848
+ this.searchField.setAttribute('main-field', 'true');
849
+ this.countLabel = createElement('span', 'libs-ui-cm-search-count');
850
+ searchBox.append(createElement('i', 'libs-ui-icon-search libs-ui-cm-search-field-icon'), this.searchField, this.countLabel, this.createIconButton('prev', 'libs-ui-icon-chevron-right', phrase('previous'), () => findPrevious(view), true), this.createIconButton('next', 'libs-ui-icon-chevron-right', phrase('next'), () => findNext(view), true), createElement('span', 'libs-ui-cm-search-divider'));
851
+ for (const toggle of searchToggles) {
852
+ const button = createElement('button', 'libs-ui-cm-search-toggle', { type: 'button', name: toggle.name, title: phrase(toggle.phrase), 'aria-label': phrase(toggle.phrase) });
853
+ button.textContent = toggle.label;
854
+ button.addEventListener('click', () => {
855
+ button.setAttribute('aria-pressed', String(button.getAttribute('aria-pressed') !== 'true'));
856
+ this.commit();
857
+ });
858
+ this.toggleButtons.set(toggle.name, button);
859
+ searchBox.append(button);
860
+ }
861
+ this.dom.append(this.createLabel(phrase('Find:'), 'find-label'), searchBox, this.createTextButton('findNext', phrase('Find next'), () => findNext(view), 'is-primary'), this.createTextButton('select', phrase('all'), () => selectMatches(view)), this.createIconButton('close', 'libs-ui-icon-close', phrase('close'), () => closeSearchPanel(view)));
862
+ this.replaceField = this.createInput('replace', phrase('Replace'), this.query.replace);
863
+ if (!view.state.readOnly) {
864
+ const replaceBox = createElement('div', 'libs-ui-cm-search-field', { 'data-area': 'replace-field' });
865
+ replaceBox.append(createElement('i', 'libs-ui-icon-move-right libs-ui-cm-search-field-icon'), this.replaceField);
866
+ this.dom.append(this.createLabel(phrase('Replace:'), 'replace-label'), replaceBox, this.createTextButton('replace', phrase('replace'), () => replaceNext(view)), this.createTextButton('replaceAll', phrase('replace all'), () => replaceAll(view)));
867
+ }
868
+ this.syncToggles();
869
+ this.renderCount(view.state);
870
+ }
871
+ mount() {
872
+ this.searchField.select();
873
+ }
874
+ update(update) {
875
+ let queryChanged = false;
876
+ for (const transaction of update.transactions) {
877
+ for (const effect of transaction.effects) {
878
+ if (effect.is(setSearchQuery) && !effect.value.eq(this.query)) {
879
+ this.query = effect.value;
880
+ this.searchField.value = this.query.search;
881
+ this.replaceField.value = this.query.replace;
882
+ this.syncToggles();
883
+ queryChanged = true;
884
+ }
885
+ }
886
+ }
887
+ if (queryChanged || update.docChanged || update.selectionSet) {
888
+ this.renderCount(update.state);
889
+ }
890
+ }
891
+ createLabel(text, area) {
892
+ const label = createElement('span', 'libs-ui-cm-search-label', { 'data-area': area });
893
+ label.textContent = text;
894
+ return label;
895
+ }
896
+ createInput(name, placeholder, value) {
897
+ const input = createElement('input', 'libs-ui-cm-search-input', { name, placeholder, 'aria-label': placeholder, form: '', autocomplete: 'off', spellcheck: 'false' });
898
+ input.value = value;
899
+ input.addEventListener('input', () => this.commit());
900
+ return input;
901
+ }
902
+ createIconButton(name, iconClass, title, action, isNavigate = false) {
903
+ const button = createElement('button', 'libs-ui-cm-search-icon-button', { type: 'button', name, title, 'aria-label': title });
904
+ button.append(createElement('i', iconClass));
905
+ button.addEventListener('click', action);
906
+ if (isNavigate) {
907
+ this.navigateButtons.push(button);
908
+ }
909
+ return button;
910
+ }
911
+ createTextButton(name, label, action, variant = '') {
912
+ const button = createElement('button', `libs-ui-cm-search-button ${variant}`.trim(), { type: 'button', name });
913
+ button.textContent = label;
914
+ button.addEventListener('click', action);
915
+ return button;
916
+ }
917
+ isToggleOn(name) {
918
+ return this.toggleButtons.get(name)?.getAttribute('aria-pressed') === 'true';
919
+ }
920
+ syncToggles() {
921
+ this.toggleButtons.get('case')?.setAttribute('aria-pressed', String(this.query.caseSensitive));
922
+ this.toggleButtons.get('word')?.setAttribute('aria-pressed', String(this.query.wholeWord));
923
+ this.toggleButtons.get('re')?.setAttribute('aria-pressed', String(this.query.regexp));
924
+ }
925
+ commit() {
926
+ const query = new SearchQuery({
927
+ search: this.searchField.value,
928
+ replace: this.replaceField.value,
929
+ caseSensitive: this.isToggleOn('case'),
930
+ wholeWord: this.isToggleOn('word'),
931
+ regexp: this.isToggleOn('re'),
932
+ });
933
+ if (query.eq(this.query)) {
934
+ return;
935
+ }
936
+ this.query = query;
937
+ this.view.dispatch({ effects: setSearchQuery.of(query) });
938
+ // `update` bỏ qua hiệu ứng của chính mình (query đã trùng) — phải tự vẽ lại số đếm, không thì gõ xong vẫn trống.
939
+ this.renderCount(this.view.state);
940
+ }
941
+ renderCount(state) {
942
+ const { current, total } = countMatches(state, this.query);
943
+ const hasKeyword = this.query.search.length > 0;
944
+ const totalLabel = total >= searchCountLimit ? `${searchCountLimit}+` : `${total}`;
945
+ // Con trỏ đứng trên một chỗ khớp ⇒ "2/8"; chưa đứng ⇒ "8 kết quả" (kiểu "–/8" người đọc không hiểu).
946
+ const matchText = current ? `${current}/${totalLabel}` : state.phrase('$1 results', totalLabel);
947
+ this.countLabel.textContent = hasKeyword ? (total ? matchText : state.phrase('No results')) : '';
948
+ this.countLabel.classList.toggle('is-empty', hasKeyword && !total);
949
+ this.countLabel.classList.toggle('is-hidden', !hasKeyword);
950
+ this.searchField.parentElement?.classList.toggle('is-invalid', hasKeyword && (!total || !this.query.valid));
951
+ this.navigateButtons.forEach((button) => (button.disabled = !total));
952
+ }
953
+ handlerKeydown(event) {
954
+ if (runScopeHandlers(this.view, event, 'search-panel')) {
955
+ event.preventDefault();
956
+ return;
957
+ }
958
+ if (event.key !== 'Enter') {
959
+ return;
960
+ }
961
+ if (event.target === this.searchField) {
962
+ event.preventDefault();
963
+ (event.shiftKey ? findPrevious : findNext)(this.view);
964
+ return;
965
+ }
966
+ if (event.target === this.replaceField) {
967
+ event.preventDefault();
968
+ replaceNext(this.view);
969
+ }
970
+ }
971
+ }
972
+ /** Extension khung tìm/thay thế của ô soạn — thay khung mặc định của `@codemirror/search`. */
973
+ const buildSearchPanelExtension = () => search({ createPanel: (view) => new LibsUiSearchPanel(view) });
974
+
723
975
  /** Parse giá trị CSS px → number. Trả về undefined nếu không phải px hợp lệ (vd `none`, `0`). */
724
976
  const parsePx = (raw) => {
725
977
  if (!raw || !raw.endsWith('px')) {
@@ -728,6 +980,59 @@ const parsePx = (raw) => {
728
980
  const value = parseFloat(raw);
729
981
  return Number.isFinite(value) && value > 0 ? value : undefined;
730
982
  };
983
+ /**
984
+ * Chiều cao MỘT dòng, lấy từ CSS `line-height` của vùng nội dung.
985
+ *
986
+ * 🔴 KHÔNG đo `getBoundingClientRect()` của `.cm-line`: số đó phụ thuộc thời điểm gọi và cho ra
987
+ * hàng loạt giá trị sai khi editor vừa dựng — đo trên modal 08–09/09/2026 với dòng thật `18.19px`
988
+ * đã gặp `5.82` · `11.61` · `15.88` · `24` · `59`, mỗi lần mở một số khác. `defaultLineHeight` của
989
+ * CodeMirror cũng không dùng được vì là số mặc định (20/24px), không theo font sản phẩm.
990
+ *
991
+ * `line-height` trong CSS thì có ngay khi phần tử gắn vào DOM và không đổi theo thời điểm đọc.
992
+ */
993
+ const readLineHeight = (view) => {
994
+ const style = getComputedStyle(view.contentDOM);
995
+ const lineHeight = parseFloat(style.lineHeight);
996
+ if (Number.isFinite(lineHeight) && lineHeight > 0) {
997
+ return lineHeight;
998
+ }
999
+ // `line-height: normal` → suy ra từ cỡ chữ, hệ số 1.4 là mức CodeMirror dùng cho editor.
1000
+ const fontSize = parseFloat(style.fontSize);
1001
+ if (Number.isFinite(fontSize) && fontSize > 0) {
1002
+ return fontSize * 1.4;
1003
+ }
1004
+ return view.defaultLineHeight || 20;
1005
+ };
1006
+ /**
1007
+ * Chạy `apply` khi đã CÓ dòng thật để đo.
1008
+ *
1009
+ * Vì sao không chỉ chờ `document.fonts.ready`: editor có thể dựng SAU lúc font đã nạp (vd ô JSON chỉ
1010
+ * hiện khi người dùng bấm chạy thử). Lúc đó `fonts.ready` giải quyết ngay nhưng `.cm-line` chưa
1011
+ * render, phép đo rơi vào `defaultLineHeight` — đo 08/09/2026: khung JSON thành 895px (48 dòng)
1012
+ * thay vì 281px. Nên: chờ cả font VÀ dòng đầu tiên xuất hiện, thử lại tối đa `SO_LAN_THU` nhịp.
1013
+ */
1014
+ const SO_LAN_THU_DO = 30;
1015
+ const runWhenFontReady = (view, apply) => {
1016
+ const fonts = typeof document === 'undefined' ? undefined : document.fonts;
1017
+ const doKhiSanSang = (conLai) => {
1018
+ // Chỉ cần vùng nội dung đã gắn vào DOM là `line-height` đọc được — không cần chờ vẽ dòng.
1019
+ if (view.contentDOM.isConnected) {
1020
+ apply();
1021
+ return;
1022
+ }
1023
+ if (conLai <= 0) {
1024
+ // Hết nhịp chờ vẫn chưa có dòng thật — đo bằng số dự phòng, thà lệch hơn không chặn chiều cao.
1025
+ apply();
1026
+ return;
1027
+ }
1028
+ requestAnimationFrame(() => doKhiSanSang(conLai - 1));
1029
+ };
1030
+ if (!fonts?.ready) {
1031
+ doKhiSanSang(SO_LAN_THU_DO);
1032
+ return;
1033
+ }
1034
+ fonts.ready.then(() => doKhiSanSang(SO_LAN_THU_DO)).catch(() => doKhiSanSang(SO_LAN_THU_DO));
1035
+ };
731
1036
  /** Bù dòng trống cho đủ `minLines` (xử lý 1 lần khi khởi tạo). Đủ rồi giữ nguyên, không cắt bớt. */
732
1037
  const applyMinLines = (content, minLines) => {
733
1038
  const value = content ?? '';
@@ -751,10 +1056,9 @@ const applyContainerHeight = (view, container) => {
751
1056
  if (minPx === undefined && maxPx === undefined) {
752
1057
  return;
753
1058
  }
754
- view.requestMeasure({
1059
+ runWhenFontReady(view, () => view.requestMeasure({
755
1060
  read: (measureView) => {
756
- const line = measureView.contentDOM.querySelector('.cm-line');
757
- const lineHeight = (line ? line.getBoundingClientRect().height : measureView.defaultLineHeight) || 20;
1061
+ const lineHeight = readLineHeight(measureView);
758
1062
  const offsetTop = Math.max(measureView.scrollDOM.getBoundingClientRect().top - container.getBoundingClientRect().top, 0);
759
1063
  const toLines = (px) => Math.max(1, Math.floor((px - offsetTop - 8) / lineHeight));
760
1064
  return { lineHeight, minLines: minPx === undefined ? undefined : toLines(minPx), maxLines: maxPx === undefined ? undefined : toLines(maxPx) };
@@ -772,7 +1076,7 @@ const applyContainerHeight = (view, container) => {
772
1076
  }
773
1077
  }
774
1078
  },
775
- });
1079
+ }));
776
1080
  };
777
1081
  /**
778
1082
  * Giới hạn chiều cao editor (xử lý 1 lần). 2 chế độ loại trừ nhau:
@@ -795,16 +1099,377 @@ const applyMaxHeight = (view, options) => {
795
1099
  if (!maxLines || maxLines <= 0) {
796
1100
  return;
797
1101
  }
798
- view.requestMeasure({
799
- read: (measureView) => {
800
- const line = measureView.contentDOM.querySelector('.cm-line');
801
- return (line ? line.getBoundingClientRect().height : measureView.defaultLineHeight) || 20;
802
- },
1102
+ runWhenFontReady(view, () => view.requestMeasure({
1103
+ read: (measureView) => readLineHeight(measureView),
803
1104
  write: (lineHeight, writeView) => {
804
1105
  writeView.scrollDOM.style.maxHeight = `${maxLines * lineHeight + 8}px`;
805
1106
  writeView.scrollDOM.style.overflowY = 'auto';
806
1107
  },
807
- });
1108
+ }));
1109
+ };
1110
+
1111
+ /**
1112
+ * Định dạng lại câu lệnh SQL cho dễ đọc — người dùng không phải tự căn chỉnh bằng tay.
1113
+ *
1114
+ * 🔴 Đây là bộ định dạng THUẦN (không thêm phụ thuộc nào vào thư viện dùng chung). Nó xử lý được
1115
+ * phần lớn câu lệnh truy vấn thường gặp; câu quá lạ thì giữ nguyên chứ KHÔNG làm sai — xem
1116
+ * `sqlFormat` đoạn về nguyên tắc "không đổi nghĩa".
1117
+ *
1118
+ * Việc nó làm:
1119
+ * - mỗi từ khoá mở đầu một mệnh đề (`SELECT`, `FROM`, `WHERE`, `GROUP BY`…) xuống dòng mới;
1120
+ * - mỗi cột trong `SELECT` một dòng, thụt vào một cấp;
1121
+ * - `AND` / `OR` trong `WHERE` xuống dòng, thụt vào;
1122
+ * - `JOIN … ON …` xuống dòng, `ON` thụt vào một cấp;
1123
+ * - ngoặc lồng (câu con) tăng một cấp thụt;
1124
+ * - toán tử so sánh có đúng một dấu cách hai bên (`c=1` → `c = 1`);
1125
+ * - từ khoá viết HOA, tên bảng/cột giữ nguyên nguyên văn người dùng gõ;
1126
+ * - gom nhiều dòng trắng liên tiếp thành một.
1127
+ */
1128
+ /** Một cấp thụt = 2 dấu cách. Hai cấp là đủ thấy tầng mà không đẩy chữ ra xa mép. */
1129
+ const INDENT_STEP = ' ';
1130
+ /**
1131
+ * Từ khoá mở đầu một MỆNH ĐỀ — luôn bắt đầu một dòng mới, ở cấp thụt hiện tại.
1132
+ *
1133
+ * 🔴 Xếp cụm DÀI trước cụm ngắn (`GROUP BY` trước `GROUP`, `LEFT JOIN` trước `JOIN`): bộ so khớp
1134
+ * lấy cụm khớp đầu tiên, để ngắn trước thì `GROUP BY` bị cắt thành `GROUP` rồi `BY` lạc ra ngoài.
1135
+ */
1136
+ const CLAUSE_KEYWORDS = [
1137
+ 'SELECT DISTINCT', 'SELECT',
1138
+ 'FROM',
1139
+ 'LEFT OUTER JOIN', 'RIGHT OUTER JOIN', 'FULL OUTER JOIN',
1140
+ 'LEFT JOIN', 'RIGHT JOIN', 'INNER JOIN', 'CROSS JOIN', 'FULL JOIN', 'JOIN',
1141
+ 'WHERE',
1142
+ 'GROUP BY', 'HAVING',
1143
+ 'ORDER BY',
1144
+ 'LIMIT', 'OFFSET',
1145
+ 'UNION ALL', 'UNION', 'INTERSECT', 'EXCEPT',
1146
+ 'WITH',
1147
+ ];
1148
+ /** Từ khoá xuống dòng nhưng THỤT THÊM một cấp — nằm trong mệnh đề chứ không mở mệnh đề mới. */
1149
+ const INDENTED_KEYWORDS = ['AND', 'OR', 'ON'];
1150
+ /** Từ khoá chỉ viết HOA, không đụng tới dòng — nằm giữa biểu thức. */
1151
+ const INLINE_KEYWORDS = [
1152
+ 'CASE', 'WHEN', 'THEN', 'ELSE', 'END',
1153
+ 'AS', 'IN', 'NOT', 'NULL', 'IS', 'LIKE', 'ILIKE', 'BETWEEN', 'EXISTS',
1154
+ 'ASC', 'DESC', 'OVER', 'PARTITION BY', 'CAST', 'INTERVAL', 'USING',
1155
+ ];
1156
+ /**
1157
+ * Toán tử so sánh / tính toán — luôn có ĐÚNG MỘT dấu cách hai bên.
1158
+ *
1159
+ * 🔴 Xếp toán tử HAI KÝ TỰ trước một ký tự (`<=` trước `<`, `!=` trước `!`): so khớp lấy cụm đầu
1160
+ * tiên, để ngắn trước thì `a <= b` bị tách thành `a < = b` — sai cú pháp.
1161
+ *
1162
+ * 🔴 KHÔNG có `*`: `select *` và `count(*)` là dùng phổ biến nhất, chèn dấu cách quanh nó thành
1163
+ * `select *` thì vô hại nhưng `count( * )` thì khó đọc. Phép nhân thật thì người dùng tự gõ cách.
1164
+ */
1165
+ const OPERATORS = ['<=', '>=', '<>', '!=', '||', '=', '<', '>', '+', '-', '/', '%'];
1166
+ /**
1167
+ * Tách câu lệnh thành các mẩu, đánh dấu mẩu nào phải giữ nguyên văn.
1168
+ *
1169
+ * 🔴 Chuỗi · định danh trích dẫn · chú thích KHÔNG được đụng tới: đổi chữ trong `'Hà Nội'` thành
1170
+ * `'HÀ NỘI'` là đổi DỮ LIỆU, còn chèn dòng mới vào giữa chuỗi là làm hỏng câu lệnh. Đây là lý do
1171
+ * phải quét một lượt có trạng thái thay vì dùng regex trần.
1172
+ */
1173
+ const sqlSplitPreservingLiterals = (sql) => {
1174
+ const fragments = [];
1175
+ let buffer = '';
1176
+ let i = 0;
1177
+ const flushBuffer = () => {
1178
+ if (buffer) {
1179
+ fragments.push({ text: buffer, isLiteral: false });
1180
+ }
1181
+ buffer = '';
1182
+ };
1183
+ while (i < sql.length) {
1184
+ const ch = sql[i];
1185
+ const next = sql[i + 1];
1186
+ // Chú thích dòng `-- …`.
1187
+ if (ch === '-' && next === '-') {
1188
+ const end = sql.indexOf('\n', i);
1189
+ const stop = end === -1 ? sql.length : end;
1190
+ flushBuffer();
1191
+ fragments.push({ text: sql.slice(i, stop), isLiteral: true });
1192
+ i = stop;
1193
+ continue;
1194
+ }
1195
+ // Chú thích khối `/* … */`.
1196
+ if (ch === '/' && next === '*') {
1197
+ const end = sql.indexOf('*/', i + 2);
1198
+ const stop = end === -1 ? sql.length : end + 2;
1199
+ flushBuffer();
1200
+ fragments.push({ text: sql.slice(i, stop), isLiteral: true });
1201
+ i = stop;
1202
+ continue;
1203
+ }
1204
+ // Chuỗi và định danh trích dẫn: `'…'`, `"…"`, `` `…` ``.
1205
+ if (ch === "'" || ch === '"' || ch === '`') {
1206
+ let j = i + 1;
1207
+ while (j < sql.length) {
1208
+ if (sql[j] === '\\') {
1209
+ j += 2;
1210
+ continue;
1211
+ }
1212
+ if (sql[j] !== ch) {
1213
+ j += 1;
1214
+ continue;
1215
+ }
1216
+ // Nhân đôi dấu đóng = một dấu theo nghĩa đen, chuỗi chưa kết thúc.
1217
+ if (sql[j + 1] === ch) {
1218
+ j += 2;
1219
+ continue;
1220
+ }
1221
+ break;
1222
+ }
1223
+ const stop = Math.min(j + 1, sql.length);
1224
+ flushBuffer();
1225
+ fragments.push({ text: sql.slice(i, stop), isLiteral: true });
1226
+ i = stop;
1227
+ continue;
1228
+ }
1229
+ buffer += ch;
1230
+ i += 1;
1231
+ }
1232
+ flushBuffer();
1233
+ return fragments;
1234
+ };
1235
+ /** Từ khoá khớp tại vị trí này (đã chuẩn hoá khoảng trắng), hoặc rỗng. */
1236
+ const matchKeyword = (text, position, keywordList) => {
1237
+ for (const keyword of keywordList) {
1238
+ const slice = text.slice(position, position + keyword.length);
1239
+ if (slice.toUpperCase() !== keyword) {
1240
+ continue;
1241
+ }
1242
+ // Phải là RANH GIỚI TỪ hai đầu: `FROM` trong `FROMAGE` không phải từ khoá, và `x.on` cũng vậy.
1243
+ const prevChar = position === 0 ? ' ' : text[position - 1];
1244
+ const nextChar = text[position + keyword.length] ?? ' ';
1245
+ if (/[a-zA-Z0-9_$.]/.test(prevChar) || /[a-zA-Z0-9_$.]/.test(nextChar)) {
1246
+ continue;
1247
+ }
1248
+ return keyword;
1249
+ }
1250
+ return '';
1251
+ };
1252
+ /**
1253
+ * Thêm một dòng mới ở cấp thụt cho trước, gộp khoảng trắng đuôi.
1254
+ *
1255
+ * 🔴 Đang ở ĐẦU DÒNG rồi thì chỉ đặt lại mức thụt, KHÔNG thêm `\n` nữa: mở ngoặc câu con rồi gặp
1256
+ * ngay `SELECT` là hai lần gọi liên tiếp, thêm cả hai thì sinh một dòng trắng giữa `FROM (` và
1257
+ * `SELECT` (đo 21/09/2026).
1258
+ */
1259
+ const breakLine = (state, indentLevel) => {
1260
+ const indent = INDENT_STEP.repeat(Math.max(indentLevel, 0));
1261
+ const trimmed = state.out.replace(/[ \t]+$/, '');
1262
+ state.out = trimmed.endsWith('\n') ? `${trimmed}${indent}` : `${trimmed}\n${indent}`;
1263
+ };
1264
+ /**
1265
+ * Định dạng lại một câu lệnh SQL.
1266
+ *
1267
+ * 🔴 NGUYÊN TẮC BẤT BIẾN: chỉ đổi KHOẢNG TRẮNG và CHỮ HOA-THƯỜNG CỦA TỪ KHOÁ. Không thêm, không bớt,
1268
+ * không đổi thứ tự bất kỳ ký tự nào khác — nhờ vậy định dạng lại không bao giờ làm sai câu lệnh.
1269
+ * Bỏ khoảng trắng và chuẩn hoá chữ thì chuỗi trước và sau phải trùng khít; spec có ca kiểm điều này.
1270
+ *
1271
+ * 🔴 Câu lệnh rỗng hoặc chỉ có khoảng trắng thì trả `''` — nơi gọi không phải tự kiểm.
1272
+ */
1273
+ const sqlFormat = (sql) => {
1274
+ if (!sql?.trim()) {
1275
+ return '';
1276
+ }
1277
+ const fragments = sqlSplitPreservingLiterals(sql);
1278
+ const state = { out: '', depth: 0, fnDepth: 0 };
1279
+ for (const fragment of fragments) {
1280
+ if (fragment.isLiteral) {
1281
+ state.out += fragment.text;
1282
+ continue;
1283
+ }
1284
+ // Gộp mọi chuỗi khoảng trắng thành một dấu cách để xử lý đồng nhất.
1285
+ const text = fragment.text.replace(/\s+/g, ' ');
1286
+ let i = 0;
1287
+ while (i < text.length) {
1288
+ const ch = text[i];
1289
+ // Mở ngoặc: tăng cấp. Ngoặc của HÀM thì đánh dấu để dấu phẩy bên trong không xuống dòng.
1290
+ if (ch === '(') {
1291
+ // 🔴 Phải xét TỪ đứng ngay trước: ngoặc dán liền một định danh (`coalesce(`) là ngoặc hàm,
1292
+ // còn ngoặc sau một TỪ KHOÁ (`FROM (`, `IN (`, `EXISTS (`) mở một CÂU CON và phải được định
1293
+ // dạng như câu lệnh đầy đủ. Chỉ kiểm `[a-zA-Z0-9_$]\s*$` thì `FROM (` bị nhận nhầm là hàm,
1294
+ // nên toàn bộ câu con giữ nguyên chữ thường và không xuống dòng (đo 21/09/2026).
1295
+ const prevWord = (/([a-zA-Z0-9_$]+)\s*$/.exec(state.out)?.[1] ?? '').toUpperCase();
1296
+ const isGluedToPrev = /[a-zA-Z0-9_$]$/.test(state.out);
1297
+ const isKeyword = [...CLAUSE_KEYWORDS, ...INDENTED_KEYWORDS, ...INLINE_KEYWORDS].includes(prevWord);
1298
+ /**
1299
+ * 🔴 Ngoặc sau các từ khoá này chứa DANH SÁCH GIÁ TRỊ hoặc một biểu thức ngắn, không phải
1300
+ * câu con — giữ trên một dòng. Tách ra thì `y IN (1, 2, 3)` thành 5 dòng, đọc còn khó hơn
1301
+ * lúc chưa định dạng (đo 21/09/2026).
1302
+ */
1303
+ const isInlineParen = ['IN', 'VALUES', 'OVER', 'PARTITION BY', 'USING', 'CAST'].includes(prevWord);
1304
+ const isFnCall = (isGluedToPrev && !isKeyword) || isInlineParen;
1305
+ state.out += '(';
1306
+ state.depth += 1;
1307
+ if (isFnCall) {
1308
+ state.fnDepth += 1;
1309
+ }
1310
+ else {
1311
+ breakLine(state, state.depth);
1312
+ }
1313
+ i += 1;
1314
+ continue;
1315
+ }
1316
+ if (ch === ')') {
1317
+ state.depth = Math.max(state.depth - 1, 0);
1318
+ if (state.fnDepth > 0) {
1319
+ state.fnDepth -= 1;
1320
+ }
1321
+ else {
1322
+ breakLine(state, state.depth);
1323
+ }
1324
+ state.out += ')';
1325
+ i += 1;
1326
+ continue;
1327
+ }
1328
+ // Dấu phẩy: xuống dòng, TRỪ khi đang trong ngoặc của hàm (`sum(a, b)` giữ một dòng).
1329
+ if (ch === ',') {
1330
+ state.out = state.out.replace(/[ \t]+$/, '');
1331
+ state.out += ',';
1332
+ if (!state.fnDepth) {
1333
+ breakLine(state, state.depth + 1);
1334
+ }
1335
+ else {
1336
+ state.out += ' ';
1337
+ }
1338
+ i += 1;
1339
+ continue;
1340
+ }
1341
+ // Dấu chấm phẩy kết câu: sát chữ trước rồi xuống dòng.
1342
+ if (ch === ';') {
1343
+ state.out = `${state.out.replace(/[ \t]+$/, '')};`;
1344
+ state.depth = 0;
1345
+ state.fnDepth = 0;
1346
+ breakLine(state, 0);
1347
+ i += 1;
1348
+ continue;
1349
+ }
1350
+ // 🔴 Trong ngoặc của HÀM thì không xét từ khoá mệnh đề: `count(*) over (partition by x)` mà
1351
+ // tách `PARTITION BY` ra dòng riêng thì đọc còn khó hơn.
1352
+ if (!state.fnDepth) {
1353
+ const clauseKeyword = matchKeyword(text, i, CLAUSE_KEYWORDS);
1354
+ if (clauseKeyword) {
1355
+ if (state.out.trim()) {
1356
+ breakLine(state, state.depth);
1357
+ }
1358
+ state.out += `${clauseKeyword} `;
1359
+ i += clauseKeyword.length;
1360
+ // Bỏ dấu cách ngay sau từ khoá, đã tự thêm ở trên.
1361
+ if (text[i] === ' ') {
1362
+ i += 1;
1363
+ }
1364
+ continue;
1365
+ }
1366
+ const indentedKeyword = matchKeyword(text, i, INDENTED_KEYWORDS);
1367
+ if (indentedKeyword) {
1368
+ if (state.out.trim()) {
1369
+ breakLine(state, state.depth + 1);
1370
+ }
1371
+ state.out += `${indentedKeyword} `;
1372
+ i += indentedKeyword.length;
1373
+ if (text[i] === ' ') {
1374
+ i += 1;
1375
+ }
1376
+ continue;
1377
+ }
1378
+ }
1379
+ const inlineKeyword = matchKeyword(text, i, INLINE_KEYWORDS);
1380
+ if (inlineKeyword) {
1381
+ state.out += inlineKeyword;
1382
+ i += inlineKeyword.length;
1383
+ continue;
1384
+ }
1385
+ // Toán tử: đúng một dấu cách hai bên, dù người dùng gõ `c=1` hay `c = 1`.
1386
+ const operator = OPERATORS.find((op) => text.startsWith(op, i));
1387
+ if (operator) {
1388
+ /**
1389
+ * 🔴 Dấu trừ đứng đầu biểu thức là DẤU ÂM, không phải phép trừ: `-1` giữ nguyên, `a - 1`
1390
+ * thì tách. Nhận nhầm thì `limit -1` thành `limit - 1` — đổi hẳn nghĩa câu lệnh.
1391
+ *
1392
+ * Ba chỗ nó là dấu âm: đầu câu, ngay sau một dấu ngắt/toán tử khác, và ngay sau một TỪ KHOÁ
1393
+ * (`LIMIT -1`, `WHERE -1 = x`). Trường hợp cuối phải xét riêng vì ký tự liền trước là chữ
1394
+ * cái, không khớp bảng dấu ngắt (đo 21/09/2026).
1395
+ */
1396
+ const trimmedLeft = state.out.replace(/[ \t]+$/, '');
1397
+ const adjacentWord = /([a-zA-Z0-9_$]+)$/.exec(trimmedLeft)?.[1] ?? '';
1398
+ const afterKeyword = Boolean(adjacentWord) && [...CLAUSE_KEYWORDS, ...INDENTED_KEYWORDS, ...INLINE_KEYWORDS].includes(adjacentWord.toUpperCase());
1399
+ const isNegativeSign = operator === '-' && (!trimmedLeft || /[(,=<>+\-*/%]$/.test(trimmedLeft) || afterKeyword);
1400
+ if (isNegativeSign) {
1401
+ /**
1402
+ * 🔴 Dán liền dấu âm vào SỐ, nhưng phải giữ khoảng cách với thứ đứng trước nó — chỉ có
1403
+ * `(` và `,` là dán được:
1404
+ * `(-1)` · `(a, -1)` → dán liền
1405
+ * `LIMIT -1` · `b = -1` → phải có dấu cách, cắt sạch thì ra `LIMIT-1` / `b =-1`
1406
+ */
1407
+ const glueToPrev = /[(,]$/.test(trimmedLeft);
1408
+ state.out = glueToPrev ? `${trimmedLeft}${operator}` : `${trimmedLeft} ${operator}`;
1409
+ i += operator.length;
1410
+ continue;
1411
+ }
1412
+ state.out = `${trimmedLeft} ${operator} `;
1413
+ i += operator.length;
1414
+ // Bỏ khoảng trắng người dùng đã gõ sau toán tử, đã tự thêm một dấu cách ở trên.
1415
+ while (text[i] === ' ') {
1416
+ i += 1;
1417
+ }
1418
+ continue;
1419
+ }
1420
+ // Không gộp hai dấu cách liền nhau, và không mở đầu dòng bằng dấu cách.
1421
+ if (ch === ' ' && (state.out.endsWith(' ') || state.out.endsWith('\n') || !state.out)) {
1422
+ i += 1;
1423
+ continue;
1424
+ }
1425
+ state.out += ch;
1426
+ i += 1;
1427
+ }
1428
+ }
1429
+ return state.out
1430
+ // Gom nhiều dòng trắng liên tiếp thành một dòng trắng.
1431
+ .replace(/\n{3,}/g, '\n\n')
1432
+ // Bỏ khoảng trắng cuối mỗi dòng.
1433
+ .split('\n')
1434
+ .map((line) => line.replace(/\s+$/, ''))
1435
+ .join('\n')
1436
+ .trim();
1437
+ };
1438
+ /**
1439
+ * Bỏ mọi khoảng trắng và chuẩn hoá chữ — dùng để KIỂM việc định dạng không đổi nghĩa câu lệnh.
1440
+ *
1441
+ * 🔴 Giữ nguyên nội dung vùng chuỗi/chú thích khi chuẩn hoá: chữ trong `'Hà Nội'` là dữ liệu, không
1442
+ * phải mã lệnh, nên không được viết hoa nó khi so sánh.
1443
+ */
1444
+ const sqlNormalizeForCompare = (sql) => sqlSplitPreservingLiterals(sql)
1445
+ .map((fragment) => (fragment.isLiteral ? fragment.text : fragment.text.replace(/\s+/g, '').toUpperCase()))
1446
+ .join('');
1447
+ /** Ngôn ngữ có bộ định dạng — nơi khác hỏi trước khi hiện nút "Định dạng". */
1448
+ const FORMATTABLE_LANGUAGES = ['sql', 'json'];
1449
+ /**
1450
+ * Định dạng nội dung theo NGÔN NGỮ đang chọn. Ngôn ngữ chưa hỗ trợ thì trả nguyên văn.
1451
+ *
1452
+ * 🔴 Trả NGUYÊN VĂN khi không định dạng được (kể cả JSON hỏng cú pháp), KHÔNG ném lỗi và cũng không
1453
+ * trả rỗng: người dùng bấm nhầm nút trên một đoạn đang viết dở mà mất sạch chữ thì còn tệ hơn nhiều
1454
+ * so với việc nút không làm gì.
1455
+ */
1456
+ const formatByLanguage = (content, language) => {
1457
+ if (!content?.trim()) {
1458
+ return content ?? '';
1459
+ }
1460
+ if (language === 'sql') {
1461
+ return sqlFormat(content);
1462
+ }
1463
+ if (language === 'json') {
1464
+ try {
1465
+ return JSON.stringify(JSON.parse(content), null, 2);
1466
+ }
1467
+ catch {
1468
+ // JSON chưa hợp lệ (đang gõ dở) — giữ nguyên, người dùng tự sửa rồi bấm lại.
1469
+ return content;
1470
+ }
1471
+ }
1472
+ return content;
808
1473
  };
809
1474
 
810
1475
  class LibsUiComponentsPreviewTextDataComponent {
@@ -812,12 +1477,16 @@ class LibsUiComponentsPreviewTextDataComponent {
812
1477
  // PRIVATE PROPERTIES
813
1478
  // ==========================================================================
814
1479
  editorViewInstance;
1480
+ /** Phím tắt mở khung tìm/thay thế — máy Mac dùng ⌘ thay Ctrl, gợi ý sai phím thì người dùng bấm không ăn. */
1481
+ searchShortcut = typeof navigator !== 'undefined' && /Mac|iPhone|iPad/i.test(navigator.platform) ? '⌘ + F' : 'Ctrl + F';
815
1482
  wrapCompartment = new Compartment();
816
1483
  languageCompartment = new Compartment();
817
1484
  lineNumberCompartment = new Compartment();
818
1485
  linterCompartment = new Compartment();
819
1486
  completionsCompartment = new Compartment();
820
1487
  forbiddenCompartment = new Compartment();
1488
+ /** Nhãn của khung tìm/thay thế (Ctrl + F) — dịch theo ngôn ngữ đang dùng, đổi ngôn ngữ thì nạp lại. */
1489
+ phrasesCompartment = new Compartment();
821
1490
  contentStateNoWrap = signal('');
822
1491
  /** Cache để tránh load lại language đã load */
823
1492
  languageCache = new Map();
@@ -828,6 +1497,7 @@ class LibsUiComponentsPreviewTextDataComponent {
828
1497
  // ==========================================================================
829
1498
  notificationService = inject(LibsUiNotificationService);
830
1499
  destroyRef = inject(DestroyRef);
1500
+ translateService = inject(TranslateService);
831
1501
  // ==========================================================================
832
1502
  // PROTECTED SIGNALS
833
1503
  // ==========================================================================
@@ -863,9 +1533,22 @@ class LibsUiComponentsPreviewTextDataComponent {
863
1533
  containerElement = input();
864
1534
  /** z-index cho popover dropdown chọn ngôn ngữ. */
865
1535
  zIndexPopover = input();
1536
+ /** Ẩn ô search trong dropdown chọn ngôn ngữ (danh sách ngôn ngữ ngắn thường không cần tìm kiếm). */
1537
+ hiddenSearchLang = input(false, {
1538
+ transform: (value) => value ?? false,
1539
+ });
866
1540
  lintIgnorePatterns = input(['Cannot use import statement outside a module', 'Unexpected token export', 'import ', '@angular/core'], {
867
1541
  transform: (value) => value ?? ['Cannot use import statement outside a module', 'Unexpected token export', 'import ', '@angular/core'],
868
1542
  });
1543
+ /**
1544
+ * Mẫu token mà ỨNG DỤNG tự thay trước khi chạy câu lệnh (vd `$sqlCard.ma_dn`) — lỗi cú pháp rơi đúng vào đầu một đoạn khớp
1545
+ * mẫu thì KHÔNG báo. Hiện áp cho bộ bắt lỗi SQL. Mặc định rỗng: thư viện không tự đoán token của dự án nào.
1546
+ * @example
1547
+ * [syntaxIgnoreTokens]="[/\$sqlCard\.[a-z0-9_]+/i]"
1548
+ */
1549
+ syntaxIgnoreTokens = input([], {
1550
+ transform: (value) => value ?? [],
1551
+ });
869
1552
  /**
870
1553
  * Danh sách đối tượng/biến gợi ý khi gõ — giống IntelliSense trong IDE.
871
1554
  * Hỗ trợ dot-notation: định nghĩa `properties` để gợi ý sau dấu `.`
@@ -889,6 +1572,26 @@ class LibsUiComponentsPreviewTextDataComponent {
889
1572
  background = input('#f8f9fa', {
890
1573
  transform: (value) => value ?? '#f8f9fa',
891
1574
  });
1575
+ /**
1576
+ * Hiện nút "Định dạng" trên thanh công cụ — bấm một lần là nội dung tự căn chỉnh gọn gàng, người
1577
+ * dùng không phải gõ dấu cách và xuống dòng bằng tay.
1578
+ *
1579
+ * 🔴 Mặc định BẬT nhưng CHỈ hiện khi ô đang sửa được và ngôn ngữ đang chọn có bộ định dạng
1580
+ * (hiện có `sql` và `json`) — xem `coTheDinhDang`. Nhờ vậy nơi dùng không phải khai gì thêm, mà
1581
+ * ô chỉ-đọc hay ngôn ngữ chưa hỗ trợ cũng không mọc ra một nút bấm không làm gì.
1582
+ */
1583
+ showFormatAction = input(true, {
1584
+ transform: (value) => value ?? true,
1585
+ });
1586
+ /**
1587
+ * Tự định dạng NGAY khi nạp nội dung vào ô.
1588
+ *
1589
+ * 🔴 Mặc định TẮT: nội dung người dùng đã lưu có thể đang được họ căn theo ý riêng, tự sửa lúc mở
1590
+ * ra là ghi đè công của họ mà không ai bấm gì. Bật khi nguồn nội dung là máy sinh (mock, mẫu).
1591
+ */
1592
+ autoFormatOnLoad = input(false, {
1593
+ transform: (value) => value ?? false,
1594
+ });
892
1595
  // ==========================================================================
893
1596
  // OUTPUTS
894
1597
  // ==========================================================================
@@ -905,7 +1608,11 @@ class LibsUiComponentsPreviewTextDataComponent {
905
1608
  constructor() {
906
1609
  // Effect để sync content từ input vào editor
907
1610
  effect(() => {
908
- const newContent = this.content();
1611
+ // 🔴 `autoFormatOnLoad` áp NGAY TẠI ĐÂY, không ở `ngOnInit`: nội dung có thể về sau một nhịp
1612
+ // (từ API), lúc `ngOnInit` chạy thì `content()` còn rỗng.
1613
+ // 🔴 Đọc `langSelected` (model.required) CHỈ khi editor đã dựng — trước đó nó chưa có giá trị
1614
+ // và đọc là văng `NG0952`.
1615
+ const newContent = this.autoFormatOnLoad() && this.isInitialized ? formatByLanguage(this.content(), this.langSelected()) : this.content();
909
1616
  if (this.isInitialized && this.editorViewInstance) {
910
1617
  const currentContent = this.editorViewInstance.state.doc.toString();
911
1618
  if (newContent !== currentContent) {
@@ -947,6 +1654,10 @@ class LibsUiComponentsPreviewTextDataComponent {
947
1654
  // LIFECYCLE HOOKS
948
1655
  // ==========================================================================
949
1656
  ngOnInit() {
1657
+ // Đổi ngôn ngữ ⇒ nạp lại nhãn khung tìm/thay thế (CodeMirror chỉ đọc `phrases` lúc dựng panel).
1658
+ this.translateService.onLangChange.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => {
1659
+ this.editorViewInstance?.dispatch({ effects: this.phrasesCompartment.reconfigure(this.createSearchPhrases()) });
1660
+ });
950
1661
  if (this.langsAccept()?.length) {
951
1662
  this.configLoadDataIsHttpConfig.set(httpRequestConfigGetOptionsLang(this.langsAccept(), this.langsChangeLabel()));
952
1663
  }
@@ -992,6 +1703,8 @@ class LibsUiComponentsPreviewTextDataComponent {
992
1703
  lintGutter(),
993
1704
  this.createBracketTheme(),
994
1705
  this.createUpdateListener(),
1706
+ buildSearchPanelExtension(),
1707
+ this.phrasesCompartment.of(this.createSearchPhrases()),
995
1708
  ];
996
1709
  }
997
1710
  /**
@@ -1023,6 +1736,32 @@ class LibsUiComponentsPreviewTextDataComponent {
1023
1736
  // ==========================================================================
1024
1737
  // PRIVATE METHODS - Theme configuration
1025
1738
  // ==========================================================================
1739
+ /**
1740
+ * Nhãn khung tìm/thay thế của CodeMirror — mặc định là tiếng Anh cứng (`Find`, `next`, `match case`…).
1741
+ * Khoá bên trái là CHUỖI GỐC mà `@codemirror/search` tra trong `phrases`, không đổi được.
1742
+ */
1743
+ createSearchPhrases() {
1744
+ const translate = (key) => this.translateService.instant(key);
1745
+ return EditorState.phrases.of({
1746
+ Find: translate('i18n_code_editor_find'),
1747
+ Replace: translate('i18n_code_editor_replace'),
1748
+ next: translate('i18n_code_editor_find_next'),
1749
+ previous: translate('i18n_code_editor_find_previous'),
1750
+ all: translate('i18n_code_editor_select_all_matches'),
1751
+ 'match case': translate('i18n_code_editor_match_case'),
1752
+ regexp: translate('i18n_code_editor_regexp'),
1753
+ 'by word': translate('i18n_code_editor_by_word'),
1754
+ replace: translate('i18n_code_editor_replace_one'),
1755
+ 'replace all': translate('i18n_code_editor_replace_all'),
1756
+ close: translate('i18n_code_editor_close_search'),
1757
+ 'No results': translate('i18n_code_editor_no_results'),
1758
+ 'Find:': translate('i18n_code_editor_find_label'),
1759
+ 'Replace:': translate('i18n_code_editor_replace_label'),
1760
+ 'Find next': translate('i18n_code_editor_find_next_button'),
1761
+ // `$1` là chỗ CodeMirror chèn số khi gọi `state.phrase('$1 results', n)`.
1762
+ '$1 results': this.translateService.instant('i18n_code_editor_match_count', { count: '$1' }),
1763
+ });
1764
+ }
1026
1765
  createLightTheme() {
1027
1766
  return EditorView.theme({
1028
1767
  '&': { backgroundColor: this.background(), color: '#333' },
@@ -1083,7 +1822,7 @@ class LibsUiComponentsPreviewTextDataComponent {
1083
1822
  /** SQL linter — logic trong `linters/sql-linter.ts`. */
1084
1823
  createSqlLinter() {
1085
1824
  return linter((view) => {
1086
- const diagnostics = computeSqlDiagnostics(view);
1825
+ const diagnostics = computeSqlDiagnostics(view, this.syntaxIgnoreTokens());
1087
1826
  this.syntaxErrors.emit(diagnostics);
1088
1827
  return diagnostics;
1089
1828
  });
@@ -1099,6 +1838,49 @@ class LibsUiComponentsPreviewTextDataComponent {
1099
1838
  // ==========================================================================
1100
1839
  // PROTECTED METHODS - Event handlers
1101
1840
  // ==========================================================================
1841
+ /**
1842
+ * Nút "Định dạng" có hiện không.
1843
+ *
1844
+ * 🔴 Ba điều kiện cùng lúc: nơi dùng chưa tắt · ô đang SỬA ĐƯỢC · ngôn ngữ đang chọn có bộ định
1845
+ * dạng. Ô chỉ-đọc mà mọc ra nút bấm không làm gì thì người dùng bấm rồi tưởng hỏng.
1846
+ */
1847
+ canFormat = computed(() => {
1848
+ if (!this.showFormatAction() || !this.editable()) {
1849
+ return false;
1850
+ }
1851
+ // 🔴 `langSelected` là `model.required` — đọc lúc nơi dùng chưa gán là văng `NG0952`, mà
1852
+ // `computed` này chạy ngay nhịp vẽ đầu. Bọc lại để nút chỉ ẩn đi thay vì làm vỡ cả ô soạn.
1853
+ try {
1854
+ return FORMATTABLE_LANGUAGES.includes(this.langSelected());
1855
+ }
1856
+ catch {
1857
+ return false;
1858
+ }
1859
+ });
1860
+ /**
1861
+ * Căn chỉnh lại nội dung đang gõ theo ngôn ngữ đang chọn.
1862
+ *
1863
+ * 🔴 Đọc nội dung từ CHÍNH editor (`state.doc`), không từ `content()`: `content` là input ban đầu,
1864
+ * còn thứ người dùng vừa gõ chỉ có trong doc — lấy nhầm là bấm Định dạng xong chữ nhảy về bản cũ.
1865
+ *
1866
+ * KHÔNG phát `outChange` ở đây: `createUpdateListener` đã nghe `docChanged` và tự phát rồi, phát
1867
+ * thêm là nơi dùng nhận hai lượt cho một thao tác.
1868
+ */
1869
+ handlerFormat() {
1870
+ // 🔴 Thoát sớm khi editor CHƯA dựng: `langSelected` là `model.required`, đọc lúc chưa có giá trị
1871
+ // là văng `NG0952`. Không có editor thì cũng chẳng có gì để định dạng.
1872
+ if (!this.editorViewInstance) {
1873
+ return;
1874
+ }
1875
+ const current = this.editorViewInstance.state.doc.toString();
1876
+ const isAligned = formatByLanguage(current, this.langSelected());
1877
+ if (!isAligned || isAligned === current) {
1878
+ return;
1879
+ }
1880
+ this.editorViewInstance.dispatch({
1881
+ changes: { from: 0, to: current.length, insert: isAligned },
1882
+ });
1883
+ }
1102
1884
  handlerCopy() {
1103
1885
  navigator.clipboard.writeText(this.content() || '');
1104
1886
  this.notificationService.showCompTypeTextInfo('Sao chép thành công');
@@ -1141,16 +1923,16 @@ class LibsUiComponentsPreviewTextDataComponent {
1141
1923
  });
1142
1924
  }
1143
1925
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: LibsUiComponentsPreviewTextDataComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1144
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.14", type: LibsUiComponentsPreviewTextDataComponent, isStandalone: true, selector: "libs_ui-components-preview_text_data", inputs: { content: { classPropertyName: "content", publicName: "content", isSignal: true, isRequired: false, transformFunction: null }, langSelected: { classPropertyName: "langSelected", publicName: "langSelected", isSignal: true, isRequired: true, transformFunction: null }, langsAccept: { classPropertyName: "langsAccept", publicName: "langsAccept", isSignal: true, isRequired: false, transformFunction: null }, langsChangeLabel: { classPropertyName: "langsChangeLabel", publicName: "langsChangeLabel", isSignal: true, isRequired: false, transformFunction: null }, editable: { classPropertyName: "editable", publicName: "editable", isSignal: true, isRequired: false, transformFunction: null }, hiddenAction: { classPropertyName: "hiddenAction", publicName: "hiddenAction", isSignal: true, isRequired: false, transformFunction: null }, minLines: { classPropertyName: "minLines", publicName: "minLines", isSignal: true, isRequired: false, transformFunction: null }, maxLines: { classPropertyName: "maxLines", publicName: "maxLines", isSignal: true, isRequired: false, transformFunction: null }, containerElement: { classPropertyName: "containerElement", publicName: "containerElement", isSignal: true, isRequired: false, transformFunction: null }, zIndexPopover: { classPropertyName: "zIndexPopover", publicName: "zIndexPopover", isSignal: true, isRequired: false, transformFunction: null }, lintIgnorePatterns: { classPropertyName: "lintIgnorePatterns", publicName: "lintIgnorePatterns", isSignal: true, isRequired: false, transformFunction: null }, completions: { classPropertyName: "completions", publicName: "completions", isSignal: true, isRequired: false, transformFunction: null }, forbiddenPatterns: { classPropertyName: "forbiddenPatterns", publicName: "forbiddenPatterns", isSignal: true, isRequired: false, transformFunction: null }, background: { classPropertyName: "background", publicName: "background", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { langSelected: "langSelectedChange", outChange: "outChange", syntaxErrors: "syntaxErrors", outViolations: "outViolations" }, viewQueries: [{ propertyName: "containerPreview", first: true, predicate: ["containerPreview"], descendants: true, isSignal: true }], ngImport: i0, template: "<div\n class=\"libs-ui-preview-data-container flex flex-col w-full h-auto rounded-[8px] libs-ui-border-general px-[8px]\"\n [style.--background-color]=\"background()\"\n [class.pt-[8px]]=\"!hiddenAction()\">\n @if (!hiddenAction()) {\n <div class=\"flex items-center content-between color-[#6a7383]\">\n <libs_ui-components-dropdown\n classInclude=\"w-[200px]\"\n [listConfig]=\"configLoadDataIsHttpConfig()\"\n [listMaxItemShow]=\"5\"\n [zIndex]=\"zIndexPopover()\"\n [isNgContent]=\"true\"\n [readonly]=\"!editable() || !acceptChangeLang()\"\n [listHasButtonUnSelectOption]=\"false\"\n (outSelectKey)=\"handlerSelectKey($event)\">\n <libs_ui-components-buttons-button\n [type]=\"'button-link-third'\"\n [label]=\"labelLang() || ''\"\n [sizeButton]=\"'small'\"\n [classIconRight]=\"editable() && acceptChangeLang() ? 'libs-ui-icon-move-right rotate-90' : ''\"\n [classInclude]=\"'!p-[0px]' + (editable() && acceptChangeLang() ? '' : '!pointer-events-none !cursor-default hover:!text-[#6A7383]')\" />\n </libs_ui-components-dropdown>\n <div class=\"flex items-center\">\n <libs_ui-components-buttons-button\n [type]=\"'button-link-third'\"\n [label]=\"isWrap() ? 'i18n_remove_line_wrap' : 'i18n_line_wrap'\"\n [sizeButton]=\"'small'\"\n [classIconLeft]=\"isWrap() ? 'libs-ui-icon-unwrap' : 'libs-ui-icon-wrap'\"\n [classInclude]=\"'mo-lib-p-0px mo-lib-mr-16px'\"\n (outClick)=\"handlerLineWrap()\" />\n <libs_ui-components-buttons-button\n [type]=\"'button-link-third'\"\n [label]=\"'i18n_copy'\"\n [sizeButton]=\"'small'\"\n [classIconLeft]=\"'libs-ui-icon-copy'\"\n [classInclude]=\"'mo-lib-p-0px'\"\n (outClick)=\"handlerCopy()\" />\n </div>\n </div>\n }\n <div #containerPreview></div>\n</div>\n", styles: [":host ::ng-deep .libs-ui-preview-data-container{background-color:var(--background-color)!important}:host ::ng-deep .libs-ui-preview-data-container .cm-line{white-space:pre-wrap}:host ::ng-deep .libs-ui-preview-data-container .cm-lintRange-error{background-color:#ff323233;border-bottom:2px solid red}:host ::ng-deep .libs-ui-preview-data-container .cm-lintRange-warning{background-color:#ffc80026}:host ::ng-deep .libs-ui-preview-data-container .cm-tooltip-lint{background:#fff8f8;color:#d32f2f;border:1px solid #f44336;padding:8px 10px;font-size:13px;font-family:Inter,sans-serif;border-radius:6px;box-shadow:0 2px 8px #ff000026}:host ::ng-deep .libs-ui-preview-data-container .cm-focused{outline:none!important}:host ::ng-deep .libs-ui-preview-data-container .cm-gutters{background-color:var(--background-color)!important}\n"], dependencies: [{ kind: "component", type: LibsUiComponentsDropdownComponent, selector: "libs_ui-components-dropdown", inputs: ["useXssFilter", "popoverElementRefCustom", "classInclude", "ignoreStopPropagationEvent", "flagMouse", "flagMouseContent", "popoverCustomConfig", "isNgContent", "zIndex", "convertItemSelected", "getPopoverItemSelected", "httpRequestDetailItemById", "lengthKeys", "textDisplayWhenNoSelect", "textDisplayWhenMultiSelect", "classIncludeTextDisplayWhenNoSelect", "fieldLabel", "fieldGetLabel", "labelPopoverConfig", "labelPopoverFullWidth", "hasContentUnitRight", "listSearchNoDataTemplateRef", "dropdownTemplateRefNotSearchNoData", "fieldGetImage", "imageSize", "typeShape", "fieldGetIcon", "fieldGetTextAvatar", "fieldGetColorAvatar", "classAvatarInclude", "getLastTextAfterSpace", "linkImageError", "showError", "showBorderError", "disable", "readonly", "labelConfig", "disableLabel", "listSearchConfig", "isSearchOnline", "listHiddenInputSearch", "listSearchPadding", "listKeySearch", "listDividerClassInclude", "listConfig", "listButtonsOther", "listHasButtonUnSelectOption", "listClickExactly", "listBackgroundCustom", "listMaxItemShow", "listKeySelected", "listMultiKeySelected", "listKeysDisable", "listKeysHidden", "validRequired", "validMaxItemSelected", "changeValidUndefinedResetError", "allowSelectItemMultiple", "focusInputSearch", "onlyEmitDataWhenReset", "resetKeyWhenSelectAllKey", "listConfigHasDivider", "classIncludeIcon", "classIncludeContent", "listIgnoreClassDisableDefaultWhenUseKeysDisableItem", "tabKeyActive", "tabsConfig", "ignoreBorderBottom"], outputs: ["flagMouseChange", "flagMouseContentChange", "lengthKeysChange", "showBorderErrorChange", "listKeySelectedChange", "listMultiKeySelectedChange", "tabKeyActiveChange", "outSelectKey", "outSelectMultiKey", "outFunctionsControl", "outValidEvent", "outChangStageFlagMouse", "outDataChange", "outClickButtonOther", "outShowList", "outChangeTabKeyActive"] }, { kind: "component", type: LibsUiComponentsButtonsButtonComponent, selector: "libs_ui-components-buttons-button", inputs: ["flagMouse", "type", "buttonCustom", "sizeButton", "label", "disable", "isPending", "imageLeft", "classInclude", "classIconLeft", "classIconRight", "classLabel", "iconOnlyType", "popover", "ignoreStopPropagationEvent", "zIndex", "widthLabelPopover", "styleIconLeft", "styleButton", "ignoreFocusWhenInputTab", "ignoreSetClickWhenShowPopover", "ignorePointerEvent", "isActive", "isHandlerEnterDocumentClickButton"], outputs: ["outClick", "outPopoverEvent", "outFunctionsControl"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
1926
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.14", type: LibsUiComponentsPreviewTextDataComponent, isStandalone: true, selector: "libs_ui-components-preview_text_data", inputs: { content: { classPropertyName: "content", publicName: "content", isSignal: true, isRequired: false, transformFunction: null }, langSelected: { classPropertyName: "langSelected", publicName: "langSelected", isSignal: true, isRequired: true, transformFunction: null }, langsAccept: { classPropertyName: "langsAccept", publicName: "langsAccept", isSignal: true, isRequired: false, transformFunction: null }, langsChangeLabel: { classPropertyName: "langsChangeLabel", publicName: "langsChangeLabel", isSignal: true, isRequired: false, transformFunction: null }, editable: { classPropertyName: "editable", publicName: "editable", isSignal: true, isRequired: false, transformFunction: null }, hiddenAction: { classPropertyName: "hiddenAction", publicName: "hiddenAction", isSignal: true, isRequired: false, transformFunction: null }, minLines: { classPropertyName: "minLines", publicName: "minLines", isSignal: true, isRequired: false, transformFunction: null }, maxLines: { classPropertyName: "maxLines", publicName: "maxLines", isSignal: true, isRequired: false, transformFunction: null }, containerElement: { classPropertyName: "containerElement", publicName: "containerElement", isSignal: true, isRequired: false, transformFunction: null }, zIndexPopover: { classPropertyName: "zIndexPopover", publicName: "zIndexPopover", isSignal: true, isRequired: false, transformFunction: null }, hiddenSearchLang: { classPropertyName: "hiddenSearchLang", publicName: "hiddenSearchLang", isSignal: true, isRequired: false, transformFunction: null }, lintIgnorePatterns: { classPropertyName: "lintIgnorePatterns", publicName: "lintIgnorePatterns", isSignal: true, isRequired: false, transformFunction: null }, syntaxIgnoreTokens: { classPropertyName: "syntaxIgnoreTokens", publicName: "syntaxIgnoreTokens", isSignal: true, isRequired: false, transformFunction: null }, completions: { classPropertyName: "completions", publicName: "completions", isSignal: true, isRequired: false, transformFunction: null }, forbiddenPatterns: { classPropertyName: "forbiddenPatterns", publicName: "forbiddenPatterns", isSignal: true, isRequired: false, transformFunction: null }, background: { classPropertyName: "background", publicName: "background", isSignal: true, isRequired: false, transformFunction: null }, showFormatAction: { classPropertyName: "showFormatAction", publicName: "showFormatAction", isSignal: true, isRequired: false, transformFunction: null }, autoFormatOnLoad: { classPropertyName: "autoFormatOnLoad", publicName: "autoFormatOnLoad", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { langSelected: "langSelectedChange", outChange: "outChange", syntaxErrors: "syntaxErrors", outViolations: "outViolations" }, viewQueries: [{ propertyName: "containerPreview", first: true, predicate: ["containerPreview"], descendants: true, isSignal: true }], ngImport: i0, template: "<div\n class=\"libs-ui-preview-data-container flex flex-col w-full h-auto rounded-[8px] libs-ui-border-general px-[8px]\"\n [style.--background-color]=\"background()\"\n [class.pt-[8px]]=\"!hiddenAction()\">\n @if (!hiddenAction()) {\n <div class=\"flex items-center content-between color-[#6a7383]\">\n <libs_ui-components-dropdown\n classInclude=\"w-[200px]\"\n [listConfig]=\"configLoadDataIsHttpConfig()\"\n [listMaxItemShow]=\"5\"\n [zIndex]=\"zIndexPopover()\"\n [isNgContent]=\"true\"\n [readonly]=\"!editable() || !acceptChangeLang()\"\n [listHasButtonUnSelectOption]=\"false\"\n [listHiddenInputSearch]=\"hiddenSearchLang()\"\n (outSelectKey)=\"handlerSelectKey($event)\">\n <libs_ui-components-buttons-button\n [type]=\"'button-link-third'\"\n [label]=\"labelLang() || ''\"\n [sizeButton]=\"'small'\"\n [classIconRight]=\"editable() && acceptChangeLang() ? 'libs-ui-icon-move-right rotate-90' : ''\"\n [classInclude]=\"'!p-[0px]' + (editable() && acceptChangeLang() ? '' : '!pointer-events-none !cursor-default hover:!text-[#6A7383]')\" />\n </libs_ui-components-dropdown>\n <div class=\"flex items-center\">\n <!-- G\u1EE3i \u00FD ph\u00EDm t\u1EAFt t\u00ECm/thay th\u1EBF \u2014 khung Ctrl + F c\u1EE7a CodeMirror kh\u00F4ng c\u00F3 n\u00FAt m\u1EDF n\u00E0o tr\u00EAn thanh c\u00F4ng c\u1EE5,\n kh\u00F4ng nh\u1EAFc th\u00EC ng\u01B0\u1EDDi d\u00F9ng kh\u00F4ng bi\u1EBFt c\u00F3 (ng\u01B0\u1EDDi d\u00F9ng y\u00EAu c\u1EA7u 30/09/2026). -->\n @if (editable()) {\n <span class=\"libs-ui-font-h6r mr-[16px] whitespace-nowrap text-[#9ca2ad]\">\n {{ 'i18n_code_editor_search_hint' | translate: { key: searchShortcut } }}\n </span>\n }\n <!-- \u0110\u1ECBnh d\u1EA1ng: \u0111\u1EE9ng tr\u01B0\u1EDBc \"Xu\u1ED1ng d\u00F2ng\" v\u00EC n\u00F3 l\u00E0 thao t\u00E1c tr\u00EAn N\u1ED8I DUNG, hai n\u00FAt sau ch\u1EC9 \u0111\u1ED5i\n c\u00E1ch hi\u1EC3n th\u1ECB. Ch\u1EC9 hi\u1EC7n khi \u00F4 s\u1EEDa \u0111\u01B0\u1EE3c v\u00E0 ng\u00F4n ng\u1EEF c\u00F3 b\u1ED9 \u0111\u1ECBnh d\u1EA1ng \u2014 xem `canFormat`. -->\n @if (canFormat()) {\n <libs_ui-components-buttons-button\n [type]=\"'button-link-third'\"\n [label]=\"'i18n_format_code'\"\n [sizeButton]=\"'small'\"\n [classIconLeft]=\"'libs-ui-icon-align-left'\"\n [classInclude]=\"'mo-lib-p-0px mo-lib-mr-16px'\"\n (outClick)=\"handlerFormat()\" />\n }\n <libs_ui-components-buttons-button\n [type]=\"'button-link-third'\"\n [label]=\"isWrap() ? 'i18n_remove_line_wrap' : 'i18n_line_wrap'\"\n [sizeButton]=\"'small'\"\n [classIconLeft]=\"isWrap() ? 'libs-ui-icon-unwrap' : 'libs-ui-icon-wrap'\"\n [classInclude]=\"'mo-lib-p-0px mo-lib-mr-16px'\"\n (outClick)=\"handlerLineWrap()\" />\n <libs_ui-components-buttons-button\n [type]=\"'button-link-third'\"\n [label]=\"'i18n_copy'\"\n [sizeButton]=\"'small'\"\n [classIconLeft]=\"'libs-ui-icon-copy'\"\n [classInclude]=\"'mo-lib-p-0px'\"\n (outClick)=\"handlerCopy()\" />\n </div>\n </div>\n }\n <div #containerPreview></div>\n</div>\n", styles: [":host ::ng-deep .libs-ui-preview-data-container{background-color:var(--background-color)!important}:host ::ng-deep .libs-ui-preview-data-container .cm-line{white-space:pre-wrap}:host ::ng-deep .libs-ui-preview-data-container .cm-lintRange-error{background-color:#ff323233;border-bottom:2px solid red}:host ::ng-deep .libs-ui-preview-data-container .cm-lintRange-warning{background-color:#ffc80026}:host ::ng-deep .libs-ui-preview-data-container .cm-tooltip-lint{background:#fff8f8;color:#d32f2f;border:1px solid #f44336;padding:8px 10px;font-size:13px;font-family:Inter,sans-serif;border-radius:6px;box-shadow:0 2px 8px #ff000026}:host ::ng-deep .libs-ui-preview-data-container .cm-focused{outline:none!important}:host ::ng-deep .libs-ui-preview-data-container .cm-content,:host ::ng-deep .libs-ui-preview-data-container .cm-gutters{font-family:JetBrains Mono,Fira Code,Cascadia Mono,Consolas,DejaVu Sans Mono,monospace;font-size:12px}:host ::ng-deep .libs-ui-preview-data-container .cm-activeLine{background-color:#f4f8ff!important}:host ::ng-deep .libs-ui-preview-data-container .cm-activeLineGutter{background-color:#f4f8ff!important;color:#1a73e8}:host ::ng-deep .libs-ui-preview-data-container .cm-lineNumbers .cm-gutterElement{color:#9aa0a6}:host ::ng-deep .libs-ui-preview-data-container .cm-cursor,:host ::ng-deep .libs-ui-preview-data-container .cm-dropCursor{border-left-color:#1a73e8!important}:host ::ng-deep .libs-ui-preview-data-container .cm-matchingBracket{background-color:#d2e3fc!important;color:inherit!important;font-weight:600}:host ::ng-deep .libs-ui-preview-data-container .cm-nonmatchingBracket{background-color:#fce8e6!important;color:#c5221f!important}:host ::ng-deep .libs-ui-preview-data-container .cm-selectionBackground{background-color:#007aff40!important}:host ::ng-deep .libs-ui-preview-data-container .cm-selectionLayer{z-index:1!important}:host ::ng-deep .libs-ui-preview-data-container .cm-gutters{background-color:var(--background-color)!important}:host ::ng-deep .libs-ui-preview-data-container .cm-tooltip-autocomplete{border:1px solid #e6e7ea;border-radius:6px;background:#fff;box-shadow:0 4px 12px #0f172a1f;overflow:hidden}:host ::ng-deep .libs-ui-preview-data-container .cm-tooltip-autocomplete>ul{max-height:260px;font-family:var(--libs-ui-font-family-name, \"Arial\")}:host ::ng-deep .libs-ui-preview-data-container .cm-tooltip-autocomplete>ul>li{display:flex;align-items:baseline;gap:10px;padding:5px 10px!important;line-height:18px}:host ::ng-deep .libs-ui-preview-data-container .cm-tooltip-autocomplete>ul>li[aria-selected]{background:#e9f1fe;color:#071631}:host ::ng-deep .libs-ui-preview-data-container .cm-tooltip-autocomplete .cm-completionLabel{flex:0 0 auto;font-family:var(--libs-ui-font-family-name, \"Arial\");font-size:12px;font-weight:500;color:#071631}:host ::ng-deep .libs-ui-preview-data-container .cm-tooltip-autocomplete .cm-completionDetail{flex:1 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-family:var(--libs-ui-font-family-name, \"Arial\");font-size:11px;font-style:normal;color:#6a7383;text-align:right}:host ::ng-deep .libs-ui-preview-data-container .cm-tooltip-autocomplete .cm-completionIcon{flex:0 0 auto;font-family:var(--libs-ui-font-family-name, \"Arial\");opacity:.5}:host ::ng-deep .libs-ui-preview-data-container .cm-completionInfo{border:1px solid #e6e7ea;border-radius:6px;background:#fff;padding:8px 10px;font-family:var(--libs-ui-font-family-name, \"Arial\");font-size:11px;color:#6a7383}:host ::ng-deep .cm-panels{background-color:#fff;color:#071631}:host ::ng-deep .cm-panels-bottom{margin:0 -8px;border-top:1px solid #e6e7ea;border-radius:0 0 8px 8px;overflow:hidden}:host ::ng-deep .cm-panels{container-type:inline-size}:host ::ng-deep .cm-panels-top{border-bottom:1px solid #e6e7ea}:host ::ng-deep .libs-ui-cm-search{--cm-search-accent: var(--libs-ui-color-default, #226ff5);--cm-search-accent-soft: var(--libs-ui-color-light-2, #e9f1fe);display:grid;grid-template-columns:max-content minmax(0,1fr) minmax(96px,max-content) minmax(96px,max-content) 28px;grid-template-areas:\"find-label find-field findNext select close\" \"replace-label replace-field replace replaceAll .\";align-items:center;gap:6px 8px;padding:8px 8px 8px 12px;background-color:#f4f5f7;font-family:var(--libs-ui-font-family-name, \"Arial\");font-size:12px;line-height:18px}:host ::ng-deep .libs-ui-cm-search [data-area=find-label]{grid-area:find-label}:host ::ng-deep .libs-ui-cm-search [data-area=find-field]{grid-area:find-field}:host ::ng-deep .libs-ui-cm-search [data-area=replace-label]{grid-area:replace-label}:host ::ng-deep .libs-ui-cm-search [data-area=replace-field]{grid-area:replace-field}:host ::ng-deep .libs-ui-cm-search [name=findNext]{grid-area:findNext}:host ::ng-deep .libs-ui-cm-search [name=select]{grid-area:select}:host ::ng-deep .libs-ui-cm-search [name=replace].libs-ui-cm-search-button{grid-area:replace}:host ::ng-deep .libs-ui-cm-search [name=replaceAll]{grid-area:replaceAll}:host ::ng-deep .libs-ui-cm-search>[name=close]{grid-area:close}:host ::ng-deep .libs-ui-cm-search-label{color:#6a7383;font-size:12px;text-align:right;white-space:nowrap}:host ::ng-deep .libs-ui-cm-search-field{display:flex;min-width:0;align-items:center;gap:2px;box-sizing:border-box;height:30px;padding:0 3px 0 8px;border:1px solid #dcdfe4;border-radius:4px;background-color:#fff;transition:border-color .15s,box-shadow .15s}:host ::ng-deep .libs-ui-cm-search-field:hover{border-color:#c4c8cf}:host ::ng-deep .libs-ui-cm-search-field:focus-within{border-color:var(--cm-search-accent);box-shadow:0 0 0 3px var(--cm-search-accent-soft)}:host ::ng-deep .libs-ui-cm-search-field.is-invalid,:host ::ng-deep .libs-ui-cm-search-field.is-invalid:focus-within{border-color:#ee2d41;box-shadow:0 0 0 3px #fdeaec}:host ::ng-deep .libs-ui-cm-search-field-icon{flex-shrink:0;margin-right:6px;line-height:0}:host ::ng-deep .libs-ui-cm-search-field-icon:before{color:#9ca2ad!important;font-size:14px}:host ::ng-deep .libs-ui-cm-search-input{flex:1 1 auto;min-width:0;height:100%;padding:0;border:none;background:transparent;color:#071631;font-family:JetBrains Mono,Fira Code,Consolas,DejaVu Sans Mono,monospace;font-size:12px;outline:none}:host ::ng-deep .libs-ui-cm-search-input::placeholder{color:#9ca2ad;font-family:var(--libs-ui-font-family-name, \"Arial\")}:host ::ng-deep .libs-ui-cm-search-count{flex-shrink:0;padding:0 4px;color:#6a7383;font-size:11px;white-space:nowrap}:host ::ng-deep .libs-ui-cm-search-count.is-empty{color:#ee2d41}:host ::ng-deep .libs-ui-cm-search-count.is-hidden{display:none}:host ::ng-deep .libs-ui-cm-search-divider{flex-shrink:0;width:1px;height:16px;margin:0 3px;background-color:#e6e7ea}:host ::ng-deep .libs-ui-cm-search-toggle{flex-shrink:0;width:24px;height:22px;padding:0;border:1px solid transparent;border-radius:3px;background:transparent;color:#6a7383;font-family:JetBrains Mono,Consolas,monospace;font-size:11px;font-weight:600;line-height:20px;cursor:pointer}:host ::ng-deep .libs-ui-cm-search-toggle:hover{background-color:#f2f4f7;color:#071631}:host ::ng-deep .libs-ui-cm-search-toggle[aria-pressed=true]{border-color:var(--cm-search-accent);background-color:var(--cm-search-accent-soft);color:var(--cm-search-accent)}:host ::ng-deep .libs-ui-cm-search-toggle[name=word]{text-decoration:underline;text-underline-offset:2px}:host ::ng-deep .libs-ui-cm-search-icon-button{display:inline-flex;flex-shrink:0;align-items:center;justify-content:center;width:22px;height:22px;padding:0;border:none;border-radius:3px;background:transparent;line-height:0;cursor:pointer}:host ::ng-deep .libs-ui-cm-search-icon-button i:before{color:#6a7383!important;font-size:12px}:host ::ng-deep .libs-ui-cm-search-icon-button[name=prev] i{transform:rotate(-90deg)}:host ::ng-deep .libs-ui-cm-search-icon-button[name=next] i{transform:rotate(90deg)}:host ::ng-deep .libs-ui-cm-search-icon-button[name=close]{width:28px;height:28px}:host ::ng-deep .libs-ui-cm-search-icon-button[name=close] i:before{font-size:14px}:host ::ng-deep .libs-ui-cm-search-icon-button:hover:not(:disabled){background-color:#e9ebee}:host ::ng-deep .libs-ui-cm-search-icon-button:hover:not(:disabled) i:before{color:#071631!important}:host ::ng-deep .libs-ui-cm-search-icon-button:disabled{opacity:.35;cursor:default}:host ::ng-deep .libs-ui-cm-search-button{box-sizing:border-box;width:100%;height:30px;padding:0 8px;overflow:hidden;border:1px solid #dcdfe4;border-radius:4px;background-color:#fff;color:#071631;font-family:inherit;font-size:12px;font-weight:500;text-overflow:ellipsis;white-space:nowrap;cursor:pointer;transition:border-color .15s,color .15s,background-color .15s}:host ::ng-deep .libs-ui-cm-search-button:hover{border-color:var(--cm-search-accent);color:var(--cm-search-accent)}:host ::ng-deep .libs-ui-cm-search-button:active{background-color:var(--cm-search-accent-soft)}:host ::ng-deep .libs-ui-cm-search-button.is-primary{border-color:var(--cm-search-accent);background-color:var(--cm-search-accent);color:#fff}:host ::ng-deep .libs-ui-cm-search-button.is-primary:hover{filter:brightness(.95);color:#fff}@container (max-width: 720px){:host ::ng-deep .libs-ui-cm-search{grid-template-columns:repeat(4,minmax(0,1fr)) 28px;grid-template-areas:\"find-field find-field find-field find-field close\" \"replace-field replace-field replace-field replace-field .\" \"findNext select replace replaceAll .\"}:host ::ng-deep .libs-ui-cm-search-label{display:none}}@container (max-width: 480px){:host ::ng-deep .libs-ui-cm-search{gap:6px 4px}:host ::ng-deep .libs-ui-cm-search-button{padding:0 4px;font-size:11px}}:host ::ng-deep .cm-searchMatch{background-color:#ffc8004d;outline:1px solid rgba(255,170,0,.5)}:host ::ng-deep .cm-searchMatch-selected{background-color:#1a73e840}\n"], dependencies: [{ kind: "ngmodule", type: TranslateModule }, { kind: "pipe", type: i1.TranslatePipe, name: "translate" }, { kind: "component", type: LibsUiComponentsDropdownComponent, selector: "libs_ui-components-dropdown", inputs: ["useXssFilter", "popoverElementRefCustom", "classInclude", "ignoreStopPropagationEvent", "flagMouse", "flagMouseContent", "popoverCustomConfig", "isNgContent", "zIndex", "convertItemSelected", "getPopoverItemSelected", "httpRequestDetailItemById", "lengthKeys", "textDisplayWhenNoSelect", "textDisplayWhenMultiSelect", "classIncludeTextDisplayWhenNoSelect", "fieldLabel", "fieldGetLabel", "labelPopoverConfig", "labelPopoverFullWidth", "hasContentUnitRight", "listSearchNoDataTemplateRef", "dropdownTemplateRefNotSearchNoData", "fieldGetImage", "imageSize", "typeShape", "fieldGetIcon", "fieldGetTextAvatar", "fieldGetColorAvatar", "classAvatarInclude", "getLastTextAfterSpace", "linkImageError", "showError", "showBorderError", "disable", "readonly", "labelConfig", "disableLabel", "listSearchConfig", "isSearchOnline", "listHiddenInputSearch", "listSearchPadding", "listKeySearch", "listDividerClassInclude", "listConfig", "listButtonsOther", "listHasButtonUnSelectOption", "listClickExactly", "listBackgroundCustom", "listMaxItemShow", "listKeySelected", "listMultiKeySelected", "listKeysDisable", "listKeysHidden", "validRequired", "validMaxItemSelected", "changeValidUndefinedResetError", "allowSelectItemMultiple", "focusInputSearch", "onlyEmitDataWhenReset", "onlyEmitMultiKeyWhenManualClick", "resetKeyWhenSelectAllKey", "listConfigHasDivider", "classIncludeIcon", "classIncludeContent", "listIgnoreClassDisableDefaultWhenUseKeysDisableItem", "tabKeyActive", "tabsConfig", "ignoreBorderBottom"], outputs: ["flagMouseChange", "flagMouseContentChange", "lengthKeysChange", "showBorderErrorChange", "listKeySelectedChange", "listMultiKeySelectedChange", "tabKeyActiveChange", "outSelectKey", "outSelectMultiKey", "outFunctionsControl", "outValidEvent", "outChangStageFlagMouse", "outDataChange", "outClickButtonOther", "outShowList", "outChangeTabKeyActive"] }, { kind: "component", type: LibsUiComponentsButtonsButtonComponent, selector: "libs_ui-components-buttons-button", inputs: ["flagMouse", "type", "buttonCustom", "sizeButton", "label", "disable", "isPending", "imageLeft", "classInclude", "classIconLeft", "classIconRight", "classLabel", "iconOnlyType", "popover", "ignoreStopPropagationEvent", "zIndex", "widthLabelPopover", "styleIconLeft", "styleButton", "ignoreFocusWhenInputTab", "ignoreSetClickWhenShowPopover", "ignorePointerEvent", "isActive", "isHandlerEnterDocumentClickButton"], outputs: ["outClick", "outPopoverEvent", "outFunctionsControl"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
1145
1927
  }
1146
1928
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: LibsUiComponentsPreviewTextDataComponent, decorators: [{
1147
1929
  type: Component,
1148
- args: [{ selector: 'libs_ui-components-preview_text_data', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, imports: [LibsUiComponentsDropdownComponent, LibsUiComponentsButtonsButtonComponent], template: "<div\n class=\"libs-ui-preview-data-container flex flex-col w-full h-auto rounded-[8px] libs-ui-border-general px-[8px]\"\n [style.--background-color]=\"background()\"\n [class.pt-[8px]]=\"!hiddenAction()\">\n @if (!hiddenAction()) {\n <div class=\"flex items-center content-between color-[#6a7383]\">\n <libs_ui-components-dropdown\n classInclude=\"w-[200px]\"\n [listConfig]=\"configLoadDataIsHttpConfig()\"\n [listMaxItemShow]=\"5\"\n [zIndex]=\"zIndexPopover()\"\n [isNgContent]=\"true\"\n [readonly]=\"!editable() || !acceptChangeLang()\"\n [listHasButtonUnSelectOption]=\"false\"\n (outSelectKey)=\"handlerSelectKey($event)\">\n <libs_ui-components-buttons-button\n [type]=\"'button-link-third'\"\n [label]=\"labelLang() || ''\"\n [sizeButton]=\"'small'\"\n [classIconRight]=\"editable() && acceptChangeLang() ? 'libs-ui-icon-move-right rotate-90' : ''\"\n [classInclude]=\"'!p-[0px]' + (editable() && acceptChangeLang() ? '' : '!pointer-events-none !cursor-default hover:!text-[#6A7383]')\" />\n </libs_ui-components-dropdown>\n <div class=\"flex items-center\">\n <libs_ui-components-buttons-button\n [type]=\"'button-link-third'\"\n [label]=\"isWrap() ? 'i18n_remove_line_wrap' : 'i18n_line_wrap'\"\n [sizeButton]=\"'small'\"\n [classIconLeft]=\"isWrap() ? 'libs-ui-icon-unwrap' : 'libs-ui-icon-wrap'\"\n [classInclude]=\"'mo-lib-p-0px mo-lib-mr-16px'\"\n (outClick)=\"handlerLineWrap()\" />\n <libs_ui-components-buttons-button\n [type]=\"'button-link-third'\"\n [label]=\"'i18n_copy'\"\n [sizeButton]=\"'small'\"\n [classIconLeft]=\"'libs-ui-icon-copy'\"\n [classInclude]=\"'mo-lib-p-0px'\"\n (outClick)=\"handlerCopy()\" />\n </div>\n </div>\n }\n <div #containerPreview></div>\n</div>\n", styles: [":host ::ng-deep .libs-ui-preview-data-container{background-color:var(--background-color)!important}:host ::ng-deep .libs-ui-preview-data-container .cm-line{white-space:pre-wrap}:host ::ng-deep .libs-ui-preview-data-container .cm-lintRange-error{background-color:#ff323233;border-bottom:2px solid red}:host ::ng-deep .libs-ui-preview-data-container .cm-lintRange-warning{background-color:#ffc80026}:host ::ng-deep .libs-ui-preview-data-container .cm-tooltip-lint{background:#fff8f8;color:#d32f2f;border:1px solid #f44336;padding:8px 10px;font-size:13px;font-family:Inter,sans-serif;border-radius:6px;box-shadow:0 2px 8px #ff000026}:host ::ng-deep .libs-ui-preview-data-container .cm-focused{outline:none!important}:host ::ng-deep .libs-ui-preview-data-container .cm-gutters{background-color:var(--background-color)!important}\n"] }]
1930
+ args: [{ selector: 'libs_ui-components-preview_text_data', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, imports: [TranslateModule, LibsUiComponentsDropdownComponent, LibsUiComponentsButtonsButtonComponent], template: "<div\n class=\"libs-ui-preview-data-container flex flex-col w-full h-auto rounded-[8px] libs-ui-border-general px-[8px]\"\n [style.--background-color]=\"background()\"\n [class.pt-[8px]]=\"!hiddenAction()\">\n @if (!hiddenAction()) {\n <div class=\"flex items-center content-between color-[#6a7383]\">\n <libs_ui-components-dropdown\n classInclude=\"w-[200px]\"\n [listConfig]=\"configLoadDataIsHttpConfig()\"\n [listMaxItemShow]=\"5\"\n [zIndex]=\"zIndexPopover()\"\n [isNgContent]=\"true\"\n [readonly]=\"!editable() || !acceptChangeLang()\"\n [listHasButtonUnSelectOption]=\"false\"\n [listHiddenInputSearch]=\"hiddenSearchLang()\"\n (outSelectKey)=\"handlerSelectKey($event)\">\n <libs_ui-components-buttons-button\n [type]=\"'button-link-third'\"\n [label]=\"labelLang() || ''\"\n [sizeButton]=\"'small'\"\n [classIconRight]=\"editable() && acceptChangeLang() ? 'libs-ui-icon-move-right rotate-90' : ''\"\n [classInclude]=\"'!p-[0px]' + (editable() && acceptChangeLang() ? '' : '!pointer-events-none !cursor-default hover:!text-[#6A7383]')\" />\n </libs_ui-components-dropdown>\n <div class=\"flex items-center\">\n <!-- G\u1EE3i \u00FD ph\u00EDm t\u1EAFt t\u00ECm/thay th\u1EBF \u2014 khung Ctrl + F c\u1EE7a CodeMirror kh\u00F4ng c\u00F3 n\u00FAt m\u1EDF n\u00E0o tr\u00EAn thanh c\u00F4ng c\u1EE5,\n kh\u00F4ng nh\u1EAFc th\u00EC ng\u01B0\u1EDDi d\u00F9ng kh\u00F4ng bi\u1EBFt c\u00F3 (ng\u01B0\u1EDDi d\u00F9ng y\u00EAu c\u1EA7u 30/09/2026). -->\n @if (editable()) {\n <span class=\"libs-ui-font-h6r mr-[16px] whitespace-nowrap text-[#9ca2ad]\">\n {{ 'i18n_code_editor_search_hint' | translate: { key: searchShortcut } }}\n </span>\n }\n <!-- \u0110\u1ECBnh d\u1EA1ng: \u0111\u1EE9ng tr\u01B0\u1EDBc \"Xu\u1ED1ng d\u00F2ng\" v\u00EC n\u00F3 l\u00E0 thao t\u00E1c tr\u00EAn N\u1ED8I DUNG, hai n\u00FAt sau ch\u1EC9 \u0111\u1ED5i\n c\u00E1ch hi\u1EC3n th\u1ECB. Ch\u1EC9 hi\u1EC7n khi \u00F4 s\u1EEDa \u0111\u01B0\u1EE3c v\u00E0 ng\u00F4n ng\u1EEF c\u00F3 b\u1ED9 \u0111\u1ECBnh d\u1EA1ng \u2014 xem `canFormat`. -->\n @if (canFormat()) {\n <libs_ui-components-buttons-button\n [type]=\"'button-link-third'\"\n [label]=\"'i18n_format_code'\"\n [sizeButton]=\"'small'\"\n [classIconLeft]=\"'libs-ui-icon-align-left'\"\n [classInclude]=\"'mo-lib-p-0px mo-lib-mr-16px'\"\n (outClick)=\"handlerFormat()\" />\n }\n <libs_ui-components-buttons-button\n [type]=\"'button-link-third'\"\n [label]=\"isWrap() ? 'i18n_remove_line_wrap' : 'i18n_line_wrap'\"\n [sizeButton]=\"'small'\"\n [classIconLeft]=\"isWrap() ? 'libs-ui-icon-unwrap' : 'libs-ui-icon-wrap'\"\n [classInclude]=\"'mo-lib-p-0px mo-lib-mr-16px'\"\n (outClick)=\"handlerLineWrap()\" />\n <libs_ui-components-buttons-button\n [type]=\"'button-link-third'\"\n [label]=\"'i18n_copy'\"\n [sizeButton]=\"'small'\"\n [classIconLeft]=\"'libs-ui-icon-copy'\"\n [classInclude]=\"'mo-lib-p-0px'\"\n (outClick)=\"handlerCopy()\" />\n </div>\n </div>\n }\n <div #containerPreview></div>\n</div>\n", styles: [":host ::ng-deep .libs-ui-preview-data-container{background-color:var(--background-color)!important}:host ::ng-deep .libs-ui-preview-data-container .cm-line{white-space:pre-wrap}:host ::ng-deep .libs-ui-preview-data-container .cm-lintRange-error{background-color:#ff323233;border-bottom:2px solid red}:host ::ng-deep .libs-ui-preview-data-container .cm-lintRange-warning{background-color:#ffc80026}:host ::ng-deep .libs-ui-preview-data-container .cm-tooltip-lint{background:#fff8f8;color:#d32f2f;border:1px solid #f44336;padding:8px 10px;font-size:13px;font-family:Inter,sans-serif;border-radius:6px;box-shadow:0 2px 8px #ff000026}:host ::ng-deep .libs-ui-preview-data-container .cm-focused{outline:none!important}:host ::ng-deep .libs-ui-preview-data-container .cm-content,:host ::ng-deep .libs-ui-preview-data-container .cm-gutters{font-family:JetBrains Mono,Fira Code,Cascadia Mono,Consolas,DejaVu Sans Mono,monospace;font-size:12px}:host ::ng-deep .libs-ui-preview-data-container .cm-activeLine{background-color:#f4f8ff!important}:host ::ng-deep .libs-ui-preview-data-container .cm-activeLineGutter{background-color:#f4f8ff!important;color:#1a73e8}:host ::ng-deep .libs-ui-preview-data-container .cm-lineNumbers .cm-gutterElement{color:#9aa0a6}:host ::ng-deep .libs-ui-preview-data-container .cm-cursor,:host ::ng-deep .libs-ui-preview-data-container .cm-dropCursor{border-left-color:#1a73e8!important}:host ::ng-deep .libs-ui-preview-data-container .cm-matchingBracket{background-color:#d2e3fc!important;color:inherit!important;font-weight:600}:host ::ng-deep .libs-ui-preview-data-container .cm-nonmatchingBracket{background-color:#fce8e6!important;color:#c5221f!important}:host ::ng-deep .libs-ui-preview-data-container .cm-selectionBackground{background-color:#007aff40!important}:host ::ng-deep .libs-ui-preview-data-container .cm-selectionLayer{z-index:1!important}:host ::ng-deep .libs-ui-preview-data-container .cm-gutters{background-color:var(--background-color)!important}:host ::ng-deep .libs-ui-preview-data-container .cm-tooltip-autocomplete{border:1px solid #e6e7ea;border-radius:6px;background:#fff;box-shadow:0 4px 12px #0f172a1f;overflow:hidden}:host ::ng-deep .libs-ui-preview-data-container .cm-tooltip-autocomplete>ul{max-height:260px;font-family:var(--libs-ui-font-family-name, \"Arial\")}:host ::ng-deep .libs-ui-preview-data-container .cm-tooltip-autocomplete>ul>li{display:flex;align-items:baseline;gap:10px;padding:5px 10px!important;line-height:18px}:host ::ng-deep .libs-ui-preview-data-container .cm-tooltip-autocomplete>ul>li[aria-selected]{background:#e9f1fe;color:#071631}:host ::ng-deep .libs-ui-preview-data-container .cm-tooltip-autocomplete .cm-completionLabel{flex:0 0 auto;font-family:var(--libs-ui-font-family-name, \"Arial\");font-size:12px;font-weight:500;color:#071631}:host ::ng-deep .libs-ui-preview-data-container .cm-tooltip-autocomplete .cm-completionDetail{flex:1 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-family:var(--libs-ui-font-family-name, \"Arial\");font-size:11px;font-style:normal;color:#6a7383;text-align:right}:host ::ng-deep .libs-ui-preview-data-container .cm-tooltip-autocomplete .cm-completionIcon{flex:0 0 auto;font-family:var(--libs-ui-font-family-name, \"Arial\");opacity:.5}:host ::ng-deep .libs-ui-preview-data-container .cm-completionInfo{border:1px solid #e6e7ea;border-radius:6px;background:#fff;padding:8px 10px;font-family:var(--libs-ui-font-family-name, \"Arial\");font-size:11px;color:#6a7383}:host ::ng-deep .cm-panels{background-color:#fff;color:#071631}:host ::ng-deep .cm-panels-bottom{margin:0 -8px;border-top:1px solid #e6e7ea;border-radius:0 0 8px 8px;overflow:hidden}:host ::ng-deep .cm-panels{container-type:inline-size}:host ::ng-deep .cm-panels-top{border-bottom:1px solid #e6e7ea}:host ::ng-deep .libs-ui-cm-search{--cm-search-accent: var(--libs-ui-color-default, #226ff5);--cm-search-accent-soft: var(--libs-ui-color-light-2, #e9f1fe);display:grid;grid-template-columns:max-content minmax(0,1fr) minmax(96px,max-content) minmax(96px,max-content) 28px;grid-template-areas:\"find-label find-field findNext select close\" \"replace-label replace-field replace replaceAll .\";align-items:center;gap:6px 8px;padding:8px 8px 8px 12px;background-color:#f4f5f7;font-family:var(--libs-ui-font-family-name, \"Arial\");font-size:12px;line-height:18px}:host ::ng-deep .libs-ui-cm-search [data-area=find-label]{grid-area:find-label}:host ::ng-deep .libs-ui-cm-search [data-area=find-field]{grid-area:find-field}:host ::ng-deep .libs-ui-cm-search [data-area=replace-label]{grid-area:replace-label}:host ::ng-deep .libs-ui-cm-search [data-area=replace-field]{grid-area:replace-field}:host ::ng-deep .libs-ui-cm-search [name=findNext]{grid-area:findNext}:host ::ng-deep .libs-ui-cm-search [name=select]{grid-area:select}:host ::ng-deep .libs-ui-cm-search [name=replace].libs-ui-cm-search-button{grid-area:replace}:host ::ng-deep .libs-ui-cm-search [name=replaceAll]{grid-area:replaceAll}:host ::ng-deep .libs-ui-cm-search>[name=close]{grid-area:close}:host ::ng-deep .libs-ui-cm-search-label{color:#6a7383;font-size:12px;text-align:right;white-space:nowrap}:host ::ng-deep .libs-ui-cm-search-field{display:flex;min-width:0;align-items:center;gap:2px;box-sizing:border-box;height:30px;padding:0 3px 0 8px;border:1px solid #dcdfe4;border-radius:4px;background-color:#fff;transition:border-color .15s,box-shadow .15s}:host ::ng-deep .libs-ui-cm-search-field:hover{border-color:#c4c8cf}:host ::ng-deep .libs-ui-cm-search-field:focus-within{border-color:var(--cm-search-accent);box-shadow:0 0 0 3px var(--cm-search-accent-soft)}:host ::ng-deep .libs-ui-cm-search-field.is-invalid,:host ::ng-deep .libs-ui-cm-search-field.is-invalid:focus-within{border-color:#ee2d41;box-shadow:0 0 0 3px #fdeaec}:host ::ng-deep .libs-ui-cm-search-field-icon{flex-shrink:0;margin-right:6px;line-height:0}:host ::ng-deep .libs-ui-cm-search-field-icon:before{color:#9ca2ad!important;font-size:14px}:host ::ng-deep .libs-ui-cm-search-input{flex:1 1 auto;min-width:0;height:100%;padding:0;border:none;background:transparent;color:#071631;font-family:JetBrains Mono,Fira Code,Consolas,DejaVu Sans Mono,monospace;font-size:12px;outline:none}:host ::ng-deep .libs-ui-cm-search-input::placeholder{color:#9ca2ad;font-family:var(--libs-ui-font-family-name, \"Arial\")}:host ::ng-deep .libs-ui-cm-search-count{flex-shrink:0;padding:0 4px;color:#6a7383;font-size:11px;white-space:nowrap}:host ::ng-deep .libs-ui-cm-search-count.is-empty{color:#ee2d41}:host ::ng-deep .libs-ui-cm-search-count.is-hidden{display:none}:host ::ng-deep .libs-ui-cm-search-divider{flex-shrink:0;width:1px;height:16px;margin:0 3px;background-color:#e6e7ea}:host ::ng-deep .libs-ui-cm-search-toggle{flex-shrink:0;width:24px;height:22px;padding:0;border:1px solid transparent;border-radius:3px;background:transparent;color:#6a7383;font-family:JetBrains Mono,Consolas,monospace;font-size:11px;font-weight:600;line-height:20px;cursor:pointer}:host ::ng-deep .libs-ui-cm-search-toggle:hover{background-color:#f2f4f7;color:#071631}:host ::ng-deep .libs-ui-cm-search-toggle[aria-pressed=true]{border-color:var(--cm-search-accent);background-color:var(--cm-search-accent-soft);color:var(--cm-search-accent)}:host ::ng-deep .libs-ui-cm-search-toggle[name=word]{text-decoration:underline;text-underline-offset:2px}:host ::ng-deep .libs-ui-cm-search-icon-button{display:inline-flex;flex-shrink:0;align-items:center;justify-content:center;width:22px;height:22px;padding:0;border:none;border-radius:3px;background:transparent;line-height:0;cursor:pointer}:host ::ng-deep .libs-ui-cm-search-icon-button i:before{color:#6a7383!important;font-size:12px}:host ::ng-deep .libs-ui-cm-search-icon-button[name=prev] i{transform:rotate(-90deg)}:host ::ng-deep .libs-ui-cm-search-icon-button[name=next] i{transform:rotate(90deg)}:host ::ng-deep .libs-ui-cm-search-icon-button[name=close]{width:28px;height:28px}:host ::ng-deep .libs-ui-cm-search-icon-button[name=close] i:before{font-size:14px}:host ::ng-deep .libs-ui-cm-search-icon-button:hover:not(:disabled){background-color:#e9ebee}:host ::ng-deep .libs-ui-cm-search-icon-button:hover:not(:disabled) i:before{color:#071631!important}:host ::ng-deep .libs-ui-cm-search-icon-button:disabled{opacity:.35;cursor:default}:host ::ng-deep .libs-ui-cm-search-button{box-sizing:border-box;width:100%;height:30px;padding:0 8px;overflow:hidden;border:1px solid #dcdfe4;border-radius:4px;background-color:#fff;color:#071631;font-family:inherit;font-size:12px;font-weight:500;text-overflow:ellipsis;white-space:nowrap;cursor:pointer;transition:border-color .15s,color .15s,background-color .15s}:host ::ng-deep .libs-ui-cm-search-button:hover{border-color:var(--cm-search-accent);color:var(--cm-search-accent)}:host ::ng-deep .libs-ui-cm-search-button:active{background-color:var(--cm-search-accent-soft)}:host ::ng-deep .libs-ui-cm-search-button.is-primary{border-color:var(--cm-search-accent);background-color:var(--cm-search-accent);color:#fff}:host ::ng-deep .libs-ui-cm-search-button.is-primary:hover{filter:brightness(.95);color:#fff}@container (max-width: 720px){:host ::ng-deep .libs-ui-cm-search{grid-template-columns:repeat(4,minmax(0,1fr)) 28px;grid-template-areas:\"find-field find-field find-field find-field close\" \"replace-field replace-field replace-field replace-field .\" \"findNext select replace replaceAll .\"}:host ::ng-deep .libs-ui-cm-search-label{display:none}}@container (max-width: 480px){:host ::ng-deep .libs-ui-cm-search{gap:6px 4px}:host ::ng-deep .libs-ui-cm-search-button{padding:0 4px;font-size:11px}}:host ::ng-deep .cm-searchMatch{background-color:#ffc8004d;outline:1px solid rgba(255,170,0,.5)}:host ::ng-deep .cm-searchMatch-selected{background-color:#1a73e840}\n"] }]
1149
1931
  }], ctorParameters: () => [] });
1150
1932
 
1151
1933
  /**
1152
1934
  * Generated bundle index. Do not edit.
1153
1935
  */
1154
1936
 
1155
- export { DEFAULT_SECURITY_PATTERNS, LibsUiComponentsPreviewTextDataComponent, astSkipKeys, astTypeKeys, createDefaultLanguage, httpRequestConfigGetOptionsLang, languageRegistry, optionsLangData, tsValueNodes };
1937
+ export { DEFAULT_SECURITY_PATTERNS, DEFAULT_SQL_FORBIDDEN_PATTERNS, FORMATTABLE_LANGUAGES, LibsUiComponentsPreviewTextDataComponent, astSkipKeys, astTypeKeys, createDefaultLanguage, formatByLanguage, httpRequestConfigGetOptionsLang, languageRegistry, optionsLangData, sqlFormat, sqlNormalizeForCompare, sqlSplitPreservingLiterals, tsValueNodes };
1156
1938
  //# sourceMappingURL=libs-ui-components-preview-text-data.mjs.map