Skip to content

Commit 635f42b

Browse files
committed
fix: latest
1 parent 0df8a70 commit 635f42b

205 files changed

Lines changed: 29946 additions & 1412 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Run tests for example apps
2+
3+
on:
4+
workflow_call:
5+
# TODO: Enable this when we test this workflow manually
6+
# pull_request:
7+
# branches:
8+
# - develop
9+
10+
jobs:
11+
run-tests-example-apps:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v4
16+
17+
- name: Setup node
18+
uses: actions/setup-node@v4
19+
with:
20+
node-version: 22
21+
cache: npm
22+
23+
- name: Install dependencies
24+
run: cd examples/tests && npm ci
25+
26+
- name: Install Playwright browsers
27+
run: cd examples/tests && npx playwright install --with-deps
28+
29+
- name: Run tests
30+
run: cd examples/tests && npm test

eslint.config.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ export default [
9191
}
9292
},
9393
rules: {
94-
'no-unused-vars': 'warn', // See warnings but don't block
94+
'no-unused-vars': ['warn', { "varsIgnorePattern": "^_" }], // See warnings but don't block
9595

9696
// Relax these rules - they're more style than bugs
9797
'no-empty': ['warn', { allowEmptyCatch: true }], // Allow empty catch blocks
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"dirname": "loading-from-json",
3+
"tags": [
4+
"editing",
5+
"viewing",
6+
"vanilla-js"
7+
],
8+
"title": "Loading from JSON"
9+
}
86.6 KB
Loading
150 KB
Binary file not shown.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>SuperDoc Vanilla Example</title>
7+
</head>
8+
<body>
9+
<div class="container">
10+
<header>
11+
<h1>SuperDoc Example</h1>
12+
<button id="loadButton">Upload DOCX</button>
13+
<button id="loadJSON">Load JSON</button>
14+
<input
15+
type="file"
16+
id="fileInput"
17+
accept=".docx,.pdf,.html"
18+
style="display: none"
19+
/>
20+
</header>
21+
<main>
22+
<div id="superdoc-toolbar"></div>
23+
<div id="superdoc"></div>
24+
</main>
25+
</div>
26+
<script type="module" src="/src/main.js"></script>
27+
</body>
28+
</html>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "vanilla-superdoc-example",
3+
"private": true,
4+
"version": "0.0.1",
5+
"type": "module",
6+
"scripts": {
7+
"dev": "vite"
8+
},
9+
"dependencies": {
10+
"@harbour-enterprises/superdoc": "^0.15.16"
11+
},
12+
"devDependencies": {
13+
"vite": "^4.4.6"
14+
}
15+
}
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
// Imports
2+
import { SuperDoc } from '@harbour-enterprises/superdoc';
3+
import '@harbour-enterprises/superdoc/style.css';
4+
import './style.css';
5+
6+
// Init
7+
let editor = null;
8+
9+
//Init SuperDoc from DOCX file
10+
function initSuperDocFromFile(file = null) {
11+
if (editor) {
12+
editor = null;
13+
}
14+
15+
editor = new SuperDoc({
16+
selector: '#superdoc',
17+
toolbar: '#superdoc-toolbar',
18+
document: file, // DOCX URL, File object, or document config
19+
documentMode: 'editing',
20+
mode: 'docx',
21+
pagination: true,
22+
rulers: true,
23+
onReady: (event) => {
24+
const docJSON = event.superdoc.activeEditor.getJSON();
25+
console.log('SuperDoc ready - JSON', docJSON);
26+
},
27+
onEditorUpdate: (event) => {
28+
const docJSON = event.editor.getJSON();
29+
console.log('SuperDoc updated - JSON', docJSON);
30+
},
31+
});
32+
}
33+
34+
//Init SuperDoc from JSON
35+
function initSuperDocFromJSON() {
36+
if (editor) {
37+
editor = null;
38+
}
39+
40+
//Hardcoded demo JSON
41+
const demoJSON = {
42+
type: 'doc',
43+
content: [
44+
{
45+
type: 'paragraph',
46+
content: [
47+
{
48+
type: 'text',
49+
text: 'Hello, SuperDoc~!!',
50+
},
51+
],
52+
},
53+
],
54+
};
55+
56+
editor = new SuperDoc({
57+
selector: '#superdoc',
58+
toolbar: '#superdoc-toolbar',
59+
documentMode: 'editing',
60+
61+
/* LOADING JSON */
62+
//https://docs.superdoc.dev/core/supereditor/configuration#param-options-content
63+
mode: 'docx',
64+
jsonOverride: demoJSON,
65+
66+
pagination: true,
67+
rulers: true,
68+
onReady: (event) => {
69+
const docJSON = event.superdoc.activeEditor.getJSON();
70+
console.log('SuperDoc ready - JSON', docJSON);
71+
},
72+
onEditorUpdate: (event) => {
73+
const docJSON = event.editor.getJSON();
74+
console.log('SuperDoc updated - JSON', docJSON);
75+
},
76+
});
77+
}
78+
79+
// Setup file input handling
80+
const fileInput = document.getElementById('fileInput');
81+
const loadButton = document.getElementById('loadButton');
82+
const loadJSON = document.getElementById('loadJSON');
83+
84+
loadButton.addEventListener('click', () => {
85+
fileInput.click();
86+
});
87+
88+
loadJSON.addEventListener('click', () => {
89+
initSuperDocFromJSON();
90+
});
91+
92+
fileInput.addEventListener('change', (event) => {
93+
const file = event.target.files?.[0];
94+
if (file) {
95+
initSuperDocFromFile(file);
96+
}
97+
});
98+
99+
// Initialize empty editor on page load
100+
initSuperDocFromFile(null);
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
.container {
2+
height: 100vh;
3+
display: flex;
4+
flex-direction: column;
5+
}
6+
7+
header {
8+
padding: 1rem;
9+
background: #f5f5f5;
10+
display: flex;
11+
align-items: center;
12+
gap: 1rem;
13+
}
14+
15+
button {
16+
padding: 0.5rem 1rem;
17+
background: #1355ff;
18+
color: white;
19+
border: none;
20+
border-radius: 4px;
21+
cursor: pointer;
22+
}
23+
24+
button:hover {
25+
background: #0044ff;
26+
}
27+
28+
main {
29+
flex: 1;
30+
padding: 1rem;
31+
display: flex;
32+
flex-direction: column;
33+
}
34+
35+
#superdoc-toolbar {
36+
border-bottom: 1px solid #eee;
37+
}
38+
39+
#superdoc {
40+
display: flex;
41+
justify-content: center;
42+
flex: 1;
43+
overflow: auto;
44+
}
45+
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { defineConfig } from 'vite';
2+
3+
export default defineConfig({
4+
optimizeDeps: {
5+
include: ['@harbour-enterprises/superdoc']
6+
}
7+
});

0 commit comments

Comments
 (0)