Skip to content
Draft
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,6 @@ AGENTS.md
codex.config.json
perf-baseline-results.json
.claude

*storybook.log
storybook-static
30 changes: 23 additions & 7 deletions e2e-tests/templates/vue/src/App.vue
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
<script setup>
import 'superdoc/style.css';
import '@/style.css';
import BlankDOCX from './data/blank.docx?url';
import { onMounted, shallowRef } from 'vue';
import { SuperDoc } from 'superdoc';
import { SuperDoc } from '@superdoc';

import { CustomMark } from './custom-mark.js';
import { nextTick } from 'process';
import process from 'process';

const props = defineProps({
filename: String,
onReady: Function,
superDocConfig: Object,
});

window.fileData = null;
const useLayoutEngine = new URLSearchParams(window.location.search).get('layout') === '1';

const superdoc = shallowRef(null);
const init = async () => {
if (superdoc.value) superdoc.value.destroy();
Expand Down Expand Up @@ -44,6 +51,9 @@ const init = async () => {
tooltip: 'Insert Custom Mark',
group: 'center',
icon: '🎧',
attributes: {
ariaLabel: 'Insert Custom Mark',
},
},
],
},
Expand Down Expand Up @@ -83,9 +93,9 @@ const init = async () => {
}
}

nextTick(() => {
process.nextTick(() => {
if (!config.modules) config.modules = {};
superdoc.value = new SuperDoc(config);
superdoc.value = new SuperDoc({ ...config, ...props.superDocConfig });
});
};

Expand All @@ -97,6 +107,9 @@ const onReady = () => {
if (window.superdocReady) {
window.superdocReady();
}
if (props.onReady) {
props.onReady();
}
};

const handleFileChange = async (event) => {
Expand Down Expand Up @@ -134,8 +147,11 @@ const onFontsResolved = ({ documentFonts, unsupportedFonts }) => {
}
};

onMounted(() => {
init();
onMounted(async () => {
if (props.filename) {
window.fileData = await getFileObject(props.filename);
}
await init();
});
</script>

Expand Down
2 changes: 1 addition & 1 deletion e2e-tests/templates/vue/src/custom-mark.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Extensions } from 'superdoc/super-editor';
import { Extensions } from '@';

const { Attribute } = Extensions;
export const CustomMark = Extensions.Mark.create({
Expand Down
6 changes: 6 additions & 0 deletions e2e-tests/templates/vue/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,10 @@ export default defineConfig({
optimizeDeps: {
exclude: ['superdoc'],
},
resolve: {
alias: {
'@': 'superdoc/super-editor',
'@superdoc': 'superdoc',
},
},
})
4 changes: 4 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// For more info, see https://github.com/storybookjs/eslint-plugin-storybook#configuration-flat-config-format
import storybook from "eslint-plugin-storybook";

import js from '@eslint/js';
import tseslint from 'typescript-eslint';
import prettierConfig from 'eslint-config-prettier';
Expand Down Expand Up @@ -176,4 +179,5 @@ export default [
'@typescript-eslint/no-empty-object-type': 'off',
},
},
...storybook.configs["flat/recommended"],
];
Loading
Loading