Skip to content

Commit 566baa0

Browse files
authored
✨ enhance image handling in handleHTMLImgs to adjust float style (#135)
* ✨ enhance image handling in handleHTMLImgs to adjust float style for parent elements containing only images * ✨ reorder imports in AIOverview.vue for better organization and readability
1 parent 0551fc9 commit 566baa0

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

apps/slax-reader-dweb/layers/core/components/Article/BookmarkArticle.vue

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,21 @@ const handleHTMLImgs = (imgs: HTMLImageElement[]) => {
279279
}
280280
281281
img.classList.add(loadingKey)
282+
283+
const parentElement = img.parentElement
284+
const parentChilds = parentElement ? Array.from(parentElement.childNodes) : []
285+
286+
const isOnlyImages = parentChilds.every(child => {
287+
if (child.nodeType === Node.ELEMENT_NODE) {
288+
const element = child as HTMLElement
289+
return element.tagName.toLowerCase() === 'img'
290+
}
291+
return true
292+
})
293+
294+
if (isOnlyImages) {
295+
img.style.cssFloat = 'none'
296+
}
282297
})
283298
}
284299

apps/slax-reader-extensions/src/components/AIOverview.vue

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,16 @@
3434
</template>
3535

3636
<script lang="ts" setup>
37-
import type { BookmarkBriefDetail, BookmarkTag } from '@commons/types/interface'
3837
import BookmarkTags from './BookmarkTags.vue'
39-
import { RESTMethodPath } from '@commons/types/const'
40-
import { RequestMethodType } from '@commons/utils/request'
41-
import Toast, { ToastType } from './Toast'
42-
import MarkdownText from './Markdown/MarkdownText.vue'
4338
import DotLoading from './DotLoading.vue'
39+
import MarkdownText from './Markdown/MarkdownText.vue'
40+
4441
import { Resize } from '@commons/utils/directive'
42+
import { RequestMethodType } from '@commons/utils/request'
43+
44+
import Toast, { ToastType } from './Toast'
45+
import { RESTMethodPath } from '@commons/types/const'
46+
import type { BookmarkBriefDetail, BookmarkTag } from '@commons/types/interface'
4547
4648
type OverviewSocketData =
4749
| {

0 commit comments

Comments
 (0)