@datawheel/bespoke 0.3.21 → 0.3.22

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.
Files changed (2) hide show
  1. package/dist/index.js +11 -10
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -8044,28 +8044,29 @@ function ImageTab(props) {
8044
8044
  const translations = { ...DEFAULT_TRANSLATIONS3, ...optionsTranslations["image_tab"] };
8045
8045
  const { siteProps } = useBespoke();
8046
8046
  const includeLogo = siteProps?.logoSrc && typeof siteProps.logoSrc === "string";
8047
- const sectionHash = section.settings?.name ? `#${section.settings.name}` : `#section-${section.id}`;
8047
+ const sectionId = section?.settings?.name || `section-${section.id}`;
8048
+ const sectionHash = `#${sectionId}`;
8048
8049
  const theme = useMantineTheme();
8049
8050
  const vizSelectedHasSVG = () => {
8050
- const vizNode = getVizNode(section.id, vizSelected);
8051
+ const vizNode = getVizNode(vizSelected);
8051
8052
  const svgCount = select(vizNode).select("svg").size();
8052
8053
  return svgCount === 1;
8053
8054
  };
8054
- const getFileName = () => `${slugify_default(section?.settings?.name || `section-${section.id}`)}`;
8055
- const getSectionNode = (sectionId) => {
8056
- const sectionNode = document.getElementById(`section-${sectionId}`);
8055
+ const getFileName = () => `${slugify_default(sectionId)}`;
8056
+ const getSectionNode = () => {
8057
+ const sectionNode = document.getElementById(sectionId);
8057
8058
  return select(sectionNode).select(".bespoke-section-content").node();
8058
8059
  };
8059
- const getVizNode = (sectionId, vizId) => {
8060
- const sectionNode = getSectionNode(sectionId);
8060
+ const getVizNode = (vizId) => {
8061
+ const sectionNode = getSectionNode();
8061
8062
  return select(sectionNode).select(`#bespoke-visualization-${vizId}.bespoke-block-area`).node();
8062
8063
  };
8063
8064
  const getSelectedNode = () => new Promise((resolve) => {
8064
8065
  let node;
8065
8066
  if (imageContext === contextOptions.section) {
8066
- node = getSectionNode(section.id);
8067
+ node = getSectionNode();
8067
8068
  } else if (imageContext === contextOptions.viz) {
8068
- node = getVizNode(section.id, vizSelected);
8069
+ node = getVizNode(vizSelected);
8069
8070
  }
8070
8071
  const sourceContainer = document.createElement("div");
8071
8072
  sourceContainer.style.display = "flex";
@@ -8157,7 +8158,7 @@ function ImageTab(props) {
8157
8158
  const generatePreviews = async () => {
8158
8159
  const { toCanvas } = await import('html-to-image');
8159
8160
  Promise.all(
8160
- vizAvailable.map((viz) => toCanvas(getVizNode(section.id, viz.id)))
8161
+ vizAvailable.map((viz) => toCanvas(getVizNode(viz.id)))
8161
8162
  ).then((canvases) => {
8162
8163
  setVizPreviews(canvases.map((canvas) => canvas.toDataURL()));
8163
8164
  setLoadingPreviews(false);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datawheel/bespoke",
3
- "version": "0.3.21",
3
+ "version": "0.3.22",
4
4
  "description": "Content management system for creating automated data reports",
5
5
  "exports": {
6
6
  ".": {