no message
This commit is contained in:
46
js/edit.js
46
js/edit.js
@@ -63,7 +63,7 @@ const editApp = createApp({
|
||||
let uConfigData = {};
|
||||
|
||||
const cUpload = () => {
|
||||
ajaxget(`/v2/api/config/upload?type=topic`).then((res) => {
|
||||
ajaxGet(`/v2/api/config/upload?type=topic`).then((res) => {
|
||||
const data = res.data;
|
||||
uConfigData = data;
|
||||
});
|
||||
@@ -487,7 +487,49 @@ const editApp = createApp({
|
||||
return images;
|
||||
};
|
||||
|
||||
return { userInfoWin, titleLength, submit, insertLabel, emojiState, openEmoji, closeEmoji, selectEmoji, optionEmoji, isPTitle, onEditorInput, onEditorFocus, onEditorBlur, paragraphTitle, info, tagList, token, cutAnonymity, editorRef, insertImage, judgeIsEmpty, isEmpty };
|
||||
let linkUrl = ref("");
|
||||
let linkText = ref("");
|
||||
|
||||
let linkState = ref(false);
|
||||
const openLink = () => {
|
||||
console.log("打开链接");
|
||||
linkState.value = true;
|
||||
};
|
||||
|
||||
const closeLink = () => {
|
||||
console.log("关闭链接");
|
||||
linkState.value = false;
|
||||
linkText.value = "";
|
||||
linkUrl.value = "";
|
||||
|
||||
};
|
||||
|
||||
const insertLink = () => {
|
||||
if (linkText.value == "" || linkUrl.value == "") {
|
||||
creationAlertBox("error", "请输入链接文字和链接地址");
|
||||
return;
|
||||
}
|
||||
const a = document.createElement("a");
|
||||
a.href = linkUrl.value;
|
||||
a.target = "_blank";
|
||||
a.textContent = linkText.value;
|
||||
lastSelection.insertNode(a);
|
||||
|
||||
// 移动光标到元素后面并确保光标位置被正确设置和获取
|
||||
const newRange = document.createRange();
|
||||
newRange.setStartAfter(a);
|
||||
newRange.setEndAfter(a);
|
||||
|
||||
// 更新选择范围
|
||||
const selection = window.getSelection();
|
||||
selection.removeAllRanges();
|
||||
selection.addRange(newRange);
|
||||
lastSelection = newRange;
|
||||
|
||||
closeLink();
|
||||
};
|
||||
|
||||
return { insertLink, linkUrl, linkText, linkState, openLink, closeLink, userInfoWin, titleLength, submit, insertLabel, emojiState, openEmoji, closeEmoji, selectEmoji, optionEmoji, isPTitle, onEditorInput, onEditorFocus, onEditorBlur, paragraphTitle, info, tagList, token, cutAnonymity, editorRef, insertImage, judgeIsEmpty, isEmpty };
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user