collabdocchat 2.1.2 → 2.1.4

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "collabdocchat",
3
- "version": "2.1.2",
3
+ "version": "2.1.4",
4
4
  "description": "开源的实时协作文档聊天平台 - 集成任务管理、多人文档编辑、智能点名功能",
5
5
  "main": "./server/index.js",
6
6
  "type": "module",
@@ -0,0 +1,37 @@
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 files = [
9
+ '../src/pages/optimized-workflow-view.js',
10
+ '../src/pages/optimized-backup-view.js'
11
+ ];
12
+
13
+ files.forEach(file => {
14
+ const filePath = path.join(__dirname, file);
15
+ console.log(`\n处理文件: ${file}`);
16
+
17
+ let content = fs.readFileSync(filePath, 'utf8');
18
+
19
+ // 添加 export 到函数定义
20
+ if (file.includes('workflow')) {
21
+ content = content.replace(
22
+ /^async function renderOptimizedWorkflowView\(/m,
23
+ 'export async function renderOptimizedWorkflowView('
24
+ );
25
+ } else if (file.includes('backup')) {
26
+ content = content.replace(
27
+ /^async function renderOptimizedBackupView\(/m,
28
+ 'export async function renderOptimizedBackupView('
29
+ );
30
+ }
31
+
32
+ fs.writeFileSync(filePath, content, 'utf8');
33
+ console.log(`✅ 已添加 export`);
34
+ });
35
+
36
+ console.log('\n✅ 所有文件处理完成!');
37
+
@@ -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
+
@@ -44,3 +44,6 @@ fs.writeFileSync(filePath, content, 'utf8');
44
44
 
45
45
  console.log('✅ 完成!已移除 Quill 依赖并替换为原生 textarea');
46
46
 
47
+
48
+
49
+
@@ -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
+
@@ -1,6 +1,9 @@
1
1
  import { ApiService } from '../services/api.js';
2
2
  import { AuthService } from '../services/auth.js';
3
3
  import 'emoji-picker-element';
4
+ import { renderOptimizedKnowledgeView } from './optimized-knowledge-view.js';
5
+ import { renderOptimizedWorkflowView } from './optimized-workflow-view.js';
6
+ import { renderOptimizedBackupView } from './optimized-backup-view.js';
4
7
 
5
8
  export function renderAdminDashboard(user, wsService) {
6
9
  const app = document.getElementById('app');
@@ -52,6 +55,15 @@ export function renderAdminDashboard(user, wsService) {
52
55
  <button class="nav-item" data-view="audit">
53
56
  <span class="icon">📊</span> 操作记录
54
57
  </button>
58
+ <button class="nav-item" data-view="knowledge">
59
+ <span class="icon">📚</span> 知识库
60
+ </button>
61
+ <button class="nav-item" data-view="workflow">
62
+ <span class="icon">⚙️</span> 工作流
63
+ </button>
64
+ <button class="nav-item" data-view="backup">
65
+ <span class="icon">💾</span> 备份管理
66
+ </button>
55
67
  </nav>
56
68
 
57
69
  <button class="btn-logout" id="logoutBtn">退出登录</button>
@@ -106,6 +118,15 @@ export function renderAdminDashboard(user, wsService) {
106
118
  case 'audit':
107
119
  await renderAuditView(contentArea);
108
120
  break;
121
+ case 'knowledge':
122
+ await renderOptimizedKnowledgeView(contentArea, currentGroup, apiService, currentUserId);
123
+ break;
124
+ case 'workflow':
125
+ await renderOptimizedWorkflowView(contentArea, currentGroup, apiService);
126
+ break;
127
+ case 'backup':
128
+ await renderOptimizedBackupView(contentArea);
129
+ break;
109
130
  }
110
131
  }
111
132
 
@@ -1,7 +1,7 @@
1
1
  // 优化后的备份管理界面
2
2
  // 使用卡片式布局,提升视觉效果和用户体验
3
3
 
4
- async function renderOptimizedBackupView(container) {
4
+ export async function renderOptimizedBackupView(container) {
5
5
  try {
6
6
  const token = localStorage.getItem('token');
7
7
 
@@ -2,7 +2,7 @@
2
2
  * 优化后的工作流管理界�? * 可视化创建工作流,无需编写JSON代码
3
3
  */
4
4
 
5
- async function renderOptimizedWorkflowView(container, currentGroup, apiService) {
5
+ export async function renderOptimizedWorkflowView(container, currentGroup, apiService) {
6
6
  if (!currentGroup) {
7
7
  container.innerHTML = '<div class="empty-state">请先选择一个群�?/div>';
8
8
  return;
@@ -787,4 +787,4 @@ function setupWorkflowEvents(token, container, currentGroup, apiService) {
787
787
  // 导出函数
788
788
  export { renderOptimizedWorkflowView };
789
789
 
790
-
790
+