Skip to content

Commit adb2717

Browse files
authored
Add component ch-code-diff-editor and refactoring the ch-code-editor interface (#346)
* Move monaco to common * Update references to monaco * Remove diff support and add options property * Update ch-code-editor showcase * Add component ch-code-diff-editor * Add ch-code-diff-editor showcase * Update component.d.ts * Disconnect ResizeObserver * Theme initialization * ReadOnly initialization * Remove if() and use .? instead * Add Watch in "options" property * Sort the code according to the StencilJS documentation * Add updateOptions method * Readonly improvements * Update generated files * Fix updateOptions parameter * Sort properties alphabetical * Fix backsticks
1 parent 6b246b1 commit adb2717

19 files changed

+716
-301
lines changed

Diff for: .gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ build/Release
3131
# Dependency directories
3232
node_modules/
3333
jspm_packages/
34-
src/components/code-editor/monaco/output
34+
src/common/monaco/output
3535

3636
# TypeScript v1 declaration files
3737
typings/
File renamed without changes.
File renamed without changes.

Diff for: src/components.d.ts

+83-32
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import { ActionGroupModel } from "./components/action-group/types";
1111
import { ActionListItemActionable, ActionListItemAdditionalInformation, ActionListItemModel, ActionListModel } from "./components/action-list/types";
1212
import { ActionListFixedChangeEventDetail } from "./components/action-list/internal/action-list-item/types";
1313
import { MarkdownCodeRender } from "./components/code/internal/types";
14+
import { CodeDiffEditorOptions } from "./components/code-diff-editor/code-diff-editor-types.js";
15+
import { CodeEditorOptions } from "./components/code-editor/code-editor-types.js";
1416
import { ComboBoxFilterOptions, ComboBoxFilterType, ComboBoxModel } from "./components/combobox/types";
1517
import { ChPopoverAlign, ChPopoverSizeMatch, PopoverActionElement } from "./components/popover/types";
1618
import { GxDataTransferInfo, ImageRender, LabelPosition } from "./common/types";
@@ -58,6 +60,8 @@ export { ActionGroupModel } from "./components/action-group/types";
5860
export { ActionListItemActionable, ActionListItemAdditionalInformation, ActionListItemModel, ActionListModel } from "./components/action-list/types";
5961
export { ActionListFixedChangeEventDetail } from "./components/action-list/internal/action-list-item/types";
6062
export { MarkdownCodeRender } from "./components/code/internal/types";
63+
export { CodeDiffEditorOptions } from "./components/code-diff-editor/code-diff-editor-types.js";
64+
export { CodeEditorOptions } from "./components/code-editor/code-editor-types.js";
6165
export { ComboBoxFilterOptions, ComboBoxFilterType, ComboBoxModel } from "./components/combobox/types";
6266
export { ChPopoverAlign, ChPopoverSizeMatch, PopoverActionElement } from "./components/popover/types";
6367
export { GxDataTransferInfo, ImageRender, LabelPosition } from "./common/types";
@@ -484,41 +488,65 @@ export namespace Components {
484488
*/
485489
"value": string;
486490
}
487-
interface ChCodeEditor {
488-
/**
489-
* Allow the user to resize the diff editor split view. This property only works if `mode` === `"diff-editor"`.
490-
*/
491-
"enableSplitViewResizing": boolean;
491+
interface ChCodeDiffEditor {
492492
/**
493493
* Specifies the language of the auto created model in the editor.
494494
*/
495495
"language": string;
496496
/**
497-
* Specifies the rendered mode of the editor, allowing to set a normal editor or a diff editor.
497+
* Specifies the modified value of the diff editor.
498498
*/
499-
"mode": "editor" | "diff-editor";
499+
"modifiedValue": string;
500500
/**
501-
* Specifies the modified value of the diff editor. This property only works if `mode` === `"diff-editor"`.
501+
* Specifies the editor options.
502502
*/
503-
"modifiedValue": string;
503+
"options": CodeDiffEditorOptions;
504+
/**
505+
* Specifies if the editor should be readonly. If the ´readOnly´ or ´originalEditable´ property is specified in the ´options´ property, this property has no effect.
506+
*/
507+
"readonly": boolean;
504508
/**
505-
* Specifies if the modified value of the diff editor should be readonly. This property only works if `mode` === `"diff-editor"`.
509+
* Specifies the theme to be used for rendering.
506510
*/
507-
"modifiedValueReadonly": boolean;
511+
"theme": string;
508512
/**
509-
* Specifies if the editor should be readonly. When `mode` === `"diff-editor"` this property will apply to the left pane. - If `mode` === `"editor"` defaults to `false`. - If `mode` === `"diff-editor"` defaults to `true`.
513+
* Update the editor's options after the editor has been created.
514+
* @param options Set of options to be updated
510515
*/
511-
"readonly"?: boolean;
516+
"updateOptions": (options: CodeDiffEditorOptions) => Promise<void>;
517+
/**
518+
* Specifies the original value of the diff editor.
519+
*/
520+
"value": string;
512521
/**
513-
* Render the differences in two side-by-side editors. Only works if `mode` === `"diff-editor"`.
522+
* Specifies the schema URI for the YAML language.
523+
*/
524+
"yamlSchemaUri": string;
525+
}
526+
interface ChCodeEditor {
527+
/**
528+
* Specifies the language of the auto created model in the editor.
514529
*/
515-
"renderSideBySide": boolean;
530+
"language": string;
531+
/**
532+
* Specifies the editor options.
533+
*/
534+
"options": CodeEditorOptions;
535+
/**
536+
* Specifies if the editor should be readonly. If the ´readOnly´ property is specified in the ´options´ property, this property has no effect.
537+
*/
538+
"readonly": boolean;
516539
/**
517540
* Specifies the theme to be used for rendering.
518541
*/
519542
"theme": string;
520543
/**
521-
* Specifies the value of the editor. If `mode` === `"diff-editor"`, this property will be used as the original model.
544+
* Update the editor's options after the editor has been created.
545+
* @param options Set of options to be updated
546+
*/
547+
"updateOptions": (options: CodeEditorOptions) => Promise<void>;
548+
/**
549+
* Specifies the value of the editor.
522550
*/
523551
"value": string;
524552
/**
@@ -3656,6 +3684,12 @@ declare global {
36563684
prototype: HTMLChCodeElement;
36573685
new (): HTMLChCodeElement;
36583686
};
3687+
interface HTMLChCodeDiffEditorElement extends Components.ChCodeDiffEditor, HTMLStencilElement {
3688+
}
3689+
var HTMLChCodeDiffEditorElement: {
3690+
prototype: HTMLChCodeDiffEditorElement;
3691+
new (): HTMLChCodeDiffEditorElement;
3692+
};
36593693
interface HTMLChCodeEditorElement extends Components.ChCodeEditor, HTMLStencilElement {
36603694
}
36613695
var HTMLChCodeEditorElement: {
@@ -5091,6 +5125,7 @@ declare global {
50915125
"ch-barcode-scanner": HTMLChBarcodeScannerElement;
50925126
"ch-checkbox": HTMLChCheckboxElement;
50935127
"ch-code": HTMLChCodeElement;
5128+
"ch-code-diff-editor": HTMLChCodeDiffEditorElement;
50945129
"ch-code-editor": HTMLChCodeEditorElement;
50955130
"ch-combo-box": HTMLChComboBoxElement;
50965131
"ch-dialog": HTMLChDialogElement;
@@ -5613,41 +5648,55 @@ declare namespace LocalJSX {
56135648
*/
56145649
"value"?: string;
56155650
}
5616-
interface ChCodeEditor {
5617-
/**
5618-
* Allow the user to resize the diff editor split view. This property only works if `mode` === `"diff-editor"`.
5619-
*/
5620-
"enableSplitViewResizing"?: boolean;
5651+
interface ChCodeDiffEditor {
56215652
/**
56225653
* Specifies the language of the auto created model in the editor.
56235654
*/
56245655
"language": string;
56255656
/**
5626-
* Specifies the rendered mode of the editor, allowing to set a normal editor or a diff editor.
5627-
*/
5628-
"mode"?: "editor" | "diff-editor";
5629-
/**
5630-
* Specifies the modified value of the diff editor. This property only works if `mode` === `"diff-editor"`.
5657+
* Specifies the modified value of the diff editor.
56315658
*/
56325659
"modifiedValue"?: string;
56335660
/**
5634-
* Specifies if the modified value of the diff editor should be readonly. This property only works if `mode` === `"diff-editor"`.
5661+
* Specifies the editor options.
56355662
*/
5636-
"modifiedValueReadonly"?: boolean;
5663+
"options"?: CodeDiffEditorOptions;
56375664
/**
5638-
* Specifies if the editor should be readonly. When `mode` === `"diff-editor"` this property will apply to the left pane. - If `mode` === `"editor"` defaults to `false`. - If `mode` === `"diff-editor"` defaults to `true`.
5665+
* Specifies if the editor should be readonly. If the ´readOnly´ or ´originalEditable´ property is specified in the ´options´ property, this property has no effect.
56395666
*/
56405667
"readonly"?: boolean;
56415668
/**
5642-
* Render the differences in two side-by-side editors. Only works if `mode` === `"diff-editor"`.
5669+
* Specifies the theme to be used for rendering.
5670+
*/
5671+
"theme"?: string;
5672+
/**
5673+
* Specifies the original value of the diff editor.
5674+
*/
5675+
"value"?: string;
5676+
/**
5677+
* Specifies the schema URI for the YAML language.
5678+
*/
5679+
"yamlSchemaUri"?: string;
5680+
}
5681+
interface ChCodeEditor {
5682+
/**
5683+
* Specifies the language of the auto created model in the editor.
5684+
*/
5685+
"language": string;
5686+
/**
5687+
* Specifies the editor options.
56435688
*/
5644-
"renderSideBySide"?: boolean;
5689+
"options"?: CodeEditorOptions;
5690+
/**
5691+
* Specifies if the editor should be readonly. If the ´readOnly´ property is specified in the ´options´ property, this property has no effect.
5692+
*/
5693+
"readonly"?: boolean;
56455694
/**
56465695
* Specifies the theme to be used for rendering.
56475696
*/
56485697
"theme"?: string;
56495698
/**
5650-
* Specifies the value of the editor. If `mode` === `"diff-editor"`, this property will be used as the original model.
5699+
* Specifies the value of the editor.
56515700
*/
56525701
"value"?: string;
56535702
/**
@@ -8455,6 +8504,7 @@ declare namespace LocalJSX {
84558504
"ch-barcode-scanner": ChBarcodeScanner;
84568505
"ch-checkbox": ChCheckbox;
84578506
"ch-code": ChCode;
8507+
"ch-code-diff-editor": ChCodeDiffEditor;
84588508
"ch-code-editor": ChCodeEditor;
84598509
"ch-combo-box": ChComboBox;
84608510
"ch-dialog": ChDialog;
@@ -8576,6 +8626,7 @@ declare module "@stencil/core" {
85768626
* - When the code highlighting is needed at runtime, the control will load on demand the code parser and the programming language needed to parse the code.
85778627
*/
85788628
"ch-code": LocalJSX.ChCode & JSXBase.HTMLAttributes<HTMLChCodeElement>;
8629+
"ch-code-diff-editor": LocalJSX.ChCodeDiffEditor & JSXBase.HTMLAttributes<HTMLChCodeDiffEditorElement>;
85798630
"ch-code-editor": LocalJSX.ChCodeEditor & JSXBase.HTMLAttributes<HTMLChCodeEditorElement>;
85808631
"ch-combo-box": LocalJSX.ChComboBox & JSXBase.HTMLAttributes<HTMLChComboBoxElement>;
85818632
/**
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import * as monaco from "monaco-editor";
2+
3+
export interface CodeDiffEditorOptions
4+
extends monaco.editor.IStandaloneDiffEditorConstructionOptions {}
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// This is a WA to import required styles for the editor in production build
2+
@import "../../common/monaco/monaco-styles-after-build.scss";
3+
4+
ch-code-diff-editor {
5+
display: grid;
6+
position: relative;
7+
}
8+
9+
.ch-code-diff-editor-absolute-content {
10+
display: grid;
11+
position: absolute;
12+
inset: 0;
13+
}

0 commit comments

Comments
 (0)