jedison 0.3.23 → 0.3.24

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.
@@ -4511,6 +4511,13 @@ class EditorStringSimpleMDE extends EditorString {
4511
4511
  super.refreshUI();
4512
4512
  this.simplemde.value(this.instance.getValue());
4513
4513
  }
4514
+ destroy() {
4515
+ if (this.aceEditor) {
4516
+ this.aceEditor.destroy();
4517
+ this.aceEditor.container.remove();
4518
+ }
4519
+ super.destroy();
4520
+ }
4514
4521
  }
4515
4522
  class EditorStringQuill extends EditorString {
4516
4523
  static resolves(schema) {
@@ -4922,6 +4929,83 @@ class EditorNumberRange extends EditorNumber {
4922
4929
  }
4923
4930
  }
4924
4931
  }
4932
+ class EditorStringAce extends EditorString {
4933
+ static resolves(schema) {
4934
+ const format2 = getSchemaXOption(schema, "format");
4935
+ return isSet(format2) && format2 === "ace" && window.ace && getSchemaType(schema) === "string";
4936
+ }
4937
+ build() {
4938
+ this.control = this.theme.getTextareaControl({
4939
+ title: this.getTitle(),
4940
+ description: this.getDescription(),
4941
+ id: this.getIdFromPath(this.instance.path),
4942
+ titleIconClass: getSchemaXOption(this.instance.schema, "titleIconClass"),
4943
+ titleHidden: getSchemaXOption(this.instance.schema, "titleHidden"),
4944
+ info: this.getInfo()
4945
+ });
4946
+ try {
4947
+ const aceOptions = getSchemaXOption(this.instance.schema, "ace") ?? {};
4948
+ const mode = aceOptions.mode || "text";
4949
+ this.aceContainer = document.createElement("div");
4950
+ const height = aceOptions.height || "300px";
4951
+ const width = aceOptions.width || "100%";
4952
+ const minHeight = aceOptions.minHeight;
4953
+ const maxHeight = aceOptions.maxHeight;
4954
+ const minWidth = aceOptions.minWidth;
4955
+ const maxWidth = aceOptions.maxWidth;
4956
+ this.aceContainer.style.height = height;
4957
+ this.aceContainer.style.width = width;
4958
+ if (minHeight) this.aceContainer.style.minHeight = minHeight;
4959
+ if (maxHeight) this.aceContainer.style.maxHeight = maxHeight;
4960
+ if (minWidth) this.aceContainer.style.minWidth = minWidth;
4961
+ if (maxWidth) this.aceContainer.style.maxWidth = maxWidth;
4962
+ this.control.input.style.display = "none";
4963
+ this.control.input.parentNode.insertBefore(this.aceContainer, this.control.input);
4964
+ this.aceEditor = window.ace.edit(this.aceContainer);
4965
+ this.aceEditor.setTheme(aceOptions.theme || "ace/theme/chrome");
4966
+ try {
4967
+ this.aceEditor.session.setMode(`ace/mode/${mode}`);
4968
+ } catch {
4969
+ console.warn(`Ace mode "${mode}" not loaded`);
4970
+ }
4971
+ const initialValue = this.instance.getValue();
4972
+ this.aceEditor.setValue(typeof initialValue === "string" ? initialValue : "");
4973
+ this.aceEditor.clearSelection();
4974
+ } catch (e) {
4975
+ console.error("Ace editor is not available or not loaded correctly.", e);
4976
+ }
4977
+ }
4978
+ addEventListeners() {
4979
+ if (!this.aceEditor) return;
4980
+ this.aceEditor.on("blur", () => {
4981
+ const aceText = this.aceEditor.getValue();
4982
+ const currentValue = this.instance.getValue();
4983
+ if (aceText !== currentValue) {
4984
+ this.instance.setValue(aceText, true, "user");
4985
+ }
4986
+ });
4987
+ }
4988
+ refreshDisabledState() {
4989
+ if (this.disabled || this.readOnly) {
4990
+ this.aceEditor.setReadOnly(true);
4991
+ this.aceContainer.style.opacity = "0.6";
4992
+ this.aceContainer.classList.add("ace-disabled");
4993
+ } else {
4994
+ this.aceEditor.setReadOnly(false);
4995
+ this.aceContainer.style.opacity = "1";
4996
+ this.aceContainer.classList.remove("ace-disabled");
4997
+ }
4998
+ }
4999
+ refreshUI() {
5000
+ super.refreshUI();
5001
+ const value = this.instance.getValue();
5002
+ const stringValue = typeof value === "string" ? value : String(value || "");
5003
+ if (this.aceEditor.getValue() !== stringValue) {
5004
+ this.aceEditor.setValue(stringValue);
5005
+ this.aceEditor.clearSelection();
5006
+ }
5007
+ }
5008
+ }
4925
5009
  class UiResolver {
4926
5010
  constructor(options) {
4927
5011
  this.customEditors = options.customEditors ?? [];
@@ -4943,6 +5027,7 @@ class UiResolver {
4943
5027
  EditorStringJodit,
4944
5028
  EditorStringFlatpickr,
4945
5029
  EditorStringIMask,
5030
+ EditorStringAce,
4946
5031
  EditorStringInput,
4947
5032
  EditorNumberIMask,
4948
5033
  EditorNumberRaty,