Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
Vanessa 2022-10-17 11:43:46 +08:00
commit 23651ad9d9
12 changed files with 30 additions and 11 deletions

View file

@ -1,4 +1,5 @@
{
"breadcrumb": "Breadcrumb",
"embedBlockBreadcrumb": "Embed Block Breadcrumb",
"embedBlockBreadcrumbTip": "After enabling embed block will show breadcrumbs",
"appearanceMode": "Appearance Mode",

View file

@ -1,4 +1,5 @@
{
"miga de pan": "Miga de pan",
"embedBlockBreadcrumb": "Incrustar migas de pan de bloque",
"embedBlockBreadcrumbTip": "Después de habilitar el bloque incrustado, se mostrarán migas de pan",
"appearanceMode": "Modo de apariencia",

View file

@ -1,4 +1,5 @@
{
"fil d'Ariane": "Fil d'Ariane",
"embedBlockBreadcrumb": "Intégrer le fil d'Ariane du bloc",
"embedBlockBreadcrumbTip": "Après avoir activé le bloc d'intégration, le fil d'Ariane s'affichera",
"appearanceMode": "Mode d'apparence",

View file

@ -1,4 +1,5 @@
{
"breadcrumb": "麵包屑",
"embedBlockBreadcrumb": "嵌入塊麵包屑",
"embedBlockBreadcrumbTip": "啟用後嵌入塊將顯示麵包屑",
"appearanceMode": "外觀模式",

View file

@ -1,4 +1,5 @@
{
"breadcrumb": "面包屑",
"embedBlockBreadcrumb": "嵌入块面包屑",
"embedBlockBreadcrumbTip": "启用后嵌入块将显示面包屑",
"appearanceMode": "外观模式",

File diff suppressed because one or more lines are too long

View file

@ -138,8 +138,13 @@ func searchEmbedBlock(c *gin.Context) {
if nil != headingModeArg {
headingMode = int(headingModeArg.(float64))
}
breadcrumb := false
breadcrumbArg := arg["breadcrumb"]
if nil != breadcrumbArg {
breadcrumb = breadcrumbArg.(bool)
}
blocks := model.SearchEmbedBlock(stmt, excludeIDs, headingMode)
blocks := model.SearchEmbedBlock(stmt, excludeIDs, headingMode, breadcrumb)
ret.Data = map[string]interface{}{
"blocks": blocks,
}

View file

@ -6,7 +6,7 @@ require (
github.com/88250/clipboard v0.1.5
github.com/88250/css v0.1.2
github.com/88250/gulu v1.2.3-0.20221007162906-ded80d955178
github.com/88250/lute v1.7.5-0.20221016161716-7eb0cc34cd93
github.com/88250/lute v1.7.5-0.20221017025933-73f0193d2ef2
github.com/88250/pdfcpu v0.3.13
github.com/88250/vitess-sqlparser v0.0.0-20210205111146-56a2ded2aba1
github.com/ConradIrwin/font v0.0.0-20210318200717-ce8d41cc0732

View file

@ -27,6 +27,8 @@ github.com/88250/lute v1.7.5-0.20221016091231-5b3f92fac78a h1:KUtNpX01Dx2GOv9Da6
github.com/88250/lute v1.7.5-0.20221016091231-5b3f92fac78a/go.mod h1:cEoBGi0zArPqAsp0MdG9SKinvH/xxZZWXU7sRx8vHSA=
github.com/88250/lute v1.7.5-0.20221016161716-7eb0cc34cd93 h1:3JaFT1DfYBJ1SlscaEGW5jDbQOlhYjVtLYFrsXGCxxg=
github.com/88250/lute v1.7.5-0.20221016161716-7eb0cc34cd93/go.mod h1:cEoBGi0zArPqAsp0MdG9SKinvH/xxZZWXU7sRx8vHSA=
github.com/88250/lute v1.7.5-0.20221017025933-73f0193d2ef2 h1:P+dYHdkf5p9onVVgDhBCaxOCy7Mo9Xtmelc+0bksiIA=
github.com/88250/lute v1.7.5-0.20221017025933-73f0193d2ef2/go.mod h1:cEoBGi0zArPqAsp0MdG9SKinvH/xxZZWXU7sRx8vHSA=
github.com/88250/pdfcpu v0.3.13 h1:touMWMZkCGalMIbEg9bxYp7rETM+zwb9hXjwhqi4I7Q=
github.com/88250/pdfcpu v0.3.13/go.mod h1:S5YT38L/GCjVjmB4PB84PymA1qfopjEhfhTNQilLpv4=
github.com/88250/vitess-sqlparser v0.0.0-20210205111146-56a2ded2aba1 h1:48T899JQDwyyRu9yXHePYlPdHtpJfrJEUGBMH3SMBWY=

View file

@ -381,7 +381,7 @@ func getBlock(id string) (ret *Block, err error) {
return
}
func getEmbeddedBlock(trees map[string]*parse.Tree, sqlBlock *sql.Block, headingMode int) (block *Block, blockPaths []*BlockPath) {
func getEmbeddedBlock(trees map[string]*parse.Tree, sqlBlock *sql.Block, headingMode int, breadcrumb bool) (block *Block, blockPaths []*BlockPath) {
tree, _ := trees[sqlBlock.RootID]
if nil == tree {
tree, _ = loadTreeByBlockID(sqlBlock.RootID)
@ -434,8 +434,15 @@ func getEmbeddedBlock(trees map[string]*parse.Tree, sqlBlock *sql.Block, heading
luteEngine.RenderOptions.ProtyleContenteditable = false // 不可编辑
dom := renderBlockDOMByNodes(nodes, luteEngine)
block = &Block{Box: def.Box, Path: def.Path, HPath: b.HPath, ID: def.ID, Type: def.Type.String(), Content: dom}
if Conf.Editor.EmbedBlockBreadcrumb {
blockPaths = buildBlockBreadcrumb(def)
defBreadCrumb := def.IALAttr("breadcrumb")
if "" != defBreadCrumb {
if "true" == defBreadCrumb {
blockPaths = buildBlockBreadcrumb(def)
}
} else {
if Conf.Editor.EmbedBlockBreadcrumb {
blockPaths = buildBlockBreadcrumb(def)
}
}
if 1 > len(blockPaths) {
blockPaths = []*BlockPath{}

View file

@ -1041,7 +1041,7 @@ func exportTree(tree *parse.Tree, wysiwyg, expandKaTexMacros, keepFold bool) (re
var defMd string
stmt := n.ChildByType(ast.NodeBlockQueryEmbedScript).TokensStr()
stmt = html.UnescapeString(stmt)
embedBlocks := searchEmbedBlock(stmt, nil, 0)
embedBlocks := searchEmbedBlock(stmt, nil, 0, false)
if 1 > len(embedBlocks) {
return ast.WalkContinue
}

View file

@ -43,12 +43,12 @@ type EmbedBlock struct {
BlockPaths []*BlockPath `json:"blockPaths"`
}
func SearchEmbedBlock(stmt string, excludeIDs []string, headingMode int) (ret []*EmbedBlock) {
func SearchEmbedBlock(stmt string, excludeIDs []string, headingMode int, breadcrumb bool) (ret []*EmbedBlock) {
WaitForWritingFiles()
return searchEmbedBlock(stmt, excludeIDs, headingMode)
return searchEmbedBlock(stmt, excludeIDs, headingMode, breadcrumb)
}
func searchEmbedBlock(stmt string, excludeIDs []string, headingMode int) (ret []*EmbedBlock) {
func searchEmbedBlock(stmt string, excludeIDs []string, headingMode int, breadcrumb bool) (ret []*EmbedBlock) {
sqlBlocks := sql.SelectBlocksRawStmtNoParse(stmt, Conf.Search.Limit)
var tmp []*sql.Block
for _, b := range sqlBlocks {
@ -76,7 +76,7 @@ func searchEmbedBlock(stmt string, excludeIDs []string, headingMode int) (ret []
}
for _, sb := range sqlBlocks {
block, blockPaths := getEmbeddedBlock(trees, sb, headingMode)
block, blockPaths := getEmbeddedBlock(trees, sb, headingMode, breadcrumb)
if nil == block {
continue
}