Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions examples/commands-example/demo-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"dirname": "commands-example",
"tags": [
"editing",
"commands",
"vue"
],
"title": "Commands Explorer"
}
12 changes: 12 additions & 0 deletions examples/commands-example/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>SuperDoc Commands Explorer</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.js"></script>
</body>
</html>
20 changes: 20 additions & 0 deletions examples/commands-example/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "commands-superdoc-example",
"private": true,
"version": "0.0.1",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview",
"deploy": "npm run build && wrangler pages deploy dist"
},
"dependencies": {
"superdoc": "0.35.3",
"vue": "^3.5.13"
},
"devDependencies": {
"@vitejs/plugin-vue": "^4.2.3",
"vite": "^4.4.6"
}
}
114 changes: 114 additions & 0 deletions examples/commands-example/src/App.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
<template>
<div class="app">
<header>
<h1>SuperDoc Commands Explorer</h1>
<button @click="fileInput?.click()">Load Document</button>
<input
type="file"
ref="fileInput"
accept=".docx,.pdf"
class="hidden"
@change="handleFileChange"
>
</header>

<div class="main-content">
<aside class="sidebar">
<CommandsPanel :editor="superdocInstance" />
</aside>

<main>
<DocumentEditor
:initial-data="documentFile"
@editor-ready="handleEditorReady"
/>
</main>
</div>
</div>
</template>

<script setup>
import { ref } from 'vue';
import DocumentEditor from './components/DocumentEditor.vue';
import CommandsPanel from './components/CommandsPanel.vue';

const documentFile = ref(null);
const fileInput = ref(null);
const superdocInstance = ref(null);

const handleFileChange = (event) => {
const file = event.target.files?.[0];
if (file) {
documentFile.value = file;
}
};

const handleEditorReady = (editor) => {
console.log('SuperDoc editor is ready', editor);
superdocInstance.value = editor;
};
</script>

<style>
* {
box-sizing: border-box;
}

.app {
height: 100vh;
display: flex;
flex-direction: column;
}

header {
padding: 0.75rem 1rem;
background: #f5f5f5;
display: flex;
align-items: center;
gap: 1rem;
border-bottom: 1px solid #ddd;
flex-shrink: 0;
}

header h1 {
margin: 0;
font-size: 1.25rem;
}

header button {
padding: 0.5rem 1rem;
background: #1355ff;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
}

header button:hover {
background: #0044ff;
}

.hidden {
display: none;
}

.main-content {
flex: 1;
display: flex;
overflow: hidden;
}

.sidebar {
width: 320px;
flex-shrink: 0;
border-right: 1px solid #ddd;
overflow-y: auto;
background: #f9f9f9;
}

main {
flex: 1;
padding: 1rem;
overflow: auto;
}
</style>
Loading