collabdocchat 2.1.2 → 2.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
|
|
5
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
6
|
+
const __dirname = path.dirname(__filename);
|
|
7
|
+
|
|
8
|
+
const filePath = path.join(__dirname, '../src/pages/user-dashboard.js');
|
|
9
|
+
|
|
10
|
+
console.log('正在读取文件...');
|
|
11
|
+
let content = fs.readFileSync(filePath, 'utf8');
|
|
12
|
+
|
|
13
|
+
console.log('移除 Quill 导入...');
|
|
14
|
+
// 移除 Quill 导入
|
|
15
|
+
content = content.replace(/import Quill from 'quill';\r?\n/g, '');
|
|
16
|
+
content = content.replace(/import 'quill\/dist\/quill\.snow\.css';\r?\n/g, '');
|
|
17
|
+
|
|
18
|
+
console.log('查找并替换 Quill 编辑器代码...');
|
|
19
|
+
|
|
20
|
+
// 查找 renderDocumentEditor 函数中的 Quill 代码
|
|
21
|
+
// 替换编辑器 HTML 结构
|
|
22
|
+
content = content.replace(
|
|
23
|
+
/<div id="editor"><\/div>/g,
|
|
24
|
+
'<textarea id="editor" style="width: 100%; min-height: 400px; padding: 10px; font-family: monospace; border: 1px solid #ddd; border-radius: 4px; resize: vertical;"></textarea>'
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
// 替换 Quill 初始化代码块
|
|
28
|
+
const quillInitPattern = /\/\/ 初始化 Quill 编辑器[\s\S]*?const quill = new Quill\('#editor', \{[\s\S]*?\}\);[\s\S]*?\/\/ 设置初始内容[\s\S]*?quill\.root\.innerHTML = doc\.content \|\| '';/;
|
|
29
|
+
const textareaInit = `// 使用原生 textarea
|
|
30
|
+
const editor = document.getElementById('editor');
|
|
31
|
+
|
|
32
|
+
// 设置初始内容
|
|
33
|
+
editor.value = doc.content || '';`;
|
|
34
|
+
|
|
35
|
+
content = content.replace(quillInitPattern, textareaInit);
|
|
36
|
+
|
|
37
|
+
// 替换 quill.on('text-change' 为 editor.addEventListener('input'
|
|
38
|
+
content = content.replace(
|
|
39
|
+
/quill\.on\('text-change', \(\) => \{/g,
|
|
40
|
+
"editor.addEventListener('input', () => {"
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
// 替换 quill.root.innerHTML 为 editor.value
|
|
44
|
+
content = content.replace(/quill\.root\.innerHTML/g, 'editor.value');
|
|
45
|
+
|
|
46
|
+
// 替换 quill.getSelection() 和 quill.setSelection() 的代码块
|
|
47
|
+
const selectionPattern = /const selection = quill\.getSelection\(\);\s*quill\.root\.innerHTML = data\.content;\s*if \(selection\) \{\s*quill\.setSelection\(selection\);\s*\}/g;
|
|
48
|
+
const textareaSelection = `const cursorPos = editor.selectionStart;
|
|
49
|
+
editor.value = data.content;
|
|
50
|
+
editor.setSelectionRange(cursorPos, cursorPos);`;
|
|
51
|
+
|
|
52
|
+
content = content.replace(selectionPattern, textareaSelection);
|
|
53
|
+
|
|
54
|
+
console.log('写入文件...');
|
|
55
|
+
fs.writeFileSync(filePath, content, 'utf8');
|
|
56
|
+
|
|
57
|
+
console.log('✅ 完成!已移除 Quill 依赖并替换为原生 textarea');
|
|
58
|
+
console.log('📝 文件已保存,中文字符已保留');
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
|
|
5
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
6
|
+
const __dirname = path.dirname(__filename);
|
|
7
|
+
|
|
8
|
+
const filePath = path.join(__dirname, '../src/pages/user-dashboard.js');
|
|
9
|
+
|
|
10
|
+
console.log('正在读取文件...');
|
|
11
|
+
const content = fs.readFileSync(filePath, 'utf8');
|
|
12
|
+
|
|
13
|
+
console.log('按行处理文件...');
|
|
14
|
+
const lines = content.split('\n');
|
|
15
|
+
const newLines = lines.filter(line => {
|
|
16
|
+
// 移除 Quill 相关的导入行
|
|
17
|
+
if (line.includes("import Quill from 'quill'")) return false;
|
|
18
|
+
if (line.includes("import 'quill/dist/quill.snow.css'")) return false;
|
|
19
|
+
return true;
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
const newContent = newLines.join('\n');
|
|
23
|
+
|
|
24
|
+
console.log('写入文件...');
|
|
25
|
+
fs.writeFileSync(filePath, newContent, 'utf8');
|
|
26
|
+
|
|
27
|
+
console.log('✅ 完成!已移除 Quill 导入行');
|
|
28
|
+
console.log(`原始行数: ${lines.length}, 新行数: ${newLines.length}`);
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|