@bagelink/vue 1.2.79 → 1.2.81

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/dist/index.cjs CHANGED
@@ -554,7 +554,7 @@ const _hoisted_2$K = ["data-date", "onClick"];
554
554
  const _hoisted_3$E = { class: "event-content" };
555
555
  const _hoisted_4$r = { class: "event-time" };
556
556
  const _hoisted_5$q = { class: "event-details" };
557
- const _hoisted_6$n = { class: "event-title" };
557
+ const _hoisted_6$m = { class: "event-title" };
558
558
  const _sfc_main$17 = /* @__PURE__ */ vue.defineComponent({
559
559
  __name: "AgendaView",
560
560
  props: {
@@ -677,7 +677,7 @@ const _sfc_main$17 = /* @__PURE__ */ vue.defineComponent({
677
677
  vue.createElementVNode("div", _hoisted_3$E, [
678
678
  vue.createElementVNode("div", _hoisted_4$r, vue.toDisplayString(vue.unref(formatDate)(event.start_time, { fmt: "HH:mm" })), 1),
679
679
  vue.createElementVNode("div", _hoisted_5$q, [
680
- vue.createElementVNode("div", _hoisted_6$n, vue.toDisplayString(event.title), 1),
680
+ vue.createElementVNode("div", _hoisted_6$m, vue.toDisplayString(event.title), 1),
681
681
  vue.createElementVNode("div", {
682
682
  class: vue.normalizeClass(["event-day", { today: event.isToday }])
683
683
  }, vue.toDisplayString(event.dayLabel), 3)
@@ -696,7 +696,7 @@ const _hoisted_2$J = { class: "border-bottom me-1 txt-center p-05 dayGrid" };
696
696
  const _hoisted_3$D = { class: "overflow h-100p pe-05" };
697
697
  const _hoisted_4$q = { class: "time-column" };
698
698
  const _hoisted_5$p = { class: "events-column" };
699
- const _hoisted_6$m = ["onClick"];
699
+ const _hoisted_6$l = ["onClick"];
700
700
  const _hoisted_7$h = { class: "event-content" };
701
701
  const _hoisted_8$b = { class: "white-space ellipsis-1" };
702
702
  const _hoisted_9$7 = { class: "event-time opacity-8" };
@@ -880,7 +880,7 @@ const _sfc_main$16 = /* @__PURE__ */ vue.defineComponent({
880
880
  vue.createElementVNode("div", _hoisted_8$b, vue.toDisplayString(event.title), 1),
881
881
  vue.createElementVNode("div", _hoisted_9$7, vue.toDisplayString(vue.unref(formatDate)(new Date(event.start_time), { fmt: "HH:mm" })) + " - " + vue.toDisplayString(vue.unref(formatDate)(new Date(event.end_time), { fmt: "HH:mm" })), 1)
882
882
  ])
883
- ], 12, _hoisted_6$m);
883
+ ], 12, _hoisted_6$l);
884
884
  }), 128))
885
885
  ]),
