ep_data_tables 0.0.95 → 0.0.96

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ep_data_tables",
3
- "version": "0.0.95",
3
+ "version": "0.0.96",
4
4
  "description": "BETA - etherpad tables plugin, compatible with other character/line based styling and other features",
5
5
  "author": {
6
6
  "name": "DCastelone",
@@ -611,7 +611,7 @@ function buildTableFromDelimitedHTML(metadata, innerHTMLSegments) {
611
611
  if (!metadata || typeof metadata.tblId === 'undefined' || typeof metadata.row === 'undefined') {
612
612
  console.error(`[ep_data_tables] ${funcName}: Invalid or missing metadata. Aborting.`);
613
613
  // log(`${funcName}: END - Error`);
614
- return '<table class="dataTable dataTable-error"><tbody><tr><td>Error: Missing table metadata</td></tr></tbody></table>';
614
+ return '<table class="dataTable dataTable-error" writingsuggestions="false" autocorrect="off" autocapitalize="off" spellcheck="false"><tbody><tr><td>Error: Missing table metadata</td></tr></tbody></table>';
615
615
  }
616
616
 
617
617
  const numCols = innerHTMLSegments.length;
@@ -691,7 +691,7 @@ function buildTableFromDelimitedHTML(metadata, innerHTMLSegments) {
691
691
  const resizeHandle = !isLastColumn ?
692
692
  `<div class="ep-data_tables-resize-handle" data-column="${index}" style="position: absolute; top: 0; right: -2px; width: 4px; height: 100%; cursor: col-resize; background: transparent; z-index: 10;"></div>` : '';
693
693
 
694
- const tdContent = `<td style="${cellStyle}" data-column="${index}" draggable="false">${modifiedSegment}${resizeHandle}</td>`;
694
+ const tdContent = `<td style="${cellStyle}" data-column="${index}" draggable="false" autocorrect="off" autocapitalize="off" spellcheck="false">${modifiedSegment}${resizeHandle}</td>`;
695
695
  return tdContent;
696
696
  }).join('');
697
697
  // log(`${funcName}: Joined all cellsHtml:`, cellsHtml);
@@ -699,7 +699,7 @@ function buildTableFromDelimitedHTML(metadata, innerHTMLSegments) {
699
699
  const firstRowClass = metadata.row === 0 ? ' dataTable-first-row' : '';
700
700
  // log(`${funcName}: First row class applied: '${firstRowClass}'`);
701
701
 
702
- const tableHtml = `<table class="dataTable${firstRowClass}" writingsuggestions="false" data-tblId="${metadata.tblId}" data-row="${metadata.row}" style="width:100%; border-collapse: collapse; table-layout: fixed;" draggable="false"><tbody><tr>${cellsHtml}</tr></tbody></table>`;
702
+ const tableHtml = `<table class="dataTable${firstRowClass}" writingsuggestions="false" autocorrect="off" autocapitalize="off" spellcheck="false" data-tblId="${metadata.tblId}" data-row="${metadata.row}" style="width:100%; border-collapse: collapse; table-layout: fixed;" draggable="false"><tbody><tr>${cellsHtml}</tr></tbody></table>`;
703
703
  // log(`${funcName}: Generated final table HTML:`, tableHtml);
704
704
  // log(`${funcName}: END - Success`);
705
705
  return tableHtml;
@@ -1704,33 +1704,53 @@ exports.aceInitialized = (h, ctx) => {
1704
1704
  ed.ep_data_tables_editor = editor;
1705
1705
  // log(`${logPrefix}: Stored editor reference as ed.ep_data_tables_editor.`);
1706
1706
 
1707
- let $inner;
1708
- try {
1709
- // log(`${callWithAceLogPrefix} Attempting to find inner iframe body for listener attachment.`);
1707
+ // Retry logic for iframe access to handle timing/race conditions
1708
+ const tryGetIframeBody = (attempt = 0) => {
1709
+ if (attempt > 0) {
1710
+ console.log(`${callWithAceLogPrefix} Retry attempt ${attempt}/5 to access iframe body`);
1711
+ }
1712
+
1710
1713
  const $iframeOuter = $('iframe[name="ace_outer"]');
1711
1714
  if ($iframeOuter.length === 0) {
1712
- console.error(`${callWithAceLogPrefix} ERROR: Could not find outer iframe (ace_outer).`);
1713
- // log(`${callWithAceLogPrefix} Failed to find ace_outer.`);
1715
+ if (attempt < 5) {
1716
+ setTimeout(() => tryGetIframeBody(attempt + 1), 100);
1717
+ return;
1718
+ }
1719
+ console.error(`${callWithAceLogPrefix} ERROR: Could not find outer iframe (ace_outer) after ${attempt} attempts.`);
1714
1720
  return;
1715
1721
  }
1716
- // log(`${callWithAceLogPrefix} Found ace_outer:`, $iframeOuter);
1717
1722
 
1718
1723
  const $iframeInner = $iframeOuter.contents().find('iframe[name="ace_inner"]');
1719
1724
  if ($iframeInner.length === 0) {
1720
- console.error(`${callWithAceLogPrefix} ERROR: Could not find inner iframe (ace_inner).`);
1721
- // log(`${callWithAceLogPrefix} Failed to find ace_inner within ace_outer.`);
1725
+ if (attempt < 5) {
1726
+ setTimeout(() => tryGetIframeBody(attempt + 1), 100);
1727
+ return;
1728
+ }
1729
+ console.error(`${callWithAceLogPrefix} ERROR: Could not find inner iframe (ace_inner) after ${attempt} attempts.`);
1722
1730
  return;
1723
1731
  }
1724
- // log(`${callWithAceLogPrefix} Found ace_inner:`, $iframeInner);
1725
1732
 
1726
1733
  const innerDocBody = $iframeInner.contents().find('body');
1727
1734
  if (innerDocBody.length === 0) {
1728
- console.error(`${callWithAceLogPrefix} ERROR: Could not find body element in inner iframe.`);
1729
- // log(`${callWithAceLogPrefix} Failed to find body in ace_inner.`);
1735
+ if (attempt < 5) {
1736
+ setTimeout(() => tryGetIframeBody(attempt + 1), 100);
1737
+ return;
1738
+ }
1739
+ console.error(`${callWithAceLogPrefix} ERROR: Could not find body element in inner iframe after ${attempt} attempts.`);
1730
1740
  return;
1731
1741
  }
1732
- $inner = $(innerDocBody[0]);
1733
- // log(`${callWithAceLogPrefix} Successfully found inner iframe body:`, $inner);
1742
+
1743
+ const $inner = $(innerDocBody[0]);
1744
+ if (attempt > 0) {
1745
+ console.log(`${callWithAceLogPrefix} Successfully found iframe body on attempt ${attempt + 1}`);
1746
+ }
1747
+
1748
+ // SUCCESS - Now attach all listeners and set attributes
1749
+ attachListeners($inner, $iframeOuter, $iframeInner, innerDocBody);
1750
+ };
1751
+
1752
+ const attachListeners = ($inner, $iframeOuter, $iframeInner, innerDocBody) => {
1753
+ try {
1734
1754
 
1735
1755
  const mobileSuggestionBlocker = (evt) => {
1736
1756
  const t = evt && evt.inputType || '';
@@ -1911,37 +1931,38 @@ exports.aceInitialized = (h, ctx) => {
1911
1931
  };
1912
1932
 
1913
1933
  // IME/autocorrect diagnostics: capture-phase logging and newline soft-normalization for table lines
1914
- const logIMEEvent = (rawEvt, tag) => {
1915
- try {
1916
- const e = rawEvt && (rawEvt.originalEvent || rawEvt);
1917
- const rep = ed.ace_getRep && ed.ace_getRep();
1918
- const selStart = rep && rep.selStart;
1919
- const lineNum = selStart ? selStart[0] : -1;
1920
- let isTableLine = false;
1921
- if (lineNum >= 0) {
1922
- let s = docManager && docManager.getAttributeOnLine ? docManager.getAttributeOnLine(lineNum, ATTR_TABLE_JSON) : null;
1923
- if (!s) {
1924
- const meta = getTableLineMetadata(lineNum, ed, docManager);
1925
- isTableLine = !!meta && typeof meta.cols === 'number';
1926
- } else {
1927
- isTableLine = true;
1928
- }
1929
- }
1930
- if (!isTableLine) return;
1931
- const payload = {
1932
- tag,
1933
- type: e && e.type,
1934
- inputType: e && e.inputType,
1935
- data: typeof (e && e.data) === 'string' ? e.data : null,
1936
- isComposing: !!(e && e.isComposing),
1937
- key: e && e.key,
1938
- code: e && e.code,
1939
- which: e && e.which,
1940
- keyCode: e && e.keyCode,
1941
- };
1942
- console.debug('[ep_data_tables:ime-diag]', payload);
1943
- } catch (_) {}
1944
- };
1934
+ // COMMENTED OUT FOR PRODUCTION - Uncomment for debugging IME/composition issues
1935
+ // const logIMEEvent = (rawEvt, tag) => {
1936
+ // try {
1937
+ // const e = rawEvt && (rawEvt.originalEvent || rawEvt);
1938
+ // const rep = ed.ace_getRep && ed.ace_getRep();
1939
+ // const selStart = rep && rep.selStart;
1940
+ // const lineNum = selStart ? selStart[0] : -1;
1941
+ // let isTableLine = false;
1942
+ // if (lineNum >= 0) {
1943
+ // let s = docManager && docManager.getAttributeOnLine ? docManager.getAttributeOnLine(lineNum, ATTR_TABLE_JSON) : null;
1944
+ // if (!s) {
1945
+ // const meta = getTableLineMetadata(lineNum, ed, docManager);
1946
+ // isTableLine = !!meta && typeof meta.cols === 'number';
1947
+ // } else {
1948
+ // isTableLine = true;
1949
+ // }
1950
+ // }
1951
+ // if (!isTableLine) return;
1952
+ // const payload = {
1953
+ // tag,
1954
+ // type: e && e.type,
1955
+ // inputType: e && e.inputType,
1956
+ // data: typeof (e && e.data) === 'string' ? e.data : null,
1957
+ // isComposing: !!(e && e.isComposing),
1958
+ // key: e && e.key,
1959
+ // code: e && e.code,
1960
+ // which: e && e.which,
1961
+ // keyCode: e && e.keyCode,
1962
+ // };
1963
+ // console.debug('[ep_data_tables:ime-diag]', payload);
1964
+ // } catch (_) {}
1965
+ // };
1945
1966
 
1946
1967
  const softBreakNormalizer = (rawEvt) => {
1947
1968
  try {
@@ -1991,9 +2012,10 @@ exports.aceInitialized = (h, ctx) => {
1991
2012
 
1992
2013
  if ($inner && $inner.length > 0 && $inner[0].addEventListener) {
1993
2014
  const el = $inner[0];
1994
- ['beforeinput','input','textInput','compositionstart','compositionupdate','compositionend','keydown','keyup'].forEach((t) => {
1995
- el.addEventListener(t, (ev) => logIMEEvent(ev, 'capture'), true);
1996
- });
2015
+ // COMMENTED OUT FOR PRODUCTION - Uncomment for debugging IME/composition issues
2016
+ // ['beforeinput','input','textInput','compositionstart','compositionupdate','compositionend','keydown','keyup'].forEach((t) => {
2017
+ // el.addEventListener(t, (ev) => logIMEEvent(ev, 'capture'), true);
2018
+ // });
1997
2019
  el.addEventListener('beforeinput', softBreakNormalizer, true);
1998
2020
  }
1999
2021
 
@@ -2023,20 +2045,16 @@ exports.aceInitialized = (h, ctx) => {
2023
2045
  el.setAttribute('autocomplete', 'off');
2024
2046
  el.setAttribute('autocapitalize', 'off');
2025
2047
  el.setAttribute('spellcheck', 'false');
2048
+ el.setAttribute('data-gramm', 'false');
2049
+ el.setAttribute('data-enable-grammarly', 'false');
2026
2050
  };
2027
2051
  disableAuto(innerDocBody[0] || innerDocBody);
2028
2052
  } catch (_) {}
2029
- } catch (e) {
2030
- console.error(`${callWithAceLogPrefix} ERROR: Exception while trying to find inner iframe body:`, e);
2031
- // log(`${callWithAceLogPrefix} Exception details:`, { message: e.message, stack: e.stack });
2032
- return;
2033
- }
2034
-
2035
- if (!$inner || $inner.length === 0) {
2036
- console.error(`${callWithAceLogPrefix} ERROR: $inner is not valid after attempting to find iframe body. Cannot attach listeners.`);
2037
- // log(`${callWithAceLogPrefix} $inner is invalid. Aborting.`);
2038
- return;
2039
- }
2053
+
2054
+ if (!$inner || $inner.length === 0) {
2055
+ console.error(`${callWithAceLogPrefix} ERROR: $inner is not valid. Cannot attach listeners.`);
2056
+ return;
2057
+ }
2040
2058
 
2041
2059
  // log(`${callWithAceLogPrefix} Attaching cut event listener to $inner (inner iframe body).`);
2042
2060
  $inner.on('cut', (evt) => {
@@ -3639,6 +3657,13 @@ exports.aceInitialized = (h, ctx) => {
3639
3657
  setupGlobalHandlers();
3640
3658
 
3641
3659
  // log(`${callWithAceLogPrefix} Column resize listeners attached successfully.`);
3660
+ } catch (e) {
3661
+ console.error(`${callWithAceLogPrefix} ERROR: Exception while attaching listeners:`, e);
3662
+ }
3663
+ }; // End of attachListeners function
3664
+
3665
+ // Start the retry process to access iframes and attach all listeners
3666
+ tryGetIframeBody(0);
3642
3667
 
3643
3668
  }, 'tablePasteAndResizeListeners', true);
3644
3669
  // log(`${logPrefix} ace_callWithAce for listeners setup completed.`);