@swell/apps-sdk 1.0.177 → 1.0.178

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/dist/index.js CHANGED
@@ -3268,13 +3268,20 @@
3268
3268
  blocks: props.Blocks?.filter(
3269
3269
  (propBlock) => Boolean(propBlock.props.compiled?._component)
3270
3270
  ).map((propBlock) => {
3271
- const blockProps = propBlock.props.compiled.props;
3272
- const blockType = propBlock.props.compiled._component.split("__")[2];
3271
+ const {
3272
+ _id: id,
3273
+ _component: component,
3274
+ disabled: isDisabled,
3275
+ props: blockProps
3276
+ } = propBlock.props.compiled;
3277
+ const blockType = component.split("__")[2];
3273
3278
  const blockSchema = sectionSchema.blocks?.find(
3274
3279
  (block) => block.type === blockType
3275
3280
  );
3276
3281
  return {
3282
+ id,
3277
3283
  type: blockType,
3284
+ disabled: isDisabled,
3278
3285
  settings: blockSchema?.fields?.reduce(
3279
3286
  (acc, field) => {
3280
3287
  if (field?.id) {
@@ -14791,7 +14798,7 @@ ${injects.join("\n")}<\/script>`;
14791
14798
  const value = yield (0, import_liquidjs16.evalToken)(valueToken, ctx, ctx.opts.lenientIf);
14792
14799
  if (target === value) {
14793
14800
  const blockOutput = yield r.renderTemplates(branch.templates, ctx);
14794
- output += this.isBlock && liquidSwell.isEditor ? `<span class="swell-block">${blockOutput}</span>` : blockOutput;
14801
+ output += blockOutput;
14795
14802
  branchHit = true;
14796
14803
  break;
14797
14804
  }
@@ -18816,6 +18823,7 @@ ${this.shopifyCompatibility.getContentForHeader()}`;
18816
18823
  );
18817
18824
  blocks = blocks?.map((block) => ({
18818
18825
  ...block,
18826
+ ...getBlockAttributes(theme, block),
18819
18827
  settings: resolveThemeSettings(
18820
18828
  theme,
18821
18829
  block.settings,
@@ -18957,6 +18965,17 @@ ${this.shopifyCompatibility.getContentForHeader()}`;
18957
18965
  }
18958
18966
  return null;
18959
18967
  }
18968
+ function getBlockAttributes(theme, block) {
18969
+ if (!theme.swell.isEditor) {
18970
+ return;
18971
+ }
18972
+ const { id } = block;
18973
+ const attributes = `data-editor-block="${JSON.stringify({ id }).replaceAll('"', "&quot;")}"`;
18974
+ return {
18975
+ swell_attributes: attributes,
18976
+ shopify_attributes: attributes
18977
+ };
18978
+ }
18960
18979
  function parseJsonConfig(config) {
18961
18980
  try {
18962
18981
  return import_json56.default.parse(config?.file_data || "{}");