886
886
  dragState.value.isDragging && dragState.value.start && dragState.value.end ? (vue.openBlock(), vue.createElementBlock("div", {
@@ -908,7 +908,7 @@ const _hoisted_2$I = { class: "month-header" };
908
908
  const _hoisted_3$C = { class: "month-grid" };
909
909
  const _hoisted_4$p = { class: "day-number" };
910
910
  const _hoisted_5$o = { class: "day-events" };
911
- const _hoisted_6$l = {
911
+ const _hoisted_6$k = {
912
912
  key: 0,
913
913
  class: "event-dot"
914
914
  };
@@ -1011,7 +1011,7 @@ const _sfc_main$15 = /* @__PURE__ */ vue.defineComponent({
1011
1011
  vue.createElementVNode("div", _hoisted_4$p, vue.toDisplayString(vue.unref(fmtDate)(day.date, { fmt: "DD" })), 1),
1012
1012
  vue.createElementVNode("div", _hoisted_5$o, [
1013
1013
  isMobile.value ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 0 }, [
1014
- day.events.length > 0 ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_6$l)) : vue.createCommentVNode("", true)
1014
+ day.events.length > 0 ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_6$k)) : vue.createCommentVNode("", true)
1015
1015
  ], 64)) : (vue.openBlock(true), vue.createElementBlock(vue.Fragment, { key: 1 }, vue.renderList(day.events, (event) => {
1016
1016
  return vue.openBlock(), vue.createElementBlock("div", {
1017
1017
  key: event.id,
@@ -1037,7 +1037,7 @@ const _hoisted_2$H = { class: "overflow h-100p pe-05" };
1037
1037
  const _hoisted_3$B = ["onMousedown"];
1038
1038
  const _hoisted_4$o = ["onClick"];
1039
1039
  const _hoisted_5$n = { class: "overflow-hidden color-white p-025 txt12 h-100p" };
1040
- const _hoisted_6$k = { class: "white-space ellipsis-1" };
1040
+ const _hoisted_6$j = { class: "white-space ellipsis-1" };
1041
1041
  const _hoisted_7$f = { class: "txt10 opacity-8 user-select-none" };
1042
1042
  const _hoisted_8$9 = { class: "color-primary txt-12 p-025" };
1043
1043
  const slotHeight = 60;
@@ -1368,7 +1368,7 @@ const _sfc_main$14 = /* @__PURE__ */ vue.defineComponent({
1368
1368
  onClick: vue.withModifiers(($event) => handleEventSelection(event, $event), ["stop"])
1369
1369
  }, [
1370
1370
  vue.createElementVNode("div", _hoisted_5$n, [
1371
- vue.createElementVNode("div", _hoisted_6$k, vue.toDisplayString(event.title), 1),
1371
+ vue.createElementVNode("div", _hoisted_6$j, vue.toDisplayString(event.title), 1),
1372
1372
  vue.createElementVNode("div", _hoisted_7$f, vue.toDisplayString(vue.unref(formatDate)(event.start_time, { fmt: "HH:mm" })) + " - " + vue.toDisplayString(vue.unref(formatDate)(event.end_time, { fmt: "HH:mm" })), 1)
1373
1373
  ])
1374
1374
  ], 44, _hoisted_4$o);
@@ -7927,7 +7927,7 @@ const _hoisted_2$1$1 = ["width", "height", "viewBox"];
7927
7927
  const _hoisted_3$y = { class: "layer-rectangles" };
7928
7928
  const _hoisted_4$m = ["transform", "onMouseover"];
7929
7929
  const _hoisted_5$m = ["width", "height"];
7930
- const _hoisted_6$j = {
7930
+ const _hoisted_6$i = {
7931
7931
  x: 0 + 10,
7932
7932
  y: 0 + 20,
7933
7933
  "font-size": `15px`,
@@ -7970,7 +7970,7 @@ function render$1(_ctx, _cache, $props, $setup, $data, $options) {
7970
7970
  }, () => [
7971
7971
  vue.createElementVNode(
7972
7972
  "text",
7973
- _hoisted_6$j,
7973
+ _hoisted_6$i,
7974
7974
  vue.toDisplayString(r2.data.name),
7975
7975
  1
7976
7976
  /* TEXT */
@@ -9533,7 +9533,7 @@ const _hoisted_2$C = {
9533
9533
  const _hoisted_3$x = { class: "infinite-wrapper" };
9534
9534
  const _hoisted_4$l = { class: "row first-row" };
9535
9535
  const _hoisted_5$l = { key: 0 };
9536
- const _hoisted_6$i = ["onClick"];
9536
+ const _hoisted_6$h = ["onClick"];
9537
9537
  const _hoisted_7$d = { class: "flex" };
9538
9538
  const _hoisted_8$8 = ["onClick"];
9539
9539
  const _hoisted_9$5 = { key: 0 };
@@ -9695,7 +9695,7 @@ const _sfc_main$_ = /* @__PURE__ */ vue.defineComponent({
9695
9695
  }, null, 8, ["class"])
9696
9696
  ], 2)
9697
9697
  ])
9698
- ], 8, _hoisted_6$i);
9698
+ ], 8, _hoisted_6$h);
9699
9699
  }), 128))
9700
9700
  ]),
