chore: 恢复开发文档全目录进库并同步阅读页与脚本改动
Made-with: Cursor
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
* { type: 'mention', userId, nickname } — @某人,点击加好友(提交存客宝见 utils/soulBridge.submitCkbLead)
|
||||
* { type: 'linkTag', label, url, ... } — #链接标签,点击跳转(阅读页 onLinkTagTap:外链→link-preview、小程序→navigateToMiniProgram)
|
||||
* { type: 'image', src, alt } — 图片
|
||||
* { type: 'video', src } — 正文内嵌视频(管理端 rich-video-wrap / <video>)
|
||||
*/
|
||||
|
||||
/** 判断内容是否为 HTML */
|
||||
@@ -249,6 +250,24 @@ function parseHtmlToSegments(html, config) {
|
||||
return '\n__Q_' + idx + '__\n'
|
||||
})
|
||||
|
||||
// 2.5 内嵌视频:去掉管理端「rich-video-caption」说明(仅编辑器用);整段 <video> 抽成占位
|
||||
// 须在列表拆解之前执行,否则 li/段落内 video 会在 parseBlockToSegments 里被 strip 成纯文本
|
||||
const videos = []
|
||||
text = text.replace(/<div[^>]*\brich-video-caption\b[^>]*>[\s\S]*?<\/div>/gi, '')
|
||||
text = text.replace(/<video\b[^>]*>[\s\S]*?<\/video>/gi, function (match) {
|
||||
const sm = match.match(/\bsrc\s*=\s*"([^"]*)"/i) || match.match(/\bsrc\s*=\s*'([^']*)'/i)
|
||||
const rawSrc = sm ? String(sm[1] || '').trim() : ''
|
||||
if (!rawSrc) return match
|
||||
const decoded = decodeEntities(rawSrc)
|
||||
const src =
|
||||
config && config.assetBase
|
||||
? resolveArticleImageSrc(decoded, config.assetBase)
|
||||
: resolveArticleImageSrc(decoded, '')
|
||||
const idx = videos.length
|
||||
videos.push({ src })
|
||||
return '\n__VIDEO_' + idx + '__\n'
|
||||
})
|
||||
|
||||
// 3. 列表 → listItem 占位(保留 ordered 标记)
|
||||
var olDepth = 0
|
||||
var olCounter = 0
|
||||
@@ -259,6 +278,11 @@ function parseHtmlToSegments(html, config) {
|
||||
text = text.replace(/<li[^>]*>([\s\S]*?)<\/li>/gi, function (_, inner) {
|
||||
var cleaned = inner.replace(/<p[^>]*>/gi, '').replace(/<\/p>/gi, '').trim()
|
||||
if (!cleaned) return '\n'
|
||||
// 列表项内仅有视频占位时,提升为独立视频块(避免 __VIDEO_n__ 当正文展示)
|
||||
var onlyVid = cleaned.match(/^__VIDEO_(\d+)__$/)
|
||||
if (onlyVid) {
|
||||
return '\n__VIDEO_' + onlyVid[1] + '__\n'
|
||||
}
|
||||
if (olDepth > 0) {
|
||||
olCounter++
|
||||
return '\n__LI_O_' + olCounter + '__ ' + cleaned + '\n'
|
||||
@@ -292,6 +316,17 @@ function parseHtmlToSegments(html, config) {
|
||||
continue
|
||||
}
|
||||
|
||||
// video
|
||||
var vidM = block.trim().match(/^__VIDEO_(\d+)__$/)
|
||||
if (vidM) {
|
||||
var vid = videos[parseInt(vidM[1], 10)]
|
||||
if (vid && vid.src) {
|
||||
lines.push('')
|
||||
segments.push([{ type: 'video', src: vid.src }])
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
// heading
|
||||
var hM = block.trim().match(/^__H_(\d+)__$/)
|
||||
if (hM) {
|
||||
|
||||
Reference in New Issue
Block a user