@bagelink/vue 0.0.1294 → 0.0.1298

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.
@@ -1 +1 @@
1
- {"version":3,"file":"useEditor.d.ts","sourceRoot":"","sources":["../../../../../../src/components/form/inputs/RichText/composables/useEditor.ts"],"names":[],"mappings":"AAmCA,wBAAgB,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eALR,UAAU;;;;;;;;;;;;qDAlBI,CAAC;;+CAG9B,CAAD;;;;2CAGC,CAAC;;;gBAsTiB,QAAQ;;;0BApPR,MAAM,GAAG,MAAM;;;;;;;;;EAwUlC"}
1
+ {"version":3,"file":"useEditor.d.ts","sourceRoot":"","sources":["../../../../../../src/components/form/inputs/RichText/composables/useEditor.ts"],"names":[],"mappings":"AAmCA,wBAAgB,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eALR,UAAU;;;;;;;;;;;;qDAlBI,CAAC;;+CAG9B,CAAD;;;;2CAGC,CAAC;;;gBAkSiB,QAAQ;;;0BAhOR,MAAM,GAAG,MAAM;;;;;;;;;EAuTlC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.vue.d.ts","sourceRoot":"","sources":["../../../../../src/components/form/inputs/RichText/index.vue"],"names":[],"mappings":"AAsSA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAQpD,KAAK,WAAW,GAAG;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,aAAa,CAAC,EAAE,aAAa,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;;;;;;;;AAiW1G,wBASG"}
1
+ {"version":3,"file":"index.vue.d.ts","sourceRoot":"","sources":["../../../../../src/components/form/inputs/RichText/index.vue"],"names":[],"mappings":"AAgSA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAQpD,KAAK,WAAW,GAAG;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,aAAa,CAAC,EAAE,aAAa,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;;;;;;;;AA2V1G,wBASG"}
@@ -1 +1 @@
1
- {"version":3,"file":"media.d.ts","sourceRoot":"","sources":["../../../../../../src/components/form/inputs/RichText/utils/media.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAKnD,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,QAwClE;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,QAmBjE;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,QA0DlE"}
1
+ {"version":3,"file":"media.d.ts","sourceRoot":"","sources":["../../../../../../src/components/form/inputs/RichText/utils/media.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAKnD,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,QAyClE;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,QAoBjE;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,QA2DlE"}
@@ -1 +1 @@
1
- {"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../../../../../src/components/form/inputs/RichText/utils/table.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAEnD,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,QAmBzE;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,QAAQ,QAcrD;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,QAAQ,QAiBpD;AAED,wBAAgB,MAAM,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,QAAQ,QAY/E;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,KAAK,QAQrC;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,KAAK,QAQvC;AAED,wBAAgB,YAAY,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,EAAE,KAAK,EAAE,KAAK,QAgBtE;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,KAAK,QAkBxC;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,GAAG,SAAS,QAgB3F"}
1
+ {"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../../../../../src/components/form/inputs/RichText/utils/table.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAEnD,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,QAoBzE;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,QAAQ,QAoBrD;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,QAAQ,QAuBpD;AAED,wBAAgB,MAAM,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,QAAQ,QAkB/E;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,KAAK,QAerC;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,KAAK,QAevC;AAED,wBAAgB,YAAY,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,EAAE,KAAK,EAAE,KAAK,QAsBtE;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,KAAK,QAyBxC;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,GAAG,SAAS,QAsB3F"}
package/dist/index.cjs CHANGED
@@ -18470,6 +18470,7 @@ function insertImage(modal, state2) {
18470
18470
  })() : img;
18471
18471
  range2.collapse(false);
18472
18472
  range2.insertNode(node);
18473
+ state2.content = doc.body.innerHTML;
18473
18474
  }
18474
18475
  }
18475
18476
  });
@@ -18489,6 +18490,7 @@ function insertLink(modal, state2) {
18489
18490
  anchor.href = data2.url;
18490
18491
  if (data2.openInNewTab) anchor.target = "_blank";
18491
18492
  range2.surroundContents(anchor);
18493
+ state2.content = doc.body.innerHTML;
18492
18494
  }
18493
18495
  }
18494
18496
  });
@@ -18536,6 +18538,7 @@ function insertEmbed(modal, state2) {
18536
18538
  wrapper.appendChild(iframe);
18537
18539
  range2.deleteContents();
18538
18540
  range2.insertNode(wrapper);
18541
+ state2.content = doc.body.innerHTML;
18539
18542
  }
18540
18543
  });
18541
18544
  }
@@ -18557,6 +18560,7 @@ function insertTable(rows, cols, state2) {
18557
18560
  } else {
18558
18561
  state2.doc.body.appendChild(table);
18559
18562
  }
18563
+ state2.content = state2.doc.body.innerHTML;
18560
18564
  }
18561
18565
  function mergeCells(range2, doc) {
18562
18566
  var _a;
@@ -18570,6 +18574,10 @@ function mergeCells(range2, doc) {
18570
18574
  const actualCell = doc.getElementById(cell.id);
18571
18575
  actualCell == null ? void 0 : actualCell.remove();
18572
18576
  });
18577
+ const state2 = doc.editorState;
18578
+ if (state2) {
18579
+ state2.content = doc.body.innerHTML;
18580
+ }
18573
18581
  }
