ep_data_tables 0.0.4 → 0.0.6

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.4",
3
+ "version": "0.0.6",
4
4
  "description": "BETA - etherpad tables plugin, compatible with other character/line based styling and other features",
5
5
  "author": {
6
6
  "name": "DCastelone",
@@ -17,6 +17,7 @@ const ATTR_TABLE_JSON = 'tbljson';
17
17
  const ATTR_CELL = 'td';
18
18
  const ATTR_CLASS_PREFIX = 'tbljson-'; // For finding the class in DOM
19
19
  const log = (...m) => console.debug('[ep_data_tables:client_hooks]', ...m);
20
+ log('version 0.0.6');
20
21
  const DELIMITER = '\u241F'; // Internal column delimiter (␟)
21
22
  // Use the same rare character inside the hidden span so acePostWriteDomLineHTML can
22
23
  // still find delimiters when it splits node.innerHTML.
@@ -965,11 +966,33 @@ exports.acePostWriteDomLineHTML = function (hook_name, args, cb) {
965
966
  // NEW: Remove all hidden-delimiter <span> wrappers **before** we split so
966
967
  // the embedded delimiter character they carry doesn't inflate or shrink
967
968
  // the segment count.
968
- const spanDelimRegex = new RegExp('<span class="ep-data_tables-delim"[^>]*>' + DELIMITER + '<\\/span>', 'ig');
969
+ const spanDelimRegex = new RegExp('<span class="ep-data_tables-delim"[^>]*>' + DELIMITER + '</span>', 'ig');
970
+ // Safari-specific normalization: it may serialize the delimiter as entities and inject Apple spans
971
+ const delimiterEntityHexRE = /&#x241f;/ig; // hex entity for U+241F
972
+ const delimiterEntityDecRE = /&#9247;/g; // decimal entity for U+241F
973
+ const appleConvertedSpaceRE = /<span class="Apple-converted-space">[\s\u00A0]*<\/span>/ig;
974
+ const zeroWidthCharsRE = /[\u200B\u200C\u200D\uFEFF]/g;
975
+
976
+ const hexMatches = ((delimitedTextFromLine || '').match(delimiterEntityHexRE) || []).length;
977
+ const decMatches = ((delimitedTextFromLine || '').match(delimiterEntityDecRE) || []).length;
978
+ const appleSpaceMatches = ((delimitedTextFromLine || '').match(appleConvertedSpaceRE) || []).length;
979
+
969
980
  const sanitizedHTMLForSplit = (delimitedTextFromLine || '')
970
981
  .replace(spanDelimRegex, '')
971
982
  // strip caret anchors from raw line html before split
972
- .replace(/<span class="ep-data_tables-caret-anchor"[^>]*><\/span>/ig, '');
983
+ .replace(/<span class="ep-data_tables-caret-anchor"[^>]*><\/span>/ig, '')
984
+ // Safari may serialize the delimiter as HTML entities – convert back to raw char
985
+ .replace(delimiterEntityHexRE, DELIMITER)
986
+ .replace(delimiterEntityDecRE, DELIMITER)
987
+ // Safari sometimes injects Apple-converted-space wrappers; collapse to a normal space
988
+ .replace(appleConvertedSpaceRE, ' ')
989
+ // Guard against invisible characters that can disturb splitting
990
+ .replace(zeroWidthCharsRE, '');
991
+
992
+ if ((hexMatches + decMatches + appleSpaceMatches) > 0) {
993
+ console.warn(`[ep_data_tables] ${funcName} NodeID#${nodeId}: Normalized Safari entities/spans before splitting: hex=${hexMatches}, dec=${decMatches}, appleSpaces=${appleSpaceMatches}`);
994
+ }
995
+
973
996
  const htmlSegments = sanitizedHTMLForSplit.split(DELIMITER);
974
997
 
975
998
  // log(`${logPrefix} NodeID#${nodeId}: *** SEGMENT ANALYSIS ***`);