@aquera/ngx-smart-table 0.0.17-patch-0.2 → 0.0.17-patch-0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm2020/lib/editors/nile-code-editor.mjs +227 -65
- package/fesm2015/aquera-ngx-smart-table.mjs +246 -83
- package/fesm2015/aquera-ngx-smart-table.mjs.map +1 -1
- package/fesm2020/aquera-ngx-smart-table.mjs +226 -64
- package/fesm2020/aquera-ngx-smart-table.mjs.map +1 -1
- package/lib/editors/nile-code-editor.d.ts +28 -4
- package/package.json +1 -1
|
@@ -4731,11 +4731,13 @@ function injectCodeEditorStyles() {
|
|
|
4731
4731
|
const style = document.createElement('style');
|
|
4732
4732
|
style.id = styleId;
|
|
4733
4733
|
style.textContent = `
|
|
4734
|
-
/* Nile Code Editor cell styling */
|
|
4734
|
+
/* Nile Code Editor cell styling - constrained to cell height */
|
|
4735
4735
|
nile-code-editor.st-cell-editor {
|
|
4736
4736
|
display: block;
|
|
4737
4737
|
width: 100%;
|
|
4738
4738
|
height: 100%;
|
|
4739
|
+
max-height: 32px;
|
|
4740
|
+
overflow: hidden;
|
|
4739
4741
|
font-size: inherit !important;
|
|
4740
4742
|
font-family: inherit !important;
|
|
4741
4743
|
line-height: inherit !important;
|
|
@@ -4743,19 +4745,31 @@ function injectCodeEditorStyles() {
|
|
|
4743
4745
|
nile-code-editor.st-cell-editor::part(code-editor-base) {
|
|
4744
4746
|
border: none !important;
|
|
4745
4747
|
min-height: 100% !important;
|
|
4748
|
+
max-height: 32px !important;
|
|
4746
4749
|
background: transparent !important;
|
|
4747
4750
|
font-size: inherit !important;
|
|
4748
4751
|
font-family: inherit !important;
|
|
4749
4752
|
line-height: inherit !important;
|
|
4753
|
+
overflow: hidden !important;
|
|
4750
4754
|
}
|
|
4751
4755
|
/* Ensure proper sizing within table cell */
|
|
4752
4756
|
.st-nile-code-editor {
|
|
4753
4757
|
width: 100%;
|
|
4754
4758
|
height: 100%;
|
|
4759
|
+
max-height: 32px;
|
|
4755
4760
|
min-height: 28px;
|
|
4756
4761
|
font-size: inherit !important;
|
|
4762
|
+
overflow: hidden;
|
|
4763
|
+
}
|
|
4764
|
+
/* CodeMirror content should inherit font size and be constrained */
|
|
4765
|
+
nile-code-editor.st-cell-editor .cm-editor {
|
|
4766
|
+
max-height: 32px !important;
|
|
4767
|
+
overflow: hidden !important;
|
|
4768
|
+
}
|
|
4769
|
+
nile-code-editor.st-cell-editor .cm-scroller {
|
|
4770
|
+
max-height: 32px !important;
|
|
4771
|
+
overflow: hidden !important;
|
|
4757
4772
|
}
|
|
4758
|
-
/* CodeMirror content should inherit font size */
|
|
4759
4773
|
nile-code-editor.st-cell-editor .cm-content,
|
|
4760
4774
|
nile-code-editor.st-cell-editor .cm-line {
|
|
4761
4775
|
font-size: inherit !important;
|
|
@@ -4768,12 +4782,15 @@ function injectCodeEditorStyles() {
|
|
|
4768
4782
|
align-items: center;
|
|
4769
4783
|
width: 100%;
|
|
4770
4784
|
height: 100%;
|
|
4785
|
+
max-height: 32px;
|
|
4771
4786
|
gap: 4px;
|
|
4772
4787
|
}
|
|
4773
4788
|
.st-code-editor-wrapper .st-code-editor-input {
|
|
4774
4789
|
flex: 1;
|
|
4775
4790
|
min-width: 0;
|
|
4776
4791
|
height: 100%;
|
|
4792
|
+
max-height: 32px;
|
|
4793
|
+
overflow: hidden;
|
|
4777
4794
|
}
|
|
4778
4795
|
.st-code-editor-wrapper .st-expand-button {
|
|
4779
4796
|
display: flex;
|
|
@@ -4794,13 +4811,22 @@ function injectCodeEditorStyles() {
|
|
|
4794
4811
|
background: var(--nile-color-neutral-100, #f3f4f6);
|
|
4795
4812
|
color: var(--nile-color-neutral-700, #374151);
|
|
4796
4813
|
}
|
|
4797
|
-
/* Dialog code editor styling */
|
|
4814
|
+
/* Dialog code editor styling - fixed header/footer, scrollable content */
|
|
4798
4815
|
.st-code-editor-dialog::part(panel) {
|
|
4799
4816
|
max-height: var(--max-height, 80vh) !important;
|
|
4800
4817
|
overflow: hidden !important;
|
|
4818
|
+
display: flex !important;
|
|
4819
|
+
flex-direction: column !important;
|
|
4820
|
+
}
|
|
4821
|
+
.st-code-editor-dialog::part(header) {
|
|
4822
|
+
flex-shrink: 0 !important;
|
|
4801
4823
|
}
|
|
4802
4824
|
.st-code-editor-dialog::part(body) {
|
|
4803
|
-
overflow:
|
|
4825
|
+
overflow: hidden !important;
|
|
4826
|
+
flex: 1 !important;
|
|
4827
|
+
display: flex !important;
|
|
4828
|
+
flex-direction: column !important;
|
|
4829
|
+
padding: 0 !important;
|
|
4804
4830
|
}
|
|
4805
4831
|
.st-code-editor-dialog nile-code-editor {
|
|
4806
4832
|
width: 100%;
|
|
@@ -4809,14 +4835,6 @@ function injectCodeEditorStyles() {
|
|
|
4809
4835
|
.st-code-editor-dialog nile-code-editor::part(code-editor-base) {
|
|
4810
4836
|
border: 1px solid var(--nile-color-neutral-200, #e5e7eb) !important;
|
|
4811
4837
|
border-radius: 4px !important;
|
|
4812
|
-
overflow: auto !important;
|
|
4813
|
-
min-height: var(--dialog-editor-min-height, 300px) !important;
|
|
4814
|
-
}
|
|
4815
|
-
.st-code-editor-dialog nile-code-editor .cm-editor {
|
|
4816
|
-
min-height: var(--dialog-editor-min-height, 300px) !important;
|
|
4817
|
-
}
|
|
4818
|
-
.st-code-editor-dialog nile-code-editor .cm-content {
|
|
4819
|
-
min-height: var(--dialog-editor-min-height, 300px) !important;
|
|
4820
4838
|
}
|
|
4821
4839
|
`;
|
|
4822
4840
|
document.head.appendChild(style);
|
|
@@ -4833,19 +4851,26 @@ class NileCodeEditor {
|
|
|
4833
4851
|
this.dialogOpen = false;
|
|
4834
4852
|
this.expandButtonClicked = false;
|
|
4835
4853
|
this.trackedValue = null;
|
|
4854
|
+
this.syncingFromDialog = false; // Flag to prevent inline editor from overwriting multiline content
|
|
4855
|
+
this.userEditedInline = false; // Flag to track if user has typed in inline editor
|
|
4856
|
+
this.dialogOriginalValue = ''; // Store original value when dialog opens
|
|
4857
|
+
this.dialogCurrentValue = ''; // Track current value in dialog
|
|
4836
4858
|
}
|
|
4837
4859
|
edit(context) {
|
|
4838
|
-
var _a, _b, _c, _d, _e, _f;
|
|
4860
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
4839
4861
|
if (!context.container) {
|
|
4840
4862
|
console.warn('NileCodeEditor requires a container element');
|
|
4841
4863
|
return;
|
|
4842
4864
|
}
|
|
4843
4865
|
this.context = context;
|
|
4844
|
-
|
|
4866
|
+
// Initialize tracked value from context
|
|
4867
|
+
this.trackedValue = String((_a = context.value) !== null && _a !== void 0 ? _a : '');
|
|
4868
|
+
this.syncingFromDialog = false;
|
|
4869
|
+
this.userEditedInline = false;
|
|
4845
4870
|
// Inject global styles once
|
|
4846
4871
|
injectCodeEditorStyles();
|
|
4847
4872
|
// Check if we should show expand button (default: true)
|
|
4848
|
-
const showExpandButton = ((
|
|
4873
|
+
const showExpandButton = ((_b = this.options) === null || _b === void 0 ? void 0 : _b.showExpandButton) !== false;
|
|
4849
4874
|
if (showExpandButton) {
|
|
4850
4875
|
// Create wrapper for editor + expand button
|
|
4851
4876
|
this.wrapper = document.createElement('div');
|
|
@@ -4855,12 +4880,17 @@ class NileCodeEditor {
|
|
|
4855
4880
|
editorContainer.className = 'st-code-editor-input';
|
|
4856
4881
|
// Create NileCodeEditor custom element
|
|
4857
4882
|
this.editor = document.createElement('nile-code-editor');
|
|
4858
|
-
this.editor.value = String((
|
|
4883
|
+
this.editor.value = String((_c = context.value) !== null && _c !== void 0 ? _c : '');
|
|
4859
4884
|
this.editor.className = 'st-cell-editor st-nile-code-editor';
|
|
4860
4885
|
this.editor.style.width = '100%';
|
|
4861
4886
|
this.editor.style.height = '100%';
|
|
4862
4887
|
this.editor.style.boxSizing = 'border-box';
|
|
4863
|
-
this.editor.noborder = ((
|
|
4888
|
+
this.editor.noborder = ((_d = this.options) === null || _d === void 0 ? void 0 : _d.noborder) !== false;
|
|
4889
|
+
// Enable multiline by default for inline editor to support paste and multiline content
|
|
4890
|
+
this.editor.multiline = ((_e = this.options) === null || _e === void 0 ? void 0 : _e.multiline) !== false;
|
|
4891
|
+
this.editor.hasScroller = true;
|
|
4892
|
+
// No line numbers for inline editor
|
|
4893
|
+
this.editor.lineNumbers = false;
|
|
4864
4894
|
editorContainer.appendChild(this.editor);
|
|
4865
4895
|
this.wrapper.appendChild(editorContainer);
|
|
4866
4896
|
// Create expand button
|
|
@@ -4888,12 +4918,17 @@ class NileCodeEditor {
|
|
|
4888
4918
|
else {
|
|
4889
4919
|
// Create NileCodeEditor custom element without wrapper
|
|
4890
4920
|
this.editor = document.createElement('nile-code-editor');
|
|
4891
|
-
this.editor.value = String((
|
|
4921
|
+
this.editor.value = String((_f = context.value) !== null && _f !== void 0 ? _f : '');
|
|
4892
4922
|
this.editor.className = 'st-cell-editor st-nile-code-editor';
|
|
4893
4923
|
this.editor.style.width = '100%';
|
|
4894
4924
|
this.editor.style.height = '100%';
|
|
4895
4925
|
this.editor.style.boxSizing = 'border-box';
|
|
4896
|
-
this.editor.noborder = ((
|
|
4926
|
+
this.editor.noborder = ((_g = this.options) === null || _g === void 0 ? void 0 : _g.noborder) !== false;
|
|
4927
|
+
// Enable multiline by default for inline editor to support paste and multiline content
|
|
4928
|
+
this.editor.multiline = ((_h = this.options) === null || _h === void 0 ? void 0 : _h.multiline) !== false;
|
|
4929
|
+
this.editor.hasScroller = true;
|
|
4930
|
+
// No line numbers for inline editor
|
|
4931
|
+
this.editor.lineNumbers = false;
|
|
4897
4932
|
// Clear container and append editor
|
|
4898
4933
|
context.container.innerHTML = '';
|
|
4899
4934
|
context.container.appendChild(this.editor);
|
|
@@ -4903,7 +4938,7 @@ class NileCodeEditor {
|
|
|
4903
4938
|
// Set up event listeners
|
|
4904
4939
|
this.setupEventListeners(context);
|
|
4905
4940
|
// Auto focus - need a slight delay for nile-code-editor to fully initialize
|
|
4906
|
-
if (((
|
|
4941
|
+
if (((_j = this.options) === null || _j === void 0 ? void 0 : _j.autoFocus) !== false) {
|
|
4907
4942
|
// Listen for the nile-after-init event which fires when editor is ready
|
|
4908
4943
|
const initHandler = () => {
|
|
4909
4944
|
var _a;
|
|
@@ -4942,15 +4977,48 @@ class NileCodeEditor {
|
|
|
4942
4977
|
// Silently handle any errors
|
|
4943
4978
|
}
|
|
4944
4979
|
}
|
|
4980
|
+
/**
|
|
4981
|
+
* Read the live value directly from CodeMirror's internal state,
|
|
4982
|
+
* bypassing debounced nile-change events and the possibly-stale .value property.
|
|
4983
|
+
*
|
|
4984
|
+
* Priority order:
|
|
4985
|
+
* 1. trackedValue - always up to date from change events
|
|
4986
|
+
* 2. CodeMirror internal state - for real-time reading
|
|
4987
|
+
* 3. editor.value property - fallback
|
|
4988
|
+
*/
|
|
4989
|
+
getLiveEditorValue() {
|
|
4990
|
+
var _a, _b;
|
|
4991
|
+
// Use tracked value if available (updated by change events)
|
|
4992
|
+
if (this.trackedValue !== null) {
|
|
4993
|
+
return this.trackedValue;
|
|
4994
|
+
}
|
|
4995
|
+
if (!this.editor)
|
|
4996
|
+
return '';
|
|
4997
|
+
try {
|
|
4998
|
+
const shadowRoot = this.editor.shadowRoot;
|
|
4999
|
+
if (shadowRoot) {
|
|
5000
|
+
const cmEditor = shadowRoot.querySelector('.cm-editor');
|
|
5001
|
+
if ((_a = cmEditor === null || cmEditor === void 0 ? void 0 : cmEditor.cmView) === null || _a === void 0 ? void 0 : _a.view) {
|
|
5002
|
+
return cmEditor.cmView.view.state.doc.toString();
|
|
5003
|
+
}
|
|
5004
|
+
}
|
|
5005
|
+
}
|
|
5006
|
+
catch (_c) {
|
|
5007
|
+
// Fall through to other methods
|
|
5008
|
+
}
|
|
5009
|
+
return (_b = this.editor.value) !== null && _b !== void 0 ? _b : '';
|
|
5010
|
+
}
|
|
4945
5011
|
/**
|
|
4946
5012
|
* Open the full editor dialog
|
|
4947
5013
|
*/
|
|
4948
5014
|
openDialog() {
|
|
4949
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m
|
|
5015
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
4950
5016
|
if (this.dialogOpen)
|
|
4951
5017
|
return;
|
|
4952
5018
|
this.dialogOpen = true;
|
|
4953
5019
|
this.expandButtonClicked = false; // Reset flag now that dialog is opening
|
|
5020
|
+
// Store original value for cancel functionality
|
|
5021
|
+
this.dialogOriginalValue = this.getLiveEditorValue();
|
|
4954
5022
|
// Create dialog with configurable dimensions
|
|
4955
5023
|
const dialogWidth = ((_a = this.options) === null || _a === void 0 ? void 0 : _a.dialogWidth) || '600px';
|
|
4956
5024
|
const dialogMaxHeight = ((_b = this.options) === null || _b === void 0 ? void 0 : _b.dialogMaxHeight) || '80vh';
|
|
@@ -4961,86 +5029,91 @@ class NileCodeEditor {
|
|
|
4961
5029
|
this.dialog.label = dialogTitle;
|
|
4962
5030
|
this.dialog.style.setProperty('--width', dialogWidth);
|
|
4963
5031
|
this.dialog.style.setProperty('--max-height', dialogMaxHeight);
|
|
4964
|
-
// Create dialog content
|
|
5032
|
+
// Create dialog content wrapper - flex column to handle fixed header/footer
|
|
5033
|
+
const contentWrapper = document.createElement('div');
|
|
5034
|
+
contentWrapper.style.display = 'flex';
|
|
5035
|
+
contentWrapper.style.flexDirection = 'column';
|
|
5036
|
+
contentWrapper.style.height = `calc(${dialogMaxHeight} - 60px)`; // Account for dialog header
|
|
5037
|
+
contentWrapper.style.maxHeight = `calc(${dialogMaxHeight} - 60px)`;
|
|
5038
|
+
// Create editor content area - this is the scrollable part
|
|
4965
5039
|
const content = document.createElement('div');
|
|
4966
5040
|
content.style.padding = '16px';
|
|
4967
|
-
content.style.
|
|
5041
|
+
content.style.paddingBottom = '8px';
|
|
5042
|
+
content.style.flex = '1';
|
|
4968
5043
|
content.style.overflow = 'auto';
|
|
5044
|
+
content.style.minHeight = '0'; // Important for flex shrinking
|
|
4969
5045
|
// Create full editor
|
|
4970
5046
|
this.dialogEditor = document.createElement('nile-code-editor');
|
|
4971
|
-
|
|
4972
|
-
const currentValue = ((_g = this.editor) === null || _g === void 0 ? void 0 : _g.value) || '';
|
|
4973
|
-
const currentLineCount = (currentValue.match(/\n/g) || []).length + 1;
|
|
4974
|
-
const paddingLines = Math.max(0, minLines - currentLineCount);
|
|
4975
|
-
this.dialogEditor.value = currentValue + '\n'.repeat(paddingLines);
|
|
5047
|
+
this.dialogEditor.value = this.dialogOriginalValue;
|
|
4976
5048
|
this.dialogEditor.multiline = true;
|
|
4977
5049
|
this.dialogEditor.lineNumbersMultiline = true;
|
|
4978
5050
|
this.dialogEditor.hasScroller = true;
|
|
4979
|
-
|
|
4980
|
-
const minHeightFromLines = `${minLines * lineHeightPx}px`;
|
|
4981
|
-
this.dialogEditor.style.minHeight = `max(${dialogEditorHeight}, ${minHeightFromLines})`;
|
|
4982
|
-
this.dialogEditor.style.maxHeight = `calc(${dialogMaxHeight} - 120px)`;
|
|
4983
|
-
content.style.setProperty('--dialog-editor-min-height', `max(${dialogEditorHeight}, ${minHeightFromLines})`);
|
|
5051
|
+
this.dialogEditor.style.minHeight = dialogEditorHeight;
|
|
4984
5052
|
// Apply same options to dialog editor
|
|
4985
|
-
if ((
|
|
5053
|
+
if ((_e = this.options) === null || _e === void 0 ? void 0 : _e.language) {
|
|
4986
5054
|
this.dialogEditor.language = this.options.language;
|
|
4987
5055
|
}
|
|
4988
|
-
if ((
|
|
5056
|
+
if ((_f = this.options) === null || _f === void 0 ? void 0 : _f.placeholder) {
|
|
4989
5057
|
this.dialogEditor.placeholder = this.options.placeholder;
|
|
4990
5058
|
}
|
|
4991
|
-
if (((
|
|
5059
|
+
if (((_g = this.options) === null || _g === void 0 ? void 0 : _g.tabCompletion) !== undefined) {
|
|
4992
5060
|
this.dialogEditor.tabCompletion = this.options.tabCompletion;
|
|
4993
5061
|
}
|
|
4994
|
-
if (((
|
|
5062
|
+
if (((_h = this.options) === null || _h === void 0 ? void 0 : _h.enableSearch) !== undefined) {
|
|
4995
5063
|
this.dialogEditor.enableSearch = this.options.enableSearch;
|
|
4996
5064
|
}
|
|
4997
|
-
if (((
|
|
5065
|
+
if (((_j = this.options) === null || _j === void 0 ? void 0 : _j.enableFoldGutters) !== undefined) {
|
|
4998
5066
|
this.dialogEditor.enableFoldGutters = this.options.enableFoldGutters;
|
|
4999
5067
|
}
|
|
5000
|
-
if ((
|
|
5068
|
+
if ((_k = this.options) === null || _k === void 0 ? void 0 : _k.customAutoCompletions) {
|
|
5001
5069
|
this.dialogEditor.customAutoCompletions = this.options.customAutoCompletions;
|
|
5002
5070
|
}
|
|
5003
|
-
if ((
|
|
5071
|
+
if ((_l = this.options) === null || _l === void 0 ? void 0 : _l.customCompletionsPaths) {
|
|
5004
5072
|
this.dialogEditor.customCompletionsPaths = this.options.customCompletionsPaths;
|
|
5005
5073
|
}
|
|
5006
|
-
if ((
|
|
5074
|
+
if ((_m = this.options) === null || _m === void 0 ? void 0 : _m.customThemeCSS) {
|
|
5007
5075
|
this.dialogEditor.customThemeCSS = this.options.customThemeCSS;
|
|
5008
5076
|
}
|
|
5009
5077
|
this.dialogEditor.expandable = false;
|
|
5010
|
-
//
|
|
5078
|
+
// Initialize dialog current value
|
|
5079
|
+
this.dialogCurrentValue = this.dialogOriginalValue;
|
|
5080
|
+
// Track changes in dialog editor
|
|
5011
5081
|
this.dialogEditor.addEventListener('nile-change', (e) => {
|
|
5012
|
-
var _a;
|
|
5013
|
-
|
|
5014
|
-
this.trackedValue = dialogValue;
|
|
5015
|
-
if (this.editor) {
|
|
5016
|
-
this.editor.value = dialogValue;
|
|
5017
|
-
}
|
|
5018
|
-
if (this.context) {
|
|
5019
|
-
this.context.onChange(dialogValue);
|
|
5020
|
-
}
|
|
5082
|
+
var _a, _b;
|
|
5083
|
+
this.dialogCurrentValue = (_b = (_a = e.detail) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : '';
|
|
5021
5084
|
});
|
|
5022
5085
|
content.appendChild(this.dialogEditor);
|
|
5023
|
-
|
|
5024
|
-
//
|
|
5086
|
+
contentWrapper.appendChild(content);
|
|
5087
|
+
// Create footer with Ok button - fixed at bottom
|
|
5088
|
+
const footer = document.createElement('div');
|
|
5089
|
+
footer.style.display = 'flex';
|
|
5090
|
+
footer.style.justifyContent = 'flex-end';
|
|
5091
|
+
footer.style.padding = '12px 16px';
|
|
5092
|
+
footer.style.borderTop = '1px solid var(--nile-color-neutral-200, #e5e7eb)';
|
|
5093
|
+
footer.style.gap = '8px';
|
|
5094
|
+
footer.style.flexShrink = '0'; // Prevent footer from shrinking
|
|
5095
|
+
footer.style.backgroundColor = 'var(--nile-color-neutral-0, #ffffff)';
|
|
5096
|
+
const okButton = document.createElement('nile-button');
|
|
5097
|
+
okButton.setAttribute('variant', 'primary');
|
|
5098
|
+
okButton.textContent = 'Ok';
|
|
5099
|
+
okButton.addEventListener('click', () => {
|
|
5100
|
+
this.applyDialogChanges();
|
|
5101
|
+
});
|
|
5102
|
+
footer.appendChild(okButton);
|
|
5103
|
+
contentWrapper.appendChild(footer);
|
|
5104
|
+
this.dialog.appendChild(contentWrapper);
|
|
5105
|
+
// Handle dialog close events (clicking X button - cancel changes)
|
|
5025
5106
|
this.dialog.addEventListener('nile-request-close', (e) => {
|
|
5026
|
-
|
|
5027
|
-
|
|
5028
|
-
|
|
5029
|
-
if (((_a = customEvent.detail) === null || _a === void 0 ? void 0 : _a.source) === 'overlay') {
|
|
5030
|
-
// Clicking outside the dialog - save and exit edit mode
|
|
5031
|
-
this.closeDialog(true);
|
|
5032
|
-
}
|
|
5033
|
-
else {
|
|
5034
|
-
// Clicking X button - stay in edit mode
|
|
5035
|
-
this.closeDialog(false);
|
|
5036
|
-
}
|
|
5107
|
+
e.preventDefault();
|
|
5108
|
+
// X button or overlay click - cancel changes
|
|
5109
|
+
this.cancelDialogChanges();
|
|
5037
5110
|
});
|
|
5038
|
-
// Handle Escape key in dialog -
|
|
5111
|
+
// Handle Escape key in dialog - cancel changes
|
|
5039
5112
|
this.dialog.addEventListener('keydown', (e) => {
|
|
5040
5113
|
if (e.key === 'Escape') {
|
|
5041
5114
|
e.preventDefault();
|
|
5042
5115
|
e.stopPropagation();
|
|
5043
|
-
this.
|
|
5116
|
+
this.cancelDialogChanges();
|
|
5044
5117
|
}
|
|
5045
5118
|
});
|
|
5046
5119
|
// Append to body and show
|
|
@@ -5058,34 +5131,115 @@ class NileCodeEditor {
|
|
|
5058
5131
|
}, 0);
|
|
5059
5132
|
}
|
|
5060
5133
|
/**
|
|
5061
|
-
*
|
|
5134
|
+
* Get the current value from the dialog editor
|
|
5062
5135
|
*/
|
|
5063
|
-
|
|
5136
|
+
getDialogEditorValue() {
|
|
5137
|
+
var _a;
|
|
5138
|
+
// Use tracked value from change events (most reliable)
|
|
5139
|
+
if (this.dialogCurrentValue) {
|
|
5140
|
+
return this.dialogCurrentValue.replace(/\n+$/, '');
|
|
5141
|
+
}
|
|
5142
|
+
if (!this.dialogEditor)
|
|
5143
|
+
return this.dialogOriginalValue;
|
|
5144
|
+
// Try to get value from CodeMirror's internal state
|
|
5145
|
+
try {
|
|
5146
|
+
const shadowRoot = this.dialogEditor.shadowRoot;
|
|
5147
|
+
if (shadowRoot) {
|
|
5148
|
+
const cmEditor = shadowRoot.querySelector('.cm-editor');
|
|
5149
|
+
if ((_a = cmEditor === null || cmEditor === void 0 ? void 0 : cmEditor.cmView) === null || _a === void 0 ? void 0 : _a.view) {
|
|
5150
|
+
const value = cmEditor.cmView.view.state.doc.toString();
|
|
5151
|
+
return value.replace(/\n+$/, '');
|
|
5152
|
+
}
|
|
5153
|
+
}
|
|
5154
|
+
}
|
|
5155
|
+
catch (_b) {
|
|
5156
|
+
// Fall through to other methods
|
|
5157
|
+
}
|
|
5158
|
+
// Fallback to value property
|
|
5159
|
+
const value = this.dialogEditor.value;
|
|
5160
|
+
return (value !== null && value !== void 0 ? value : '').replace(/\n+$/, '');
|
|
5161
|
+
}
|
|
5162
|
+
/**
|
|
5163
|
+
* Apply changes from dialog and close it
|
|
5164
|
+
*/
|
|
5165
|
+
applyDialogChanges() {
|
|
5166
|
+
var _a, _b;
|
|
5167
|
+
if (!this.dialogOpen)
|
|
5168
|
+
return;
|
|
5169
|
+
// Get the value from dialog editor - try multiple sources
|
|
5170
|
+
let dialogValue = this.dialogCurrentValue;
|
|
5171
|
+
// If no tracked value, try reading directly from dialog editor
|
|
5172
|
+
if (!dialogValue && this.dialogEditor) {
|
|
5173
|
+
try {
|
|
5174
|
+
const shadowRoot = this.dialogEditor.shadowRoot;
|
|
5175
|
+
if (shadowRoot) {
|
|
5176
|
+
const cmEditor = shadowRoot.querySelector('.cm-editor');
|
|
5177
|
+
if ((_a = cmEditor === null || cmEditor === void 0 ? void 0 : cmEditor.cmView) === null || _a === void 0 ? void 0 : _a.view) {
|
|
5178
|
+
dialogValue = cmEditor.cmView.view.state.doc.toString();
|
|
5179
|
+
}
|
|
5180
|
+
}
|
|
5181
|
+
}
|
|
5182
|
+
catch (_c) {
|
|
5183
|
+
// Fall through
|
|
5184
|
+
}
|
|
5185
|
+
// Fallback to value property
|
|
5186
|
+
if (!dialogValue) {
|
|
5187
|
+
dialogValue = (_b = this.dialogEditor.value) !== null && _b !== void 0 ? _b : '';
|
|
5188
|
+
}
|
|
5189
|
+
}
|
|
5190
|
+
// Strip trailing newlines
|
|
5191
|
+
dialogValue = (dialogValue || '').replace(/\n+$/, '');
|
|
5192
|
+
// Update tracked value and inline editor
|
|
5193
|
+
this.trackedValue = dialogValue;
|
|
5194
|
+
this.userEditedInline = false;
|
|
5195
|
+
this.syncingFromDialog = true;
|
|
5196
|
+
if (this.editor) {
|
|
5197
|
+
this.editor.value = dialogValue;
|
|
5198
|
+
}
|
|
5199
|
+
setTimeout(() => {
|
|
5200
|
+
this.syncingFromDialog = false;
|
|
5201
|
+
}, 0);
|
|
5202
|
+
// Notify context of the change
|
|
5203
|
+
if (this.context) {
|
|
5204
|
+
this.context.onChange(dialogValue);
|
|
5205
|
+
}
|
|
5206
|
+
// Close dialog
|
|
5207
|
+
this.closeDialogUI();
|
|
5208
|
+
// Refocus the cell editor to stay in edit mode
|
|
5209
|
+
setTimeout(() => {
|
|
5210
|
+
this.focusEditor();
|
|
5211
|
+
}, 50);
|
|
5212
|
+
}
|
|
5213
|
+
/**
|
|
5214
|
+
* Cancel dialog changes and revert to original value
|
|
5215
|
+
*/
|
|
5216
|
+
cancelDialogChanges() {
|
|
5064
5217
|
if (!this.dialogOpen)
|
|
5065
5218
|
return;
|
|
5066
|
-
//
|
|
5219
|
+
// Revert to original value (don't change anything)
|
|
5220
|
+
// trackedValue and inline editor remain as they were before dialog opened
|
|
5221
|
+
// Close dialog
|
|
5222
|
+
this.closeDialogUI();
|
|
5223
|
+
// Refocus the cell editor to stay in edit mode
|
|
5224
|
+
setTimeout(() => {
|
|
5225
|
+
this.focusEditor();
|
|
5226
|
+
}, 50);
|
|
5227
|
+
}
|
|
5228
|
+
/**
|
|
5229
|
+
* Close and remove the dialog UI
|
|
5230
|
+
*/
|
|
5231
|
+
closeDialogUI() {
|
|
5067
5232
|
this.dialogOpen = false;
|
|
5068
|
-
|
|
5233
|
+
this.dialogCurrentValue = '';
|
|
5069
5234
|
if (this.dialog) {
|
|
5070
5235
|
this.dialog.open = false;
|
|
5071
5236
|
const dialogRef = this.dialog;
|
|
5072
|
-
const dialogEditorRef = this.dialogEditor;
|
|
5073
5237
|
this.dialog = undefined;
|
|
5074
5238
|
this.dialogEditor = undefined;
|
|
5075
5239
|
// Remove from DOM after animation
|
|
5076
5240
|
setTimeout(() => {
|
|
5077
5241
|
dialogRef === null || dialogRef === void 0 ? void 0 : dialogRef.remove();
|
|
5078
5242
|
}, 200);
|
|
5079
|
-
if (saveAndExit && this.context) {
|
|
5080
|
-
// Save and exit edit mode
|
|
5081
|
-
this.context.onSave(this.getCurrentValue());
|
|
5082
|
-
}
|
|
5083
|
-
else {
|
|
5084
|
-
// Refocus the cell editor to stay in edit mode
|
|
5085
|
-
setTimeout(() => {
|
|
5086
|
-
this.focusEditor();
|
|
5087
|
-
}, 50);
|
|
5088
|
-
}
|
|
5089
5243
|
}
|
|
5090
5244
|
}
|
|
5091
5245
|
/**
|
|
@@ -5251,6 +5405,11 @@ class NileCodeEditor {
|
|
|
5251
5405
|
var _a, _b;
|
|
5252
5406
|
const customEvent = e;
|
|
5253
5407
|
const newValue = (_b = (_a = customEvent.detail) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : '';
|
|
5408
|
+
// Don't process if we're syncing from dialog (prevents feedback loop)
|
|
5409
|
+
if (this.syncingFromDialog) {
|
|
5410
|
+
return;
|
|
5411
|
+
}
|
|
5412
|
+
// Update tracked value
|
|
5254
5413
|
this.trackedValue = newValue;
|
|
5255
5414
|
context.onChange(newValue);
|
|
5256
5415
|
};
|
|
@@ -5319,16 +5478,20 @@ class NileCodeEditor {
|
|
|
5319
5478
|
this.expandButton = undefined;
|
|
5320
5479
|
this.context = undefined;
|
|
5321
5480
|
this.expandButtonClicked = false;
|
|
5481
|
+
this.syncingFromDialog = false;
|
|
5482
|
+
this.trackedValue = null;
|
|
5483
|
+
this.userEditedInline = false;
|
|
5484
|
+
this.dialogOriginalValue = '';
|
|
5485
|
+
this.dialogCurrentValue = '';
|
|
5322
5486
|
}
|
|
5323
5487
|
focus() {
|
|
5324
5488
|
var _a;
|
|
5325
5489
|
(_a = this.editor) === null || _a === void 0 ? void 0 : _a.focus();
|
|
5326
5490
|
}
|
|
5327
5491
|
getCurrentValue() {
|
|
5328
|
-
var _a;
|
|
5329
5492
|
if (!this.editor)
|
|
5330
5493
|
return '';
|
|
5331
|
-
const value =
|
|
5494
|
+
const value = this.getLiveEditorValue();
|
|
5332
5495
|
return value.replace(/\n+$/, '');
|
|
5333
5496
|
}
|
|
5334
5497
|
/**
|