|
@@ -305,6 +305,7 @@ const statusPage = ref([false, true]); // 0 --> 目录 1 --> operate
|
|
|
const load = ref(false);
|
|
|
const toolShow = ref(true);
|
|
|
const btnType = ref('short');
|
|
|
+let text = '';
|
|
|
|
|
|
const getSidFun = () => {
|
|
|
getSID().then(r => {
|
|
@@ -358,11 +359,21 @@ const editorConfig = {
|
|
|
};
|
|
|
|
|
|
const contentChange = () => {
|
|
|
- // const s = window.getSelection().getRangeAt(0);
|
|
|
- // const offset = s.startOffset;
|
|
|
- // const innerText = s.startContainer.innerText;
|
|
|
- // const T = e.getHtml().split(innerText);
|
|
|
- // console.log(T, innerText , offset, s);
|
|
|
+ try {
|
|
|
+ if (!window.getSelection()) return;
|
|
|
+ const s = window.getSelection().getRangeAt(0);
|
|
|
+ let SText = s.startContainer || s.endContainer || s.commonAncestorContainer;
|
|
|
+ SText = SText.nodeValue || SText.innerText;
|
|
|
+ if (!SText) return;
|
|
|
+ const offset = editorRef.value.selection
|
|
|
+ ? editorRef.value.selection.focus.offset
|
|
|
+ : undefined;
|
|
|
+ const NSText = SText.substring(0, offset) + '///' + SText.substring(offset);
|
|
|
+ const ot = editorRef.value.getHtml().replace(SText, NSText);
|
|
|
+ text = ot.split('///');
|
|
|
+ } catch (error) {
|
|
|
+ console.log(error)
|
|
|
+ }
|
|
|
// 编辑器修改
|
|
|
};
|
|
|
|
|
@@ -446,11 +457,12 @@ const saveDagang = generateType => {
|
|
|
return;
|
|
|
}
|
|
|
load.value = true;
|
|
|
+ console.log(text);
|
|
|
const p = {
|
|
|
data: {
|
|
|
title: titleh1.value,
|
|
|
- prev: '一、第一章\n', // 获取大纲内容
|
|
|
- next: '',
|
|
|
+ prev: text[0] || undefined, // 获取大纲内容
|
|
|
+ next: text[1] || undefined,
|
|
|
},
|
|
|
generateType,
|
|
|
length: btnType.value,
|