18574
18582
  function splitCell(range2, doc) {
18575
18583
  var _a;
@@ -18587,6 +18595,10 @@ function splitCell(range2, doc) {
18587
18595
  newCells.slice(1).forEach((newCell) => {
18588
18596
  newCells[0].insertAdjacentElement("afterend", newCell);
18589
18597
  });
18598
+ const state2 = doc.editorState;
18599
+ if (state2) {
18600
+ state2.content = doc.body.innerHTML;
18601
+ }
18590
18602
  }
18591
18603
  function addRow(position, range2, doc) {
18592
18604
  var _a;
@@ -18598,6 +18610,10 @@ function addRow(position, range2, doc) {
18598
18610
  const newRow = row.cloneNode(true);
18599
18611
  Array.from(newRow.cells).forEach((cell2) => cell2.innerHTML = " ");
18600
18612
  row.insertAdjacentElement(position === "before" ? "beforebegin" : "afterend", newRow);
18613
+ const state2 = doc.editorState;
18614
+ if (state2) {
18615
+ state2.content = doc.body.innerHTML;
18616
+ }
18601
18617
  }
18602
18618
  function deleteRow(range2) {
18603
18619
  var _a;
@@ -18605,7 +18621,12 @@ function deleteRow(range2) {
18605
18621
  if (!cell) return;
18606
18622
  const row = cell.parentElement;
18607
18623
  if (!row) return;
18624
+ const doc = row.ownerDocument;
18608
18625
  row.remove();
18626
+ const state2 = doc.editorState;
18627
+ if (state2) {
18628
+ state2.content = doc.body.innerHTML;
18629
+ }
18609
18630
  }
18610
18631
  function deleteTable(range2) {
18611
18632
  var _a;
@@ -18613,7 +18634,12 @@ function deleteTable(range2) {
18613
18634
  if (!cell) return;
18614
18635
  const table = cell.closest("table");
18615
18636
  if (!table) return;
18637
+ const doc = table.ownerDocument;
18616
18638
  table.remove();
18639
+ const state2 = doc.editorState;
18640
+ if (state2) {
18641
+ state2.content = doc.body.innerHTML;
18642
+ }
18617
18643
  }
18618
18644
  function insertColumn(position, range2) {
18619
18645
  var _a;
@@ -18629,6 +18655,10 @@ function insertColumn(position, range2) {
18629
18655
  newCell.style.border = "1px solid var(--border-color)";
18630
18656
  newCell.style.padding = "8px";
18631
18657
  }
18658
+ const state2 = table.ownerDocument.editorState;
18659
+ if (state2) {
18660
+ state2.content = table.ownerDocument.body.innerHTML;
18661
+ }
18632
18662
  }
18633
18663
  function deleteColumn(range2) {
18634
18664
  var _a;
@@ -18638,12 +18668,17 @@ function deleteColumn(range2) {
18638
18668
  if (!table) return;
18639
18669
  const columnIndex = cell.cellIndex;
18640
18670
  const { rows } = table;
18671
+ const doc = table.ownerDocument;
18641
18672
  for (let i2 = 0; i2 < rows.length; i2++) {
18642
18673
  rows[i2].deleteCell(columnIndex);
18643
18674
  }
18644
18675
  if (rows[0].cells.length === 0) {
18645
18676
  table.remove();
18646
18677
  }
18678
+ const state2 = doc.editorState;
18679
+ if (state2) {
18680
+ state2.content = doc.body.innerHTML;
18681
+ }
18647
18682
  }
18648
18683
  function alignColumn(range2, alignment) {
18649
18684
  var _a;
@@ -18659,6 +18694,10 @@ function alignColumn(range2, alignment) {
18659
18694
  cell2.style.textAlign = alignment;
18660
18695
  }
18661
18696
  }
18697
+ const state2 = table.ownerDocument.editorState;
18698
+ if (state2) {
18699
+ state2.content = table.ownerDocument.body.innerHTML;
18700
+ }
18662
18701
  }
18663
18702
  function createCommand(name, execute, isActive) {
18664
18703
  return {
@@ -19224,42 +19263,31 @@ function useEditor() {
19224
19263
  cleanupListeners = null;
19225
19264
  }
19226
19265
  let isUpdating = false;
19227
- let contentUpdateTimeout = null;
19228
- let selectionUpdateTimeout = null;
19229
19266
  const events = {
19230
19267
  input: () => {
19231
19268
  if (isUpdating) return;
19232
19269
  isUpdating = true;
19233
- if (contentUpdateTimeout) {
19234
- window.clearTimeout(contentUpdateTimeout);
19270
+ const newContent = doc.body.innerHTML;
19271
+ if (newContent !== state2.content) {
19272
+ state2.content = newContent;
19235
19273
  }
19236
- contentUpdateTimeout = window.setTimeout(() => {
19237
- const newContent = doc.body.innerHTML;
19238
- if (newContent !== state2.content) {
19239
- state2.content = newContent;
19240
- }
19241
- isUpdating = false;
19242
- }, 100);
19274
+ isUpdating = false;
19243
19275
  },
19244
19276
  selectionchange: () => {
19245
- if (isUpdating) return;
19246
- if (selectionUpdateTimeout) {
19247
- window.clearTimeout(selectionUpdateTimeout);
19277
+ if (!isUpdating) {
19278
+ updateState.selection();
19248
19279
  }
19249
- selectionUpdateTimeout = window.setTimeout(() => {
19250
- if (!isUpdating) {
19251
- updateState.selection();
19252
- }
19253
- }, 150);
19254
19280
  },
19255
19281
  mouseup: () => {
19256
- if (isUpdating) return;
19257
- updateState.selection();
19282
+ if (!isUpdating) {
19283
+ updateState.selection();
19284
+ }
19258
19285
  },
19259
19286
  keyup: (e) => {
19260
- if (isUpdating) return;
19261
- if (["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"].includes(e.key)) {
19262
- updateState.selection();
19287
+ if (!isUpdating) {
19288
+ if (["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"].includes(e.key)) {
19289
+ updateState.selection();
19290
+ }
19263
19291
  }
19264
19292
  }
19265
19293
  };
@@ -19267,8 +19295,6 @@ function useEditor() {
19267
19295
  doc.addEventListener(event, handler);
19268
19296
  });
19269
19297
  cleanupListeners = () => {
19270
- if (contentUpdateTimeout) window.clearTimeout(contentUpdateTimeout);
19271
- if (selectionUpdateTimeout) window.clearTimeout(selectionUpdateTimeout);
19272
19298
  Object.entries(events).forEach(([event, handler]) => {
19273
19299
  doc.removeEventListener(event, handler);
19274
19300
  });
@@ -19284,6 +19310,7 @@ function useEditor() {
19284
19310
  }
19285
19311
  state2.doc = doc;
19286
19312
  state2.hasInit = true;
19313
+ doc.editorState = state2;
19287
19314
  if (state2.content) {
19288
19315
  const preserved = preserveIframes(state2.content);
19289
19316
  doc.body.innerHTML = preserved.html;
@@ -19556,12 +19583,6 @@ const _sfc_main$z = /* @__PURE__ */ vue.defineComponent({
19556
19583
  }
19557
19584
  emit2("update:modelValue", newValue);
19558
19585
  });
19559
- vue.watch(() => editor.state.isSplitView, (isEnabled) => {
19560
- var _a;
19561
- if (isEnabled) {
19562
- editor.state.content = ((_a = editor.state.doc) == null ? void 0 : _a.body.innerHTML) || "";
19563
- }
19564
- });
19565
19586
  return (_ctx, _cache) => {
19566
19587
  var _a, _b;
19567
19588
  return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$s, [
@@ -19645,7 +19666,7 @@ const _sfc_main$z = /* @__PURE__ */ vue.defineComponent({
19645
19666
  };
19646
19667
  }
19647
19668
  });
19648
- const RichText = /* @__PURE__ */ _export_sfc(_sfc_main$z, [["__scopeId", "data-v-0aa61b83"]]);
19669
+ const RichText = /* @__PURE__ */ _export_sfc(_sfc_main$z, [["__scopeId", "data-v-30bcda4c"]]);
19649
19670
  const _hoisted_1$r = { class: "flex gap-05" };
19650
19671
  const _hoisted_2$h = ["disabled"];
19651
19672
  const _hoisted_3$d = { key: 1 };
@@ -37146,16 +37167,16 @@ const translations = {
37146
37167
  second: "seconde",
37147
37168
  ago: "il y a",
37148
37169
  in: "dans",
37149
- justNow: "À linstant"
37170
+ justNow: "À l'instant"
37150
37171
  },
37151
37172
  he: {
37152
- year: "שנה",
37153
- month: "חודש",
37154
- week: "שבוע",
37155
- day: "יום",
37156
- hour: "שעה",
37157
- minute: "דקה",
37158
- second: "שנייה",
37173
+ year: { singular: "שנה", plural: "שנים" },
37174
+ month: { singular: "חודש", plural: "חודשים" },
37175
+ week: { singular: "שבוע", plural: "שבועות" },
37176
+ day: { singular: "יום", plural: "ימים" },
37177
+ hour: { singular: "שעה", plural: "שעות" },
37178
+ minute: { singular: "דקה", plural: "דקות" },
37179
+ second: { singular: "שנייה", plural: "שניות" },
37159
37180
  ago: "לפני",
37160
37181
  in: "בעוד",
37161
37182
  justNow: "זה עתה"
@@ -37182,7 +37203,19 @@ function timeAgo(date2, lang = "en") {
37182
37203
  const count2 = Math.floor(Math.abs(seconds) / interval.seconds);
37183
37204
  if (count2 >= 1) {
37184
37205
  const suffix = seconds < 0 ? ` ${selectedLang.ago}` : "";
37185
- const prefix = "";
37206
+ const prefix = seconds > 0 && selectedLang.in !== "in" ? `${selectedLang.in} ` : "";
37207
+ if (lang === "he") {
37208
+ const timeUnit = selectedLang[interval.label];
37209
+ const form = count2 === 1 ? timeUnit.singular : timeUnit.plural;
37210
+ const hebrewPrefix = seconds < 0 ? `${selectedLang.ago} ` : seconds > 0 ? `${selectedLang.in} ` : "";
37211
+ if (interval.label === "day" && seconds > 0) {
37212
+ const hours = Math.floor(Math.abs(seconds) % 86400 / 3600);
37213
+ const hourUnit = selectedLang.hour;
37214
+ const hourForm = hours === 1 ? hourUnit.singular : hourUnit.plural;
37215
+ return `${hebrewPrefix}${count2} ${form}${hours > 0 ? ` ${hours} ${hourForm}` : ""}`;
37216
+ }
37217
+ return `${hebrewPrefix}${count2} ${form}`;
37218
+ }
37186
37219
  if (interval.label === "day" && seconds > 0) {
37187
37220
  const hours = Math.floor(Math.abs(seconds) % 86400 / 3600);
37188
37221
  const hourLabel = hours > 1 ? `${selectedLang.hour}s` : selectedLang.hour;
package/dist/index.mjs CHANGED
@@ -18468,6 +18468,7 @@ function insertImage(modal, state2) {
18468
18468
  })() : img;
18469
18469
  range2.collapse(false);
18470
18470
  range2.insertNode(node);
18471
+ state2.content = doc.body.innerHTML;
18471
18472
  }
18472
18473
  }
18473
18474
  });
@@ -18487,6 +18488,7 @@ function insertLink(modal, state2) {
18487
18488
  anchor.href = data2.url;
18488
18489
  if (data2.openInNewTab) anchor.target = "_blank";
18489
18490
  range2.surroundContents(anchor);
18491
+ state2.content = doc.body.innerHTML;
18490
18492
  }
18491
18493
  }
18492
18494
  });
@@ -18534,6 +18536,7 @@ function insertEmbed(modal, state2) {
18534
18536
  wrapper.appendChild(iframe);
18535
18537
  range2.deleteContents();
18536
18538
  range2.insertNode(wrapper);
18539
+ state2.content = doc.body.innerHTML;
18537
18540
  }
18538
18541
  });
18539
18542
  }
@@ -18555,6 +18558,7 @@ function insertTable(rows, cols, state2) {
18555
18558
  } else {
18556
18559
  state2.doc.body.appendChild(table);
18557
18560
  }
18561
+ state2.content = state2.doc.body.innerHTML;
18558
18562
  }
18559
18563
  function mergeCells(range2, doc) {
18560
18564
  var _a;
@@ -18568,6 +18572,10 @@ function mergeCells(range2, doc) {
18568
18572
  const actualCell = doc.getElementById(cell.id);
18569
18573
  actualCell == null ? void 0 : actualCell.remove();
18570
18574
  });
18575
+ const state2 = doc.editorState;
18576
+ if (state2) {
18577
+ state2.content = doc.body.innerHTML;
18578
+ }
18571
18579
  }
