@knime/kds-rich-text-editor 2.7.0 → 2.8.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @knime/kds-rich-text-editor
2
2
 
3
+ ## 2.8.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [33e87f5]
8
+ - @knime/kds-components@2.8.1
9
+ - @knime/kds-styles@2.8.1
10
+
11
+ ## 2.8.0
12
+
13
+ ### Patch Changes
14
+
15
+ - 3e99bd2: Declare `sideEffects` in `package.json` (all files pure except `dist/*.css`) so consuming bundlers can tree-shake unused modules while keeping the injected CSS imports.
16
+ - Updated dependencies [2920e61]
17
+ - Updated dependencies [3e99bd2]
18
+ - @knime/kds-components@2.8.0
19
+ - @knime/kds-styles@2.8.0
20
+
3
21
  ## 2.7.0
4
22
 
5
23
  ### Patch Changes
package/dist/index.js CHANGED
@@ -9,8 +9,8 @@ import Link from "@tiptap/extension-link";
9
9
  import { Plugin, PluginKey } from "@tiptap/pm/state";
10
10
  import TextAlign from "@tiptap/extension-text-align";
11
11
  import Paragraph from "@tiptap/extension-paragraph";
12
- import './index.css';//#region ../../node_modules/.pnpm/dompurify@3.4.11/node_modules/dompurify/dist/purify.es.mjs
13
- /*! @license DOMPurify 3.4.11 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.11/LICENSE */
12
+ import './index.css';//#region ../../node_modules/.pnpm/dompurify@3.4.12/node_modules/dompurify/dist/purify.es.mjs
13
+ /*! @license DOMPurify 3.4.12 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.12/LICENSE */
14
14
  function _arrayLikeToArray(r, a) {
15
15
  (null == a || a > r.length) && (a = r.length);
16
16
  for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
@@ -649,6 +649,7 @@ var svg = freeze([
649
649
  "direction",
650
650
  "display",
651
651
  "divisor",
652
+ "dominant-baseline",
652
653
  "dur",
653
654
  "edgemode",
654
655
  "elevation",
@@ -776,6 +777,7 @@ var svg = freeze([
776
777
  "transform-origin",
777
778
  "text-anchor",
778
779
  "text-decoration",
780
+ "text-orientation",
779
781
  "text-rendering",
780
782
  "textlength",
781
783
  "type",
@@ -958,7 +960,7 @@ var _resolveSetOption = function _resolveSetOption(cfg, key, fallback, options)
958
960
  function createDOMPurify() {
959
961
  let window = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : getGlobal();
960
962
  const DOMPurify = (root) => createDOMPurify(root);
961
- DOMPurify.version = "3.4.11";
963
+ DOMPurify.version = "3.4.12";
962
964
  DOMPurify.removed = [];
963
965
  if (!window || !window.document || window.document.nodeType !== NODE_TYPE.document || !window.Element) {
964
966
  DOMPurify.isSupported = false;
@@ -1425,6 +1427,7 @@ function createDOMPurify() {
1425
1427
  * @param root the in-place root to empty
1426
1428
  */
1427
1429
  const _neutralizeRoot = function _neutralizeRoot(root) {
1430
+ _neutralizeSubtree(root);
1428
1431
  const childNodes = getChildNodes(root);
1429
1432
  if (childNodes) {
1430
1433
  const snapshot = [];
@@ -1526,6 +1529,65 @@ function createDOMPurify() {
1526
1529
  }
1527
1530
  };
1528
1531
  /**
1532
+ * _neutralizePatchLinkage
1533
+ *
1534
+ * IN_PLACE entry pre-pass (declarative-partial-updates / streaming
1535
+ * hardening, https://github.com/WICG/declarative-partial-updates).
1536
+ *
1537
+ * The main walk strips patch linkage (`for`/`patchsrc`) and removes range
1538
+ * markers (PIs / markup comments) node-by-node, in document order, AS it
1539
+ * reaches each node. On a live in-place root that leaves a window: from the
1540
+ * moment the root is connected until the walk arrives at a given node, that
1541
+ * node's linkage is live. A patch applied on connection/stream can fire as
1542
+ * a microtask during the walk and inject or teleport an unsanitized DOM
1543
+ * range into a region the iterator has already passed and will not revisit,
1544
+ * so the post-return "tree is sanitized" contract is violated. Sweep the
1545
+ * whole tree once up front and sever every linkage before the walk begins,
1546
+ * closing that window.
1547
+ *
1548
+ * This CANNOT undo a patch that already fired before sanitize ran — that is
1549
+ * the irreducible "do not IN_PLACE a live-connected attacker tree" caveat —
1550
+ * but it closes everything from sanitize-start onward. Gated on SAFE_FOR_XML
1551
+ * to group with the rest of the declarative-partial-updates handling and
1552
+ * stay overridable, consistent with the codebase.
1553
+ *
1554
+ * Clobber-safe traversal (cached childNodes getter); per-node try/catch so a
1555
+ * clobbered root cannot defeat the sweep of its non-clobbered descendants.
1556
+ *
1557
+ * NOTE (pending real-Chrome confirmation, see test/declarative-patch-probe
1558
+ * .html Q1): this mirrors the existing policy of keeping `for` on
1559
+ * <label>/<output>. If the shipping feature can drive a patch through a
1560
+ * surviving `for`-on-label/output + `id` pair, this pre-pass and the
1561
+ * attribute check at _isBasicCustomElement's caller must additionally drop
1562
+ * that pair on the IN_PLACE path. Left as-is until the taxonomy is verified.
1563
+ *
1564
+ * @param root the in-place root to sweep
1565
+ */
1566
+ const _neutralizePatchLinkage = function _neutralizePatchLinkage(root) {
1567
+ if (!SAFE_FOR_XML) return;
1568
+ const stack = [root];
1569
+ while (stack.length > 0) {
1570
+ const node = stack.pop();
1571
+ const nodeType = getNodeType ? getNodeType(node) : node.nodeType;
1572
+ if (nodeType === NODE_TYPE.processingInstruction || nodeType === NODE_TYPE.comment && regExpTest(COMMENT_MARKUP_PROBE, node.data)) {
1573
+ try {
1574
+ remove(node);
1575
+ } catch (_) {}
1576
+ continue;
1577
+ }
1578
+ if (nodeType === NODE_TYPE.element) {
1579
+ const element = node;
1580
+ const lcTag = transformCaseFunc(getNodeName ? getNodeName(node) : node.nodeName);
1581
+ try {
1582
+ if (element.hasAttribute && element.hasAttribute("patchsrc")) element.removeAttribute("patchsrc");
1583
+ if (element.hasAttribute && element.hasAttribute("for") && lcTag !== "label" && lcTag !== "output") element.removeAttribute("for");
1584
+ } catch (_) {}
1585
+ }
1586
+ const childNodes = getChildNodes(node);
1587
+ if (childNodes) for (let i = childNodes.length - 1; i >= 0; --i) stack.push(childNodes[i]);
1588
+ }
1589
+ };
1590
+ /**
1529
1591
  * _initDocument
1530
1592
  *
1531
1593
  * @param dirty - a string of dirty markup
@@ -1693,9 +1755,15 @@ function createDOMPurify() {
1693
1755
  /**
1694
1756
  * Handle a node whose tag is forbidden or not allowlisted: keep
1695
1757
  * allowed custom elements (false return exits _sanitizeElements
1696
- * early - namespace/fallback checks and the afterSanitizeElements
1697
- * hook are intentionally skipped for kept custom elements), else
1698
- * hoist content per KEEP_CONTENT and remove.
1758
+ * early - the namespace and fallback-tag removal checks are
1759
+ * intentionally skipped for kept custom elements), else hoist
1760
+ * content per KEEP_CONTENT and remove.
1761
+ *
1762
+ * A kept custom element is the ONLY case in which this function
1763
+ * returns false, so the caller uses that return value to run the
1764
+ * afterSanitizeElements hook on the kept element and keep the
1765
+ * element-hook lifecycle consistent with normal allowlisted
1766
+ * elements (GHSA-c2j3-45gr-mqc4).
1699
1767
  *
1700
1768
  * @param currentNode the disallowed node
1701
1769
  * @param tagName the node's transformCaseFunc'd tag name
@@ -1729,8 +1797,9 @@ function createDOMPurify() {
1729
1797
  * @param currentNode to check for permission to exist
1730
1798
  * @return true if node was killed, false if left alive
1731
1799
  */
1732
- const _sanitizeElements = function _sanitizeElements(currentNode) {
1800
+ const _sanitizeElements = function _sanitizeElements(currentNode, root) {
1733
1801
  _executeHooks(hooks.beforeSanitizeElements, currentNode, null);
1802
+ if (currentNode !== root && getParentNode(currentNode) === null) return true;
1734
1803
  if (_isClobbered(currentNode)) {
1735
1804
  _forceRemove(currentNode);
1736
1805
  return true;
@@ -1740,11 +1809,16 @@ function createDOMPurify() {
1740
1809
  tagName,
1741
1810
  allowedTags: ALLOWED_TAGS
1742
1811
  });
1812
+ if (currentNode !== root && getParentNode(currentNode) === null) return true;
1743
1813
  if (_isUnsafeNode(currentNode, tagName)) {
1744
1814
  _forceRemove(currentNode);
1745
1815
  return true;
1746
1816
  }
1747
- if (FORBID_TAGS[tagName] || !(EXTRA_ELEMENT_HANDLING.tagCheck instanceof Function && EXTRA_ELEMENT_HANDLING.tagCheck(tagName)) && !ALLOWED_TAGS[tagName]) return _sanitizeDisallowedNode(currentNode, tagName);
1817
+ if (FORBID_TAGS[tagName] || !(EXTRA_ELEMENT_HANDLING.tagCheck instanceof Function && EXTRA_ELEMENT_HANDLING.tagCheck(tagName)) && !ALLOWED_TAGS[tagName]) {
1818
+ const removed = _sanitizeDisallowedNode(currentNode, tagName);
1819
+ if (removed === false) _executeHooks(hooks.afterSanitizeElements, currentNode, null);
1820
+ return removed;
1821
+ }
1748
1822
  if ((getNodeType ? getNodeType(currentNode) : currentNode.nodeType) === NODE_TYPE.element && !_checkValidNamespace(currentNode)) {
1749
1823
  _forceRemove(currentNode);
1750
1824
  return true;
@@ -1773,6 +1847,8 @@ function createDOMPurify() {
1773
1847
  */
1774
1848
  const _isValidAttribute = function _isValidAttribute(lcTag, lcName, value) {
1775
1849
  if (FORBID_ATTR[lcName]) return false;
1850
+ if (SAFE_FOR_XML && lcName === "patchsrc") return false;
1851
+ if (SAFE_FOR_XML && lcName === "for" && lcTag !== "label" && lcTag !== "output") return false;
1776
1852
  if (SANITIZE_DOM && (lcName === "id" || lcName === "name") && (value in document || value in formElement)) return false;
1777
1853
  const nameIsPermitted = ALLOWED_ATTR[lcName] || EXTRA_ELEMENT_HANDLING.attributeCheck instanceof Function && EXTRA_ELEMENT_HANDLING.attributeCheck(lcName, lcTag);
1778
1854
  if (ALLOW_DATA_ATTR && regExpTest(DATA_ATTR$1, lcName));
@@ -1926,7 +2002,7 @@ function createDOMPurify() {
1926
2002
  _executeHooks(hooks.beforeSanitizeShadowDOM, fragment, null);
1927
2003
  while (shadowNode = shadowIterator.nextNode()) {
1928
2004
  _executeHooks(hooks.uponSanitizeShadowNode, shadowNode, null);
1929
- _sanitizeElements(shadowNode);
2005
+ _sanitizeElements(shadowNode, fragment);
1930
2006
  _sanitizeAttributes(shadowNode);
1931
2007
  if (_isDocumentFragment(shadowNode.content)) _sanitizeShadowDOM2(shadowNode.content);
1932
2008
  if ((getNodeType ? getNodeType(shadowNode) : shadowNode.nodeType) === NODE_TYPE.element) {
@@ -2020,12 +2096,19 @@ function createDOMPurify() {
2020
2096
  DOMPurify.removed = [];
2021
2097
  const inPlace = IN_PLACE && typeof dirty !== "string" && _isNode(dirty);
2022
2098
  if (inPlace) {
2099
+ _neutralizePatchLinkage(dirty);
2023
2100
  const nn = getNodeName ? getNodeName(dirty) : dirty.nodeName;
2024
2101
  if (typeof nn === "string") {
2025
2102
  const tagName = transformCaseFunc(nn);
2026
- if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) throw typeErrorCreate("root node is forbidden and cannot be sanitized in-place");
2103
+ if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
2104
+ _neutralizeRoot(dirty);
2105
+ throw typeErrorCreate("root node is forbidden and cannot be sanitized in-place");
2106
+ }
2107
+ }
2108
+ if (_isClobbered(dirty)) {
2109
+ _neutralizeRoot(dirty);
2110
+ throw typeErrorCreate("root node is clobbered and cannot be sanitized in-place");
2027
2111
  }
2028
- if (_isClobbered(dirty)) throw typeErrorCreate("root node is clobbered and cannot be sanitized in-place");
2029
2112
  try {
2030
2113
  _sanitizeAttachedShadowRoots(dirty);
2031
2114
  } catch (error) {
@@ -2045,15 +2128,21 @@ function createDOMPurify() {
2045
2128
  if (!body) return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : "";
2046
2129
  }
2047
2130
  if (body && FORCE_BODY) _forceRemove(body.firstChild);
2048
- const nodeIterator = _createNodeIterator(inPlace ? dirty : body);
2131
+ const walkRoot = inPlace ? dirty : body;
2132
+ const nodeIterator = _createNodeIterator(walkRoot);
2049
2133
  try {
2050
2134
  while (currentNode = nodeIterator.nextNode()) {
2051
- _sanitizeElements(currentNode);
2135
+ _sanitizeElements(currentNode, walkRoot);
2052
2136
  _sanitizeAttributes(currentNode);
2053
2137
  if (_isDocumentFragment(currentNode.content)) _sanitizeShadowDOM2(currentNode.content);
2054
2138
  }
2055
2139
  } catch (error) {
2056
- if (inPlace) _neutralizeRoot(dirty);
2140
+ if (inPlace) {
2141
+ _neutralizeRoot(dirty);
2142
+ arrayForEach(DOMPurify.removed, (entry) => {
2143
+ if (entry.element) _neutralizeSubtree(entry.element);
2144
+ });
2145
+ }
2057
2146
  throw error;
2058
2147
  }
2059
2148
  if (inPlace) {