labellife-design-tool 2.5.0 → 2.5.2
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/cjs/canvas/workspace.js.map +1 -1
- package/dist/cjs/config.js +18 -0
- package/dist/cjs/config.js.map +1 -1
- package/dist/cjs/index.js +88 -10
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/side-panel/index.js +88 -10
- package/dist/cjs/side-panel/index.js.map +1 -1
- package/dist/cjs/side-panel/side-panel.js +88 -10
- package/dist/cjs/side-panel/side-panel.js.map +1 -1
- package/dist/cjs/toolbar/toolbar.js.map +1 -1
- package/dist/esm/canvas/workspace.js.map +1 -1
- package/dist/esm/config.js +17 -1
- package/dist/esm/config.js.map +1 -1
- package/dist/esm/index.js +88 -10
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/side-panel/index.js +88 -10
- package/dist/esm/side-panel/index.js.map +1 -1
- package/dist/esm/side-panel/side-panel.js +88 -10
- package/dist/esm/side-panel/side-panel.js.map +1 -1
- package/dist/esm/toolbar/toolbar.js.map +1 -1
- package/package.json +2 -2
|
@@ -424,6 +424,17 @@ function t(key, defaultValue) {
|
|
|
424
424
|
return defaultValue || key;
|
|
425
425
|
}
|
|
426
426
|
|
|
427
|
+
// ── Backend API base URL (used by background-panel.js's Unsplash proxy calls) ─
|
|
428
|
+
// Window-level singleton, same reasoning as translations/input-fields config above:
|
|
429
|
+
// each Rollup output bundle (index, side-panel, toolbar, canvas...) gets its own copy
|
|
430
|
+
// of this module, so a plain closure variable set from one bundle (e.g. via the host
|
|
431
|
+
// app's top-level `labellife-design-tool/config` import) would never be seen by another
|
|
432
|
+
// bundle (e.g. background-panel.js, built into the side-panel bundle).
|
|
433
|
+
var API_BASE_URL_KEY = '__labellife_api_base_url__';
|
|
434
|
+
function getApiBaseUrl() {
|
|
435
|
+
return typeof window !== 'undefined' && window[API_BASE_URL_KEY] || '';
|
|
436
|
+
}
|
|
437
|
+
|
|
427
438
|
// ── Input Fields Dialog Config ───────────────────────────────────────
|
|
428
439
|
var INPUT_FIELDS_CONFIG_KEY = '__labellife_input_fields_config__';
|
|
429
440
|
if (typeof window !== 'undefined' && !window[INPUT_FIELDS_CONFIG_KEY]) {
|
|
@@ -1008,6 +1019,33 @@ var TextSection = {
|
|
|
1008
1019
|
Panel: TextPanelContent
|
|
1009
1020
|
};
|
|
1010
1021
|
|
|
1022
|
+
// src/side-panel/unsplash-api.js
|
|
1023
|
+
//
|
|
1024
|
+
// Pure, framework-free URL helpers for the Unsplash background search, proxied through the
|
|
1025
|
+
// labellife backend (see labellifeBackendRepo's UnsplashBackgroundSearchView /
|
|
1026
|
+
// UnsplashTrackDownloadView). Deliberately has no internal imports so it can be unit-tested
|
|
1027
|
+
// with plain `node`, following the same convention as ./fonts.js.
|
|
1028
|
+
|
|
1029
|
+
var UNSPLASH_UTM_SOURCE = 'labellife';
|
|
1030
|
+
function buildUnsplashSearchUrl(apiBaseUrl, query) {
|
|
1031
|
+
var page = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
|
1032
|
+
var perPage = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 20;
|
|
1033
|
+
var trimmed = query && String(query).trim();
|
|
1034
|
+
var q = trimmed || 'gradient';
|
|
1035
|
+
return "".concat(apiBaseUrl, "/api/polotno/unsplash/search/?query=").concat(encodeURIComponent(q), "&per_page=").concat(perPage, "&page=").concat(page);
|
|
1036
|
+
}
|
|
1037
|
+
function buildUnsplashTrackDownloadUrl(apiBaseUrl) {
|
|
1038
|
+
return "".concat(apiBaseUrl, "/api/polotno/unsplash/track-download/");
|
|
1039
|
+
}
|
|
1040
|
+
|
|
1041
|
+
// Unsplash API Guidelines require attribution links back to unsplash.com and to the
|
|
1042
|
+
// photographer's profile to carry UTM params identifying this app.
|
|
1043
|
+
function withUnsplashAttribution(url) {
|
|
1044
|
+
if (!url) return url;
|
|
1045
|
+
var separator = url.includes('?') ? '&' : '?';
|
|
1046
|
+
return "".concat(url).concat(separator, "utm_source=").concat(encodeURIComponent(UNSPLASH_UTM_SOURCE), "&utm_medium=referral");
|
|
1047
|
+
}
|
|
1048
|
+
|
|
1011
1049
|
function hsvToRgb(h, s, v) {
|
|
1012
1050
|
var i = Math.floor(h / 60) % 6;
|
|
1013
1051
|
var f = h / 60 - Math.floor(h / 60);
|
|
@@ -1083,8 +1121,6 @@ function hueToColor(h) {
|
|
|
1083
1121
|
|
|
1084
1122
|
// ─── Constants ───────────────────────────────────────────────────────
|
|
1085
1123
|
|
|
1086
|
-
var UNSPLASH_KEY = 'zwiE802FyRjTmLhZjXqW';
|
|
1087
|
-
var UNSPLASH_BASE = 'https://api.polotno.com/api/get-unsplash';
|
|
1088
1124
|
var SWATCH_COLORS = ['#ffffff', '#1a237e', '#ff6d00', '#2e7d32', '#fdd835', '#9c27b0'];
|
|
1089
1125
|
var PICKER_PRESETS = ['#f44336', '#ff9800', '#ffeb3b', '#4caf50', '#2196f3', '#9c27b0', '#00bcd4', '#8bc34a', '#cddc39', '#000000', '#607d8b', '#ffffff'];
|
|
1090
1126
|
var CHECKER_SVG = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16'%3E%3Crect width='8' height='8' fill='%23ccc'/%3E%3Crect x='8' y='8' width='8' height='8' fill='%23ccc'/%3E%3Crect x='8' width='8' height='8' fill='%23fff'/%3E%3Crect y='8' width='8' height='8' fill='%23fff'/%3E%3C/svg%3E";
|
|
@@ -1682,7 +1718,7 @@ var BackgroundPanelContent = observer(function (_ref5) {
|
|
|
1682
1718
|
_context.p = 2;
|
|
1683
1719
|
q = query || 'gradient';
|
|
1684
1720
|
_context.n = 3;
|
|
1685
|
-
return fetch(
|
|
1721
|
+
return fetch(buildUnsplashSearchUrl(getApiBaseUrl(), q, pg, 20));
|
|
1686
1722
|
case 3:
|
|
1687
1723
|
res = _context.v;
|
|
1688
1724
|
_context.n = 4;
|
|
@@ -1914,7 +1950,7 @@ var BackgroundPanelContent = observer(function (_ref5) {
|
|
|
1914
1950
|
color: '#888'
|
|
1915
1951
|
},
|
|
1916
1952
|
children: ["Photos by", ' ', /*#__PURE__*/jsx("a", {
|
|
1917
|
-
href:
|
|
1953
|
+
href: withUnsplashAttribution('https://unsplash.com'),
|
|
1918
1954
|
target: "_blank",
|
|
1919
1955
|
rel: "noopener noreferrer",
|
|
1920
1956
|
style: {
|
|
@@ -1930,16 +1966,33 @@ var BackgroundPanelContent = observer(function (_ref5) {
|
|
|
1930
1966
|
gap: 1
|
|
1931
1967
|
},
|
|
1932
1968
|
children: photos.map(function (photo, idx) {
|
|
1933
|
-
var _photo$urls, _photo$urls2;
|
|
1969
|
+
var _photo$urls, _photo$urls2, _photo$user, _photo$user2;
|
|
1934
1970
|
var thumb = ((_photo$urls = photo.urls) === null || _photo$urls === void 0 ? void 0 : _photo$urls.small) || ((_photo$urls2 = photo.urls) === null || _photo$urls2 === void 0 ? void 0 : _photo$urls2.thumb) || photo.src;
|
|
1935
1971
|
if (!thumb) return null;
|
|
1936
|
-
|
|
1972
|
+
var photographerName = (_photo$user = photo.user) === null || _photo$user === void 0 ? void 0 : _photo$user.name;
|
|
1973
|
+
var photographerUrl = ((_photo$user2 = photo.user) === null || _photo$user2 === void 0 || (_photo$user2 = _photo$user2.links) === null || _photo$user2 === void 0 ? void 0 : _photo$user2.html) && withUnsplashAttribution(photo.user.links.html);
|
|
1974
|
+
return /*#__PURE__*/jsxs(Box, {
|
|
1937
1975
|
onClick: function onClick() {
|
|
1938
|
-
var _photo$urls3, _photo$urls4;
|
|
1976
|
+
var _photo$urls3, _photo$urls4, _photo$links;
|
|
1939
1977
|
var url = ((_photo$urls3 = photo.urls) === null || _photo$urls3 === void 0 ? void 0 : _photo$urls3.regular) || ((_photo$urls4 = photo.urls) === null || _photo$urls4 === void 0 ? void 0 : _photo$urls4.small) || photo.src;
|
|
1940
|
-
if (url)
|
|
1978
|
+
if (!url) return;
|
|
1979
|
+
setBackground(url);
|
|
1980
|
+
// Unsplash API Guidelines require registering a "download" whenever a photo is used.
|
|
1981
|
+
// Best-effort: don't block or fail background-setting if this ping fails.
|
|
1982
|
+
if ((_photo$links = photo.links) !== null && _photo$links !== void 0 && _photo$links.download_location) {
|
|
1983
|
+
fetch(buildUnsplashTrackDownloadUrl(getApiBaseUrl()), {
|
|
1984
|
+
method: 'POST',
|
|
1985
|
+
headers: {
|
|
1986
|
+
'Content-Type': 'application/json'
|
|
1987
|
+
},
|
|
1988
|
+
body: JSON.stringify({
|
|
1989
|
+
download_location: photo.links.download_location
|
|
1990
|
+
})
|
|
1991
|
+
})["catch"](function () {});
|
|
1992
|
+
}
|
|
1941
1993
|
},
|
|
1942
1994
|
sx: {
|
|
1995
|
+
position: 'relative',
|
|
1943
1996
|
cursor: 'pointer',
|
|
1944
1997
|
borderRadius: '8px',
|
|
1945
1998
|
overflow: 'hidden',
|
|
@@ -1949,7 +2002,7 @@ var BackgroundPanelContent = observer(function (_ref5) {
|
|
|
1949
2002
|
},
|
|
1950
2003
|
transition: 'opacity 0.15s'
|
|
1951
2004
|
},
|
|
1952
|
-
children: /*#__PURE__*/jsx("img", {
|
|
2005
|
+
children: [/*#__PURE__*/jsx("img", {
|
|
1953
2006
|
src: thumb,
|
|
1954
2007
|
alt: photo.alt_description || 'Background',
|
|
1955
2008
|
style: {
|
|
@@ -1959,7 +2012,32 @@ var BackgroundPanelContent = observer(function (_ref5) {
|
|
|
1959
2012
|
display: 'block'
|
|
1960
2013
|
},
|
|
1961
2014
|
loading: "lazy"
|
|
1962
|
-
})
|
|
2015
|
+
}), photographerName && /*#__PURE__*/jsx(Typography, {
|
|
2016
|
+
variant: "caption",
|
|
2017
|
+
component: "a",
|
|
2018
|
+
href: photographerUrl || undefined,
|
|
2019
|
+
target: "_blank",
|
|
2020
|
+
rel: "noopener noreferrer",
|
|
2021
|
+
onClick: function onClick(e) {
|
|
2022
|
+
return e.stopPropagation();
|
|
2023
|
+
},
|
|
2024
|
+
sx: {
|
|
2025
|
+
position: 'absolute',
|
|
2026
|
+
left: 0,
|
|
2027
|
+
right: 0,
|
|
2028
|
+
bottom: 0,
|
|
2029
|
+
px: 0.75,
|
|
2030
|
+
py: 0.25,
|
|
2031
|
+
fontSize: 10,
|
|
2032
|
+
color: '#fff',
|
|
2033
|
+
textDecoration: 'none',
|
|
2034
|
+
background: 'linear-gradient(to top, rgba(0,0,0,0.55), transparent)',
|
|
2035
|
+
whiteSpace: 'nowrap',
|
|
2036
|
+
overflow: 'hidden',
|
|
2037
|
+
textOverflow: 'ellipsis'
|
|
2038
|
+
},
|
|
2039
|
+
children: photographerName
|
|
2040
|
+
})]
|
|
1963
2041
|
}, photo.id || idx);
|
|
1964
2042
|
})
|
|
1965
2043
|
}), hasMore && /*#__PURE__*/jsx(Box, {
|