Skip to content

Commit 778c941

Browse files
committed
Merge branch 'develop' of github.com:Harbour-Enterprises/SuperDoc into feat_numbering_validator
2 parents ee49f70 + 251b102 commit 778c941

136 files changed

Lines changed: 25522 additions & 791 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.

examples/vue-custom-node-example/src/custom-node.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { Extensions } from '@harbour-enterprises/superdoc/super-editor';
1+
import { Extensions } from '@harbour-enterprises/superdoc';
22

33
// Extensions includes the necessary classes for creating custom nodes
4-
const { Attribute } = Extensions;
4+
const { Attribute, Node } = Extensions;
55

6-
export const myCustomNode = Extensions.Node.create({
6+
export const myCustomNode = Node.create({
77
name: 'customNode',
88

99
group: 'inline',

examples/vue-linked-editor-sections/src/App.vue

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import '@harbour-enterprises/superdoc/style.css';
33
import { onMounted, shallowRef, ref } from 'vue';
44
import { SuperDoc } from '@harbour-enterprises/superdoc';
55
import UploadFile from './UploadFile.vue';
6-
import { SectionHelpers } from '@harbour-enterprises/superdoc';
76
87
98
const superdoc = shallowRef(null);
@@ -69,7 +68,7 @@ const addSection = (section) => {
6968
html,
7069
}
7170
72-
const subEditor = SectionHelpers.getLinkedSectionEditor(id, options, editor.value);
71+
const subEditor = editor.value.helpers.documentSection.getLinkedSectionEditor(id, options, editor.value);
7372
}
7473
7574
const removeSection = (id) => {
@@ -90,12 +89,12 @@ const loadedMockHTML = {
9089
}
9190
9291
const saveSectionsHTML = () => {
93-
const sections = SectionHelpers.exportSectionsToHTML(editor.value);
92+
const sections = editor.value.helpers.documentSection.exportSectionsToHTML(editor.value);
9493
console.log('Saving sections to DB:', sections);
9594
}
9695
9796
const saveSectionsJSON = () => {
98-
const sections = SectionHelpers.exportSectionsToJSON(editor.value);
97+
const sections = editor.value.helpers.documentSection.exportSectionsToJSON(editor.value);
9998
console.log('Saving sections to DB:', sections);
10099
}
101100

package-lock.json

Lines changed: 1351 additions & 672 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"shared/*"
88
],
99
"scripts": {
10-
"test": "vitest --root ./packages/super-editor",
10+
"test": "vitest ./packages/superdoc/ ./packages/super-editor/",
1111
"unzip": "bash packages/super-editor/src/tests/helpers/unzip.sh",
1212
"dev": "npm --workspace=@harbour-enterprises/superdoc run dev",
1313
"dev:superdoc": "npm run dev --workspace=packages/superdoc",
@@ -32,7 +32,8 @@
3232
"pack": "npm run build:super-editor && npm --prefix ./packages/superdoc run pack",
3333
"prepare": "husky",
3434
"lint:staged": "lint-staged",
35-
"watch": "npm run watch:es --workspace=packages/superdoc"
35+
"watch": "npm run watch:es --workspace=packages/superdoc",
36+
"check:all": "npm run format && npm run lint:fix && npm --workspace=packages/super-editor run types:build"
3637
},
3738
"lint-staged": {
3839
"*.{js,jsx}": [
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
coverage/
2+
dist/
3+
node_modules/

packages/ooxml-inspector/README.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# OOXML Inspector
2+
3+
**OOXML Inspector** is a developer tool + library for working with [Office Open XML (OOXML)](https://en.wikipedia.org/wiki/Office_Open_XML) schemas.
4+
It bundles the transitional WordprocessingML schema into JSON and provides both:
5+
6+
- a **CLI** (`ooxml`) for inspecting schema relationships, and
7+
- a **JavaScript/TypeScript library** for programmatic access.
8+
9+
## Features
10+
11+
- Query OOXML element children, attributes, and namespaces
12+
- Explore schema relationships and tag hierarchies
13+
- Use as a CLI or import as a library in Node.js/TypeScript
14+
15+
## Installation
16+
17+
```bash
18+
npm install @superdoc-dev/ooxml-inspector
19+
```
20+
21+
## CLI Usage
22+
23+
```bash
24+
npx ooxml children w:p
25+
npx ooxml tags --parents
26+
npx ooxml namespaces
27+
npx ooxml attrs w:p
28+
```
29+
30+
- `children <prefix:local>`: List allowed children for an element
31+
- `tags [prefix] [--parents] [--plain]`: List tags, optionally filtering by namespace or parent status
32+
- `namespaces`: List all namespaces in the schema
33+
- `attrs <prefix:local>`: List attributes for an element
34+
35+
## Library Usage
36+
37+
```js
38+
import { childrenOf } from '@superdoc-dev/ooxml-inspector';
39+
40+
const children = childrenOf('w:p'); // Get children of <w:p>
41+
```
42+
43+
## Development
44+
45+
- Build: `npm run build`
46+
- Test: `npm run test`
47+
- Coverage: `npm run test:cov`
48+
49+
## License
50+
51+
AGPLv3
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { childrenOf } from '@superdoc-dev/ooxml-inspector';
2+
3+
const children = childrenOf('w:p');
4+
console.debug('Children of w:p', children);
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { runGenerator } from './src/index.js';
2+
3+
runGenerator();
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**
2+
* Auto-assign a prefix for a given target namespace.
3+
* @param {string} tns - The target namespace
4+
* @param {Object} nsMap - The namespace map
5+
* @returns {string} - The assigned prefix
6+
*/
7+
export const autoPrefix = (tns, nsMap) => {
8+
if (!tns) return 'unknown';
9+
if (nsMap[tns]) return nsMap[tns];
10+
const newPrefix = 'g' + Object.keys(nsMap).length;
11+
nsMap[tns] = newPrefix;
12+
return newPrefix;
13+
};
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import { describe, it, expect } from 'vitest';
2+
import { autoPrefix } from './index.js';
3+
4+
describe('autoPrefix', () => {
5+
it('returns "unknown" if tns is falsy', () => {
6+
const nsMap = {};
7+
expect(autoPrefix('', nsMap)).toBe('unknown');
8+
expect(autoPrefix(null, nsMap)).toBe('unknown');
9+
expect(autoPrefix(undefined, nsMap)).toBe('unknown');
10+
});
11+
12+
it('returns existing prefix if tns is already in nsMap', () => {
13+
const nsMap = { 'http://example.com': 'ex' };
14+
const result = autoPrefix('http://example.com', nsMap);
15+
expect(result).toBe('ex');
16+
expect(nsMap).toEqual({ 'http://example.com': 'ex' }); // unchanged
17+
});
18+
19+
it('assigns a new prefix if tns is not in nsMap', () => {
20+
const nsMap = {};
21+
const result = autoPrefix('http://new.com', nsMap);
22+
expect(result).toBe('g0');
23+
expect(nsMap).toEqual({ 'http://new.com': 'g0' });
24+
});
25+
26+
it('assigns incrementing prefixes based on nsMap size', () => {
27+
const nsMap = { 'http://one.com': 'g0', 'http://two.com': 'g1' };
28+
const result = autoPrefix('http://three.com', nsMap);
29+
expect(result).toBe('g2');
30+
expect(nsMap).toEqual({
31+
'http://one.com': 'g0',
32+
'http://two.com': 'g1',
33+
'http://three.com': 'g2',
34+
});
35+
});
36+
37+
it('does not overwrite existing mapping for different tns', () => {
38+
const nsMap = { 'http://foo.com': 'g0' };
39+
autoPrefix('http://bar.com', nsMap);
40+
expect(nsMap).toHaveProperty('http://foo.com', 'g0');
41+
expect(nsMap).toHaveProperty('http://bar.com', 'g1');
42+
});
43+
});

0 commit comments

Comments
 (0)