Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
cfc636cf62
6 changed files with 42 additions and 23 deletions
|
@ -12,7 +12,7 @@ import {MenuItem} from "../../menus/Menu";
|
|||
import {openFileAttr,} from "../../menus/commonMenuItem";
|
||||
import {Constants} from "../../constants";
|
||||
import {matchHotKey} from "../util/hotKey";
|
||||
import {isMac, readText, writeText} from "../util/compatibility";
|
||||
import {isMac, readText} from "../util/compatibility";
|
||||
import * as dayjs from "dayjs";
|
||||
import {openFileById} from "../../editor/util";
|
||||
import {setTitle} from "../../dialog/processSystem";
|
||||
|
@ -25,6 +25,7 @@ import {hideTooltip} from "../../dialog/tooltip";
|
|||
import {commonClick} from "../wysiwyg/commonClick";
|
||||
import {openTitleMenu} from "./openTitleMenu";
|
||||
import {electronUndo} from "../undo";
|
||||
import {enableLuteMarkdownSyntax, restoreLuteMarkdownSyntax} from "../util/paste";
|
||||
|
||||
export class Title {
|
||||
public element: HTMLElement;
|
||||
|
@ -77,7 +78,9 @@ export class Title {
|
|||
navigator.clipboard.readText().then(textPlain => {
|
||||
// 对 HTML 标签进行内部转义,避免被 Lute 解析以后变为小写 https://github.com/siyuan-note/siyuan/issues/10620
|
||||
textPlain = textPlain.replace(/</g, ";;;lt;;;").replace(/>/g, ";;;gt;;;");
|
||||
enableLuteMarkdownSyntax(protyle);
|
||||
let content = protyle.lute.BlockDOM2EscapeMarkerContent(protyle.lute.Md2BlockDOM(textPlain));
|
||||
restoreLuteMarkdownSyntax(protyle);
|
||||
// 移除 ;;;lt;;; 和 ;;;gt;;; 转义及其包裹的内容
|
||||
content = content.replace(/;;;lt;;;[^;]+;;;gt;;;/g, "");
|
||||
document.execCommand("insertText", false, replaceFileName(content));
|
||||
|
@ -229,7 +232,9 @@ export class Title {
|
|||
click: async () => {
|
||||
navigator.clipboard.readText().then(textPlain => {
|
||||
textPlain = textPlain.replace(/</g, ";;;lt;;;").replace(/>/g, ";;;gt;;;");
|
||||
enableLuteMarkdownSyntax(protyle);
|
||||
let content = protyle.lute.BlockDOM2EscapeMarkerContent(protyle.lute.Md2BlockDOM(textPlain));
|
||||
restoreLuteMarkdownSyntax(protyle);
|
||||
// 移除 ;;;lt;;; 和 ;;;gt;;; 转义及其包裹的内容
|
||||
content = content.replace(/;;;lt;;;[^;]+;;;gt;;;/g, "");
|
||||
document.execCommand("insertText", false, replaceFileName(content));
|
||||
|
|
|
@ -190,21 +190,9 @@ export const pasteAsPlainText = async (protyle: IProtyle) => {
|
|||
textPlain = textPlain.replace(/__@kbd@__/g, "<kbd>").replace(/__@\/kbd@__/g, "</kbd>");
|
||||
textPlain = textPlain.replace(/__@u@__/g, "<u>").replace(/__@\/u@__/g, "</u>");
|
||||
|
||||
protyle.lute.SetInlineAsterisk(true);
|
||||
protyle.lute.SetGFMStrikethrough(true);
|
||||
protyle.lute.SetInlineMath(true);
|
||||
protyle.lute.SetSub(true);
|
||||
protyle.lute.SetSup(true);
|
||||
protyle.lute.SetTag(true);
|
||||
protyle.lute.SetInlineUnderscore(true);
|
||||
enableLuteMarkdownSyntax(protyle);
|
||||
const content = protyle.lute.BlockDOM2EscapeMarkerContent(protyle.lute.Md2BlockDOM(textPlain));
|
||||
protyle.lute.SetInlineAsterisk(window.siyuan.config.editor.markdown.inlineAsterisk);
|
||||
protyle.lute.SetGFMStrikethrough(window.siyuan.config.editor.markdown.inlineStrikethrough);
|
||||
protyle.lute.SetInlineMath(window.siyuan.config.editor.markdown.inlineMath);
|
||||
protyle.lute.SetSub(window.siyuan.config.editor.markdown.inlineSub);
|
||||
protyle.lute.SetSup(window.siyuan.config.editor.markdown.inlineSup);
|
||||
protyle.lute.SetTag(window.siyuan.config.editor.markdown.inlineTag);
|
||||
protyle.lute.SetInlineUnderscore(window.siyuan.config.editor.markdown.inlineUnderscore);
|
||||
restoreLuteMarkdownSyntax(protyle);
|
||||
|
||||
// insertHTML 会进行内部反转义
|
||||
insertHTML(content, protyle, false, false, true);
|
||||
|
@ -213,6 +201,26 @@ export const pasteAsPlainText = async (protyle: IProtyle) => {
|
|||
}
|
||||
};
|
||||
|
||||
export const enableLuteMarkdownSyntax = (protyle: IProtyle) => {
|
||||
protyle.lute.SetInlineAsterisk(true);
|
||||
protyle.lute.SetGFMStrikethrough(true);
|
||||
protyle.lute.SetInlineMath(true);
|
||||
protyle.lute.SetSub(true);
|
||||
protyle.lute.SetSup(true);
|
||||
protyle.lute.SetTag(true);
|
||||
protyle.lute.SetInlineUnderscore(true);
|
||||
}
|
||||
|
||||
export const restoreLuteMarkdownSyntax = (protyle: IProtyle) => {
|
||||
protyle.lute.SetInlineAsterisk(window.siyuan.config.editor.markdown.inlineAsterisk);
|
||||
protyle.lute.SetGFMStrikethrough(window.siyuan.config.editor.markdown.inlineStrikethrough);
|
||||
protyle.lute.SetInlineMath(window.siyuan.config.editor.markdown.inlineMath);
|
||||
protyle.lute.SetSub(window.siyuan.config.editor.markdown.inlineSub);
|
||||
protyle.lute.SetSup(window.siyuan.config.editor.markdown.inlineSup);
|
||||
protyle.lute.SetTag(window.siyuan.config.editor.markdown.inlineTag);
|
||||
protyle.lute.SetInlineUnderscore(window.siyuan.config.editor.markdown.inlineUnderscore);
|
||||
}
|
||||
|
||||
export const pasteText = (protyle: IProtyle, textPlain: string, nodeElement: Element, toBlockDOM = true) => {
|
||||
const range = getEditorRange(protyle.wysiwyg.element);
|
||||
if (nodeElement.getAttribute("data-type") === "NodeCodeBlock") {
|
||||
|
|
|
@ -5,6 +5,7 @@ import {renderBacklink} from "../wysiwyg/renderBacklink";
|
|||
import {hasClosestByClassName} from "./hasClosest";
|
||||
import {preventScroll} from "../scroll/preventScroll";
|
||||
import {searchMarkRender} from "../render/searchMarkRender";
|
||||
import {restoreLuteMarkdownSyntax} from "./paste";
|
||||
|
||||
export const reloadProtyle = (protyle: IProtyle, focus: boolean, updateReadonly?: boolean) => {
|
||||
if (!protyle.preview.element.classList.contains("fn__none")) {
|
||||
|
@ -28,13 +29,7 @@ export const reloadProtyle = (protyle: IProtyle, focus: boolean, updateReadonly?
|
|||
}
|
||||
protyle.lute.SetProtyleMarkNetImg(window.siyuan.config.editor.displayNetImgMark);
|
||||
protyle.lute.SetSpellcheck(window.siyuan.config.editor.spellcheck);
|
||||
protyle.lute.SetInlineAsterisk(window.siyuan.config.editor.markdown.inlineAsterisk);
|
||||
protyle.lute.SetInlineUnderscore(window.siyuan.config.editor.markdown.inlineUnderscore);
|
||||
protyle.lute.SetSup(window.siyuan.config.editor.markdown.inlineSup);
|
||||
protyle.lute.SetSub(window.siyuan.config.editor.markdown.inlineSub);
|
||||
protyle.lute.SetTag(window.siyuan.config.editor.markdown.inlineTag);
|
||||
protyle.lute.SetInlineMath(window.siyuan.config.editor.markdown.inlineMath);
|
||||
protyle.lute.SetGFMStrikethrough(window.siyuan.config.editor.markdown.inlineStrikethrough);
|
||||
restoreLuteMarkdownSyntax(protyle);
|
||||
protyle.lute.SetGFMStrikethrough1(false);
|
||||
addLoading(protyle);
|
||||
if (protyle.options.backlinkData) {
|
||||
|
|
|
@ -65,6 +65,7 @@ func ServeAPI(ginServer *gin.Engine) {
|
|||
ginServer.Handle("POST", "/api/system/getNetwork", model.CheckAuth, model.CheckAdminRole, getNetwork)
|
||||
ginServer.Handle("POST", "/api/system/exportConf", model.CheckAuth, model.CheckAdminRole, exportConf)
|
||||
ginServer.Handle("POST", "/api/system/importConf", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, importConf)
|
||||
ginServer.Handle("POST", "/api/system/getWorkspaceInfo", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, getWorkspaceInfo)
|
||||
|
||||
ginServer.Handle("POST", "/api/storage/setLocalStorage", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, setLocalStorage)
|
||||
ginServer.Handle("POST", "/api/storage/getLocalStorage", model.CheckAuth, getLocalStorage)
|
||||
|
|
|
@ -35,6 +35,16 @@ import (
|
|||
"github.com/siyuan-note/siyuan/kernel/util"
|
||||
)
|
||||
|
||||
func getWorkspaceInfo(c *gin.Context) {
|
||||
ret := gulu.Ret.NewResult()
|
||||
defer c.JSON(http.StatusOK, ret)
|
||||
|
||||
ret.Data = map[string]any{
|
||||
"workspaceDir": util.WorkspaceDir,
|
||||
"siyuanVer": util.Ver,
|
||||
}
|
||||
}
|
||||
|
||||
func getNetwork(c *gin.Context) {
|
||||
ret := gulu.Ret.NewResult()
|
||||
defer c.JSON(http.StatusOK, ret)
|
||||
|
|
|
@ -232,7 +232,7 @@ func CheckAuth(c *gin.Context) {
|
|||
c.Next()
|
||||
return
|
||||
}
|
||||
if strings.HasPrefix(c.Request.RequestURI, "/api/system/getNetwork") {
|
||||
if strings.HasPrefix(c.Request.RequestURI, "/api/system/getNetwork") || strings.HasPrefix(c.Request.RequestURI, "/api/system/getWorkspaceInfo") {
|
||||
c.Set(RoleContextKey, RoleAdministrator)
|
||||
c.Next()
|
||||
return
|
||||
|
|
Loading…
Add table
Reference in a new issue