TagSpaces is an offline, open source, document manager with tagging support
chore: migration from react-slick to swiperjs
Ilian Sapundshiev6f60ab13e0e3
diff --git a/package-lock.json b/package-lock.jsonindex 14f6cd249..f31220c91 100644--- a/package-lock.json+++ b/package-lock.json@@ -68,15 +68,14 @@"react-leaflet-markercluster": "4.2.1","react-qrcode-logo": "^2.8.0","react-redux": "^8.0.2",- "react-slick": "0.31.0","react-virtuoso": "4.13.0","redux": "^4.2.0","redux-persist": "^5.10.0","redux-thunk": "2.4.2","remove-markdown": "0.6.2","semver": "^7.3.5",- "slick-carousel": "1.8.1","source-map-support": "0.5.21",+ "swiper": "^12.0.3","tga-js": "1.1.1","ts-react-splitter": "3.0.0","utif": "github:photopea/UTIF.js",@@ -28070,11 +28069,6 @@"url": "https://github.com/chalk/supports-color?sponsor=1"}},- "node_modules/jquery": {- "version": "3.7.1",- "license": "MIT",- "peer": true- },"node_modules/js-cookie": {"version": "2.2.1","resolved": "https://registry.npmjs.org/js-cookie/-/js-cookie-2.2.1.tgz",@@ -28213,13 +28207,6 @@"dev": true,"license": "ISC"},- "node_modules/json2mq": {- "version": "0.2.0",- "license": "MIT",- "dependencies": {- "string-convert": "^0.2.0"- }- },"node_modules/json5": {"version": "2.2.3","license": "MIT",@@ -28785,6 +28772,7 @@},"node_modules/lodash.debounce": {"version": "4.0.8",+ "dev": true,"license": "MIT"},"node_modules/lodash.difference": {@@ -36569,22 +36557,6 @@"react": "^16.0.0 || ^17.0.0 || ^18.0.0"}},- "node_modules/react-slick": {- "version": "0.31.0",- "resolved": "https://registry.npmjs.org/react-slick/-/react-slick-0.31.0.tgz",- "integrity": "sha512-zo6VLT8wuSBJffg/TFPbzrw2dEnfZ/cUKmYsKByh3AgatRv29m2LoFbq5vRMa3R3A4wp4d8gwbJKO2fWZFaI3g==",- "license": "MIT",- "dependencies": {- "classnames": "^2.2.5",- "json2mq": "^0.2.0",- "lodash.debounce": "^4.0.8",- "resize-observer-polyfill": "^1.5.0"- },- "peerDependencies": {- "react": "^0.14.0 || ^15.0.1 || ^16.0.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",- "react-dom": "^0.14.0 || ^15.0.1 || ^16.0.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"- }- },"node_modules/react-test-renderer": {"version": "18.2.0","dev": true,@@ -38198,13 +38170,6 @@"node": ">=8"}},- "node_modules/slick-carousel": {- "version": "1.8.1",- "license": "MIT",- "peerDependencies": {- "jquery": ">=1.8.0"- }- },"node_modules/smart-buffer": {"version": "4.2.0","dev": true,@@ -38527,10 +38492,6 @@"safe-buffer": "~5.2.0"}},- "node_modules/string-convert": {- "version": "0.2.1",- "license": "MIT"- },"node_modules/string-length": {"version": "4.0.2","dev": true,@@ -39134,6 +39095,25 @@"url": "https://github.com/fb55/domutils?sponsor=1"}},+ "node_modules/swiper": {+ "version": "12.0.3",+ "resolved": "https://registry.npmjs.org/swiper/-/swiper-12.0.3.tgz",+ "integrity": "sha512-BHd6U1VPEIksrXlyXjMmRWO0onmdNPaTAFduzqR3pgjvi7KfmUCAm/0cj49u2D7B0zNjMw02TSeXfinC1hDCXg==",+ "funding": [+ {+ "type": "patreon",+ "url": "https://www.patreon.com/swiperjs"+ },+ {+ "type": "open_collective",+ "url": "http://opencollective.com/swiper"+ }+ ],+ "license": "MIT",+ "engines": {+ "node": ">= 4.7.0"+ }+ },"node_modules/symbol-tree": {"version": "3.2.4","license": "MIT"diff --git a/package.json b/package.jsonindex 70fe886b8..8dfaaa4e4 100644--- a/package.json+++ b/package.json@@ -159,7 +159,7 @@"ts-extension-symlink": "rimraf app/node_modules/@tagspaces/extensions && cd app/node_modules/@tagspaces && ln -s ../../../extensions extensions && cd ../../..","type-check": "npm run typescript-clean && tsc --noEmit","typescript-clean": "tsc --build --clean",- "update-changelog": "git log v6.7.2..HEAD --no-merges --format=%B > CHANGELOG.TXT",+ "update-changelog": "git log v6.7.3..HEAD --no-merges --format=%B > CHANGELOG.TXT","update-changelog-pro": "cd tagspacespro && git log v5.6.2..HEAD --no-merges --format=%B > ../../CHANGELOG-PRO.TXT","update-i18n": "./tx pull -a -f","version-meta": "node scripts/versionmeta.js",@@ -225,15 +225,14 @@"react-leaflet-markercluster": "4.2.1","react-qrcode-logo": "^2.8.0","react-redux": "^8.0.2",- "react-slick": "0.31.0","react-virtuoso": "4.13.0","redux": "^4.2.0","redux-persist": "^5.10.0","redux-thunk": "2.4.2","remove-markdown": "0.6.2","semver": "^7.3.5",- "slick-carousel": "1.8.1","source-map-support": "0.5.21",+ "swiper": "^12.0.3","tga-js": "1.1.1","ts-react-splitter": "3.0.0","utif": "github:photopea/UTIF.js",diff --git a/src/renderer/app.global.css b/src/renderer/app.global.cssindex 22cefd015..7165e7026 100644--- a/src/renderer/app.global.css+++ b/src/renderer/app.global.css@@ -6,8 +6,6 @@@import 'assets/rc-table.css';@import '~leaflet/dist/leaflet.css';@import '~react-image-gallery/styles/css/image-gallery.css';-@import "~slick-carousel/slick/slick.css"; /* used from react-slick */-@import "~slick-carousel/slick/slick-theme.css";@import '~react-leaflet-markercluster/styles';@import "~@milkdown/crepe/theme/common/style.css";@import "~@milkdown/crepe/theme/frame.css";diff --git a/src/renderer/components/dialogs/OnboardingDialog.tsx b/src/renderer/components/dialogs/OnboardingDialog.tsxindex fa939c95e..1c9a57cb8 100644--- a/src/renderer/components/dialogs/OnboardingDialog.tsx+++ b/src/renderer/components/dialogs/OnboardingDialog.tsx@@ -21,7 +21,6 @@ import BrowserExtension from '-/assets/images/collectcontent.svg';import WizardFinished from '-/assets/images/computer-desk.svg';import NewLook from '-/assets/images/desktop.svg';import Organize from '-/assets/images/organize.svg';-import { NavigateBeforeIcon, NavigateNextIcon } from '-/components/CommonIcons';import TsButton from '-/components/TsButton';import TsToggleButton from '-/components/TsToggleButton';import TsDialogTitle from '-/components/dialogs/components/TsDialogTitle';@@ -44,9 +43,13 @@ import Typography from '@mui/material/Typography';import { useTheme } from '@mui/material/styles';import useMediaQuery from '@mui/material/useMediaQuery';import Links from 'assets/links';+import { useRef } from 'react';import { useTranslation } from 'react-i18next';import { useDispatch, useSelector } from 'react-redux';-import Slider from 'react-slick';+import 'swiper/css';+import 'swiper/css/navigation';+import { Navigation } from 'swiper/modules';+import { Swiper, SwiperSlide } from 'swiper/react';interface Props {classes: any;@@ -57,6 +60,7 @@ interface Props {function OnboardingDialog(props: Props) {const { t } = useTranslation();const { open, onClose } = props;+ const swiperRef = useRef(null);const isPersistTagsInSidecar = useSelector(getPersistTagsInSidecarFile);const currentTheme = useSelector(getCurrentTheme);const dispatch: AppDispatch = useDispatch();@@ -79,39 +83,6 @@ function OnboardingDialog(props: Props) {const theme = useTheme();const smallScreen = useMediaQuery(theme.breakpoints.down('md'));- function NextArrow(props) {- const { className, style, onClick } = props;- return (- <div className={className} onClick={onClick}>- <NavigateNextIcon fontSize="large" color="primary" />- </div>- );- }-- function PrevArrow(props) {- const { className, style, onClick } = props;- return (- <div className={className} onClick={onClick}>- <NavigateBeforeIcon fontSize="large" color="primary" />- </div>- );- }-- const sliderSettings = {- className: 'center',- centerMode: true,- // dots: true,- infinite: false,- initialSlide: 0,- centerPadding: '0px',- speed: 500,- slidesToShow: 1,- slidesToScroll: 1,- adaptiveHeight: true,- nextArrow: <NextArrow />,- prevArrow: <PrevArrow />,- };-return (<Dialogopen={open}@@ -132,235 +103,234 @@ function OnboardingDialog(props: Props) {overflowX: 'hidden',}}>- <style>- {`- .slick-arrow {- height: 200px;- width: 50px;- display: flex;- align-items: center;- }- .slick-next:before {- content: '';- }- .slick-prev:before {- content: '';- }- `}- </style>- <Slider {...sliderSettings}>- <div>- <div- style={{- textAlign: 'center',- }}+ {open && (+ <>+ <style>+ {`+ .onboarding-swiper {+ width: 100%;+ height: 100%;+ }+ .swiper-slide {+ height: auto;+ text-align: center;+ }+ .swiper-button-next,+ .swiper-button-prev {+ color: ${theme.palette.primary.main};+ }+ `}+ </style>+ <Swiper+ ref={swiperRef}+ modules={[Navigation]}+ navigation+ slidesPerView={1}+ speed={500}+ initialSlide={0}+ loop={false}+ className="onboarding-swiper">- <Typography variant="h5">- {t('core:welcomeToTagSpaces')}- </Typography>- <img- style={{- maxHeight: 250,- paddingTop: 15,- paddingBottom: 40,- margin: 'auto',- display: 'block',- }}- src={NewLook}- alt=""- />- <Typography variant="h6">{t('obTryThemes')}</Typography>- <Typography variant="h6"> </Typography>- <ToggleButtonGroup- value={currentTheme}- exclusive- onChange={(event, theme) => {- setCurrentTheme(theme);- }}- >- <TsToggleButton+ <SwiperSlide>+ <Typography variant="h5">+ {t('core:welcomeToTagSpaces')}+ </Typography>+ <imgstyle={{- borderTopRightRadius: 0,- borderBottomRightRadius: 0,+ maxHeight: 250,+ paddingTop: 15,+ paddingBottom: 40,+ margin: 'auto',+ display: 'block',}}- value="light"+ src={NewLook}+ alt=""+ />+ <Typography variant="h6">{t('obTryThemes')}</Typography>+ <Typography variant="h6"> </Typography>+ <ToggleButtonGroup+ value={currentTheme}+ exclusive+ onChange={(event, theme) => {+ setCurrentTheme(theme);+ }}+ >+ <TsToggleButton+ style={{+ borderTopRightRadius: 0,+ borderBottomRightRadius: 0,+ }}+ value="light"+ >+ {t('light')}+ </TsToggleButton>+ <TsToggleButton+ style={{+ borderTopLeftRadius: 0,+ borderBottomLeftRadius: 0,+ }}+ value="dark"+ >+ {t('dark')}+ </TsToggleButton>+ </ToggleButtonGroup>+ </SwiperSlide>+ <SwiperSlide>+ <Typography variant="h5">+ {t('obChooseTaggingTitle')}+ </Typography>+ <Typography variant="h5"> </Typography>+ <FormControl+ style={{ marginTop: 20, marginBottom: 20 }}+ component="fieldset">- {t('light')}- </TsToggleButton>- <TsToggleButton+ <RadioGroup+ aria-label="fileTaggingType"+ name="isPersistTagsInSidecar"+ onChange={toggleTaggingType}+ >+ <FormControlLabel+ value="false"+ control={<Radio checked={!isPersistTagsInSidecar} />}+ label={+ <Typography+ variant="subtitle1"+ style={{ textAlign: 'left' }}+ >+ {t('obChooseTaggingFilename')}+ </Typography>+ }+ />+ <FormControlLabel+ style={{ marginTop: 20 }}+ value="true"+ control={<Radio checked={isPersistTagsInSidecar} />}+ label={+ <Typography+ variant="subtitle1"+ style={{ textAlign: 'left' }}+ >+ {t('obChooseTaggingSidecar')}+ </Typography>+ }+ />+ </RadioGroup>+ </FormControl>+ <img+ style={{ maxHeight: 200, margin: 'auto' }}+ src={ChooseTagging}+ alt=""+ />+ <Typography variant="body2">+ {t('obChooseTaggingClarification')}+ </Typography>+ </SwiperSlide>+ <SwiperSlide>+ <Typography variant="h5" style={{ marginBottom: 20 }}>+ {t('obWebClipperTitle')}+ </Typography>+ <Typography variant="body1">{t('obWebClipperMain')}</Typography>+ <img+ style={{+ maxHeight: 300,+ paddingTop: 15,+ paddingBottom: 20,+ margin: 'auto',+ display: 'block',+ }}+ src={BrowserExtension}+ alt=""+ />+ <Typography variant="body1">+ {t('obWebClipperClarification')}+ </Typography>+ <TsButtonstyle={{- borderTopLeftRadius: 0,- borderBottomLeftRadius: 0,+ marginTop: 20,+ marginLeft: 'auto',+ marginRight: 'auto',+ marginBottom: 20,+ display: 'block',+ }}+ onClick={() => {+ openURLExternally(Links.links.webClipper, true);}}- value="dark">- {t('dark')}- </TsToggleButton>- </ToggleButtonGroup>- </div>- </div>- <div>- <div- style={{- textAlign: 'center',- }}- >- <Typography variant="h5">{t('obChooseTaggingTitle')}</Typography>- <Typography variant="h5"> </Typography>- <FormControl- style={{ marginTop: 20, marginBottom: 20 }}- component="fieldset"- >- <RadioGroup- aria-label="fileTaggingType"- name="isPersistTagsInSidecar"- onChange={toggleTaggingType}+ {t('obWebClipperCTA')}+ </TsButton>+ </SwiperSlide>+ <SwiperSlide>+ <Typography variant="h5" style={{ marginBottom: 20 }}>+ {t('obExplanationsTitle')}+ </Typography>+ <Typography variant="body1">+ {t('obExplanationsMain1')}+ </Typography>+ <img+ style={{+ maxHeight: 300,+ maxWidth: '90%',+ paddingTop: 15,+ paddingBottom: 20,+ margin: 'auto',+ display: 'block',+ }}+ src={Organize}+ alt=""+ />+ <Typography variant="body1">+ {t('obExplanationsMain2')}+ </Typography>+ <TsButton+ style={{+ marginTop: 20,+ marginLeft: 'auto',+ marginRight: 'auto',+ marginBottom: 20,+ display: 'block',+ }}+ onClick={() => {+ openURLExternally(Links.links.productPro, true);+ }}+ >+ {t('obExplanationsCTA')}+ </TsButton>+ </SwiperSlide>+ <SwiperSlide>+ <Typography variant="h5">{t('obFinalTitle')}</Typography>+ <img+ style={{+ maxHeight: 300,+ maxWidth: '90%',+ paddingTop: 70,+ margin: 'auto',+ display: 'block',+ }}+ src={WizardFinished}+ alt=""+ />+ <Typography variant="body1">+ {t('obFinalExplanation')}+ </Typography>+ <TsButton+ style={{+ marginTop: 20,+ marginLeft: 'auto',+ marginRight: 'auto',+ marginBottom: 20,+ display: 'block',+ }}+ onClick={() => {+ onClose();+ closeAllLocations();+ }}>- <FormControlLabel- value="false"- control={<Radio checked={!isPersistTagsInSidecar} />}- label={- <Typography- variant="subtitle1"- style={{ textAlign: 'left' }}- >- {t('obChooseTaggingFilename')}- </Typography>- }- />- <FormControlLabel- style={{ marginTop: 20 }}- value="true"- control={<Radio checked={isPersistTagsInSidecar} />}- label={- <Typography- variant="subtitle1"- style={{ textAlign: 'left' }}- >- {t('obChooseTaggingSidecar')}- </Typography>- }- />- </RadioGroup>- </FormControl>- <img- style={{ maxHeight: 200, margin: 'auto' }}- src={ChooseTagging}- alt=""- />- <Typography variant="body2">- {t('obChooseTaggingClarification')}- </Typography>- </div>- </div>- <div>- <div style={{ textAlign: 'center' }}>- <Typography variant="h5" style={{ marginBottom: 20 }}>- {t('obWebClipperTitle')}- </Typography>- <Typography variant="body1">{t('obWebClipperMain')}</Typography>- <img- style={{- maxHeight: 300,- paddingTop: 15,- paddingBottom: 20,- margin: 'auto',- display: 'block',- }}- src={BrowserExtension}- alt=""- />- <Typography variant="body1">- {t('obWebClipperClarification')}- </Typography>- <TsButton- style={{- marginTop: 20,- marginLeft: 'auto',- marginRight: 'auto',- marginBottom: 20,- display: 'block',- }}- onClick={() => {- openURLExternally(Links.links.webClipper, true);- }}- >- {t('obWebClipperCTA')}- </TsButton>- </div>- </div>- <div>- <div style={{ textAlign: 'center' }}>- <Typography variant="h5" style={{ marginBottom: 20 }}>- {t('obExplanationsTitle')}- </Typography>- <Typography variant="body1">- {t('obExplanationsMain1')}- </Typography>- <img- style={{- maxHeight: 300,- maxWidth: '90%',- paddingTop: 15,- paddingBottom: 20,- margin: 'auto',- display: 'block',- }}- src={Organize}- alt=""- />- <Typography variant="body1">- {t('obExplanationsMain2')}- </Typography>- <TsButton- style={{- marginTop: 20,- marginLeft: 'auto',- marginRight: 'auto',- marginBottom: 20,- display: 'block',- }}- onClick={() => {- openURLExternally(Links.links.productPro, true);- }}- >- {t('obExplanationsCTA')}- </TsButton>- </div>- </div>- <div>- <div style={{ textAlign: 'center' }}>- <Typography variant="h5">{t('obFinalTitle')}</Typography>- <img- style={{- maxHeight: 300,- maxWidth: '90%',- paddingTop: 70,- margin: 'auto',- display: 'block',- }}- src={WizardFinished}- alt=""- />- <Typography variant="body1">{t('obFinalExplanation')}</Typography>- <TsButton- style={{- marginTop: 20,- marginLeft: 'auto',- marginRight: 'auto',- marginBottom: 20,- display: 'block',- }}- onClick={() => {- onClose();- closeAllLocations();- }}- >- {t('startUsingTagSpaces')}- </TsButton>- </div>- </div>- </Slider>+ {t('startUsingTagSpaces')}+ </TsButton>+ </SwiperSlide>+ </Swiper>+ </>+ )}</DialogContent></Dialog>);diff --git a/src/renderer/components/dialogs/ProTeaserDialog.tsx b/src/renderer/components/dialogs/ProTeaserDialog.tsxindex 83426722c..b759c1c29 100644--- a/src/renderer/components/dialogs/ProTeaserDialog.tsx+++ b/src/renderer/components/dialogs/ProTeaserDialog.tsx@@ -17,7 +17,6 @@*/import AppConfig from '-/AppConfig';-import { NavigateBeforeIcon, NavigateNextIcon } from '-/components/CommonIcons';import DraggablePaper from '-/components/DraggablePaper';import TsButton from '-/components/TsButton';import TsDialogTitle from '-/components/dialogs/components/TsDialogTitle';@@ -31,9 +30,12 @@ import Typography from '@mui/material/Typography';import { useTheme } from '@mui/material/styles';import useMediaQuery from '@mui/material/useMediaQuery';import Links from 'assets/links';-import React from 'react';+import React, { useRef } from 'react';import { useTranslation } from 'react-i18next';-import Slider from 'react-slick';+import 'swiper/css';+import 'swiper/css/navigation';+import { Navigation } from 'swiper/modules';+import { Swiper, SwiperSlide } from 'swiper/react';interface Props {open: boolean;@@ -72,10 +74,8 @@ function Slide(props: SlideProps) {return (<divstyle={{- padding: 15,- textAlign: 'left',- overflowY: 'hidden',- overflowX: 'hidden',+ padding: 40,+ marginTop: -40,}}><Typography@@ -158,8 +158,7 @@ function Slide(props: SlideProps) {function ProTeaserDialog(props: Props) {const { t } = useTranslation();- //const swiperElRef = useRef(null); //<SwiperRef>- //const slideIndex = useSelector(getProTeaserIndex);+ const swiperRef = useRef(null);const slidesEN = getProTeaserSlides(t);@@ -168,46 +167,8 @@ function ProTeaserDialog(props: Props) {const theme = useTheme();const smallScreen = useMediaQuery(theme.breakpoints.down('md'));- const slides = [];- for (let index in slidesEN) {- slides.push(<Slide key={index} {...slidesEN[index]} />);- }-const initialSlide = slideIndex && slideIndex > -1 ? Number(slideIndex) : 0;- function NextArrow(props) {- const { className, style, onClick } = props;- return (- <div className={className} onClick={onClick}>- <NavigateNextIcon fontSize="large" color="primary" />- </div>- );- }-- function PrevArrow(props) {- const { className, style, onClick } = props;- return (- <div className={className} onClick={onClick}>- <NavigateBeforeIcon fontSize="large" color="primary" />- </div>- );- }-- const sliderSettings = {- className: 'center',- centerMode: true,- // dots: true,- infinite: false,- initialSlide: initialSlide,- centerPadding: '0px',- speed: 500,- slidesToShow: 1,- slidesToScroll: 1,- adaptiveHeight: true,- nextArrow: <NextArrow />,- prevArrow: <PrevArrow />,- };-return (<Dialogopen={open}@@ -225,27 +186,45 @@ function ProTeaserDialog(props: Props) {/><DialogContentstyle={{- overflowY: 'auto',- overflowX: 'hidden',+ padding: 0,}}>- <style>- {`- .slick-arrow {- height: 200px;- width: 50px;- display: flex;- align-items: center;- }- .slick-next:before {- content: '';- }- .slick-prev:before {- content: '';- }- `}- </style>- <Slider {...sliderSettings}>{slides}</Slider>+ {open && (+ <>+ <style>+ {`+ .pro-teaser-swiper {+ width: 100%;+ height: 100%;+ }+ .swiper-slide {+ height: auto;+ }+ .swiper-button-next,+ .swiper-button-prev {+ color: ${theme.palette.primary.main} !important;+ }+ `}+ </style>+ <Swiper+ ref={swiperRef}+ modules={[Navigation]}+ navigation+ pagination={{ clickable: true }}+ slidesPerView={1}+ speed={500}+ initialSlide={initialSlide}+ loop={false}+ className="pro-teaser-swiper"+ >+ {Object.values(slidesEN).map((slideData, index) => (+ <SwiperSlide key={index}>+ <Slide {...slideData} />+ </SwiperSlide>+ ))}+ </Swiper>+ </>+ )}</DialogContent></Dialog>);