isserver-fixes
This commit is contained in:
parent
9b257912c8
commit
5c98489a67
|
@ -1,5 +1,6 @@
|
||||||
import type { Editor } from '@tiptap/core'
|
import type { Editor } from '@tiptap/core'
|
||||||
import { Show, createEffect, createSignal } from 'solid-js'
|
import { Show, createEffect, createSignal } from 'solid-js'
|
||||||
|
import { isServer } from 'solid-js/web'
|
||||||
import { renderUploadedImage } from '~/components/Upload/renderUploadedImage'
|
import { renderUploadedImage } from '~/components/Upload/renderUploadedImage'
|
||||||
import { Icon } from '~/components/_shared/Icon'
|
import { Icon } from '~/components/_shared/Icon'
|
||||||
import { useLocalize } from '~/context/localize'
|
import { useLocalize } from '~/context/localize'
|
||||||
|
@ -23,6 +24,7 @@ const embedData = (data: string) => {
|
||||||
const element = document.createRange().createContextualFragment(data)
|
const element = document.createRange().createContextualFragment(data)
|
||||||
const { attributes } = element.firstChild as HTMLIFrameElement
|
const { attributes } = element.firstChild as HTMLIFrameElement
|
||||||
const result: { src: string; width?: string; height?: string } = { src: '' }
|
const result: { src: string; width?: string; height?: string } = { src: '' }
|
||||||
|
if (isServer) return result
|
||||||
|
|
||||||
for (let i = 0; i < attributes.length; i++) {
|
for (let i = 0; i < attributes.length; i++) {
|
||||||
const attribute = attributes.item(i)
|
const attribute = attributes.item(i)
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import { A, redirect, useSearchParams } from '@solidjs/router'
|
import { A, redirect, useSearchParams } from '@solidjs/router'
|
||||||
import { clsx } from 'clsx'
|
import { clsx } from 'clsx'
|
||||||
import { Show, createEffect, createSignal, onCleanup, onMount } from 'solid-js'
|
import { Show, createEffect, createSignal, onCleanup, onMount } from 'solid-js'
|
||||||
|
import { isServer } from 'solid-js/web'
|
||||||
import { useLocalize } from '~/context/localize'
|
import { useLocalize } from '~/context/localize'
|
||||||
import { useSession } from '~/context/session'
|
import { useSession } from '~/context/session'
|
||||||
import { useUI } from '~/context/ui'
|
import { useUI } from '~/context/ui'
|
||||||
|
@ -53,6 +54,7 @@ export const Header = (props: Props) => {
|
||||||
let windowScrollTop = 0
|
let windowScrollTop = 0
|
||||||
|
|
||||||
createEffect(() => {
|
createEffect(() => {
|
||||||
|
if (isServer) return
|
||||||
const mainContent = document.querySelector<HTMLDivElement>('.main-content')
|
const mainContent = document.querySelector<HTMLDivElement>('.main-content')
|
||||||
|
|
||||||
if (fixed() || modal() !== null) {
|
if (fixed() || modal() !== null) {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { clsx } from 'clsx'
|
import { clsx } from 'clsx'
|
||||||
import { Show, createEffect, createMemo, createSignal, on, onCleanup, onMount } from 'solid-js'
|
import { Show, createEffect, createMemo, createSignal, on, onCleanup, onMount } from 'solid-js'
|
||||||
|
import { isServer } from 'solid-js/web'
|
||||||
import { throttle } from 'throttle-debounce'
|
import { throttle } from 'throttle-debounce'
|
||||||
|
|
||||||
import { useLocalize } from '~/context/localize'
|
import { useLocalize } from '~/context/localize'
|
||||||
import { PAGE_SIZE, useNotifications } from '~/context/notifications'
|
import { PAGE_SIZE, useNotifications } from '~/context/notifications'
|
||||||
import { useSession } from '~/context/session'
|
import { useSession } from '~/context/session'
|
||||||
|
@ -9,7 +9,6 @@ import { useEscKeyDownHandler } from '~/lib/useEscKeyDownHandler'
|
||||||
import { useOutsideClickHandler } from '~/lib/useOutsideClickHandler'
|
import { useOutsideClickHandler } from '~/lib/useOutsideClickHandler'
|
||||||
import { Button } from '../_shared/Button'
|
import { Button } from '../_shared/Button'
|
||||||
import { Icon } from '../_shared/Icon'
|
import { Icon } from '../_shared/Icon'
|
||||||
|
|
||||||
import { EmptyMessage } from './EmptyMessage'
|
import { EmptyMessage } from './EmptyMessage'
|
||||||
import { NotificationGroup } from './NotificationView/NotificationGroup'
|
import { NotificationGroup } from './NotificationView/NotificationGroup'
|
||||||
|
|
||||||
|
@ -72,6 +71,7 @@ export const NotificationsPanel = (props: Props) => {
|
||||||
let windowScrollTop = 0
|
let windowScrollTop = 0
|
||||||
|
|
||||||
createEffect(() => {
|
createEffect(() => {
|
||||||
|
if (isServer) return
|
||||||
const mainContent = document.querySelector<HTMLDivElement>('.main-content')
|
const mainContent = document.querySelector<HTMLDivElement>('.main-content')
|
||||||
|
|
||||||
if (props.isOpen && mainContent && window) {
|
if (props.isOpen && mainContent && window) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { clsx } from 'clsx'
|
import { clsx } from 'clsx'
|
||||||
import { Show, createEffect, createMemo, createSignal, on, onCleanup } from 'solid-js'
|
import { Show, createEffect, createMemo, createSignal, on, onCleanup, onMount } from 'solid-js'
|
||||||
|
|
||||||
import { getImageUrl } from '~/lib/getThumbUrl'
|
import { getImageUrl } from '~/lib/getThumbUrl'
|
||||||
import { useEscKeyDownHandler } from '~/lib/useEscKeyDownHandler'
|
import { useEscKeyDownHandler } from '~/lib/useEscKeyDownHandler'
|
||||||
|
@ -23,7 +23,7 @@ export const Lightbox = (props: Props) => {
|
||||||
const [translateX, setTranslateX] = createSignal(0)
|
const [translateX, setTranslateX] = createSignal(0)
|
||||||
const [translateY, setTranslateY] = createSignal(0)
|
const [translateY, setTranslateY] = createSignal(0)
|
||||||
const [transitionEnabled, setTransitionEnabled] = createSignal(false)
|
const [transitionEnabled, setTransitionEnabled] = createSignal(false)
|
||||||
let lightboxRef: HTMLElement | null
|
const [lightboxRef, setLightboxRef] = createSignal<HTMLDivElement | undefined>()
|
||||||
|
|
||||||
const handleSmoothAction = (action: () => void) => {
|
const handleSmoothAction = (action: () => void) => {
|
||||||
setTransitionEnabled(true)
|
setTransitionEnabled(true)
|
||||||
|
@ -32,11 +32,8 @@ export const Lightbox = (props: Props) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const closeLightbox = () => {
|
const closeLightbox = () => {
|
||||||
lightboxRef?.classList.add(styles.fadeOut)
|
lightboxRef()?.classList.add(styles.fadeOut)
|
||||||
|
setTimeout(props.onClose, 200)
|
||||||
setTimeout(() => {
|
|
||||||
props.onClose()
|
|
||||||
}, 200)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const zoomIn = (event: MouseEvent & { currentTarget: HTMLButtonElement; target: Element }) => {
|
const zoomIn = (event: MouseEvent & { currentTarget: HTMLButtonElement; target: Element }) => {
|
||||||
|
@ -88,30 +85,30 @@ export const Lightbox = (props: Props) => {
|
||||||
|
|
||||||
useEscKeyDownHandler(closeLightbox)
|
useEscKeyDownHandler(closeLightbox)
|
||||||
|
|
||||||
let startX = 0
|
const [startX, setStartX] = createSignal(0)
|
||||||
let startY = 0
|
const [startY, setStartY] = createSignal(0)
|
||||||
let isDragging = false
|
const [isDragging, setIsDragging] = createSignal(false)
|
||||||
|
|
||||||
const onMouseDown: (event: MouseEvent) => void = (event) => {
|
const onMouseDown: (event: MouseEvent) => void = (event) => {
|
||||||
startX = event.clientX - translateX()
|
setStartX(event.clientX - translateX())
|
||||||
startY = event.clientY - translateY()
|
setStartY(event.clientY - translateY())
|
||||||
isDragging = true
|
setIsDragging(true)
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
}
|
}
|
||||||
|
|
||||||
const onMouseMove: (event: MouseEvent) => void = (event) => {
|
const onMouseMove: (event: MouseEvent) => void = (event) => {
|
||||||
if (isDragging) {
|
if (isDragging()) {
|
||||||
setTranslateX(event.clientX - startX)
|
setTranslateX(event.clientX - startX())
|
||||||
setTranslateY(event.clientY - startY)
|
setTranslateY(event.clientY - startY())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const onMouseUp: () => void = () => {
|
const onMouseUp = () => setIsDragging(false)
|
||||||
isDragging = false
|
|
||||||
}
|
|
||||||
|
|
||||||
document.addEventListener('mousemove', onMouseMove)
|
onMount(() => {
|
||||||
document.addEventListener('mouseup', onMouseUp)
|
document.addEventListener('mousemove', onMouseMove)
|
||||||
|
document.addEventListener('mouseup', onMouseUp)
|
||||||
|
})
|
||||||
|
|
||||||
onCleanup(() => {
|
onCleanup(() => {
|
||||||
document.removeEventListener('mousemove', onMouseMove)
|
document.removeEventListener('mousemove', onMouseMove)
|
||||||
|
@ -125,7 +122,6 @@ export const Lightbox = (props: Props) => {
|
||||||
}))
|
}))
|
||||||
|
|
||||||
let fadeTimer: string | number | NodeJS.Timeout
|
let fadeTimer: string | number | NodeJS.Timeout
|
||||||
|
|
||||||
createEffect(
|
createEffect(
|
||||||
on(
|
on(
|
||||||
zoomLevel,
|
zoomLevel,
|
||||||
|
@ -147,7 +143,7 @@ export const Lightbox = (props: Props) => {
|
||||||
class={clsx(styles.Lightbox, props.class)}
|
class={clsx(styles.Lightbox, props.class)}
|
||||||
onClick={closeLightbox}
|
onClick={closeLightbox}
|
||||||
onWheel={(e) => e.preventDefault()}
|
onWheel={(e) => e.preventDefault()}
|
||||||
ref={(el) => (lightboxRef = el)}
|
ref={setLightboxRef}
|
||||||
>
|
>
|
||||||
<Show when={pictureScalePercentage()}>
|
<Show when={pictureScalePercentage()}>
|
||||||
<div class={styles.scalePercentage}>{`${pictureScalePercentage()}%`}</div>
|
<div class={styles.scalePercentage}>{`${pictureScalePercentage()}%`}</div>
|
||||||
|
|
|
@ -70,11 +70,3 @@ export function createTooltip(referenceElement?: Element, tooltipElement?: HTMLE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Usage example
|
|
||||||
const referenceElement = document.querySelector('#reference')
|
|
||||||
const tooltipElement = document.querySelector('#tooltip')
|
|
||||||
createTooltip(referenceElement as HTMLElement, tooltipElement as HTMLElement, {
|
|
||||||
placement: 'top',
|
|
||||||
offset: [0, 8]
|
|
||||||
})
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user