first commit

This commit is contained in:
CrazyJasonwell
2026-07-23 20:36:13 +08:00
commit 513b68be8c
7915 changed files with 2642530 additions and 0 deletions
+62
View File
@@ -0,0 +1,62 @@
# Obsidian OnlyOffice Plugin
Integrate the powerful OnlyOffice document editors directly into Obsidian. Edit `.docx` files seamlessly within your vault.
## How It Works
This plugin uses Docker to run a local instance of the OnlyOffice Document Server. It then serves your vault files to this server, allowing you to edit them in a secure, self-contained environment.
## Getting Started
For a complete, step-by-step tutorial from scratch (including how to set up a Docker environment on Windows), please follow our detailed setup guide:
➡️ **[Click here for the Complete Setup Guide](./GUIDE.md)**
## Quick Setup (If you already have Docker)
1. **Ensure your Docker environment is running.**
2. Navigate to the plugin folder: `<Your Vault>/.obsidian/plugins/OnlyOffice/`.
3. Run `start-onlyoffice.bat` (Windows) or `./start-onlyoffice.sh` (macOS/Linux).
4. In Obsidian's OnlyOffice plugin settings, ensure the **JWT Secret** matches the one in the scripts.
## Managing the Server
You can manage the OnlyOffice server using the other scripts in the plugin folder:
- `stop-onlyoffice`: Stops the server to free up system resources.
- `update-onlyoffice`: Downloads the latest version of OnlyOffice and prepares for an update. Run `start-onlyoffice` again after updating.
- `remove-onlyoffice`: Completely removes the OnlyOffice container from your system.
- `check-setup`: A diagnostic script to verify your setup.
## Troubleshooting
If the plugin isn't working, run the `check-setup.bat` (Windows) or `./check-setup.sh` (macOS/Linux) script. It will diagnose common problems with your Docker setup and server connection.
### Step 3: Configure the Plugin
1. Open Obsidian's settings and go to "OnlyOffice".
2. Ensure the **JWT Secret** in the settings matches the one in the script files.
**For better security, you should change the default secret:**
1. Open the `start-onlyoffice`, `update-onlyoffice`, and `check-setup` scripts and change the `JWT_SECRET` variable to a new, unique value.
2. Copy your new secret into the "JWT Secret" field in the plugin settings.
3. If the server is already running, use the `remove-onlyoffice` and `start-onlyoffice` scripts to restart it with the new secret.
That's it! You can now open `.docx` files in Obsidian.
## Managing the Server
You can manage the OnlyOffice server using the other scripts in the plugin folder:
- `stop-onlyoffice`: Stops the server to free up system resources.
- `update-onlyoffice`: Downloads the latest version of OnlyOffice and prepares for an update. Run `start-onlyoffice` again after updating.
- `remove-onlyoffice`: Completely removes the OnlyOffice container from your system.
- `check-setup`: A diagnostic script to verify your setup.
## Troubleshooting
If the plugin isn't working, run the `check-setup.bat` (Windows) or `./check-setup.sh` (macOS/Linux) script. It will diagnose common problems, including:
- If Docker is installed.
- If the Docker service is running.
- If the OnlyOffice container is running.
- If the server is accessible.
- If your JWT secret matches the one in the scripts.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+13
View File
@@ -0,0 +1,13 @@
{
"onlyOfficeServerPort": 8080,
"jwtSecret": "your-secret-key-please-change",
"localServerAddress": "192.168.1.181",
"htmlServerPort": 0,
"callbackServerPort": 0,
"useRequestToken": true,
"useSystemSaveAs": false,
"hideDownloadAs": true,
"promptNameOnCreate": true,
"restrictToLocalhost": false,
"debugLogging": false
}
+59
View File
@@ -0,0 +1,59 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>OnlyOffice Embedded Editor</title>
<style>
html, body { margin: 0; padding: 0; width: 100%; height: 100%; overflow: hidden; }
#placeholder { width: 100%; height: 100%; }
</style>
</head>
<body>
<div id="placeholder"></div>
<script>
// Host injects a script that defines init payload
(function() {
function boot() {
if (!window.__OO_INIT__) { return setTimeout(boot, 50); }
const { apiScriptUrl, buildConfig, bridge } = window.__OO_INIT__;
const script = document.createElement('script');
script.src = apiScriptUrl;
script.onload = function() {
try {
const cfg = buildConfig();
// Wire events into both config.events and editorConfig.events for compatibility
cfg.events = cfg.events || {};
cfg.editorConfig = cfg.editorConfig || {};
cfg.editorConfig.events = cfg.editorConfig.events || {};
const ev = {
onAppReady: function() { bridge('onlyoffice-app-ready', {}); },
onDocumentStateChange: function(e){ bridge('onlyoffice-dirty-state', { isDirty: !!(e && e.data) }); },
onDocumentContentChanged: function(){ bridge('onlyoffice-dirty-state', { isDirty: true }); },
onDownloadAs: function(e){ bridge('onlyoffice-save-as', e && e.data || {}); },
onRequestSaveAs: function(e){ bridge('onlyoffice-save-as', e && e.data || {}); },
onRequestCreateNew: function(e){ bridge('onlyoffice-create-new', e && e.data || {}); }
};
Object.assign(cfg.events, ev);
Object.assign(cfg.editorConfig.events, ev);
window.docEditor = new window.DocsAPI.DocEditor('placeholder', cfg);
console.log('[embedded-editor] initialized');
// Messages from /api/* pages
window.addEventListener('message', function(ev){
if (!ev || !ev.data) return;
if (ev.data.type === 'onlyoffice-save-as') bridge('onlyoffice-save-as', ev.data.data || {});
if (ev.data.type === 'onlyoffice-create-new') bridge('onlyoffice-create-new', ev.data || {});
});
} catch (err) {
console.error('[embedded-editor] init error', err);
}
};
script.onerror = function(){ console.error('[embedded-editor] failed to load API', apiScriptUrl); };
document.head.appendChild(script);
}
boot();
})();
</script>
</body>
</html>
File diff suppressed because it is too large Load Diff
+10
View File
@@ -0,0 +1,10 @@
{
"id": "onlyoffice",
"name": "OnlyOffice",
"version": "1.0.2",
"minAppVersion": "0.15.0",
"description": "Edit DOCX files using OnlyOffice Document Server",
"author": "Jan Sandström",
"authorUrl": "https://github.com/PixeroJan",
"isDesktopOnly": true
}
+21
View File
@@ -0,0 +1,21 @@
.onlyoffice-root { height:100%; width:100%; display:flex; flex-direction:column; }
.onlyoffice-webview { width:100%; height:100%; border:none; }
.onlyoffice-cancel-btn { margin-left:10px; }
.onlyoffice-adv-header { margin-top:1.5em; }
.onlyoffice-webview-wrapper { flex-grow:1; position:relative; width:100%; height:100%; }
.onlyoffice-loading { position:absolute; top:50%; left:50%; transform:translate(-50%, -50%); z-index:10; background:rgba(255,255,255,0.9); padding:24px 40px; border-radius:8px; box-shadow:0 2px 8px rgba(0,0,0,0.1); font-size:1.2em; color:#333; }
.onlyoffice-error { padding:16px; background:var(--background-secondary); border:1px solid var(--background-modifier-border); border-radius:6px; }
/* New Document Modal */
.oo-modal { padding:26px 32px 22px; min-width:600px; max-width:600px; box-sizing:border-box; overflow:hidden; }
.oo-modal h2 { margin:0 0 16px 0; font-weight:600; font-size:22px; letter-spacing:.4px; }
.oo-form-wrapper { display:flex; flex-direction:column; gap:16px; }
.oo-grid { display:grid; gap:18px; grid-template-columns:320px 118px; align-items:end; width:536px; }
.oo-field-col { display:flex; flex-direction:column; gap:6px; min-width:0; }
.oo-field-col label { font-size:11px; font-weight:600; letter-spacing:.5px; text-transform:uppercase; color:var(--text-muted); }
.oo-input { padding:8px 12px; font-size:14px; line-height:20px; height:40px; border:1px solid var(--background-modifier-border); border-radius:10px; width:100%; max-width:320px; box-sizing:border-box; background:var(--background-primary); }
.oo-select { padding:8px 12px; font-size:14px; line-height:20px; height:40px; border:1px solid var(--background-modifier-border); border-radius:10px; background:var(--background-primary); box-sizing:border-box; width:118px; }
.oo-btn-row { display:flex; justify-content:flex-end; gap:10px; margin-top:6px; width:536px; }
.oo-btn { padding:8px 20px; font-size:14px; font-weight:500; border:none; border-radius:10px; cursor:pointer; line-height:20px; }
.oo-btn-cancel { background:var(--background-modifier-border); color:var(--text-normal); }
.oo-btn-primary { background:var(--interactive-accent); color:var(--text-on-accent,#fff); }
+5
View File
@@ -0,0 +1,5 @@
{
"1.0.0": "0.15.0",
"1.0.1": "0.15.0",
"1.0.2": "0.15.0"
}