diff --git a/app/appearance/langs/ar_SA.json b/app/appearance/langs/ar_SA.json index 98ba31de5..0c1cc2e6d 100644 --- a/app/appearance/langs/ar_SA.json +++ b/app/appearance/langs/ar_SA.json @@ -1,4 +1,5 @@ { + "contentBlock": "كتلة المحتوى", "insertItemBefore": "إدراج ${x} عنصر(عناصر) قبل", "insertItemAfter": "إدراج ${x} عنصر(عناصر) بعد", "allViews": "جميع العروض", diff --git a/app/appearance/langs/de_DE.json b/app/appearance/langs/de_DE.json index 6a3dfa1d8..d0c1e6454 100644 --- a/app/appearance/langs/de_DE.json +++ b/app/appearance/langs/de_DE.json @@ -1,4 +1,5 @@ { + "contentBlock": "Inhaltsblock", "insertItemBefore": "${x} Element(e) davor einfügen", "insertItemAfter": "${x} Element(e) danach einfügen", "allViews": "Alle Ansichten", diff --git a/app/appearance/langs/en_US.json b/app/appearance/langs/en_US.json index 98569b49e..88cd55c12 100644 --- a/app/appearance/langs/en_US.json +++ b/app/appearance/langs/en_US.json @@ -1,4 +1,5 @@ { + "contentBlock": "Content block", "insertItemBefore": "Insert ${x} item(s) before", "insertItemAfter": "Insert ${x} item(s) after", "allViews": "All views", diff --git a/app/appearance/langs/es_ES.json b/app/appearance/langs/es_ES.json index 8db9b43fe..3f6b7a8a9 100644 --- a/app/appearance/langs/es_ES.json +++ b/app/appearance/langs/es_ES.json @@ -1,4 +1,5 @@ { + "contentBlock": "Bloque de contenido", "insertItemBefore": "Insertar ${x} elemento(s) antes", "insertItemAfter": "Insertar ${x} elemento(s) después", "allViews": "Todas las vistas", diff --git a/app/appearance/langs/fr_FR.json b/app/appearance/langs/fr_FR.json index e9f9a5c90..25d9aa2ca 100644 --- a/app/appearance/langs/fr_FR.json +++ b/app/appearance/langs/fr_FR.json @@ -1,4 +1,5 @@ { + "contentBlock": "Bloc de contenu", "insertItemBefore": "Insérer ${x} élément(s) avant", "insertItemAfter": "Insérer ${x} élément(s) après", "allViews": "Toutes les vues", diff --git a/app/appearance/langs/he_IL.json b/app/appearance/langs/he_IL.json index 07754caa8..144ac54a7 100644 --- a/app/appearance/langs/he_IL.json +++ b/app/appearance/langs/he_IL.json @@ -1,4 +1,5 @@ { + "contentBlock": "בלוק תוכן", "insertItemBefore": "הוסף ${x} פריט(ים) לפני", "insertItemAfter": "הוסף ${x} פריט(ים) אחרי", "allViews": "כל התצוגות", diff --git a/app/appearance/langs/it_IT.json b/app/appearance/langs/it_IT.json index fbb9104e8..2f97ff01a 100644 --- a/app/appearance/langs/it_IT.json +++ b/app/appearance/langs/it_IT.json @@ -1,4 +1,5 @@ { + "contentBlock": "Blocco di contenuto", "insertItemBefore": "Inserisci ${x} elemento(i) prima", "insertItemAfter": "Inserisci ${x} elemento(i) dopo", "allViews": "Tutte le viste", diff --git a/app/appearance/langs/ja_JP.json b/app/appearance/langs/ja_JP.json index e21ed06a8..eaecc868b 100644 --- a/app/appearance/langs/ja_JP.json +++ b/app/appearance/langs/ja_JP.json @@ -1,4 +1,5 @@ { + "contentBlock": "コンテンツブロック", "insertItemBefore": "${x}項目を前に挿入", "insertItemAfter": "${x}項目を後に挿入", "allViews": "すべてのビュー", diff --git a/app/appearance/langs/pl_PL.json b/app/appearance/langs/pl_PL.json index d627a1634..9dd6b6e28 100644 --- a/app/appearance/langs/pl_PL.json +++ b/app/appearance/langs/pl_PL.json @@ -1,4 +1,5 @@ { + "contentBlock": "Blok treści", "insertItemBefore": "Wstaw ${x} element(y) przed", "insertItemAfter": "Wstaw ${x} element(y) po", "allViews": "Wszystkie widoki", diff --git a/app/appearance/langs/pt_BR.json b/app/appearance/langs/pt_BR.json index 1cc73aab9..a900204f5 100644 --- a/app/appearance/langs/pt_BR.json +++ b/app/appearance/langs/pt_BR.json @@ -1,4 +1,5 @@ { + "contentBlock": "Bloco de conteúdo", "insertItemBefore": "Inserir ${x} item(ns) antes", "insertItemAfter": "Inserir ${x} item(ns) depois", "allViews": "Todas as visualizações", diff --git a/app/appearance/langs/ru_RU.json b/app/appearance/langs/ru_RU.json index 651c105b6..613d83dea 100644 --- a/app/appearance/langs/ru_RU.json +++ b/app/appearance/langs/ru_RU.json @@ -1,4 +1,5 @@ { + "contentBlock": "Блок контента", "insertItemBefore": "Вставить ${x} элемент(ов) перед", "insertItemAfter": "Вставить ${x} элемент(ов) после", "allViews": "Все виды", diff --git a/app/appearance/langs/zh_CHT.json b/app/appearance/langs/zh_CHT.json index a49236a10..5f2fdfcec 100644 --- a/app/appearance/langs/zh_CHT.json +++ b/app/appearance/langs/zh_CHT.json @@ -1,4 +1,5 @@ { + "contentBlock": "內容塊", "insertItemBefore": "在前方插入${x}條", "insertItemAfter": "在後方插入${x}條", "allViews": "所有視圖", diff --git a/app/appearance/langs/zh_CN.json b/app/appearance/langs/zh_CN.json index 16dc3efc6..e3fc4ff40 100644 --- a/app/appearance/langs/zh_CN.json +++ b/app/appearance/langs/zh_CN.json @@ -1,4 +1,5 @@ { + "contentBlock": "内容块", "insertItemBefore": "在前方插入${x}条", "insertItemAfter": "在后方插入${x}条", "allViews": "所有视图", diff --git a/app/src/types/index.d.ts b/app/src/types/index.d.ts index 3dbece0e2..61cd61155 100644 --- a/app/src/types/index.d.ts +++ b/app/src/types/index.d.ts @@ -850,7 +850,7 @@ interface IAVTable extends IAVView { } interface IAVGallery extends IAVView { - coverFrom: number; // 0:无,1:内容图,2:资源字段 + coverFrom: number; // 0:无,1:内容图,2:资源字段,3:内容块 coverFromAssetKeyID?: string; cardSize: number; // 0:小卡片,1:中卡片,2:大卡片 cardAspectRatio: number; diff --git a/kernel/av/layout_gallery.go b/kernel/av/layout_gallery.go index 1fc42ab37..885ddb585 100644 --- a/kernel/av/layout_gallery.go +++ b/kernel/av/layout_gallery.go @@ -77,6 +77,7 @@ const ( CoverFromNone CoverFrom = iota // 无封面 CoverFromContentImage // 内容图 CoverFromAssetField // 资源字段 + CoverFromContentBlock // 内容块 ) // ViewGalleryCardField 描述了画廊卡片字段的结构。 diff --git a/kernel/sql/av_gallery.go b/kernel/sql/av_gallery.go index 51bd4229f..d9b494b5e 100644 --- a/kernel/sql/av_gallery.go +++ b/kernel/sql/av_gallery.go @@ -195,19 +195,7 @@ func fillAttributeViewGalleryCardCover(attrView *av.AttributeView, view *av.View }) if "" == galleryCard.CoverURL { - isDoc := ast.NodeDocument == node.Type - if isDoc { - node = node.FirstChild - } - - buf := bytes.Buffer{} - for c := node; nil != c; c = c.Next { - buf.WriteString(renderBlockDOMByNode(c, luteEngine)) - if !isDoc || 1024*4 < buf.Len() { - break - } - } - galleryCard.CoverContent = buf.String() + galleryCard.CoverContent = renderCoverContentBlock(node, luteEngine) return } case av.CoverFromAssetField: @@ -222,9 +210,40 @@ func fillAttributeViewGalleryCardCover(attrView *av.AttributeView, view *av.View galleryCard.CoverURL = assetValue.MAsset[0].Content return + case av.CoverFromContentBlock: + blockValue := getBlockValue(cardValues) + if blockValue.IsDetached { + break + } + + tree := trees[blockValue.BlockID] + if nil == tree { + break + } + node := treenode.GetNodeInTree(tree, blockValue.BlockID) + if nil == node { + break + } + galleryCard.CoverContent = renderCoverContentBlock(node, luteEngine) } } +func renderCoverContentBlock(node *ast.Node, luteEngine *lute.Lute) string { + isDoc := ast.NodeDocument == node.Type + if isDoc { + node = node.FirstChild + } + + buf := bytes.Buffer{} + for c := node; nil != c; c = c.Next { + buf.WriteString(renderBlockDOMByNode(c, luteEngine)) + if !isDoc || 1024*4 < buf.Len() { + break + } + } + return buf.String() +} + func renderBlockDOMByNode(node *ast.Node, luteEngine *lute.Lute) string { tree := &parse.Tree{Root: &ast.Node{Type: ast.NodeDocument}, Context: &parse.Context{ParseOption: luteEngine.ParseOptions}} blockRenderer := render.NewProtyleRenderer(tree, luteEngine.RenderOptions)