splice-stab-patch
This commit is contained in:
parent
b9705ab8ba
commit
2a80dce98a
|
@ -34,6 +34,7 @@ export const AudioUploader = (props: Props) => {
|
||||||
|
|
||||||
const handleChangeIndex = (direction: 'up' | 'down', index: number) => {
|
const handleChangeIndex = (direction: 'up' | 'down', index: number) => {
|
||||||
const media = [...props.audio]
|
const media = [...props.audio]
|
||||||
|
if (media?.length > 0) {
|
||||||
if (direction === 'up' && index > 0) {
|
if (direction === 'up' && index > 0) {
|
||||||
const copy = media.splice(index, 1)[0]
|
const copy = media.splice(index, 1)[0]
|
||||||
media.splice(index - 1, 0, copy)
|
media.splice(index - 1, 0, copy)
|
||||||
|
@ -41,6 +42,7 @@ export const AudioUploader = (props: Props) => {
|
||||||
const copy = media.splice(index, 1)[0]
|
const copy = media.splice(index, 1)[0]
|
||||||
media.splice(index + 1, 0, copy)
|
media.splice(index + 1, 0, copy)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
props.onAudioSorted(media)
|
props.onAudioSorted(media)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -146,7 +146,7 @@ export const EditView = (props: Props) => {
|
||||||
|
|
||||||
const handleMediaDelete = (index) => {
|
const handleMediaDelete = (index) => {
|
||||||
const copy = [...mediaItems()]
|
const copy = [...mediaItems()]
|
||||||
copy.splice(index, 1)
|
if (copy?.length > 0) copy.splice(index, 1)
|
||||||
handleInputChange('media', JSON.stringify(copy))
|
handleInputChange('media', JSON.stringify(copy))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -121,6 +121,7 @@ export const EditorSwiper = (props: Props) => {
|
||||||
|
|
||||||
const handleChangeIndex = (direction: 'left' | 'right', index: number) => {
|
const handleChangeIndex = (direction: 'left' | 'right', index: number) => {
|
||||||
const images = [...props.images]
|
const images = [...props.images]
|
||||||
|
if (images?.length > 0) {
|
||||||
if (direction === 'left' && index > 0) {
|
if (direction === 'left' && index > 0) {
|
||||||
const copy = images.splice(index, 1)[0]
|
const copy = images.splice(index, 1)[0]
|
||||||
images.splice(index - 1, 0, copy)
|
images.splice(index - 1, 0, copy)
|
||||||
|
@ -133,6 +134,7 @@ export const EditorSwiper = (props: Props) => {
|
||||||
mainSwipeRef.current.swiper.slideTo(direction === 'left' ? index - 1 : index + 1)
|
mainSwipeRef.current.swiper.slideTo(direction === 'left' ? index - 1 : index + 1)
|
||||||
}, 0)
|
}, 0)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const handleSaveBeforeSlideChange = () => {
|
const handleSaveBeforeSlideChange = () => {
|
||||||
handleSlideDescriptionChange(slideIndex(), 'body', slideBody())
|
handleSlideDescriptionChange(slideIndex(), 'body', slideBody())
|
||||||
|
|
|
@ -184,7 +184,7 @@ function initServerProvider() {
|
||||||
const index = tags.findIndex(
|
const index = tags.findIndex(
|
||||||
(prev) => prev.tag === tagDesc.tag && getTagKey(prev, properties) === tagDescKey,
|
(prev) => prev.tag === tagDesc.tag && getTagKey(prev, properties) === tagDescKey,
|
||||||
)
|
)
|
||||||
if (index !== -1) {
|
if (index !== -1 && tags?.length > 0) {
|
||||||
tags.splice(index, 1)
|
tags.splice(index, 1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user