lexxy 1.0.0 → 1.0.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '0803aecbfd440c3370e6e56e31d83feb61c5fe7f67b6ed680454a69d72287ef8'
4
- data.tar.gz: 29a9e95d82c1cbe491befe7326dc26af484a86a93b8f92426d9a26686d5659aa
3
+ metadata.gz: 2e36cf0fe5dbfc145f5f63cb4a247a79e95875a95907b8fba0c407b1ee506d9d
4
+ data.tar.gz: cd060894313224a0ef74a0ea4789230d691b4702f21a49a74bf4903d831c137e
5
5
  SHA512:
6
- metadata.gz: 8c1dfe3472300ad2486becf99e635797c9ca1908d51ea6357ca2257abff223c1525cbab325c089a48e673055d8ba6d069e844a84abb7ca6d191f57bca81174a9
7
- data.tar.gz: 482aea181eb387c79c29052b606dd6c05f42b4140197ce7d0159e7f8974c500c31a423f7c1d7b142abd823c18b40e9ce3af8df1f502ae37ad14404c443bd4e60
6
+ metadata.gz: 7c19cd19e51116f1a3f8fa648f6eb1aa8a11c0ca5fa286959138509d84ad1bc99cdfee587da48cc00eb290c52765e6672dddf46e16c4489b5c7e2e3cb6c1c488
7
+ data.tar.gz: e039e4e728b66a0698207463c44e7a21bcf13bdfd45f8aef9621726e5d6d1d8534a81604b342b51ec39361f0e4e3577e2f4500ac0d6d4443d1440a4dbd72ea31
@@ -10103,14 +10103,14 @@ function extendTextNodeConversion(conversionName, ...callbacks) {
10103
10103
  ...conversionOutput,
10104
10104
  forChild: (lexicalNode, parentNode) => {
10105
10105
  const originalForChild = conversionOutput?.forChild ?? (x => x);
10106
- let childNode = originalForChild(lexicalNode, parentNode);
10107
-
10106
+ const childNode = originalForChild(lexicalNode, parentNode);
10108
10107
 
10109
10108
  if (Tr(childNode)) {
10110
- childNode = callbacks.reduce(
10109
+ return callbacks.reduce(
10111
10110
  (childNode, callback) => callback(childNode, element) ?? childNode,
10112
10111
  childNode
10113
- );
10112
+ )
10113
+ } else {
10114
10114
  return childNode
10115
10115
  }
10116
10116
  }
@@ -14523,6 +14523,7 @@ class PastedContentFormatter {
14523
14523
  format() {
14524
14524
  this.#inlinePreservableStyles();
14525
14525
  this.#stripStyleElements();
14526
+ this.#stripInterchangeNewlines();
14526
14527
  this.#unwrapPlaceholderAnchors();
14527
14528
  this.#stripTableCellColorStyles();
14528
14529
  new OfficeFormatter(this.doc).format();
@@ -14558,6 +14559,35 @@ class PastedContentFormatter {
14558
14559
  }
14559
14560
  }
14560
14561
 
14562
+ // Chrome and Safari append <br class="Apple-interchange-newline"> when the
14563
+ // copied selection ends at a line end (Google Docs does this on every copy).
14564
+ // It marks the end of the selection, not a line the author wrote, so left in
14565
+ // place it pastes as an extra empty paragraph. Only the trailing marker goes:
14566
+ // one at the start of the fragment is a real line boundary.
14567
+ #stripInterchangeNewlines() {
14568
+ for (const br of this.doc.querySelectorAll("br.Apple-interchange-newline")) {
14569
+ if (this.#isAtEndOfBody(br)) {
14570
+ br.remove();
14571
+ }
14572
+ }
14573
+ }
14574
+
14575
+ #isAtEndOfBody(node) {
14576
+ for (let current = node; current && current !== this.doc.body; current = current.parentNode) {
14577
+ for (let sibling = current.nextSibling; sibling; sibling = sibling.nextSibling) {
14578
+ if (!this.#isIgnorableTrailingNode(sibling)) return false
14579
+ }
14580
+ }
14581
+ return true
14582
+ }
14583
+
14584
+ #isIgnorableTrailingNode(node) {
14585
+ if (node.nodeType === Node.COMMENT_NODE) {
14586
+ return true
14587
+ }
14588
+ return node.nodeType === Node.TEXT_NODE && node.textContent.trim() === ""
14589
+ }
14590
+
14561
14591
  // Anchors with non-meaningful hrefs (e.g. "#", "") appear in content copied
14562
14592
  // from rendered views where mentions and interactive elements are wrapped in
14563
14593
  // <a href="#"> tags. Unwrap them so their text content pastes as plain text
@@ -16405,7 +16435,7 @@ class TrixContentExtension extends LexxyExtension {
16405
16435
  priority: 1
16406
16436
  }),
16407
16437
  span: (element) => onlyStyledElements(element, {
16408
- conversion: extendTextNodeConversion("mark", $applyHighlightStyle),
16438
+ conversion: extendTextNodeConversion("span", $applyHighlightStyle),
16409
16439
  priority: 1
16410
16440
  }),
16411
16441
  strong: (element) => onlyStyledElements(element, {
Binary file
Binary file