9701
9701
  vue.createElementVNode("tbody", null, [
@@ -13396,17 +13396,19 @@ function getFallbackSchema(data2, columns) {
13396
13396
  function sleep(ms = 100) {
13397
13397
  return new Promise((resolve) => setTimeout(resolve, ms));
13398
13398
  }
13399
- function appendScript(src, options) {
13400
- return new Promise((resolve, reject3) => {
13401
- if (options == null ? void 0 : options.id) {
13402
- if (document.getElementById(options.id)) {
13403
- resolve();
13404
- return;
13405
- }
13406
- } else if (document.querySelector(`script[src="${src}"]`)) {
13407
- resolve();
13408
- return;
13409
- }
13399
+ const scriptsLoading = /* @__PURE__ */ new Map();
13400
+ async function appendScript(src, options) {
13401
+ const scriptId = (options == null ? void 0 : options.id) || src;
13402
+ await sleep(1);
13403
+ if (scriptsLoading.has(scriptId)) {
13404
+ return scriptsLoading.get(scriptId);
13405
+ }
13406
+ if ((options == null ? void 0 : options.id) && document.getElementById(options.id)) {
13407
+ return Promise.resolve();
13408
+ } else if (document.querySelector(`script[src="${src}"]`)) {
13409
+ return Promise.resolve();
13410
+ }
13411
+ const loadingPromise = new Promise((resolve, reject3) => {
13410
13412
  const script2 = document.createElement("script");
13411
13413
  script2.src = src;
13412
13414
  if (options == null ? void 0 : options.id) {
@@ -13414,10 +13416,16 @@ function appendScript(src, options) {
13414
13416
  }
13415
13417
  script2.onload = () => {
13416
13418
  resolve();
13419
+ scriptsLoading.delete(scriptId);
13420
+ };
13421
+ script2.onerror = (err) => {
13422
+ reject3(err);
13423
+ scriptsLoading.delete(scriptId);
13417
13424
  };
13418
- script2.onerror = reject3;
13419
13425
  document.head.append(script2);
13420
13426
  });
13427
+ scriptsLoading.set(scriptId, loadingPromise);
13428
+ return loadingPromise;
13421
13429
  }
13422
13430
  function appendStyle(src) {
13423
13431
  return new Promise((resolve, reject3) => {
@@ -13549,6 +13557,10 @@ const _sfc_main$V = /* @__PURE__ */ vue.defineComponent({
13549
13557
  var _a;
13550
13558
  return ((_a = form.value) == null ? void 0 : _a.reportValidity()) ?? false;
13551
13559
  };
13560
+ const checkValidity = () => {
13561
+ var _a;
13562
+ return ((_a = form.value) == null ? void 0 : _a.checkValidity()) ?? false;
13563
+ };
13552
13564
  const formError = vue.ref();
13553
13565
  async function handleSubmit() {
13554
13566
  var _a;
@@ -13588,7 +13600,7 @@ const _sfc_main$V = /* @__PURE__ */ vue.defineComponent({
13588
13600
  updateFormData(input.name, value);
13589
13601
  }
13590
13602
  }
13591
- __expose({ form, isDirty, validateForm, resolveSchema, refreshSchema });
13603
+ __expose({ form, isDirty, validateForm, resolveSchema, refreshSchema, checkValidity });
13592
13604
  return (_ctx, _cache) => {
13593
13605
  return vue.openBlock(), vue.createElementBlock(vue.Fragment, null, [
13594
13606
  formState.value !== "success" || !_ctx.$slots.success ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 0 }, [
@@ -13651,7 +13663,7 @@ const _hoisted_5$k = {
13651
13663
  key: 0,
13652
13664
  class: "bgl-step-label"
13653
13665
  };
13654
- const _hoisted_6$h = { class: "bgl-form-wrapper" };
13666
+ const _hoisted_6$g = { class: "bgl-form-wrapper" };
13655
13667
  const _hoisted_7$c = { class: "bgl-step-controls" };
13656
13668
  const _sfc_main$U = /* @__PURE__ */ vue.defineComponent({
13657
13669
  __name: "BglMultiStepForm",
@@ -13673,6 +13685,7 @@ const _sfc_main$U = /* @__PURE__ */ vue.defineComponent({
13673
13685
  }),
13674
13686
  emits: /* @__PURE__ */ vue.mergeModels(["submit", "stepChange"], ["update:modelValue"]),
13675
13687
  setup(__props, { expose: __expose, emit: __emit }) {
13688
+ var _a;
13676
13689
  const props2 = __props;
13677
13690
  const emits = __emit;
13678
13691
  const formRef = vue.ref();
@@ -13734,8 +13747,6 @@ const _sfc_main$U = /* @__PURE__ */ vue.defineComponent({
13734
13747
  const actualIndex = schemaIndexMap.value[currentStep.value];
13735
13748
  return [computedSchema.value[actualIndex]];
13736
13749
  });
13737
- const isStepping = vue.ref(false);
13738
- let isSteppingTO;
13739
13750
  const slideDirection = vue.ref(props2.rtl ? "right" : "left");
13740
13751
  vue.watch(
13741
13752
  () => currentStep.value,
@@ -13746,9 +13757,6 @@ const _sfc_main$U = /* @__PURE__ */ vue.defineComponent({
13746
13757
  slideDirection.value = props2.direction;
13747
13758
  }
13748
13759
  previousStep.value = oldStep;
13749
- clearTimeout(isSteppingTO);
13750
- isStepping.value = true;
13751
- isSteppingTO = setTimeout(() => isStepping.value = false, 200);
13752
13760
  emits("stepChange", {
13753
13761
  newStep,
13754
13762
  oldStep,
@@ -13757,15 +13765,24 @@ const _sfc_main$U = /* @__PURE__ */ vue.defineComponent({
13757
13765
  });
13758
13766
  }
13759
13767
  );
13760
- const canDoNext = vue.computed(() => currentStep.value < numberOfSteps.value - 1);
13768
+ const isLastStep = vue.computed(() => currentStep.value === numberOfSteps.value - 1);
13761
13769
  const isStepValidated = vue.computed(() => (stepIndex) => validatedSteps.value.includes(stepIndex));
13770
+ const isStepValid = vue.ref(false);
13771
+ async function checkCurrentStepValidity() {
13772
+ var _a2;
13773
+ await vue.nextTick();
13774
+ if (!props2.validateOnSteps) isStepValid.value = true;
13775
+ else isStepValid.value = ((_a2 = formRef.value) == null ? void 0 : _a2.checkValidity()) ?? false;
13776
+ }
13762
13777
  function prevStep() {
13763
13778
  if (currentStep.value > 0) currentStep.value--;
13764
13779
  }
13765
13780
  const formContainer = vue.ref();
13766
- function nextStep() {
13781
+ async function nextStep() {
13767
13782
  if (props2.validateOnSteps && reportValidity() === false) return;
13768
- if (canDoNext.value) currentStep.value++;
13783
+ if (!isLastStep.value) currentStep.value++;
13784
+ await sleep(400);
13785
+ checkCurrentStepValidity();
13769
13786
  }
13770
13787
  function goToStep(stepIndex) {
13771
13788
  if (stepIndex < currentStep.value || validatedSteps.value.includes(stepIndex)) {
@@ -13790,6 +13807,7 @@ const _sfc_main$U = /* @__PURE__ */ vue.defineComponent({
13790
13807
  currentStep.value = 0;
13791
13808
  }
13792
13809
  vue.watch(() => formData.value, () => {
13810
+ checkCurrentStepValidity();
13793
13811
  if (currentStep.value >= numberOfSteps.value && numberOfSteps.value > 0) {
13794
13812
  currentStep.value = 0;
13795
13813
  }
@@ -13797,14 +13815,16 @@ const _sfc_main$U = /* @__PURE__ */ vue.defineComponent({
13797
13815
  __expose({
13798
13816
  submit: handleSubmit,
13799
13817
  validateForm: reportValidity,
13818
+ checkValidity: (_a = formRef.value) == null ? void 0 : _a.checkValidity,
13800
13819
  isDirty: vue.computed(() => {
13801
- var _a;
13802
- return (_a = formRef.value) == null ? void 0 : _a.isDirty;
13820
+ var _a2;
13821
+ return (_a2 = formRef.value) == null ? void 0 : _a2.isDirty;
13803
13822
  }),
13804
13823
  reset,
13805
13824
  goToStep,
13806
13825
  currentStep: vue.computed(() => currentStep.value),
13807
13826
  totalSteps: vue.computed(() => numberOfSteps.value),
13827
+ isStepValid,
13808
13828
  nextStep,
13809
13829
  prevStep
13810
13830
  });
@@ -13837,13 +13857,13 @@ const _sfc_main$U = /* @__PURE__ */ vue.defineComponent({
13837
13857
  ])
13838
13858
  ], true)
13839
13859
  ])) : vue.createCommentVNode("", true),
13840
- vue.createElementVNode("div", _hoisted_6$h, [
13860
+ vue.createElementVNode("div", _hoisted_6$g, [
13841
13861
  vue.createVNode(vue.Transition, {
13842
13862
  name: slideDirection.value === "right" ? "slide-right" : "slide-left",
13843
13863
  mode: "out-in"
13844
13864
  }, {
13845
13865
  default: vue.withCtx(() => [
13846
- !isStepping.value ? (vue.openBlock(), vue.createElementBlock("div", {
13866
+ (vue.openBlock(), vue.createElementBlock("div", {
13847
13867
  key: currentStep.value,
13848
13868
  ref_key: "formContainer",
13849
13869
  ref: formContainer,
@@ -13871,7 +13891,7 @@ const _sfc_main$U = /* @__PURE__ */ vue.defineComponent({
13871
13891
  key: "1"
13872
13892
  } : void 0
13873
13893
  ]), 1040, ["modelValue", "schema"])
13874
- ])) : vue.createCommentVNode("", true)
13894
+ ]))
13875
13895
  ]),
13876
13896
  _: 3
13877
13897
  }, 8, ["name"]),
@@ -13882,19 +13902,21 @@ const _sfc_main$U = /* @__PURE__ */ vue.defineComponent({
13882
13902
  submit: handleSubmit,
13883
13903
  currentStep: currentStep.value,
13884
13904
  totalSteps: numberOfSteps.value,
13885
- canDoNext: canDoNext.value
13905
+ isLastStep: isLastStep.value,
13906
+ isStepValid: isStepValid.value
13886
13907
  })), () => [
13887
13908
  currentStep.value !== 0 ? (vue.openBlock(), vue.createBlock(vue.unref(Btn), {
13888
13909
  key: 0,
13889
13910
  color: "gray",
13890
13911
  icon: "arrow_back",
13891
- click: "prevStep"
13912
+ onClick: prevStep
13892
13913
  })) : vue.createCommentVNode("", true),
13893
- canDoNext.value ? (vue.openBlock(), vue.createBlock(vue.unref(Btn), {
13914
+ !isLastStep.value ? (vue.openBlock(), vue.createBlock(vue.unref(Btn), {
13894
13915
  key: 1,
13895
13916
  icon: "arrow_forward",
13917
+ disabled: props2.validateOnSteps && !isStepValid.value,
13896
13918
  onClick: nextStep
13897
- })) : (vue.openBlock(), vue.createBlock(vue.unref(Btn), {
13919
+ }, null, 8, ["disabled"])) : (vue.openBlock(), vue.createBlock(vue.unref(Btn), {
13898
13920
  key: 2,
13899
13921
  value: "Submit",
13900
13922
  onClick: handleSubmit
@@ -13906,7 +13928,7 @@ const _sfc_main$U = /* @__PURE__ */ vue.defineComponent({
13906
13928
  };
13907
13929
  }
13908
13930
  });
13909
- const BglMultiStepForm = /* @__PURE__ */ _export_sfc(_sfc_main$U, [["__scopeId", "data-v-53bb3be3"]]);
13931
+ const BglMultiStepForm = /* @__PURE__ */ _export_sfc(_sfc_main$U, [["__scopeId", "data-v-9c0b618c"]]);
13910
13932
  const _hoisted_1$M = {
13911
13933
  key: 0,
13912
13934
  class: "label mb-05"
@@ -13924,7 +13946,7 @@ const _hoisted_5$j = {
13924
13946
  key: 0,
13925
13947
  class: "minimizedText txt14 p-025 opacity-7"
13926
13948
  };
13927
- const _hoisted_6$g = { class: "bg-gray-80 -my-05 px-025 pt-065 pb-05 txt-center space-between flex column" };
13949
+ const _hoisted_6$f = { class: "bg-gray-80 -my-05 px-025 pt-065 pb-05 txt-center space-between flex column" };
13928
13950
  const _sfc_main$T = /* @__PURE__ */ vue.defineComponent({
13929
13951
  __name: "FieldArray",
13930
13952
  props: {
@@ -14058,7 +14080,7 @@ const _sfc_main$T = /* @__PURE__ */ vue.defineComponent({
14058
14080
  schema: resolvedSchemaData.value,
14059
14081
  "onUpdate:modelValue": (val) => updateItem(i2, val)
14060
14082
  }, null, 8, ["model-value", "schema", "onUpdate:modelValue"])),
14061
- vue.createElementVNode("div", _hoisted_6$g, [
14083
+ vue.createElementVNode("div", _hoisted_6$f, [
14062
14084
  showMinimizeButton.value ? (vue.openBlock(), vue.createBlock(vue.unref(Btn), {
14063
14085
  key: 0,
14064
14086
  class: "block rotate-180 txt10 opacity-7 p-025",
@@ -14172,55 +14194,54 @@ const _sfc_main$R = /* @__PURE__ */ vue.defineComponent({
14172
14194
  }
14173
14195
  });
14174
14196
  const CheckInput = /* @__PURE__ */ _export_sfc(_sfc_main$R, [["__scopeId", "data-v-722373de"]]);
14175
- const _hoisted_1$J = { class: "mb-05" };
14176
- const _hoisted_2$x = {
14197
+ const _hoisted_1$J = {
14177
14198
  key: 0,
14178
- class: "label txt-start"
14199
+ class: "label"
14179
14200
  };
14201
+ const _hoisted_2$x = { class: "editor-content-papa relative" };
14180
14202
  const _hoisted_3$t = {
14181
- key: 1,
14182
- class: "code-editor-wrap grid rounded p-1 overflow hm-300px ltr txt-start relative h-100p"
14203
+ class: "code-display",
14204
+ wrap: ""
14183
14205
  };
14184
- const _hoisted_4$i = { class: "overflow-hidden absolute inset-0 p-0 m-0 h-100 codeText" };
14185
- const _hoisted_5$i = ["innerHTML"];
14186
- const _hoisted_6$f = ["onKeydown"];
14206
+ const _hoisted_4$i = ["innerHTML"];
14207
+ const _hoisted_5$i = ["value"];
14187
14208
  const _sfc_main$Q = /* @__PURE__ */ vue.defineComponent({
14188
14209
  __name: "Index",
14189
14210
  props: {
14190
- language: {},
14211
+ language: { default: "html" },
14191
14212
  readonly: { type: Boolean, default: false },
14192
14213
  modelValue: { default: "" },
14193
- autodetect: { type: Boolean },
14214
+ autodetect: { type: Boolean, default: true },
14194
14215
  ignoreIllegals: { type: Boolean, default: true },
14195
- label: {},
14196
- height: { default: "300px" }
14216
+ label: { default: "" },
14217
+ height: { default: "240px" }
14197
14218
  },
14198
14219
  emits: ["update:modelValue"],
14199
14220
  setup(__props, { emit: __emit }) {
14221
+ const props2 = __props;
14200
14222
  const emit2 = __emit;
14201
- let hljs = vue.ref(null);
14202
- let elHeight = vue.ref(__props.height);
14203
- let code = vue.ref("");
14204
- const textarea = vue.ref();
14205
- let loaded = vue.ref(false);
14206
- const cannotDetectLanguage = vue.computed(() => {
14207
- var _a;
14208
- const lang = __props.language || "";
14209
- return !(__props.autodetect ?? !lang) && !((_a = hljs.value) == null ? void 0 : _a.getLanguage(lang));
14210
- });
14211
- const className = vue.computed(() => {
14212
- if (cannotDetectLanguage.value) return "";
14213
- return `hljs ${__props.language || ""}`;
14214
- });
14215
- const highlightedCode = vue.computed(() => {
14216
- var _a, _b;
14217
- if (cannotDetectLanguage.value) {
14218
- console.warn(`The language "${__props.language}" you specified could not be found.`);
14223
+ const code = vue.ref(props2.modelValue || "");
14224
+ const editorRef = vue.ref();
14225
+ const loaded = vue.ref(false);
14226
+ const hljs = vue.ref(null);
14227
+ const maxHeight = vue.computed(() => {
14228
+ const h2 = props2.height ?? "240px";
14229
+ return h2.match(/^\d+$/) ? `${h2}px` : h2;
14230
+ });
14231
+ const formattedCode = vue.computed(() => {
14232
+ if (!hljs.value) return escapeHtml(code.value);
14233
+ try {
14234
+ const lang = props2.language || "";
14235
+ if (lang && !props2.autodetect && !hljs.value.getLanguage(lang)) {
14236
+ console.warn(`The language "${lang}" is not available.`);
14237
+ return escapeHtml(code.value);
14238
+ }
14239
+ const result2 = props2.autodetect ? hljs.value.highlightAuto(code.value) : hljs.value.highlight(code.value, { language: lang, ignoreIllegals: props2.ignoreIllegals });
14240
+ return result2.value || escapeHtml(code.value);
14241
+ } catch (error) {
14242
+ console.error("Highlighting error:", error);
14219
14243
  return escapeHtml(code.value);
14220
14244
  }
14221
- const lang = __props.language || "";
14222
- const result2 = __props.autodetect ? (_a = hljs.value) == null ? void 0 : _a.highlightAuto(code.value) : (_b = hljs.value) == null ? void 0 : _b.highlight(code.value, { language: lang, ignoreIllegals: __props.ignoreIllegals });
14223
- return (result2 == null ? void 0 : result2.value) || "";
14224
14245
  });
14225
14246
  function escapeHtml(unsafe) {
14226
14247
  return unsafe.replace(/[&<>"']/g, (m2) => {
@@ -14234,75 +14255,77 @@ const _sfc_main$Q = /* @__PURE__ */ vue.defineComponent({
14234
14255
  return replacements[m2] || "";
14235
14256
  });
14236
14257
  }
14258
+ function handleInput(e) {
14259
+ const target = e.target;
14260
+ code.value = target.value;
14261
+ emit2("update:modelValue", code.value);
14262
+ }
14237
14263
  function handleTab(event) {
14264
+ if (event.key !== "Tab") return;
14265
+ event.preventDefault();
14238
14266
  const target = event.target;
14239
14267
  const start = target.selectionStart;
14240
- const tab = " ";
14241
- code.value = code.value.slice(0, start) + tab + code.value.slice(start);
14242
- vue.nextTick(() => {
14243
- target.selectionStart = target.selectionEnd = start + tab.length;
14244
- });
14245
- }
14246
- function adjustHeight() {
14247
- var _a;
14248
- if (((_a = textarea.value) == null ? void 0 : _a.scrollHeight) && textarea.value.scrollHeight > Number.parseInt(elHeight.value)) {
14249
- elHeight.value = `${textarea.value.scrollHeight}px`;
14250
- }
14268
+ const end = target.selectionEnd;
14269
+ const newValue = `${code.value.substring(0, start)} ${code.value.substring(end)}`;
14270
+ code.value = newValue;
14271
+ emit2("update:modelValue", code.value);
14272
+ setTimeout(() => {
14273
+ target.selectionStart = target.selectionEnd = start + 2;
14274
+ }, 0);
14251
14275
  }
14252
14276
  vue.onMounted(async () => {
14253
- await appendScript("https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.11.0/highlight.min.js", { id: "hljs-cdn" });
14254
- await appendStyle("https://cdn.jsdelivr.net/npm/highlight.js/styles/atom-one-dark.min.css");
14255
- if (window.hljs) {
14256
- hljs.value = window.hljs;
14257
- loaded.value = true;
14258
- } else {
14259
- console.error("Highlight.js failed to load.");
14277
+ try {
14278
+ await appendScript("https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.11.0/highlight.min.js", { id: "hljs-cdn" });
14279
+ await appendStyle("https://cdn.jsdelivr.net/npm/highlight.js/styles/atom-one-dark.min.css");
14280
+ if (window.hljs) {
14281
+ hljs.value = window.hljs;
14282
+ loaded.value = true;
14283
+ } else {
14284
+ console.error("Failed to load highlight.js");
14285
+ }
14286
+ } catch (error) {
14287
+ console.error("Error loading highlight.js:", error);
14260
14288
  }
14261
14289
  });
14262
- vue.watch(() => __props.modelValue, (newVal) => {
14263
- adjustHeight();
14264
- if (newVal !== code.value) {
14290
+ vue.watch(() => props2.modelValue, (newVal) => {
14291
+ if (newVal !== void 0 && newVal !== code.value) {
14265
14292
  code.value = newVal;
14266
14293
  }
14267
14294
  }, { immediate: true });
14268
14295
  return (_ctx, _cache) => {
14269
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$J, [
14270
- _ctx.label ? (vue.openBlock(), vue.createElementBlock("label", _hoisted_2$x, vue.toDisplayString(_ctx.label), 1)) : vue.createCommentVNode("", true),
14271
- vue.unref(loaded) ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_3$t, [
14272
- vue.createElementVNode("div", {
14273
- class: "relative block h-100",
14274
- style: vue.normalizeStyle({ height: `calc(${vue.unref(elHeight)} - 2rem)` })
14275
- }, [
14276
- vue.createElementVNode("pre", _hoisted_4$i, [
14277
- _cache[2] || (_cache[2] = vue.createTextVNode(" ")),
14278
- vue.createElementVNode("code", {
14279
- class: vue.normalizeClass(["absolute inset-0", className.value]),
14280
- innerHTML: highlightedCode.value
14281
- }, null, 10, _hoisted_5$i),
14282
- _cache[3] || (_cache[3] = vue.createTextVNode("\n "))
14296
+ return vue.openBlock(), vue.createElementBlock("div", {
14297
+ class: "code-editor-container ltr",
14298
+ style: vue.normalizeStyle({ maxHeight: maxHeight.value })
14299
+ }, [
14300
+ _ctx.label ? (vue.openBlock(), vue.createElementBlock("label", _hoisted_1$J, vue.toDisplayString(_ctx.label), 1)) : vue.createCommentVNode("", true),
14301
+ loaded.value ? (vue.openBlock(), vue.createElementBlock("div", {
14302
+ key: 1,
14303
+ ref_key: "editorRef",
14304
+ ref: editorRef,
14305
+ class: "code-editor-grandpa"
14306
+ }, [
14307
+ vue.createElementVNode("div", _hoisted_2$x, [
14308
+ vue.createElementVNode("pre", _hoisted_3$t, [
14309
+ vue.createElementVNode("code", { innerHTML: formattedCode.value }, null, 8, _hoisted_4$i)
14283
14310
  ]),
14284
- !_ctx.readonly ? vue.withDirectives((vue.openBlock(), vue.createElementBlock("textarea", {
14311
+ !_ctx.readonly ? (vue.openBlock(), vue.createElementBlock("textarea", {
14285
14312
  key: 0,
14286
- ref_key: "textarea",
14287
- ref: textarea,
14288
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => vue.isRef(code) ? code.value = $event : code = $event),
14289
- class: "code-editor absolute inset-0 bg-transparent overflow-hidden h-100 p-0 m-0 codeText border-none txt-start",
14313
+ value: code.value,
14314
+ class: "code-input",
14290
14315
  spellcheck: "false",
14291
- placeholder: "Write your code here",
14292
- "aria-label": "Code Editor",
14293
- "data-gramm": "false",
14294
- onKeydown: vue.withKeys(vue.withModifiers(handleTab, ["prevent"]), ["tab"]),
14295
- onInput: _cache[1] || (_cache[1] = ($event) => emit2("update:modelValue", vue.unref(code)))
14296
- }, null, 40, _hoisted_6$f)), [
14297
- [vue.vModelText, vue.unref(code)]
14298
- ]) : vue.createCommentVNode("", true)
14299
- ], 4)
14300
- ])) : vue.createCommentVNode("", true)
14301
- ]);
14316
+ autocomplete: "off",
14317
+ autocorrect: "off",
14318
+ autocapitalize: "off",
14319
+ onInput: handleInput,
14320
+ onKeydown: handleTab
14321
+ }, null, 40, _hoisted_5$i)) : vue.createCommentVNode("", true)
14322
+ ])
14323
+ ], 512)) : vue.createCommentVNode("", true)
14324
+ ], 4);
14302
14325
  };
14303
14326
  }
14304
14327
  });
14305
- const CodeEditor = /* @__PURE__ */ _export_sfc(_sfc_main$Q, [["__scopeId", "data-v-13335b34"]]);
14328
+ const CodeEditor = /* @__PURE__ */ _export_sfc(_sfc_main$Q, [["__scopeId", "data-v-6ab9613f"]]);
14306
14329
  const _hoisted_1$I = ["title"];
14307
14330
  const _hoisted_2$w = { class: "flex bg-input rounded px-025 colorInputPickWrap" };
14308
14331
  const _hoisted_3$s = ["id", "placeholder", "required"];
@@ -18797,6 +18820,7 @@ const _sfc_main$B = /* @__PURE__ */ vue.defineComponent({
18797
18820
  const editor = useEditor();
18798
18821
  const isInitializing = vue.ref(false);
18799
18822
  const hasInitialized = vue.ref(false);
18823
+ editor.state.content = props2.modelValue;
18800
18824
  if (props2.debug) {
18801
18825
  editor.initDebugger();
18802
18826
  }
@@ -18844,6 +18868,7 @@ const _sfc_main$B = /* @__PURE__ */ vue.defineComponent({
18844
18868
  doc.designMode = "on";
18845
18869
  doc.body.contentEditable = "true";
18846
18870
  doc.body.dir = hasRTL.value ? "rtl" : "ltr";
18871
+ editor.state.content = doc.body.innerHTML;
18847
18872
  editor.init(doc);
18848
18873
  useEditorKeyboard(doc, commands);
18849
18874
  if (!doc.body.firstElementChild) {
@@ -18851,6 +18876,7 @@ const _sfc_main$B = /* @__PURE__ */ vue.defineComponent({
18851
18876
  p2.dir = doc.body.dir;
18852
18877
  p2.innerHTML = "<br>";
18853
18878
  doc.body.appendChild(p2);
18879
+ editor.state.content = doc.body.innerHTML;
18854
18880
  } else {
18855
18881
  const walker = doc.createTreeWalker(doc.body, NodeFilter.SHOW_TEXT);
18856
18882
  const textNodes = [];
@@ -18871,6 +18897,7 @@ const _sfc_main$B = /* @__PURE__ */ vue.defineComponent({
18871
18897
  doc.body.removeChild(textNode);
18872
18898
  }
18873
18899
  });
18900
+ editor.state.content = doc.body.innerHTML;
18874
18901
  }
18875
18902
  doc.body.focus();
18876
18903
  hasInitialized.value = true;
@@ -18932,8 +18959,8 @@ const _sfc_main$B = /* @__PURE__ */ vue.defineComponent({
18932
18959
  _cache[1] || (_cache[1] = ($event) => vue.unref(editor).updateState.content("html"))
18933
18960
  ],
18934
18961
  language: "html",
18935
- class: "code-editor"
18936
- }, null, 8, ["modelValue"])) : vue.createCommentVNode("", true)
18962
+ height: vue.unref(editor).state.isFullscreen ? "calc(100vh - 4rem)" : "250px"
18963
+ }, null, 8, ["modelValue", "height"])) : vue.createCommentVNode("", true)
18937
18964
  ], 2),
18938
18965
  _ctx.debug ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_3$h, [
18939
18966
  _cache[6] || (_cache[6] = vue.createElementVNode("p", { class: "text12 txt-gray mb-0 p-0" }, " Debug ", -1)),
@@ -18979,7 +19006,7 @@ const _sfc_main$B = /* @__PURE__ */ vue.defineComponent({
18979
19006
  };
18980
19007
  }
18981
19008
  });
18982
- const RichText = /* @__PURE__ */ _export_sfc(_sfc_main$B, [["__scopeId", "data-v-30bcda4c"]]);
19009
+ const RichText = /* @__PURE__ */ _export_sfc(_sfc_main$B, [["__scopeId", "data-v-2782b5dd"]]);
18983
19010
  const _hoisted_1$t = { key: 0 };
18984
19011
  const _hoisted_2$j = { class: "flex gap-05" };
18985
19012
  const _hoisted_3$g = ["disabled"];