jedison 1.17.0 → 1.19.0

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.
@@ -4542,7 +4542,7 @@ class EditorObjectGrid extends EditorObject {
4542
4542
  class EditorObjectCategories extends EditorObject {
4543
4543
  static resolves(schema) {
4544
4544
  const format2 = getSchemaXOption(schema, "format");
4545
- const regex = /^categories-(horizontal|vertical(?:-\d+)?)$/;
4545
+ const regex = /^categories-(horizontal|vertical)$/;
4546
4546
  return getSchemaType(schema) === "object" && regex.test(format2);
4547
4547
  }
4548
4548
  init() {
@@ -4581,11 +4581,9 @@ class EditorObjectCategories extends EditorObject {
4581
4581
  const format2 = getSchemaXOption(this.instance.schema, "format");
4582
4582
  const formatParts = format2.split("-");
4583
4583
  const variant = formatParts[1];
4584
- const columns = formatParts[2];
4585
- const navColumns = variant === "horizontal" ? 12 : columns ?? 4;
4586
- const row = this.theme.getRow();
4587
- const tabListCol = this.theme.getCol(12, 12, navColumns, navColumns);
4588
- const tabContentCol = this.theme.getCol(12, 12, 12 - navColumns, 12 - navColumns);
4584
+ const navMinWidth = getSchemaXOption(this.instance.schema, "navMinWidth");
4585
+ const navMaxWidth = getSchemaXOption(this.instance.schema, "navMaxWidth");
4586
+ const { row, tabListCol, tabContentCol } = this.theme.getNavRow(variant, { minWidth: navMinWidth, maxWidth: navMaxWidth });
4589
4587
  const tabContent = this.theme.getTabContent();
4590
4588
  const tabList = this.theme.getTabList({
4591
4589
  variant
@@ -4664,7 +4662,7 @@ class EditorObjectCategories extends EditorObject {
4664
4662
  class EditorObjectNav extends EditorObject {
4665
4663
  static resolves(schema) {
4666
4664
  const format2 = getSchemaXOption(schema, "format");
4667
- const regex = /^nav-(horizontal|vertical(?:-\d+)?)$/;
4665
+ const regex = /^nav-(horizontal|vertical)$/;
4668
4666
  const hasNavFormat = regex.test(format2);
4669
4667
  return getSchemaType(schema) === "object" && hasNavFormat;
4670
4668
  }
@@ -4712,11 +4710,9 @@ class EditorObjectNav extends EditorObject {
4712
4710
  const format2 = getSchemaXOption(this.instance.schema, "format");
4713
4711
  const formatParts = format2.split("-");
4714
4712
  const variant = formatParts[1];
4715
- const columns = formatParts[2];
4716
- const navColumns = variant === "horizontal" ? 12 : columns ?? 4;
4717
- const row = this.theme.getRow();
4718
- const tabListCol = this.theme.getCol(12, 12, navColumns, navColumns);
4719
- const tabContentCol = this.theme.getCol(12, 12, 12 - navColumns, 12 - navColumns);
4713
+ const navMinWidth = getSchemaXOption(this.instance.schema, "navMinWidth");
4714
+ const navMaxWidth = getSchemaXOption(this.instance.schema, "navMaxWidth");
4715
+ const { row, tabListCol, tabContentCol } = this.theme.getNavRow(variant, { minWidth: navMinWidth, maxWidth: navMaxWidth });
4720
4716
  this.navTabContent = this.theme.getTabContent();
4721
4717
  this.navTabList = this.theme.getTabList({ variant });
4722
4718
  row.appendChild(tabListCol);
@@ -5679,7 +5675,7 @@ class EditorArrayChoices extends Editor {
5679
5675
  class EditorArrayNav extends EditorArray {
5680
5676
  static resolves(schema) {
5681
5677
  const format2 = getSchemaXOption(schema, "format");
5682
- const regex = /^nav-(horizontal|vertical(?:-\d+)?)$/;
5678
+ const regex = /^nav-(horizontal|vertical)$/;
5683
5679
  const hasNavFormat = regex.test(format2);
5684
5680
  return getSchemaType(schema) === "array" && hasNavFormat;
5685
5681
  }
@@ -5731,11 +5727,9 @@ class EditorArrayNav extends EditorArray {
5731
5727
  const format2 = getSchemaXOption(this.instance.schema, "format");
5732
5728
  const formatParts = format2.split("-");
5733
5729
  const variant = formatParts[1];
5734
- const columns = formatParts[2];
5735
- const navColumns = variant === "horizontal" ? 12 : columns ?? 4;
5736
- const row = this.theme.getRow();
5737
- const tabListCol = this.theme.getCol(12, 12, navColumns, navColumns);
5738
- const tabContentCol = this.theme.getCol(12, 12, 12 - navColumns, 12 - navColumns);
5730
+ const navMinWidth = getSchemaXOption(this.instance.schema, "navMinWidth");
5731
+ const navMaxWidth = getSchemaXOption(this.instance.schema, "navMaxWidth");
5732
+ const { row, tabListCol, tabContentCol } = this.theme.getNavRow(variant, { minWidth: navMinWidth, maxWidth: navMaxWidth });
5739
5733
  const tabContent = this.theme.getTabContent();
5740
5734
  const tabList = this.theme.getTabList({
5741
5735
  variant
@@ -6055,6 +6049,79 @@ class EditorStringSimpleMDE extends EditorString {
6055
6049
  super.destroy();
6056
6050
  }
6057
6051
  }
6052
+ class EditorStringMilkdown extends EditorString {
6053
+ static resolves(schema) {
6054
+ const format2 = getSchemaXOption(schema, "format");
6055
+ return isSet(format2) && format2 === "milkdown" && window.Milkdown && window.Milkdown.Crepe && getSchemaType(schema) === "string";
6056
+ }
6057
+ build() {
6058
+ this.control = this.theme.getPlaceholderControl({
6059
+ title: this.getTitle(),
6060
+ description: this.getDescription(),
6061
+ id: this.getIdFromPath(this.instance.path),
6062
+ titleIconClass: getSchemaXOption(this.instance.schema, "titleIconClass"),
6063
+ titleHidden: getSchemaXOption(this.instance.schema, "titleHidden"),
6064
+ info: this.getInfo()
6065
+ });
6066
+ this.mounted = false;
6067
+ try {
6068
+ const milkdownOptions = getSchemaXOption(this.instance.schema, "milkdown") ?? {};
6069
+ const { Crepe } = window.Milkdown;
6070
+ this.crepe = new Crepe({
6071
+ ...milkdownOptions,
6072
+ root: this.control.placeholder,
6073
+ defaultValue: this.instance.getValue() ?? ""
6074
+ });
6075
+ this.crepe.on((api) => {
6076
+ api.markdownUpdated((ctx, markdown) => {
6077
+ if (markdown !== this.instance.getValue()) {
6078
+ this.syncingFromEditor = true;
6079
+ this.instance.setValue(markdown, true, "user");
6080
+ this.syncingFromEditor = false;
6081
+ }
6082
+ });
6083
+ });
6084
+ this.crepe.create().then(() => {
6085
+ this.mounted = true;
6086
+ this.refreshDisabledState();
6087
+ }).catch((e) => console.error("Milkdown failed to mount.", e));
6088
+ } catch (e) {
6089
+ console.error("Milkdown is not available or not loaded correctly.", e);
6090
+ }
6091
+ }
6092
+ adaptForHorizontal(labelCol, inputCol) {
6093
+ this.theme.adaptForHorizontalInputControl(this.control, labelCol, inputCol);
6094
+ }
6095
+ addEventListeners() {
6096
+ }
6097
+ refreshDisabledState() {
6098
+ if (this.crepe && this.mounted) {
6099
+ this.crepe.setReadonly(this.disabled || this.readOnly);
6100
+ }
6101
+ }
6102
+ refreshUI() {
6103
+ super.refreshUI();
6104
+ if (!this.crepe || !this.mounted || this.syncingFromEditor) {
6105
+ return;
6106
+ }
6107
+ const value = this.instance.getValue() ?? "";
6108
+ if (value !== this.crepe.getMarkdown()) {
6109
+ try {
6110
+ const { replaceAll: replaceAll2 } = window.Milkdown;
6111
+ this.crepe.editor.action(replaceAll2(value));
6112
+ } catch (e) {
6113
+ console.error("Milkdown could not apply the updated value.", e);
6114
+ }
6115
+ }
6116
+ }
6117
+ destroy() {
6118
+ if (this.crepe) {
6119
+ this.crepe.destroy().catch(() => {
6120
+ });
6121
+ }
6122
+ super.destroy();
6123
+ }
6124
+ }
6058
6125
  class EditorStringQuill extends EditorString {
6059
6126
  static resolves(schema) {
6060
6127
  const format2 = getSchemaXOption(schema, "format");
@@ -6883,6 +6950,7 @@ class UiResolver {
6883
6950
  EditorStringAwesomplete,
6884
6951
  EditorStringEmojiButton,
6885
6952
  EditorStringSimpleMDE,
6953
+ EditorStringMilkdown,
6886
6954
  EditorStringQuill,
6887
6955
  EditorStringJodit,
6888
6956
  EditorStringPickr,
@@ -9863,6 +9931,62 @@ class Theme {
9863
9931
  }
9864
9932
  return col;
9865
9933
  }
9934
+ /**
9935
+ * Row + two columns for nav-style editors (object-nav, array-nav,
9936
+ * object-categories). Horizontal keeps the fixed full-width split (the
9937
+ * zero-width content col intentionally forces it onto a new flex line
9938
+ * below the full-width tab list) built on the regular getRow()/getCol()
9939
+ * grid. Vertical uses a plain (non-grid) flex row instead: Bootstrap's
9940
+ * `.row > *` rule forces `width: 100%` on grid columns, which would
9941
+ * fight flex-basis:auto's content-based sizing, so the shrink-to-fit nav
9942
+ * column can't share that grid. It hugs its widest pill on wider
9943
+ * containers (constrained by widthOptions.minWidth/maxWidth) and stacks
9944
+ * full-width below the container-query breakpoint in ensureNavStyles().
9945
+ */
9946
+ getNavRow(variant, widthOptions = {}) {
9947
+ if (variant === "horizontal") {
9948
+ const row2 = this.getRow();
9949
+ const tabListCol2 = this.getCol(12, 12, 12, 12);
9950
+ const tabContentCol2 = this.getCol(12, 12, 0, 0);
9951
+ return { row: row2, tabListCol: tabListCol2, tabContentCol: tabContentCol2 };
9952
+ }
9953
+ this.ensureNavStyles();
9954
+ const row = document.createElement("div");
9955
+ row.classList.add("jedi-nav-row");
9956
+ const tabListCol = document.createElement("div");
9957
+ tabListCol.classList.add("jedi-col");
9958
+ tabListCol.classList.add("jedi-nav-list-col");
9959
+ tabListCol.style.setProperty("--jedi-nav-max-width", widthOptions.maxWidth ?? "40%");
9960
+ if (widthOptions.minWidth) tabListCol.style.setProperty("--jedi-nav-min-width", widthOptions.minWidth);
9961
+ const tabContentCol = document.createElement("div");
9962
+ tabContentCol.classList.add("jedi-col");
9963
+ tabContentCol.classList.add("jedi-nav-content-col");
9964
+ return { row, tabListCol, tabContentCol };
9965
+ }
9966
+ /**
9967
+ * Mobile-first: the nav row stacks at 100% width by default; a container
9968
+ * query (not a viewport media query) switches to shrink-to-fit once the
9969
+ * row itself has >= 576px to work with, so a narrow embed (a modal, a
9970
+ * sidebar) gets the same treatment as a narrow viewport regardless of
9971
+ * how wide the page around it is. Injected once, same pattern as
9972
+ * bootstrap5.js's jedi-accordion-button-style, since inline styles can't
9973
+ * express @container.
9974
+ */
9975
+ ensureNavStyles() {
9976
+ if (document.getElementById("jedi-nav-styles")) return;
9977
+ const style = document.createElement("style");
9978
+ style.id = "jedi-nav-styles";
9979
+ style.textContent = `
9980
+ .jedi-nav-row { display: flex; flex-wrap: wrap; gap: 1rem; container-type: inline-size; }
9981
+ .jedi-nav-list-col { flex: 1 1 100%; width: 100%; max-width: 100%; }
9982
+ .jedi-nav-content-col { flex: 1 1 100%; width: 100%; min-width: 0; }
9983
+ @container (min-width: 576px) {
9984
+ .jedi-nav-list-col { flex: 0 1 auto; width: auto; max-width: var(--jedi-nav-max-width, 40%); min-width: var(--jedi-nav-min-width, auto); }
9985
+ .jedi-nav-content-col { flex: 1 1 0%; width: auto; }
9986
+ }
9987
+ `;
9988
+ document.head.appendChild(style);
9989
+ }
9866
9990
  /**
9867
9991
  * Clearfix fixes layout issues in some libraries like bootstrap 3
9868
9992
  */