Skip to content

Commit eea852c

Browse files
committed
Merge branch 'develop' into har-9795_aria-infra
2 parents 3739e31 + cdd652d commit eea852c

46 files changed

Lines changed: 832 additions & 410 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: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Publish SuperDoc Package to npm
2+
3+
on:
4+
push:
5+
branches:
6+
- develop
7+
paths-ignore:
8+
- '*.md'
9+
- 'LICENSE'
10+
- '.github/**'
11+
- '.vscode/**'
12+
- '.gitignore'
13+
- '*.toml'
14+
- '*.yml'
15+
- '*.yaml'
16+
- '.prettierrc'
17+
- 'examples/**'
18+
- '.github/**'
19+
20+
workflow_dispatch:
21+
22+
permissions:
23+
contents: write
24+
actions: write
25+
26+
jobs:
27+
run-unit-tests:
28+
uses: ./.github/workflows/run-unit-tests.yml
29+
30+
release-next:
31+
# Block the workflow until the run-unit-tests job is complete
32+
needs: run-unit-tests
33+
# Only run if:
34+
# 1. It's a workflow_dispatch event OR
35+
# 2. It's a push event AND commit message doesn't contain [skip ci] or release
36+
if: |
37+
github.event_name == 'workflow_dispatch' ||
38+
(github.event_name == 'push' && !contains(github.event.head_commit.message, '[skip ci]'))
39+
runs-on: ubuntu-latest
40+
steps:
41+
- name: Checkout code
42+
uses: actions/checkout@v4
43+
with:
44+
fetch-depth: 0
45+
token: ${{ secrets.SUPERDOC_PAT }}
46+
47+
- name: Setup node
48+
uses: actions/setup-node@v4
49+
with:
50+
node-version: 22
51+
registry-url: https://registry.npmjs.org/
52+
53+
- name: Configure Git
54+
run: |
55+
git config --global user.name "github-actions[bot]"
56+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
57+
58+
- name: Install dependencies
59+
run: npm install
60+
61+
- name: Publish "next" npm tag
62+
working-directory: packages/superdoc
63+
env:
64+
GITHUB_TOKEN: ${{ secrets.SUPERDOC_PAT }}
65+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
66+
run: npm run release:next
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.file-upload-button {
2+
cursor: pointer;
3+
padding: 8px 12px;
4+
border-radius: 8px;
5+
margin: 10px;
6+
outline: none;
7+
border: none;
8+
background-color: #1355ff;
9+
color: white;
10+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
const uploadBtn = document.querySelector('.file-upload-button');
2+
const fileInput = document.querySelector('.file-upload-input');
3+
uploadBtn.addEventListener('click', () => fileInput.click());
4+
5+
fileInput.addEventListener('change', (event) => {
6+
const file = event.target.files?.[0];
7+
const uploadEvent = new CustomEvent("file-upload", { detail: file });
8+
if (file) window.dispatchEvent(uploadEvent);
9+
});

examples/cdn-example/index.html

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<head>
44
<link rel="stylesheet" href="https://unpkg.com/@harbour-enterprises/superdoc@0.11.45/dist/style.css">
55
<script type="module" src="https://unpkg.com/@harbour-enterprises/superdoc@0.11.45/dist/superdoc.umd.js"></script>
6+
<link rel="stylesheet" href="./file-upload.css">
67
<meta charset="UTF-8">
78
<meta name="viewport" content="width=device-width, initial-scale=1.0">
89
<title>SuperDoc - CDN example</title>
@@ -21,13 +22,17 @@
2122

2223
<div class="title">SuperDoc - CDN example</div>
2324
<div id="my-toolbar"></div>
25+
26+
<button class="file-upload-button">Load Document</button>
27+
<input class="file-upload-input" style="display: none;" type="file" accept=".docx">
28+
2429
<div id="superdoc"></div>
2530

2631
<script type="module">
27-
const superdoc = new SuperDocLibrary.SuperDoc({
32+
const config = {
2833
selector: '#superdoc',
2934
toolbar: '#my-toolbar',
30-
document: './sample.docx', // URL, File or document config
35+
// document: './sample.docx', // URL, File or document config
3136
documentMode: 'editing',
3237
pagination: true,
3338
rulers: true,
@@ -37,8 +42,15 @@
3742
onEditorCreate: (event) => {
3843
console.log('Editor is created', event);
3944
},
45+
};
46+
47+
const superdoc = new SuperDocLibrary.SuperDoc(config);
48+
49+
window.addEventListener('file-upload', (event) => {
50+
new SuperDocLibrary.SuperDoc({...config, document: event.detail});
4051
});
4152
</script>
53+
<script type="module" src="./file-upload.js"></script>
4254

4355
</body>
4456
</html>

examples/docxtemplater-example/src/App.vue

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -171,14 +171,19 @@ const getProcessedTemplateAndUpdateOutput = async ({ codeString, templateFileBlo
171171
172172
// init editor driver
173173
const initSuperdoc = async ({ file, name, selector, editorRef }) => {
174-
editorRef.value = new SuperDoc({
175-
selector,
176-
documents: [{
174+
const config = {
175+
selector
176+
}
177+
178+
if (file) {
179+
config.documents = [{
177180
id: `superdoc-${name}-${selector}`,
178181
type: 'docx',
179182
data: file
180-
}],
181-
});
183+
}]
184+
}
185+
186+
editorRef.value = new SuperDoc(config);
182187
}
183188
184189
// simulate the typing of code with setTimeout
@@ -261,7 +266,7 @@ onMounted(async () => {
261266
// init template editor
262267
const file = await getFileObject(templateFileUrl, 'template.docx');
263268
await initSuperdoc({
264-
file,
269+
// file,
265270
name: 'template.docx',
266271
selector: '#template-editor',
267272
editorRef: templateEditorInstance,

examples/grading-papers-example/app/grading/[id]/_doc-links.js

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,41 @@
11
// app/grading/_doc-links.js
2-
import assign1 from '@/assets/docs/assign-1.docx?url';
3-
import assign2 from '@/assets/docs/assign-2.docx?url';
4-
import assign3 from '@/assets/docs/assign-3.docx?url';
5-
import assign4 from '@/assets/docs/assign-4.docx?url';
6-
import assign5 from '@/assets/docs/assign-5.docx?url';
2+
// import assign5 from '@/assets/docs/assign-5.docx?url';
3+
// import assign2 from '@/assets/docs/assign-2.docx?url';
4+
// import assign3 from '@/assets/docs/assign-3.docx?url';
5+
// import assign4 from '@/assets/docs/assign-4.docx?url';
6+
// import assign5 from '@/assets/docs/assign-5.docx?url';
7+
8+
import assign1B64 from '@/assets/docs/assign-1.js';
9+
import assign2B64 from '@/assets/docs/assign-2.js';
10+
import assign3B64 from '@/assets/docs/assign-3.js';
11+
import assign4B64 from '@/assets/docs/assign-4.js';
12+
import assign5B64 from '@/assets/docs/assign-5.js';
13+
14+
const base64ToDocx = (base64String, filename) => {
15+
try {
16+
const binaryString = atob(base64String);
17+
const bytes = new Uint8Array(binaryString.length);
18+
for (let i = 0; i < binaryString.length; i++) {
19+
bytes[i] = binaryString.charCodeAt(i);
20+
}
21+
22+
const blob = new Blob([bytes], {
23+
type: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
24+
});
25+
26+
const file = new File([blob], filename, { type: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' });
27+
28+
return file;
29+
} catch (error) {
30+
console.error('Error converting base64 to DOCX:', error);
31+
}
32+
}
33+
34+
const assign1 = base64ToDocx(assign1B64, 'assign-1.docx');
35+
const assign2 = base64ToDocx(assign2B64, 'assign-2.docx');
36+
const assign3 = base64ToDocx(assign3B64, 'assign-3.docx');
37+
const assign4 = base64ToDocx(assign4B64, 'assign-4.docx');
38+
const assign5 = base64ToDocx(assign5B64, 'assign-5.docx');
739

840
export const docMap = {
941
'assign-1': assign1,

examples/grading-papers-example/assets/docs/assign-1.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/grading-papers-example/assets/docs/assign-2.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/grading-papers-example/assets/docs/assign-3.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/grading-papers-example/assets/docs/assign-4.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)