18572
18580
  function splitCell(range2, doc) {
18573
18581
  var _a;
@@ -18585,6 +18593,10 @@ function splitCell(range2, doc) {
18585
18593
  newCells.slice(1).forEach((newCell) => {
18586
18594
  newCells[0].insertAdjacentElement("afterend", newCell);
18587
18595
  });
18596
+ const state2 = doc.editorState;
18597
+ if (state2) {
18598
+ state2.content = doc.body.innerHTML;
18599
+ }
18588
18600
  }
18589
18601
  function addRow(position, range2, doc) {
18590
18602
  var _a;
@@ -18596,6 +18608,10 @@ function addRow(position, range2, doc) {
18596
18608
  const newRow = row.cloneNode(true);
18597
18609
  Array.from(newRow.cells).forEach((cell2) => cell2.innerHTML = "&nbsp;");
18598
18610
  row.insertAdjacentElement(position === "before" ? "beforebegin" : "afterend", newRow);
18611
+ const state2 = doc.editorState;
18612
+ if (state2) {
18613
+ state2.content = doc.body.innerHTML;
18614
+ }
18599
18615
  }
18600
18616
  function deleteRow(range2) {
18601
18617
  var _a;
@@ -18603,7 +18619,12 @@ function deleteRow(range2) {
18603
18619
  if (!cell) return;
18604
18620
  const row = cell.parentElement;
18605
18621
  if (!row) return;
18622
+ const doc = row.ownerDocument;
18606
18623
  row.remove();
18624
+ const state2 = doc.editorState;
18625
+ if (state2) {
18626
+ state2.content = doc.body.innerHTML;
18627
+ }
18607
18628
  }
18608
18629
  function deleteTable(range2) {
18609
18630
  var _a;
@@ -18611,7 +18632,12 @@ function deleteTable(range2) {
18611
18632
  if (!cell) return;
18612
18633
  const table = cell.closest("table");
18613
18634
  if (!table) return;
18635
+ const doc = table.ownerDocument;
18614
18636
  table.remove();
18637
+ const state2 = doc.editorState;
18638
+ if (state2) {
18639
+ state2.content = doc.body.innerHTML;
18640
+ }
18615
18641
  }
18616
18642
  function insertColumn(position, range2) {
18617
18643
  var _a;
@@ -18627,6 +18653,10 @@ function insertColumn(position, range2) {
18627
18653
  newCell.style.border = "1px solid var(--border-color)";
18628
18654
  newCell.style.padding = "8px";
18629
18655
  }
18656
+ const state2 = table.ownerDocument.editorState;
18657
+ if (state2) {
18658
+ state2.content = table.ownerDocument.body.innerHTML;
18659
+ }
18630
18660
  }
18631
18661
  function deleteColumn(range2) {
18632
18662
  var _a;
@@ -18636,12 +18666,17 @@ function deleteColumn(range2) {
18636
18666
  if (!table) return;
18637
18667
  const columnIndex = cell.cellIndex;
18638
18668
  const { rows } = table;
18669
+ const doc = table.ownerDocument;
18639
18670
  for (let i2 = 0; i2 < rows.length; i2++) {
18640
18671
  rows[i2].deleteCell(columnIndex);
18641
18672
  }
18642
18673
  if (rows[0].cells.length === 0) {
18643
18674
  table.remove();
18644
18675
  }
18676
+ const state2 = doc.editorState;
18677
+ if (state2) {
18678
+ state2.content = doc.body.innerHTML;
18679
+ }
18645
18680
  }
18646
18681
  function alignColumn(range2, alignment) {
18647
18682
  var _a;
@@ -18657,6 +18692,10 @@ function alignColumn(range2, alignment) {
18657
18692
  cell2.style.textAlign = alignment;
18658
18693
  }
18659
18694
  }
18695
+ const state2 = table.ownerDocument.editorState;
18696
+ if (state2) {
18697
+ state2.content = table.ownerDocument.body.innerHTML;
18698
+ }
18660
18699
  }
18661
18700
  function createCommand(name, execute, isActive) {
18662
18701
  return {
@@ -19222,42 +19261,31 @@ function useEditor() {
19222
19261
  cleanupListeners = null;
19223
19262
  }
19224
19263
  let isUpdating = false;
19225
- let contentUpdateTimeout = null;
19226
- let selectionUpdateTimeout = null;
19227
19264
  const events = {
19228
19265
  input: () => {
19229
19266
  if (isUpdating) return;
19230
19267
  isUpdating = true;
19231
- if (contentUpdateTimeout) {
19232
- window.clearTimeout(contentUpdateTimeout);
19268
+ const newContent = doc.body.innerHTML;
19269
+ if (newContent !== state2.content) {
19270
+ state2.content = newContent;
19233
19271
  }
19234
- contentUpdateTimeout = window.setTimeout(() => {
19235
- const newContent = doc.body.innerHTML;
19236
- if (newContent !== state2.content) {
19237
- state2.content = newContent;
19238
- }
19239
- isUpdating = false;
19240
- }, 100);
19272
+ isUpdating = false;
19241
19273
  },
19242
19274
  selectionchange: () => {
19243
- if (isUpdating) return;
19244
- if (selectionUpdateTimeout) {
19245
- window.clearTimeout(selectionUpdateTimeout);
19275
+ if (!isUpdating) {
19276
+ updateState.selection();
19246
19277
  }
19247
- selectionUpdateTimeout = window.setTimeout(() => {
19248
- if (!isUpdating) {
19249
- updateState.selection();
19250
- }
19251
- }, 150);
19252
19278
  },
19253
19279
  mouseup: () => {
19254
- if (isUpdating) return;
19255
- updateState.selection();
19280
+ if (!isUpdating) {
19281
+ updateState.selection();
19282
+ }
19256
19283
  },
19257
19284
  keyup: (e) => {
19258
- if (isUpdating) return;
19259
- if (["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"].includes(e.key)) {
19260
- updateState.selection();
19285
+ if (!isUpdating) {
19286
+ if (["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"].includes(e.key)) {
19287
+ updateState.selection();
19288
+ }
19261
19289
  }
19262
19290
  }
19263
19291
  };
@@ -19265,8 +19293,6 @@ function useEditor() {
19265
19293
  doc.addEventListener(event, handler);
19266
19294
  });
19267
19295
  cleanupListeners = () => {
19268
- if (contentUpdateTimeout) window.clearTimeout(contentUpdateTimeout);
19269
- if (selectionUpdateTimeout) window.clearTimeout(selectionUpdateTimeout);
19270
19296
  Object.entries(events).forEach(([event, handler]) => {
19271
19297
  doc.removeEventListener(event, handler);
19272
19298
  });
@@ -19282,6 +19308,7 @@ function useEditor() {
19282
19308
  }
19283
19309
  state2.doc = doc;
19284
19310
  state2.hasInit = true;
19311
+ doc.editorState = state2;
19285
19312
  if (state2.content) {
19286
19313
  const preserved = preserveIframes(state2.content);
19287
19314
  doc.body.innerHTML = preserved.html;
@@ -19554,12 +19581,6 @@ const _sfc_main$z = /* @__PURE__ */ defineComponent({
19554
19581
  }
19555
19582
  emit2("update:modelValue", newValue);
19556
19583
  });
19557
- watch(() => editor.state.isSplitView, (isEnabled) => {
19558
- var _a;
19559
- if (isEnabled) {
19560
- editor.state.content = ((_a = editor.state.doc) == null ? void 0 : _a.body.innerHTML) || "";
19561
- }
19562
- });
19563
19584
  return (_ctx, _cache) => {
19564
19585
  var _a, _b;
19565
19586
  return openBlock(), createElementBlock("div", _hoisted_1$s, [
@@ -19643,7 +19664,7 @@ const _sfc_main$z = /* @__PURE__ */ defineComponent({
19643
19664
  };
19644
19665
  }
19645
19666
  });
19646
- const RichText = /* @__PURE__ */ _export_sfc(_sfc_main$z, [["__scopeId", "data-v-0aa61b83"]]);
19667
+ const RichText = /* @__PURE__ */ _export_sfc(_sfc_main$z, [["__scopeId", "data-v-30bcda4c"]]);
19647
19668
  const _hoisted_1$r = { class: "flex gap-05" };
19648
19669
  const _hoisted_2$h = ["disabled"];
19649
19670
  const _hoisted_3$d = { key: 1 };
@@ -37144,16 +37165,16 @@ const translations = {
37144
37165
  second: "seconde",
37145
37166
  ago: "il y a",
37146
37167
  in: "dans",
37147
- justNow: "À linstant"
37168
+ justNow: "À l'instant"
37148
37169
  },
37149
37170
  he: {
37150
- year: "שנה",
37151
- month: "חודש",
37152
- week: "שבוע",
37153
- day: "יום",
37154
- hour: "שעה",
37155
- minute: "דקה",
37156
- second: "שנייה",
37171
+ year: { singular: "שנה", plural: "שנים" },
37172
+ month: { singular: "חודש", plural: "חודשים" },
37173
+ week: { singular: "שבוע", plural: "שבועות" },
37174
+ day: { singular: "יום", plural: "ימים" },
37175
+ hour: { singular: "שעה", plural: "שעות" },
37176
+ minute: { singular: "דקה", plural: "דקות" },
37177
+ second: { singular: "שנייה", plural: "שניות" },
37157
37178
  ago: "לפני",
37158
37179
  in: "בעוד",
37159
37180
  justNow: "זה עתה"
@@ -37180,7 +37201,19 @@ function timeAgo(date2, lang = "en") {
37180
37201
  const count2 = Math.floor(Math.abs(seconds) / interval.seconds);
37181
37202
  if (count2 >= 1) {
37182
37203
  const suffix = seconds < 0 ? ` ${selectedLang.ago}` : "";
37183
- const prefix = "";
37204
+ const prefix = seconds > 0 && selectedLang.in !== "in" ? `${selectedLang.in} ` : "";
37205
+ if (lang === "he") {
37206
+ const timeUnit = selectedLang[interval.label];
37207
+ const form = count2 === 1 ? timeUnit.singular : timeUnit.plural;
37208
+ const hebrewPrefix = seconds < 0 ? `${selectedLang.ago} ` : seconds > 0 ? `${selectedLang.in} ` : "";
37209
+ if (interval.label === "day" && seconds > 0) {
37210
+ const hours = Math.floor(Math.abs(seconds) % 86400 / 3600);
37211
+ const hourUnit = selectedLang.hour;
37212
+ const hourForm = hours === 1 ? hourUnit.singular : hourUnit.plural;
37213
+ return `${hebrewPrefix}${count2} ${form}${hours > 0 ? ` ${hours} ${hourForm}` : ""}`;
37214
+ }
37215
+ return `${hebrewPrefix}${count2} ${form}`;
37216
+ }
37184
37217
  if (interval.label === "day" && seconds > 0) {
37185
37218
  const hours = Math.floor(Math.abs(seconds) % 86400 / 3600);
37186
37219
  const hourLabel = hours > 1 ? `${selectedLang.hour}s` : selectedLang.hour;
package/dist/style.css CHANGED
@@ -2064,26 +2064,26 @@ input[type="range"][data-v-25d991e5]:active::-webkit-slider-thumb {
2064
2064
  height: 100%;
2065
2065
  }
2066
2066
 
2067
- .rich-text-editor[data-v-0aa61b83] {
2067
+ .rich-text-editor[data-v-30bcda4c] {
2068
2068
  background: var(--input-bg);
2069
2069
  border: 1px solid var(--border-color);
2070
2070
  transition: all 0.3s ease;
2071
2071
  }
2072
- .editor-container[data-v-0aa61b83] {
2072
+ .editor-container[data-v-30bcda4c] {
2073
2073
  display: flex;
2074
2074
  gap: 1rem;
2075
2075
  }
2076
- .content-area[data-v-0aa61b83],
2077
- .preview-area[data-v-0aa61b83] {
2076
+ .content-area[data-v-30bcda4c],
2077
+ .preview-area[data-v-30bcda4c] {
2078
2078
  flex: 1;
2079
2079
  min-height: 200px;
2080
2080
  background: var(--bgl-richtext-color);
2081
2081
  }
2082
- .split-view[data-v-0aa61b83] {
2082
+ .split-view[data-v-30bcda4c] {
2083
2083
  display: grid;
2084
2084
  grid-template-columns: 1fr 1fr;
2085
2085
  }
2086
- .editableContent[data-v-0aa61b83] {
2086
+ .editableContent[data-v-30bcda4c] {
2087
2087
  width: 100%;
2088
2088
  min-height: 240px;
2089
2089
  height: 100%;
@@ -2091,7 +2091,7 @@ input[type="range"][data-v-25d991e5]:active::-webkit-slider-thumb {
2091
2091
  outline: none;
2092
2092
  background: transparent;
2093
2093
  }
2094
- .html-editor[data-v-0aa61b83] {
2094
+ .html-editor[data-v-30bcda4c] {
2095
2095
  width: 100%;
2096
2096
  height: 100%;
2097
2097
  min-height: 200px;
@@ -2102,12 +2102,12 @@ input[type="range"][data-v-25d991e5]:active::-webkit-slider-thumb {
2102
2102
  color: white;
2103
2103
  background-color: var(--bgl-black);
2104
2104
  }
2105
- .preview-area[data-v-0aa61b83] {
2105
+ .preview-area[data-v-30bcda4c] {
2106
2106
  font-family: monospace;
2107
2107
  white-space: pre-wrap;
2108
2108
  overflow-x: auto;
2109
2109
  }
2110
- .fullscreen-mode[data-v-0aa61b83] {
2110
+ .fullscreen-mode[data-v-30bcda4c] {
2111
2111
  position: fixed;
2112
2112
  top: 0;
2113
2113
  left: 0;
@@ -2116,18 +2116,18 @@ input[type="range"][data-v-25d991e5]:active::-webkit-slider-thumb {
2116
2116
  z-index: 9999;
2117
2117
  padding: 2rem;
2118
2118
  }
2119
- .fullscreen-mode .editor-container[data-v-0aa61b83] {
2119
+ .fullscreen-mode .editor-container[data-v-30bcda4c] {
2120
2120
  height: calc(100vh - 4rem);
2121
2121
  }
2122
- .fullscreen-mode .content-area[data-v-0aa61b83],
2123
- .fullscreen-mode .preview-area[data-v-0aa61b83] {
2122
+ .fullscreen-mode .content-area[data-v-30bcda4c],
2123
+ .fullscreen-mode .preview-area[data-v-30bcda4c] {
2124
2124
  height: 100%;
2125
2125
  overflow-y: auto;
2126
2126
  }
2127
- .fullscreen-mode .code-editor[data-v-0aa61b83]{
2127
+ .fullscreen-mode .code-editor[data-v-30bcda4c]{
2128
2128
  height: 100% !important;
2129
2129
  }
2130
- .debug-controls[data-v-0aa61b83] {
2130
+ .debug-controls[data-v-30bcda4c] {
2131
2131
  display: flex;
2132
2132
  gap: 0.5rem;
2133
2133
  justify-content: flex-end;
@@ -1 +1 @@
1
- {"version":3,"file":"timeAgo.d.ts","sourceRoot":"","sources":["../../src/utils/timeAgo.ts"],"names":[],"mappings":"AAAA,KAAK,sBAAsB,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAA;AAsDvD,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,EAAE,IAAI,GAAE,sBAA6B,UAmC/E"}
1
+ {"version":3,"file":"timeAgo.d.ts","sourceRoot":"","sources":["../../src/utils/timeAgo.ts"],"names":[],"mappings":"AAWA,KAAK,sBAAsB,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAA;AAqDvD,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,EAAE,IAAI,GAAE,sBAA6B,UAsD/E"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bagelink/vue",
3
3
  "type": "module",
4
- "version": "0.0.1294",
4
+ "version": "0.0.1298",
5
5
  "description": "Bagel core sdk packages",
6
6
  "author": {
7
7
  "name": "Neveh Allon",
@@ -258,53 +258,35 @@ export function useEditor() {
258
258
  }
259
259
 
260
260
  let isUpdating = false
261
- let contentUpdateTimeout: number | null = null
262
- let selectionUpdateTimeout: number | null = null
263
- let updateCount = 0
264
261
 
265
262
  const events = {
266
263
  input: () => {
267
- updateCount++
268
264
  if (isUpdating) return
269
265
  isUpdating = true
270
266
 
271
- // Clear any pending content updates
272
- if (contentUpdateTimeout) {
273
- window.clearTimeout(contentUpdateTimeout)
267
+ // Immediately update content
268
+ const newContent = doc.body.innerHTML
269
+ if (newContent !== state.content) {
270
+ state.content = newContent
274
271
  }
275
272
 
276
- contentUpdateTimeout = window.setTimeout(() => {
277
- const newContent = doc.body.innerHTML
278
- if (newContent !== state.content) {
279
- state.content = newContent
280
- }
281
- isUpdating = false
282
- }, 100)
273
+ isUpdating = false
283
274
  },
284
275
  selectionchange: () => {
285
- updateCount++
286
- if (isUpdating) return
287
-
288
- if (selectionUpdateTimeout) {
289
- window.clearTimeout(selectionUpdateTimeout)
276
+ if (!isUpdating) {
277
+ updateState.selection()
290
278
  }
291
-
292
- selectionUpdateTimeout = window.setTimeout(() => {
293
- if (!isUpdating) {
294
- updateState.selection()
295
- }
296
- }, 150)
297
279
  },
298
280
  mouseup: () => {
299
- updateCount++
300
- if (isUpdating) return
301
- updateState.selection()
281
+ if (!isUpdating) {
282
+ updateState.selection()
283
+ }
302
284
  },
303
285
  keyup: (e: KeyboardEvent) => {
304
- updateCount++
305
- if (isUpdating) return
306
- if (['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight'].includes(e.key)) {
307
- updateState.selection()
286
+ if (!isUpdating) {
287
+ if (['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight'].includes(e.key)) {
288
+ updateState.selection()
289
+ }
308
290
  }
309
291
  }
310
292
  }
@@ -316,8 +298,6 @@ export function useEditor() {
316
298
 
317
299
  // Store cleanup function
318
300
  cleanupListeners = () => {
319
- if (contentUpdateTimeout) window.clearTimeout(contentUpdateTimeout)
320
- if (selectionUpdateTimeout) window.clearTimeout(selectionUpdateTimeout)
321
301
  Object.entries(events).forEach(([event, handler]) => {
322
302
  doc.removeEventListener(event, handler as EventListener)
323
303
  })
@@ -335,7 +315,10 @@ export function useEditor() {
335
315
  }
336
316
 
337
317
  state.doc = doc
338
- state.hasInit = true
318
+ state.hasInit = true as const
319
+
320
+ // Store state reference in document for table operations
321
+ (doc as any).editorState = state
339
322
 
340
323
  // Initial setup without triggering updates
341
324
  if (state.content) {
@@ -142,12 +142,6 @@ watch(() => editor.state.content, (newValue) => {
142
142
  }
143
143
  emit('update:modelValue', newValue)
144
144
  })
145
-
146
- watch(() => editor.state.isSplitView, (isEnabled) => {
147
- if (isEnabled) {
148
- editor.state.content = editor.state.doc?.body.innerHTML || ''
149
- }
150
- })
151
145
  </script>
152
146
 
153
147
  <template>
@@ -41,6 +41,7 @@ export function insertImage(modal: typeof Modal, state: EditorState) {
41
41
 
42
42
  range.collapse(false)
43
43
  range.insertNode(node)
44
+ state.content = doc.body.innerHTML
44
45
  }
45
46
  }
46
47
  })
@@ -62,6 +63,7 @@ export function insertLink(modal: typeof Modal, state: EditorState) {
62
63
  anchor.href = data.url
63
64
  if (data.openInNewTab) anchor.target = '_blank'
64
65
  range.surroundContents(anchor)
66
+ state.content = doc.body.innerHTML
65
67
  }
66
68
  }
67
69
  })
@@ -123,6 +125,7 @@ export function insertEmbed(modal: typeof Modal, state: EditorState) {
123
125
 
124
126
  range.deleteContents()
125
127
  range.insertNode(wrapper)
128
+ state.content = doc.body.innerHTML
126
129
  }
127
130
  })
128
131
  }
@@ -19,6 +19,7 @@ export function insertTable(rows: number, cols: number, state: EditorState) {
19
19
  } else {
20
20
  state.doc.body.appendChild(table)
21
21
  }
22
+ state.content = state.doc.body.innerHTML
22
23
  }
23
24
 
24
25
  export function mergeCells(range: Range, doc: Document) {
@@ -35,6 +36,12 @@ export function mergeCells(range: Range, doc: Document) {
35
36
  const actualCell = doc.getElementById(cell.id)
36
37
  actualCell?.remove()
37
38
  })
39
+
40
+ // Update state content
41
+ const state = (doc as any).editorState as EditorState
42
+ if (state) {
43
+ state.content = doc.body.innerHTML
44
+ }
38
45
  }
39
46
 
40
47
  export function splitCell(range: Range, doc: Document) {
@@ -54,6 +61,12 @@ export function splitCell(range: Range, doc: Document) {
54
61
  newCells.slice(1).forEach((newCell) => {
55
62
  newCells[0].insertAdjacentElement('afterend', newCell)
56
63
  })
64
+
65
+ // Update state content
66
+ const state = (doc as any).editorState as EditorState
67
+ if (state) {
68
+ state.content = doc.body.innerHTML
69
+ }
57
70
  }
58
71
 
59
72
  export function addRow(position: 'before' | 'after', range: Range, doc: Document) {
@@ -68,6 +81,12 @@ export function addRow(position: 'before' | 'after', range: Range, doc: Document
68
81
  Array.from(newRow.cells).forEach(cell => cell.innerHTML = '&nbsp;')
69
82
 
70
83
  row.insertAdjacentElement(position === 'before' ? 'beforebegin' : 'afterend', newRow)
84
+
85
+ // Update state content
86
+ const state = (doc as any).editorState as EditorState
87
+ if (state) {
88
+ state.content = doc.body.innerHTML
89
+ }
71
90
  }
72
91
 
73
92
  export function deleteRow(range: Range) {
@@ -77,7 +96,14 @@ export function deleteRow(range: Range) {
77
96
  const row = cell.parentElement
78
97
  if (!row) return
79
98
 
99
+ const doc = row.ownerDocument
80
100
  row.remove()
101
+
102
+ // Update state content
103
+ const state = (doc as any).editorState as EditorState
104
+ if (state) {
105
+ state.content = doc.body.innerHTML
106
+ }
81
107
  }
82
108
 
83
109
  export function deleteTable(range: Range) {
@@ -87,7 +113,14 @@ export function deleteTable(range: Range) {
87
113
  const table = cell.closest('table')
88
114
  if (!table) return
89
115
 
116
+ const doc = table.ownerDocument
90
117
  table.remove()
118
+
119
+ // Update state content
120
+ const state = (doc as any).editorState as EditorState
121
+ if (state) {
122
+ state.content = doc.body.innerHTML
123
+ }
91
124
  }
92
125
 
93
126
  export function insertColumn(position: 'before' | 'after', range: Range) {
@@ -106,6 +139,12 @@ export function insertColumn(position: 'before' | 'after', range: Range) {
106
139
  newCell.style.border = '1px solid var(--border-color)'
107
140
  newCell.style.padding = '8px'
108
141
  }
142
+
143
+ // Update state content
144
+ const state = (table.ownerDocument as any).editorState as EditorState
145
+ if (state) {
146
+ state.content = table.ownerDocument.body.innerHTML
147
+ }
109
148
  }
110
149
 
111
150
  export function deleteColumn(range: Range) {
@@ -117,6 +156,7 @@ export function deleteColumn(range: Range) {
117
156
 
118
157
  const columnIndex = cell.cellIndex
119
158
  const { rows } = table
159
+ const doc = table.ownerDocument
120
160
 
121
161
  for (let i = 0; i < rows.length; i++) {
122
162
  rows[i].deleteCell(columnIndex)
@@ -126,6 +166,12 @@ export function deleteColumn(range: Range) {
126
166
  if (rows[0].cells.length === 0) {
127
167
  table.remove()
128
168
  }
169
+
170
+ // Update state content
171
+ const state = (doc as any).editorState as EditorState
172
+ if (state) {
173
+ state.content = doc.body.innerHTML
174
+ }
129
175
  }
130
176
 
131
177
  export function alignColumn(range: Range, alignment: 'left' | 'center' | 'right' | 'justify') {
@@ -144,4 +190,10 @@ export function alignColumn(range: Range, alignment: 'left' | 'center' | 'right'
144
190
  cell.style.textAlign = alignment
145
191
  }
146
192
  }
193
+
194
+ // Update state content
195
+ const state = (table.ownerDocument as any).editorState as EditorState
196
+ if (state) {
197
+ state.content = table.ownerDocument.body.innerHTML
198
+ }
147
199
  }
@@ -1,7 +1,16 @@
1
- type AvailableTimeLanguages = 'en' | 'es' | 'fr' | 'he'
1
+ interface TimeUnit {
2
+ singular: string
3
+ plural: string
4
+ }
5
+
6
+ type TranslationValue = string | TimeUnit
7
+
2
8
  interface LanguageTranslations {
3
- [key: string]: string
9
+ [key: string]: TranslationValue
4
10
  }
11
+
12
+ type AvailableTimeLanguages = 'en' | 'es' | 'fr' | 'he'
13
+
5
14
  const translations: Record<AvailableTimeLanguages, LanguageTranslations> = {
6
15
  en: {
7
16
  year: 'year',
@@ -37,21 +46,22 @@ const translations: Record<AvailableTimeLanguages, LanguageTranslations> = {
37
46
  second: 'seconde',
38
47
  ago: 'il y a',
39
48
  in: 'dans',
40
- justNow: 'À linstant'
49
+ justNow: 'À l\'instant'
41
50
  },
42
51
  he: {
43
- year: 'שנה',
44
- month: 'חודש',
45
- week: 'שבוע',
46
- day: 'יום',
47
- hour: 'שעה',
48
- minute: 'דקה',
49
- second: 'שנייה',
52
+ year: { singular: 'שנה', plural: 'שנים' },
53
+ month: { singular: 'חודש', plural: 'חודשים' },
54
+ week: { singular: 'שבוע', plural: 'שבועות' },
55
+ day: { singular: 'יום', plural: 'ימים' },
56
+ hour: { singular: 'שעה', plural: 'שעות' },
57
+ minute: { singular: 'דקה', plural: 'דקות' },
58
+ second: { singular: 'שנייה', plural: 'שניות' },
50
59
  ago: 'לפני',
51
60
  in: 'בעוד',
52
61
  justNow: 'זה עתה'
53
62
  }
54
63
  }
64
+
55
65
  export function timeAgo(date: string | Date, lang: AvailableTimeLanguages = 'en') {
56
66
  if (!date) return ''
57
67
  if (typeof date === 'string') date = new Date(date)
@@ -76,7 +86,26 @@ export function timeAgo(date: string | Date, lang: AvailableTimeLanguages = 'en'
76
86
  const count = Math.floor(Math.abs(seconds) / interval.seconds)
77
87
  if (count >= 1) {
78
88
  const suffix = seconds < 0 ? ` ${selectedLang.ago}` : ''
79
- const prefix = ''
89
+ const prefix = seconds > 0 && selectedLang.in !== 'in' ? `${selectedLang.in} ` : ''
90
+
91
+ // Handle Hebrew plural forms
92
+ if (lang === 'he') {
93
+ const timeUnit = selectedLang[interval.label] as TimeUnit
94
+ const form = count === 1 ? timeUnit.singular : timeUnit.plural
95
+
96
+ // For Hebrew, we place the prefix/suffix before the number
97
+ const hebrewPrefix = seconds < 0 ? `${selectedLang.ago} ` : (seconds > 0 ? `${selectedLang.in} ` : '')
98
+
99
+ if (interval.label === 'day' && seconds > 0) {
100
+ const hours = Math.floor((Math.abs(seconds) % 86400) / 3600)
101
+ const hourUnit = selectedLang.hour as TimeUnit
102
+ const hourForm = hours === 1 ? hourUnit.singular : hourUnit.plural
103
+ return `${hebrewPrefix}${count} ${form}${hours > 0 ? ` ${hours} ${hourForm}` : ''}`
104
+ }
105
+ return `${hebrewPrefix}${count} ${form}`
106
+ }
107
+
108
+ // Handle other languages
80
109
  if (interval.label === 'day' && seconds > 0) {
81
110
  const hours = Math.floor((Math.abs(seconds) % 86400) / 3600)
82
111
  const hourLabel = hours > 1 ? `${selectedLang.hour}s` : selectedLang.hour
@@ -86,5 +115,5 @@ export function timeAgo(date: string | Date, lang: AvailableTimeLanguages = 'en'
86
115
  }
87
116
  }
88
117
 
89
- return selectedLang.justNow
118
+ return selectedLang.justNow as string
90
119
  }