@lvce-editor/preview-sandbox-worker 4.1.0 → 4.3.0

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.
@@ -1232,6 +1232,10 @@ const set$1 = (uid, instance) => {
1232
1232
  states$1.set(uid, instance);
1233
1233
  };
1234
1234
 
1235
+ const mergeClassNames = (...classNames) => {
1236
+ return classNames.filter(Boolean).join(' ');
1237
+ };
1238
+
1235
1239
  const text = data => {
1236
1240
  return {
1237
1241
  childCount: 0,
@@ -1240,6 +1244,8 @@ const text = data => {
1240
1244
  };
1241
1245
  };
1242
1246
 
1247
+ const Body = 'Body';
1248
+
1243
1249
  const Div = 'div';
1244
1250
  const H1 = 'h1';
1245
1251
  const H2 = 'h2';
@@ -1552,6 +1558,15 @@ const serialize = (document, elementMap = Object.create(null)) => {
1552
1558
  for (let i = 0; i < childNodes.length; i++) {
1553
1559
  rootChildCount += serializeNode(childNodes[i], dom, css, context);
1554
1560
  }
1561
+ const bodyNode = {
1562
+ childCount: rootChildCount,
1563
+ type: Div$1
1564
+ };
1565
+ if (document.body) {
1566
+ applyAllowedAttributes(bodyNode, document.body);
1567
+ }
1568
+ bodyNode.className = bodyNode.className ? mergeClassNames(Body, bodyNode.className) : Body;
1569
+ dom.unshift(bodyNode);
1555
1570
  return {
1556
1571
  css,
1557
1572
  dom
@@ -1791,11 +1806,13 @@ const getKeyboardEventInit = (key, code) => {
1791
1806
  };
1792
1807
 
1793
1808
  const setLegacyKeyCode$1 = (event, keyCode) => {
1794
- Object.defineProperty(event, 'keyCode', {
1795
- value: keyCode
1796
- });
1797
- Object.defineProperty(event, 'which', {
1798
- value: keyCode
1809
+ Object.defineProperties(event, {
1810
+ keyCode: {
1811
+ value: keyCode
1812
+ },
1813
+ which: {
1814
+ value: keyCode
1815
+ }
1799
1816
  });
1800
1817
  };
1801
1818
  const dispatchKeydownEvent = (element, window, key, code) => {
@@ -1836,11 +1853,13 @@ const handleKeydown = (uid, hdId, key, code) => {
1836
1853
  };
1837
1854
 
1838
1855
  const setLegacyKeyCode = (event, keyCode) => {
1839
- Object.defineProperty(event, 'keyCode', {
1840
- value: keyCode
1841
- });
1842
- Object.defineProperty(event, 'which', {
1843
- value: keyCode
1856
+ Object.defineProperties(event, {
1857
+ keyCode: {
1858
+ value: keyCode
1859
+ },
1860
+ which: {
1861
+ value: keyCode
1862
+ }
1844
1863
  });
1845
1864
  };
1846
1865
  const dispatchKeyupEvent = (element, window, key, code) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/preview-sandbox-worker",
3
- "version": "4.1.0",
3
+ "version": "4.3.0",
4
4
  "description": "Preview SandBox Worker",
5
5
  "repository": {
6
6
  "type": "git",