@diplodoc/client 3.10.1 → 3.10.3
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 +19 -0
- package/build/client/{app-250ccd6b9d8d1ce4.css → app-34c68624e23be7ce.css} +2 -2
- package/build/client/{app-250ccd6b9d8d1ce4.css.map → app-34c68624e23be7ce.css.map} +1 -1
- package/build/client/app-5320a31c05d20641.js +2 -0
- package/build/client/app-5320a31c05d20641.js.map +1 -0
- package/build/client/{app-15ff6087f699f3a0.rtl.css → app-d88d1fac5b51ff99.rtl.css} +1 -1
- package/build/client/manifest.json +10 -10
- package/build/client/{search-d55c2c5eee1cd174.rtl.css → search-232df3e8600322f2.rtl.css} +1 -1
- package/build/client/search-81a7f828ef481c84.js +2 -0
- package/build/client/search-81a7f828ef481c84.js.map +1 -0
- package/build/client/{search-733d78d17e4b1925.css → search-b82629d53f2e437c.css} +2 -2
- package/build/client/{search-733d78d17e4b1925.css.map → search-b82629d53f2e437c.css.map} +1 -1
- package/build/client/{vendor-066de1f8742b5e32.js → vendor-0ca3ecbd78ee745e.js} +2 -2
- package/build/client/vendor-0ca3ecbd78ee745e.js.map +1 -0
- package/build/components/App/useLangs.d.ts +1 -1
- package/build/server/app.js +40 -63
- package/build/server/app.js.map +1 -1
- package/build/server/vendor.js +2 -21
- package/build/server/vendor.js.map +1 -1
- package/build/utils.d.ts +3 -3
- package/package.json +2 -3
- package/build/client/app-437cfd7de96fcf17.js +0 -2
- package/build/client/app-437cfd7de96fcf17.js.map +0 -1
- package/build/client/search-79373e576eb6df80.js +0 -2
- package/build/client/search-79373e576eb6df80.js.map +0 -1
- package/build/client/vendor-066de1f8742b5e32.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AppProps } from './index';
|
|
2
2
|
import type { Lang } from '@diplodoc/components';
|
|
3
|
-
export declare function useLangs({
|
|
3
|
+
export declare function useLangs({ lang, langs }: AppProps): {
|
|
4
4
|
lang: "ar" | "he" | Lang | "ru" | "en" | "es" | "fr" | "cs";
|
|
5
5
|
langs: ("ar" | "he" | Lang | "ru" | "en" | "es" | "fr" | "cs")[];
|
|
6
6
|
onChangeLang: (newLang: `${Lang}` | Lang) => void;
|
package/build/server/app.js
CHANGED
|
@@ -497,7 +497,6 @@ var LINK_KEYS = (0,_to_consumable_array._)(new Set((0,_to_consumable_array._)(LI
|
|
|
497
497
|
;// CONCATENATED MODULE: ./src/utils.ts
|
|
498
498
|
|
|
499
499
|
|
|
500
|
-
|
|
501
500
|
function isBrowser() {
|
|
502
501
|
return typeof document !== 'undefined';
|
|
503
502
|
}
|
|
@@ -592,8 +591,10 @@ function utils_setSetting(name, value) {
|
|
|
592
591
|
sessionStorage.setItem(name, String(value));
|
|
593
592
|
} catch (e) {}
|
|
594
593
|
}
|
|
594
|
+
function isDetailsTag(el) {
|
|
595
|
+
return (el === null || el === void 0 ? void 0 : el.tagName.toLowerCase()) === 'details';
|
|
596
|
+
}
|
|
595
597
|
function isHeaderTag(el) {
|
|
596
|
-
if (!el) return false;
|
|
597
598
|
return [
|
|
598
599
|
'H1',
|
|
599
600
|
'H2',
|
|
@@ -603,48 +604,56 @@ function isHeaderTag(el) {
|
|
|
603
604
|
'H6'
|
|
604
605
|
].indexOf(el.tagName) !== -1;
|
|
605
606
|
}
|
|
606
|
-
function isCutTag(el) {
|
|
607
|
-
if (!el) return false;
|
|
608
|
-
return el.matches('.yfm-cut');
|
|
609
|
-
}
|
|
610
|
-
function focusActiveTab(cutNode) {
|
|
611
|
-
cutNode.classList.toggle('open');
|
|
612
|
-
cutNode.setAttribute('open', 'true');
|
|
613
|
-
cutNode.classList.add('cut-highlight');
|
|
614
|
-
cutNode.scrollIntoView(true);
|
|
615
|
-
window.scrollBy(0, -100);
|
|
616
|
-
setTimeout(function() {
|
|
617
|
-
cutNode.classList.remove('cut-highlight');
|
|
618
|
-
}, 1000);
|
|
619
|
-
}
|
|
620
607
|
/**
|
|
621
608
|
* Scrolls to the element.
|
|
622
609
|
* If the element is a heading - simply scrolls to it, since needed offset is already in css.
|
|
623
610
|
* If the element is of any other type - calculate the offset form the element position in heading and scroll to it.
|
|
624
611
|
* @param {HTMLElement} el
|
|
625
612
|
*/ function scrollToElement(el) {
|
|
626
|
-
|
|
613
|
+
var offset = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 200;
|
|
614
|
+
if (isInViewport(el)) {
|
|
615
|
+
return;
|
|
616
|
+
}
|
|
627
617
|
if (isHeaderTag(el)) {
|
|
628
618
|
// Header already includes the offset in css
|
|
629
619
|
// That puts it where we want it when it's scrolled to
|
|
630
620
|
el.scrollIntoView();
|
|
631
|
-
} else if (isCutTag(el)) {
|
|
632
|
-
focusActiveTab(el);
|
|
633
621
|
} else {
|
|
634
|
-
|
|
635
|
-
var
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
window.scrollTo(0, anchorPosition - headerOffset);
|
|
622
|
+
var elementPosition = el.getBoundingClientRect().top;
|
|
623
|
+
var offsetPosition = elementPosition + window.scrollY - offset;
|
|
624
|
+
window.scrollTo({
|
|
625
|
+
top: offsetPosition
|
|
626
|
+
});
|
|
640
627
|
}
|
|
641
628
|
}
|
|
629
|
+
function getLangPath(lang, href) {
|
|
630
|
+
var path = href.replace(/^https?:\/\/[^/]+/, '').replace(/^\/[a-z]{2}\//, '/');
|
|
631
|
+
return "".concat(lang).concat(path);
|
|
632
|
+
}
|
|
633
|
+
function isInViewport(el) {
|
|
634
|
+
var rect = el.getBoundingClientRect();
|
|
635
|
+
return rect.top >= 0 && rect.bottom <= (window.innerHeight || document.documentElement.clientHeight);
|
|
636
|
+
}
|
|
642
637
|
function scrollToHash() {
|
|
643
638
|
var hash = window.location.hash.substring(1);
|
|
644
|
-
if (hash) {
|
|
645
|
-
|
|
646
|
-
scrollToElement(element);
|
|
639
|
+
if (!hash) {
|
|
640
|
+
return;
|
|
647
641
|
}
|
|
642
|
+
var element = document.getElementById(hash);
|
|
643
|
+
if (!element) {
|
|
644
|
+
return;
|
|
645
|
+
}
|
|
646
|
+
var node = element === null || element === void 0 ? void 0 : element.parentElement;
|
|
647
|
+
while(node){
|
|
648
|
+
if (isDetailsTag(node)) {
|
|
649
|
+
node.open = true;
|
|
650
|
+
}
|
|
651
|
+
node = node.parentElement;
|
|
652
|
+
}
|
|
653
|
+
element.focus();
|
|
654
|
+
setTimeout(function() {
|
|
655
|
+
scrollToElement(element);
|
|
656
|
+
}, 10);
|
|
648
657
|
}
|
|
649
658
|
|
|
650
659
|
// EXTERNAL MODULE: ./src/interceptors/leading-page-links.js
|
|
@@ -1166,8 +1175,6 @@ var index_min = __webpack_require__(38553);
|
|
|
1166
1175
|
var theme_useTheme = __webpack_require__(11946);
|
|
1167
1176
|
// EXTERNAL MODULE: ./node_modules/@diplodoc/tabs-extension/build/react/index.js
|
|
1168
1177
|
var tabs_extension_build_react = __webpack_require__(34952);
|
|
1169
|
-
// EXTERNAL MODULE: ./node_modules/@diplodoc/cut-extension/build/react/index.js
|
|
1170
|
-
var cut_extension_build_react = __webpack_require__(20535);
|
|
1171
1178
|
// EXTERNAL MODULE: ./node_modules/@diplodoc/page-constructor-extension/build/react/index.js
|
|
1172
1179
|
var page_constructor_extension_build_react = __webpack_require__(76638);
|
|
1173
1180
|
;// CONCATENATED MODULE: ./src/components/App/Runtime.tsx
|
|
@@ -1180,7 +1187,6 @@ var page_constructor_extension_build_react = __webpack_require__(76638);
|
|
|
1180
1187
|
|
|
1181
1188
|
|
|
1182
1189
|
|
|
1183
|
-
|
|
1184
1190
|
function Runtime() {
|
|
1185
1191
|
var theme = (0,theme_useTheme/* .useTheme */.F)();
|
|
1186
1192
|
return /*#__PURE__*/ (0,jsx_runtime.jsxs)(jsx_runtime.Fragment, {
|
|
@@ -1198,10 +1204,6 @@ function Runtime() {
|
|
|
1198
1204
|
saveTabsToLocalStorage: true,
|
|
1199
1205
|
saveTabsToQueryStateMode: "page"
|
|
1200
1206
|
}),
|
|
1201
|
-
/*#__PURE__*/ (0,jsx_runtime.jsx)(cut_extension_build_react/* .CutRuntime */.q, {
|
|
1202
|
-
offset: 200,
|
|
1203
|
-
behavior: "instant"
|
|
1204
|
-
}),
|
|
1205
1207
|
/*#__PURE__*/ (0,jsx_runtime.jsx)(page_constructor_extension_build_react/* .PageConstructorRuntime */.Hc, {})
|
|
1206
1208
|
]
|
|
1207
1209
|
});
|
|
@@ -1211,12 +1213,10 @@ function Runtime() {
|
|
|
1211
1213
|
|
|
1212
1214
|
|
|
1213
1215
|
function useLangs(param) {
|
|
1214
|
-
var
|
|
1216
|
+
var lang = param.lang, langs = param.langs;
|
|
1215
1217
|
var onChangeLang = (0,react.useCallback)(function(newLang) {
|
|
1216
|
-
window.location.replace(
|
|
1217
|
-
}, [
|
|
1218
|
-
router
|
|
1219
|
-
]);
|
|
1218
|
+
window.location.replace(getLangPath(newLang, window.location.href));
|
|
1219
|
+
}, []);
|
|
1220
1220
|
return (0,react.useMemo)(function() {
|
|
1221
1221
|
return {
|
|
1222
1222
|
lang: lang,
|
|
@@ -1567,29 +1567,6 @@ var render = function(props) {
|
|
|
1567
1567
|
}
|
|
1568
1568
|
})(Element.prototype);
|
|
1569
1569
|
}
|
|
1570
|
-
if (typeof document !== 'undefined') {
|
|
1571
|
-
document.addEventListener('click', function(event) {
|
|
1572
|
-
var href = event.target.href;
|
|
1573
|
-
var locationOrigin = window.location.origin;
|
|
1574
|
-
if (event.target.matches('.dc-doc-layout__center a') && href.startsWith(locationOrigin)) {
|
|
1575
|
-
event.preventDefault();
|
|
1576
|
-
var mainFileName = 'index';
|
|
1577
|
-
var extention = '.html';
|
|
1578
|
-
if (href.endsWith('/')) {
|
|
1579
|
-
window.location.href = "".concat(href).concat(mainFileName).concat(extention);
|
|
1580
|
-
return;
|
|
1581
|
-
}
|
|
1582
|
-
// https://../file-name, https://../file-name#fragment
|
|
1583
|
-
var splitedHref = href.split('#');
|
|
1584
|
-
if (splitedHref.length > 0 && !splitedHref[0].endsWith(extention)) {
|
|
1585
|
-
splitedHref[0] += extention;
|
|
1586
|
-
window.location.href = splitedHref.join('#');
|
|
1587
|
-
return;
|
|
1588
|
-
}
|
|
1589
|
-
window.location.href = href;
|
|
1590
|
-
}
|
|
1591
|
-
});
|
|
1592
|
-
}
|
|
1593
1570
|
})();
|
|
1594
1571
|
|
|
1595
1572
|
|