mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 06:30:14 +01:00
Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
379bbfa4fa
4 changed files with 77 additions and 5 deletions
|
|
@ -91,7 +91,7 @@
|
|||
|
||||
.drag {
|
||||
-webkit-app-region: drag;
|
||||
height: 22px;
|
||||
height: 32px;
|
||||
cursor: pointer;
|
||||
position: fixed;
|
||||
top: 0;
|
||||
|
|
@ -180,7 +180,28 @@
|
|||
}
|
||||
|
||||
(() => {
|
||||
document.querySelector('#icon').innerHTML = `<img src="${decodeURIComponent(getSearch('icon'))}"> SiYuan v${getSearch('v')}`
|
||||
if (process.platform === 'darwin') {
|
||||
document.getElementById('min').style.display = 'none';
|
||||
document.getElementById('close').style.display = 'none';
|
||||
document.querySelector('.drag').style.right = '0';
|
||||
document.querySelector('#icon').style.left = '74px';
|
||||
} else {
|
||||
document.querySelector('#icon').style.right = '70px';
|
||||
}
|
||||
|
||||
const os = require('os')
|
||||
const platformMap = {
|
||||
'darwin': 'macOS',
|
||||
'win32': 'Windows',
|
||||
'linux': 'Linux'
|
||||
}
|
||||
const platform = platformMap[process.platform] || process.platform
|
||||
const release = os.release()
|
||||
const arch = os.arch()
|
||||
const cpus = os.cpus()
|
||||
const cpuModel = cpus.length > 0 ? cpus[0].model : ''
|
||||
const systemInfo = `· ${platform} ${release} · ${arch} · ${cpuModel}`
|
||||
document.querySelector('#icon').innerHTML = `<img src="${decodeURIComponent(getSearch('icon'))}"> SiYuan v${getSearch('v')} ${systemInfo}`
|
||||
|
||||
document.getElementById('title').innerHTML = decodeURIComponent(getSearch('title'))
|
||||
document.getElementById('content').innerHTML = decodeURIComponent(getSearch('content'))
|
||||
|
|
|
|||
|
|
@ -196,7 +196,9 @@ const showErrorWindow = (title, content) => {
|
|||
const errWindow = new BrowserWindow({
|
||||
width: Math.floor(screen.getPrimaryDisplay().size.width * 0.5),
|
||||
height: Math.floor(screen.getPrimaryDisplay().workAreaSize.height * 0.8),
|
||||
frame: false,
|
||||
frame: "darwin" === process.platform,
|
||||
titleBarStyle: "hidden",
|
||||
fullscreenable: false,
|
||||
icon: path.join(appDir, "stage", "icon-large.png"),
|
||||
webPreferences: {
|
||||
nodeIntegration: true, webviewTag: true, webSecurity: false, contextIsolation: false,
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ func renderView(attrView *av.AttributeView, view *av.View, query string, depth *
|
|||
return
|
||||
}
|
||||
|
||||
func RenderTemplateField(ial map[string]string, keyValues []*av.KeyValues, tplContent string) (ret string, err error) {
|
||||
func renderTemplateField(ial map[string]string, keyValues []*av.KeyValues, tplContent string) (ret string, err error) {
|
||||
if "" == ial["id"] {
|
||||
block := getBlockValue(keyValues)
|
||||
if nil != block {
|
||||
|
|
@ -267,6 +267,11 @@ func RenderTemplateField(ial map[string]string, keyValues []*av.KeyValues, tplCo
|
|||
ret = buf.String()
|
||||
if ret == "<no value>" {
|
||||
ret = ""
|
||||
return
|
||||
}
|
||||
|
||||
if util.HasUnclosedHtmlTag(ret) {
|
||||
ret = util.EscapeHTML(ret)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
|
@ -623,7 +628,7 @@ func fillAttributeViewTemplateValues(attrView *av.AttributeView, view *av.View,
|
|||
ial = map[string]string{}
|
||||
}
|
||||
|
||||
content, renderErr := RenderTemplateField(ial, keyValues, value.Template.Content)
|
||||
content, renderErr := renderTemplateField(ial, keyValues, value.Template.Content)
|
||||
if nil != renderErr {
|
||||
key, _ := attrView.GetKey(value.KeyID)
|
||||
keyName := ""
|
||||
|
|
|
|||
|
|
@ -100,6 +100,50 @@ func UnescapeHTML(s string) (ret string) {
|
|||
return
|
||||
}
|
||||
|
||||
func HasUnclosedHtmlTag(htmlStr string) bool {
|
||||
// 检查未闭合注释
|
||||
openIdx := 0
|
||||
for {
|
||||
start := strings.Index(htmlStr[openIdx:], "<!--")
|
||||
if start == -1 {
|
||||
break
|
||||
}
|
||||
start += openIdx
|
||||
end := strings.Index(htmlStr[start+4:], "-->")
|
||||
if end == -1 {
|
||||
return true // 存在未闭合注释
|
||||
}
|
||||
openIdx = start + 4 + end + 3
|
||||
}
|
||||
|
||||
// 去除所有注释内容
|
||||
commentRe := regexp.MustCompile(`<!--[\s\S]*?-->`)
|
||||
htmlStr = commentRe.ReplaceAllString(htmlStr, "")
|
||||
|
||||
tagRe := regexp.MustCompile(`<(/?)([a-zA-Z0-9]+)[^>]*?>`)
|
||||
selfClosing := map[string]bool{
|
||||
"br": true, "img": true, "hr": true, "input": true, "meta": true, "link": true,
|
||||
}
|
||||
stack := []string{}
|
||||
matches := tagRe.FindAllStringSubmatch(htmlStr, -1)
|
||||
for _, m := range matches {
|
||||
isClose := m[1] == "/"
|
||||
tag := strings.ToLower(m[2])
|
||||
if selfClosing[tag] {
|
||||
continue
|
||||
}
|
||||
if !isClose {
|
||||
stack = append(stack, tag)
|
||||
} else {
|
||||
if len(stack) == 0 || stack[len(stack)-1] != tag {
|
||||
return true // 闭合标签不匹配
|
||||
}
|
||||
stack = stack[:len(stack)-1]
|
||||
}
|
||||
}
|
||||
return len(stack) != 0
|
||||
}
|
||||
|
||||
func Reverse(s string) string {
|
||||
runes := []rune(s)
|
||||
for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue