@lblod/ember-rdfa-editor-lblod-plugins 16.0.0 → 16.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -0
- package/README.md +9 -0
- package/addon/components/article-structure-plugin/structure-card.hbs +33 -0
- package/addon/components/article-structure-plugin/structure-card.ts +53 -0
- package/addon/plugins/article-structure-plugin/commands/index.ts +1 -0
- package/addon/plugins/article-structure-plugin/commands/recalculate-structure-numbers.ts +7 -0
- package/addon/plugins/article-structure-plugin/commands/set-structure-start-number.ts +43 -0
- package/addon/plugins/article-structure-plugin/index.ts +10 -0
- package/addon/plugins/article-structure-plugin/structures/article-paragraph.ts +23 -18
- package/addon/plugins/article-structure-plugin/structures/article.ts +19 -19
- package/addon/plugins/article-structure-plugin/structures/chapter.ts +3 -7
- package/addon/plugins/article-structure-plugin/structures/section.ts +3 -7
- package/addon/plugins/article-structure-plugin/structures/structure-header.ts +22 -15
- package/addon/plugins/article-structure-plugin/structures/subsection.ts +3 -7
- package/addon/plugins/article-structure-plugin/structures/title.ts +3 -7
- package/addon/plugins/article-structure-plugin/utils/romanize.ts +85 -0
- package/addon/plugins/article-structure-plugin/utils/structure.ts +133 -51
- package/addon/plugins/standard-template-plugin/utils/nodes.ts +31 -23
- package/addon/plugins/template-comments-plugin/node.ts +4 -3
- package/addon/utils/translation.ts +35 -0
- package/app/styles/citaten-plugin.scss +0 -2
- package/app/styles/confidentiality-plugin.scss +0 -2
- package/app/styles/template-comments-plugin.scss +3 -2
- package/components/article-structure-plugin/structure-card.d.ts +7 -0
- package/package.json +4 -4
- package/plugins/article-structure-plugin/commands/index.d.ts +1 -0
- package/plugins/article-structure-plugin/commands/set-structure-start-number.d.ts +4 -0
- package/plugins/article-structure-plugin/index.d.ts +13 -0
- package/plugins/article-structure-plugin/utils/romanize.d.ts +5 -0
- package/plugins/article-structure-plugin/utils/structure.d.ts +16 -3
- package/translations/en-US.yaml +4 -0
- package/translations/nl-BE.yaml +4 -0
- package/utils/translation.d.ts +5 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# @lblod/ember-rdfa-editor-lblod-plugins
|
|
2
2
|
|
|
3
|
+
## 16.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#377](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/377) [`c383236`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/c38323626745e55671bcbc2afc01d91b17911dd3) Thanks [@elpoelma](https://github.com/elpoelma)! - - Addition of the `say-template-comment` class to the static version of template comments.
|
|
8
|
+
|
|
9
|
+
- Addition of some extra styles to the `say-template-comment` class.
|
|
10
|
+
|
|
11
|
+
- [#378](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/378) [`7b53e51`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/7b53e514aac79286267da1f7f32b7179fea3fb7d) Thanks [@elpoelma](https://github.com/elpoelma)! - Add helper function to help with locale selection and add translation note to readme
|
|
12
|
+
|
|
13
|
+
- [#376](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/376) [`301b4b3`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/301b4b3a9288ce53f7be4117e95526bf73be1534) Thanks [@dkozickis](https://github.com/dkozickis)! - GN-4650: Allows to set a "start number" for a structure.
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- [#377](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/377) [`c383236`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/c38323626745e55671bcbc2afc01d91b17911dd3) Thanks [@elpoelma](https://github.com/elpoelma)! - Remove `@import "ember-appuniversum"` statements from plugin sass modules in order to prevent style overrding.
|
|
18
|
+
|
|
19
|
+
- [`4ddf16c`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/4ddf16c91959d77fda1cd7b033f7ca18d2857b70) Thanks [@elpoelma](https://github.com/elpoelma)! - Fix template-comment padding
|
|
20
|
+
|
|
21
|
+
## 16.0.1
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- [#375](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/375) [`93d3f7b`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/93d3f7b63bc0e720e9f6f328ffa9a384947ca31f) Thanks [@elpoelma](https://github.com/elpoelma)! - Widen support for `ember-intl` to include version 5.7.2 due to outstanding issues with the 6.x releases.
|
|
26
|
+
|
|
3
27
|
## 16.0.0
|
|
4
28
|
|
|
5
29
|
### Major Changes
|
package/README.md
CHANGED
|
@@ -859,6 +859,15 @@ To use `@lblod/ember-rdfa-editor-lblod-plugins` with Embroider some extra Webpac
|
|
|
859
859
|
|
|
860
860
|
If you already provide some Webpack configuration, you can deep merge that with the config object we provide.
|
|
861
861
|
|
|
862
|
+
## Translation
|
|
863
|
+
|
|
864
|
+
Translations are provided for UI elements using ember-intl.
|
|
865
|
+
Currently the only languages supported are English (en-US) and Dutch (nl-BE).
|
|
866
|
+
Other languages can be added by copying the contents of the file `translations/en-us.yaml` into the relevant language file in your `translations` folder and translating all of the strings.
|
|
867
|
+
|
|
868
|
+
A helper function is provided to assist with finding a reasonable fallback locale, for example providing `en-US` translations if `en` is requested.
|
|
869
|
+
See [the test app](tests/dummy/app/routes/application.ts) for example of it's usage.
|
|
870
|
+
|
|
862
871
|
## Contributing
|
|
863
872
|
|
|
864
873
|
See the [Contributing](CONTRIBUTING.md) guide for details.
|
|
@@ -79,6 +79,39 @@
|
|
|
79
79
|
|
|
80
80
|
</AuButtonGroup>
|
|
81
81
|
</Item>
|
|
82
|
+
<Item class="au-u-padding-left-small">
|
|
83
|
+
<AuFormRow>
|
|
84
|
+
{{#let (unique-id) as |id|}}
|
|
85
|
+
<AuLabel for={{id}}>
|
|
86
|
+
{{t 'article-structure-plugin.start-number.start-number'}}
|
|
87
|
+
</AuLabel>
|
|
88
|
+
<AuInput
|
|
89
|
+
id={{id}}
|
|
90
|
+
value={{this.startNumberInputValue}}
|
|
91
|
+
{{on "change" this.onStartNumberChange}}
|
|
92
|
+
placeholder={{t 'article-structure-plugin.start-number.start-number'}}
|
|
93
|
+
type="number"
|
|
94
|
+
min="1"
|
|
95
|
+
/>
|
|
96
|
+
{{/let}}
|
|
97
|
+
</AuFormRow>
|
|
98
|
+
<AuButton
|
|
99
|
+
@iconAlignment="left"
|
|
100
|
+
class="au-u-margin-top-tiny"
|
|
101
|
+
{{on 'click' this.setStructureStartNumber}}
|
|
102
|
+
>
|
|
103
|
+
{{t 'article-structure-plugin.start-number.set'}}
|
|
104
|
+
</AuButton>
|
|
105
|
+
<AuButton
|
|
106
|
+
@iconAlignment="left"
|
|
107
|
+
@skin="secondary"
|
|
108
|
+
@disabled={{not this.structureStartNumber}}
|
|
109
|
+
class="au-u-margin-top-tiny"
|
|
110
|
+
{{on 'click' this.resetStructureStartNumber}}
|
|
111
|
+
>
|
|
112
|
+
{{t 'article-structure-plugin.start-number.reset'}}
|
|
113
|
+
</AuButton>
|
|
114
|
+
</Item>
|
|
82
115
|
</AuList>
|
|
83
116
|
</c.content>
|
|
84
117
|
</AuCard>
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
moveSelectedStructure,
|
|
6
6
|
removeStructure,
|
|
7
7
|
unwrapStructure,
|
|
8
|
+
setStructureStartNumber,
|
|
8
9
|
} from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/article-structure-plugin/commands';
|
|
9
10
|
import { ArticleStructurePluginOptions } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/article-structure-plugin';
|
|
10
11
|
import { findAncestorOfType } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/article-structure-plugin/utils/structure';
|
|
@@ -20,6 +21,7 @@ type Args = {
|
|
|
20
21
|
export default class EditorPluginsStructureCardComponent extends Component<Args> {
|
|
21
22
|
@service declare intl: IntlService;
|
|
22
23
|
@tracked removeStructureContent = false;
|
|
24
|
+
@tracked startNumber: number | null = null;
|
|
23
25
|
|
|
24
26
|
get controller() {
|
|
25
27
|
return this.args.controller;
|
|
@@ -34,6 +36,57 @@ export default class EditorPluginsStructureCardComponent extends Component<Args>
|
|
|
34
36
|
this.controller.focus();
|
|
35
37
|
}
|
|
36
38
|
|
|
39
|
+
@action
|
|
40
|
+
setStructureStartNumber() {
|
|
41
|
+
if (this.startNumber) {
|
|
42
|
+
this.controller.doCommand(
|
|
43
|
+
setStructureStartNumber(this.structureTypes, this.startNumber),
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
this.startNumber = null;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
@action
|
|
51
|
+
resetStructureStartNumber() {
|
|
52
|
+
this.controller.doCommand(
|
|
53
|
+
setStructureStartNumber(this.structureTypes, null),
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
this.startNumber = null;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
get structureNumber() {
|
|
60
|
+
if (this.structure && this.currentStructureType) {
|
|
61
|
+
return this.currentStructureType.getNumber({
|
|
62
|
+
pos: this.structure.pos,
|
|
63
|
+
transaction: this.controller.mainEditorState.tr,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
get structureStartNumber() {
|
|
71
|
+
if (this.structure && this.currentStructureType) {
|
|
72
|
+
return this.currentStructureType.getStartNumber({
|
|
73
|
+
pos: this.structure.pos,
|
|
74
|
+
transaction: this.controller.mainEditorState.tr,
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
get startNumberInputValue() {
|
|
82
|
+
return this.startNumber ?? this.structureNumber ?? '';
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
onStartNumberChange = (event: InputEvent) => {
|
|
86
|
+
const target = event.target as HTMLInputElement;
|
|
87
|
+
this.startNumber = parseInt(target.value);
|
|
88
|
+
};
|
|
89
|
+
|
|
37
90
|
@action
|
|
38
91
|
removeStructure(withContent: boolean) {
|
|
39
92
|
if (this.structure && this.currentStructureType) {
|
|
@@ -4,3 +4,4 @@ export { default as recalculateStructureNumbers } from './recalculate-structure-
|
|
|
4
4
|
export { default as removeStructure } from './remove-structure';
|
|
5
5
|
export { default as unwrapStructure } from './unwrap-structure';
|
|
6
6
|
export { default as wrapStructureContent } from './wrap-structure-content';
|
|
7
|
+
export { default as setStructureStartNumber } from './set-structure-start-number';
|
|
@@ -17,6 +17,13 @@ export default function recalculateStructureNumbers(
|
|
|
17
17
|
indices[i] = 1;
|
|
18
18
|
contexts[i] = parent;
|
|
19
19
|
}
|
|
20
|
+
|
|
21
|
+
const startNumber = spec.getStartNumber({ pos, transaction });
|
|
22
|
+
|
|
23
|
+
if (startNumber) {
|
|
24
|
+
indices[i] = startNumber;
|
|
25
|
+
}
|
|
26
|
+
|
|
20
27
|
spec.updateNumber({ number: indices[i], pos, transaction });
|
|
21
28
|
indices[i] += 1;
|
|
22
29
|
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Command } from '@lblod/ember-rdfa-editor';
|
|
2
|
+
|
|
3
|
+
import { findAncestorOfType } from '../utils/structure';
|
|
4
|
+
import type { ArticleStructurePluginOptions } from '..';
|
|
5
|
+
import recalculateStructureNumbers from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/article-structure-plugin/commands/recalculate-structure-numbers';
|
|
6
|
+
import { unwrap } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/option';
|
|
7
|
+
|
|
8
|
+
const setStructureStartNumber = (
|
|
9
|
+
options: ArticleStructurePluginOptions,
|
|
10
|
+
startNumber: number | null,
|
|
11
|
+
): Command => {
|
|
12
|
+
return (state, dispatch) => {
|
|
13
|
+
const { selection, schema } = state;
|
|
14
|
+
|
|
15
|
+
const structureSpecs = options.map((type) => schema.nodes[type.name]);
|
|
16
|
+
const currentStructure = findAncestorOfType(selection, ...structureSpecs);
|
|
17
|
+
|
|
18
|
+
if (!currentStructure || currentStructure.pos === -1) {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const currentStructureSpec = unwrap(
|
|
23
|
+
options.find((spec) => spec.name === currentStructure.node.type.name),
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
if (dispatch) {
|
|
27
|
+
const transaction = state.tr;
|
|
28
|
+
|
|
29
|
+
currentStructureSpec.setStartNumber({
|
|
30
|
+
number: startNumber,
|
|
31
|
+
pos: currentStructure.pos,
|
|
32
|
+
transaction,
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
recalculateStructureNumbers(transaction, ...options);
|
|
36
|
+
|
|
37
|
+
dispatch(transaction);
|
|
38
|
+
}
|
|
39
|
+
return true;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export default setStructureStartNumber;
|
|
@@ -38,6 +38,16 @@ export type StructureSpec = {
|
|
|
38
38
|
pos: number;
|
|
39
39
|
transaction: Transaction;
|
|
40
40
|
}) => Transaction;
|
|
41
|
+
getNumber: (args: { pos: number; transaction: Transaction }) => number | null;
|
|
42
|
+
setStartNumber: (args: {
|
|
43
|
+
number: number | null;
|
|
44
|
+
pos: number;
|
|
45
|
+
transaction: Transaction;
|
|
46
|
+
}) => Transaction;
|
|
47
|
+
getStartNumber: (args: {
|
|
48
|
+
pos: number;
|
|
49
|
+
transaction: Transaction;
|
|
50
|
+
}) => number | null;
|
|
41
51
|
content?: (args: { pos: number; state: EditorState }) => Fragment;
|
|
42
52
|
continuous: boolean;
|
|
43
53
|
limitTo?: string;
|
|
@@ -4,10 +4,15 @@ import { v4 as uuid } from 'uuid';
|
|
|
4
4
|
import {
|
|
5
5
|
ELI,
|
|
6
6
|
SAY,
|
|
7
|
-
XSD,
|
|
8
7
|
} from '@lblod/ember-rdfa-editor-lblod-plugins/utils/constants';
|
|
9
8
|
import { hasRDFaAttribute } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/namespace';
|
|
10
9
|
import { getTranslationFunction } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/translation';
|
|
10
|
+
import {
|
|
11
|
+
getNumberAttributeFromElement,
|
|
12
|
+
getNumberAttributesFromNode,
|
|
13
|
+
getNumberDocSpecFromNode,
|
|
14
|
+
getNumberUtils,
|
|
15
|
+
} from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/article-structure-plugin/utils/structure';
|
|
11
16
|
|
|
12
17
|
const PLACEHOLDERS = {
|
|
13
18
|
body: 'article-structure-plugin.placeholder.paragraph.body',
|
|
@@ -27,13 +32,12 @@ export const articleParagraphSpec: StructureSpec = {
|
|
|
27
32
|
continuous: false,
|
|
28
33
|
noUnwrap: true,
|
|
29
34
|
constructor: ({ schema, number, intl, state }) => {
|
|
30
|
-
const numberConverted = number?.toString() ?? '1';
|
|
31
35
|
const translationWithDocLang = getTranslationFunction(state);
|
|
32
36
|
const node = schema.node(
|
|
33
37
|
`article_paragraph`,
|
|
34
38
|
{
|
|
35
39
|
resource: `http://data.lblod.info/paragraphs/${uuid()}`,
|
|
36
|
-
number
|
|
40
|
+
number,
|
|
37
41
|
},
|
|
38
42
|
schema.node(
|
|
39
43
|
'paragraph',
|
|
@@ -48,10 +52,7 @@ export const articleParagraphSpec: StructureSpec = {
|
|
|
48
52
|
);
|
|
49
53
|
return { node, selectionConfig: { relativePos: 1, type: 'node' } };
|
|
50
54
|
},
|
|
51
|
-
|
|
52
|
-
const numberConverted = number.toString();
|
|
53
|
-
return transaction.setNodeAttribute(pos, 'number', numberConverted);
|
|
54
|
-
},
|
|
55
|
+
...getNumberUtils(),
|
|
55
56
|
};
|
|
56
57
|
|
|
57
58
|
const contentSelector = `span[property~='${SAY('body').prefixed}'],
|
|
@@ -71,7 +72,13 @@ export const article_paragraph: NodeSpec = {
|
|
|
71
72
|
},
|
|
72
73
|
resource: {},
|
|
73
74
|
number: {
|
|
74
|
-
default:
|
|
75
|
+
default: 1,
|
|
76
|
+
},
|
|
77
|
+
numberDisplayStyle: {
|
|
78
|
+
default: 'decimal', // decimal, roman
|
|
79
|
+
},
|
|
80
|
+
startNumber: {
|
|
81
|
+
default: null,
|
|
75
82
|
},
|
|
76
83
|
},
|
|
77
84
|
toDOM(node) {
|
|
@@ -81,17 +88,10 @@ export const article_paragraph: NodeSpec = {
|
|
|
81
88
|
property: node.attrs.property as string,
|
|
82
89
|
typeof: node.attrs.typeof as string,
|
|
83
90
|
resource: node.attrs.resource as string,
|
|
91
|
+
...getNumberAttributesFromNode(node),
|
|
84
92
|
},
|
|
85
93
|
['span', { contenteditable: false }, '§'],
|
|
86
|
-
|
|
87
|
-
'span',
|
|
88
|
-
{
|
|
89
|
-
property: ELI('number').prefixed,
|
|
90
|
-
datatype: XSD('integer').prefixed,
|
|
91
|
-
contenteditable: false,
|
|
92
|
-
},
|
|
93
|
-
node.attrs.number,
|
|
94
|
-
],
|
|
94
|
+
getNumberDocSpecFromNode(node),
|
|
95
95
|
['span', { contenteditable: false }, '. '],
|
|
96
96
|
['span', { property: SAY('body').prefixed }, 0],
|
|
97
97
|
];
|
|
@@ -110,9 +110,14 @@ export const article_paragraph: NodeSpec = {
|
|
|
110
110
|
element.querySelector(contentSelector) &&
|
|
111
111
|
numberSpan
|
|
112
112
|
) {
|
|
113
|
+
const numberAttributes = getNumberAttributeFromElement(
|
|
114
|
+
element,
|
|
115
|
+
numberSpan,
|
|
116
|
+
);
|
|
117
|
+
|
|
113
118
|
return {
|
|
114
119
|
resource: element.getAttribute('resource'),
|
|
115
|
-
|
|
120
|
+
...numberAttributes,
|
|
116
121
|
};
|
|
117
122
|
}
|
|
118
123
|
return false;
|
|
@@ -3,14 +3,15 @@ import { StructureSpec } from '..';
|
|
|
3
3
|
import {
|
|
4
4
|
constructStructureBodyNodeSpec,
|
|
5
5
|
constructStructureNodeSpec,
|
|
6
|
+
getNumberDocSpecFromNode,
|
|
7
|
+
getNumberAttributesFromNode,
|
|
8
|
+
getNumberUtils,
|
|
6
9
|
getStructureHeaderAttrs,
|
|
7
10
|
} from '../utils/structure';
|
|
8
11
|
import { v4 as uuid } from 'uuid';
|
|
9
12
|
import {
|
|
10
|
-
ELI,
|
|
11
13
|
EXT,
|
|
12
14
|
SAY,
|
|
13
|
-
XSD,
|
|
14
15
|
} from '@lblod/ember-rdfa-editor-lblod-plugins/utils/constants';
|
|
15
16
|
import { unwrap } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/option';
|
|
16
17
|
import { getTranslationFunction } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/translation';
|
|
@@ -32,7 +33,6 @@ export const articleSpec: StructureSpec = {
|
|
|
32
33
|
},
|
|
33
34
|
continuous: true,
|
|
34
35
|
constructor: ({ schema, number, content, intl, state }) => {
|
|
35
|
-
const numberConverted = number?.toString() ?? '1';
|
|
36
36
|
const translationWithDocLang = getTranslationFunction(state);
|
|
37
37
|
const node = schema.node(
|
|
38
38
|
`article`,
|
|
@@ -40,7 +40,7 @@ export const articleSpec: StructureSpec = {
|
|
|
40
40
|
[
|
|
41
41
|
schema.node(
|
|
42
42
|
'article_header',
|
|
43
|
-
{ level: 4, number:
|
|
43
|
+
{ level: 4, number: number ?? 1 },
|
|
44
44
|
schema.node('placeholder', {
|
|
45
45
|
placeholderText: translationWithDocLang(
|
|
46
46
|
PLACEHOLDERS.title,
|
|
@@ -76,10 +76,7 @@ export const articleSpec: StructureSpec = {
|
|
|
76
76
|
selectionConfig,
|
|
77
77
|
};
|
|
78
78
|
},
|
|
79
|
-
|
|
80
|
-
const numberConverted = number.toString();
|
|
81
|
-
return transaction.setNodeAttribute(pos + 1, 'number', numberConverted);
|
|
82
|
-
},
|
|
79
|
+
...getNumberUtils(1),
|
|
83
80
|
content: ({ pos, state }) => {
|
|
84
81
|
const node = unwrap(state.doc.nodeAt(pos));
|
|
85
82
|
return node.child(1).content;
|
|
@@ -98,7 +95,13 @@ export const article_header: NodeSpec = {
|
|
|
98
95
|
defining: true,
|
|
99
96
|
attrs: {
|
|
100
97
|
number: {
|
|
101
|
-
default:
|
|
98
|
+
default: 1,
|
|
99
|
+
},
|
|
100
|
+
numberDisplayStyle: {
|
|
101
|
+
default: 'decimal', // decimal, roman
|
|
102
|
+
},
|
|
103
|
+
startNumber: {
|
|
104
|
+
default: null,
|
|
102
105
|
},
|
|
103
106
|
property: {
|
|
104
107
|
default: SAY('heading').prefixed,
|
|
@@ -112,17 +115,12 @@ export const article_header: NodeSpec = {
|
|
|
112
115
|
toDOM(node) {
|
|
113
116
|
return [
|
|
114
117
|
'div',
|
|
115
|
-
{
|
|
118
|
+
{
|
|
119
|
+
property: node.attrs.property as string,
|
|
120
|
+
...getNumberAttributesFromNode(node),
|
|
121
|
+
},
|
|
116
122
|
'Artikel ',
|
|
117
|
-
|
|
118
|
-
'span',
|
|
119
|
-
{
|
|
120
|
-
property: ELI('number').prefixed,
|
|
121
|
-
datatype: XSD('string').prefixed,
|
|
122
|
-
contenteditable: false,
|
|
123
|
-
},
|
|
124
|
-
node.attrs.number,
|
|
125
|
-
],
|
|
123
|
+
getNumberDocSpecFromNode(node),
|
|
126
124
|
['span', { contenteditable: false }, ': '],
|
|
127
125
|
[
|
|
128
126
|
'span',
|
|
@@ -138,9 +136,11 @@ export const article_header: NodeSpec = {
|
|
|
138
136
|
tag: 'div',
|
|
139
137
|
getAttrs(element: HTMLElement) {
|
|
140
138
|
const headerAttrs = getStructureHeaderAttrs(element);
|
|
139
|
+
|
|
141
140
|
if (headerAttrs) {
|
|
142
141
|
return headerAttrs;
|
|
143
142
|
}
|
|
143
|
+
|
|
144
144
|
return false;
|
|
145
145
|
},
|
|
146
146
|
contentElement: `span[property~='${EXT('title').prefixed}'],
|
|
@@ -2,7 +2,7 @@ import { StructureSpec } from '..';
|
|
|
2
2
|
import {
|
|
3
3
|
constructStructureBodyNodeSpec,
|
|
4
4
|
constructStructureNodeSpec,
|
|
5
|
-
|
|
5
|
+
getNumberUtils,
|
|
6
6
|
} from '../utils/structure';
|
|
7
7
|
import { v4 as uuid } from 'uuid';
|
|
8
8
|
import { SAY } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/constants';
|
|
@@ -26,7 +26,6 @@ export const chapterSpec: StructureSpec = {
|
|
|
26
26
|
removeWithContent: 'article-structure-plugin.remove-with-content.chapter',
|
|
27
27
|
},
|
|
28
28
|
constructor: ({ schema, number, content, intl, state }) => {
|
|
29
|
-
const numberConverted = romanize(number ?? 1);
|
|
30
29
|
const translationWithDocLang = getTranslationFunction(state);
|
|
31
30
|
const node = schema.node(
|
|
32
31
|
`chapter`,
|
|
@@ -34,7 +33,7 @@ export const chapterSpec: StructureSpec = {
|
|
|
34
33
|
[
|
|
35
34
|
schema.node(
|
|
36
35
|
'structure_header',
|
|
37
|
-
{ level: 4, number:
|
|
36
|
+
{ level: 4, number: number ?? 1, numberDisplayStyle: 'roman' },
|
|
38
37
|
schema.node('placeholder', {
|
|
39
38
|
placeholderText: translationWithDocLang(
|
|
40
39
|
PLACEHOLDERS.title,
|
|
@@ -70,10 +69,7 @@ export const chapterSpec: StructureSpec = {
|
|
|
70
69
|
selectionConfig,
|
|
71
70
|
};
|
|
72
71
|
},
|
|
73
|
-
|
|
74
|
-
const numberConverted = romanize(number);
|
|
75
|
-
return transaction.setNodeAttribute(pos + 1, 'number', numberConverted);
|
|
76
|
-
},
|
|
72
|
+
...getNumberUtils(1),
|
|
77
73
|
content: ({ pos, state }) => {
|
|
78
74
|
const node = unwrap(state.doc.nodeAt(pos));
|
|
79
75
|
return node.child(1).content;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
constructStructureBodyNodeSpec,
|
|
3
3
|
constructStructureNodeSpec,
|
|
4
|
-
|
|
4
|
+
getNumberUtils,
|
|
5
5
|
} from '../utils/structure';
|
|
6
6
|
import { v4 as uuid } from 'uuid';
|
|
7
7
|
import { StructureSpec } from '..';
|
|
@@ -26,7 +26,6 @@ export const sectionSpec: StructureSpec = {
|
|
|
26
26
|
removeWithContent: 'article-structure-plugin.remove-with-content.section',
|
|
27
27
|
},
|
|
28
28
|
constructor: ({ schema, number, content, intl, state }) => {
|
|
29
|
-
const numberConverted = romanize(number || 1);
|
|
30
29
|
const translationWithDocLang = getTranslationFunction(state);
|
|
31
30
|
const node = schema.node(
|
|
32
31
|
`section`,
|
|
@@ -34,7 +33,7 @@ export const sectionSpec: StructureSpec = {
|
|
|
34
33
|
[
|
|
35
34
|
schema.node(
|
|
36
35
|
'structure_header',
|
|
37
|
-
{ level: 5, number:
|
|
36
|
+
{ level: 5, number: number ?? 1, numberDisplayStyle: 'roman' },
|
|
38
37
|
schema.node('placeholder', {
|
|
39
38
|
placeholderText: translationWithDocLang(
|
|
40
39
|
PLACEHOLDERS.title,
|
|
@@ -70,10 +69,7 @@ export const sectionSpec: StructureSpec = {
|
|
|
70
69
|
selectionConfig,
|
|
71
70
|
};
|
|
72
71
|
},
|
|
73
|
-
|
|
74
|
-
const numberConverted = romanize(number);
|
|
75
|
-
return transaction.setNodeAttribute(pos + 1, 'number', numberConverted);
|
|
76
|
-
},
|
|
72
|
+
...getNumberUtils(1),
|
|
77
73
|
content: ({ pos, state }) => {
|
|
78
74
|
const node = unwrap(state.doc.nodeAt(pos));
|
|
79
75
|
return node.child(1).content;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { NodeSpec, PNode } from '@lblod/ember-rdfa-editor';
|
|
2
2
|
import {
|
|
3
|
-
ELI,
|
|
4
3
|
EXT,
|
|
5
4
|
SAY,
|
|
6
|
-
XSD,
|
|
7
5
|
} from '@lblod/ember-rdfa-editor-lblod-plugins/utils/constants';
|
|
8
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
getNumberDocSpecFromNode,
|
|
8
|
+
getNumberAttributesFromNode,
|
|
9
|
+
getStructureHeaderAttrs,
|
|
10
|
+
} from '../utils/structure';
|
|
9
11
|
|
|
10
12
|
const TAG_TO_LEVEL = new Map([
|
|
11
13
|
['h1', 1],
|
|
@@ -28,7 +30,13 @@ export const structure_header: NodeSpec = {
|
|
|
28
30
|
default: SAY('heading').prefixed,
|
|
29
31
|
},
|
|
30
32
|
number: {
|
|
31
|
-
default:
|
|
33
|
+
default: 1,
|
|
34
|
+
},
|
|
35
|
+
numberDisplayStyle: {
|
|
36
|
+
default: 'decimal', // decimal, roman
|
|
37
|
+
},
|
|
38
|
+
startNumber: {
|
|
39
|
+
default: null,
|
|
32
40
|
},
|
|
33
41
|
level: {
|
|
34
42
|
default: 1,
|
|
@@ -41,16 +49,11 @@ export const structure_header: NodeSpec = {
|
|
|
41
49
|
toDOM(node) {
|
|
42
50
|
return [
|
|
43
51
|
`h${node.attrs.level as number}`,
|
|
44
|
-
{
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
datatype: XSD('string').prefixed,
|
|
50
|
-
contenteditable: false,
|
|
51
|
-
},
|
|
52
|
-
node.attrs.number,
|
|
53
|
-
],
|
|
52
|
+
{
|
|
53
|
+
property: node.attrs.property as string,
|
|
54
|
+
...getNumberAttributesFromNode(node),
|
|
55
|
+
},
|
|
56
|
+
getNumberDocSpecFromNode(node),
|
|
54
57
|
['span', { contenteditable: false }, '. '],
|
|
55
58
|
[
|
|
56
59
|
'span',
|
|
@@ -67,8 +70,12 @@ export const structure_header: NodeSpec = {
|
|
|
67
70
|
getAttrs(element: HTMLElement) {
|
|
68
71
|
const level = TAG_TO_LEVEL.get(element.tagName.toLowerCase()) ?? 6;
|
|
69
72
|
const headerAttrs = getStructureHeaderAttrs(element);
|
|
73
|
+
|
|
70
74
|
if (headerAttrs) {
|
|
71
|
-
return {
|
|
75
|
+
return {
|
|
76
|
+
level,
|
|
77
|
+
...headerAttrs,
|
|
78
|
+
};
|
|
72
79
|
}
|
|
73
80
|
|
|
74
81
|
return false;
|
|
@@ -2,7 +2,7 @@ import { StructureSpec } from '..';
|
|
|
2
2
|
import {
|
|
3
3
|
constructStructureBodyNodeSpec,
|
|
4
4
|
constructStructureNodeSpec,
|
|
5
|
-
|
|
5
|
+
getNumberUtils,
|
|
6
6
|
} from '../utils/structure';
|
|
7
7
|
import { v4 as uuid } from 'uuid';
|
|
8
8
|
import { SAY } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/constants';
|
|
@@ -28,7 +28,6 @@ export const subsectionSpec: StructureSpec = {
|
|
|
28
28
|
'article-structure-plugin.remove-with-content.subsection',
|
|
29
29
|
},
|
|
30
30
|
constructor: ({ schema, number, intl, content, state }) => {
|
|
31
|
-
const numberConverted = romanize(number ?? 1);
|
|
32
31
|
const translationWithDocLang = getTranslationFunction(state);
|
|
33
32
|
const node = schema.node(
|
|
34
33
|
`subsection`,
|
|
@@ -36,7 +35,7 @@ export const subsectionSpec: StructureSpec = {
|
|
|
36
35
|
[
|
|
37
36
|
schema.node(
|
|
38
37
|
'structure_header',
|
|
39
|
-
{ level: 6, number:
|
|
38
|
+
{ level: 6, number: number ?? 1, numberDisplayStyle: 'roman' },
|
|
40
39
|
schema.node('placeholder', {
|
|
41
40
|
placeholderText: translationWithDocLang(
|
|
42
41
|
PLACEHOLDERS.title,
|
|
@@ -72,10 +71,7 @@ export const subsectionSpec: StructureSpec = {
|
|
|
72
71
|
selectionConfig,
|
|
73
72
|
};
|
|
74
73
|
},
|
|
75
|
-
|
|
76
|
-
const numberConverted = romanize(number);
|
|
77
|
-
return transaction.setNodeAttribute(pos + 1, 'number', numberConverted);
|
|
78
|
-
},
|
|
74
|
+
...getNumberUtils(1),
|
|
79
75
|
content: ({ pos, state }) => {
|
|
80
76
|
const node = unwrap(state.doc.nodeAt(pos));
|
|
81
77
|
return node.child(1).content;
|
|
@@ -2,7 +2,7 @@ import { StructureSpec } from '..';
|
|
|
2
2
|
import {
|
|
3
3
|
constructStructureBodyNodeSpec,
|
|
4
4
|
constructStructureNodeSpec,
|
|
5
|
-
|
|
5
|
+
getNumberUtils,
|
|
6
6
|
} from '../utils/structure';
|
|
7
7
|
import { v4 as uuid } from 'uuid';
|
|
8
8
|
import { SAY } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/constants';
|
|
@@ -26,7 +26,6 @@ export const titleSpec: StructureSpec = {
|
|
|
26
26
|
removeWithContent: 'article-structure-plugin.remove-with-content.title',
|
|
27
27
|
},
|
|
28
28
|
constructor: ({ schema, number, content, intl, state }) => {
|
|
29
|
-
const numberConverted = romanize(number ?? 1);
|
|
30
29
|
const translationWithDocLang = getTranslationFunction(state);
|
|
31
30
|
const node = schema.node(
|
|
32
31
|
`title`,
|
|
@@ -34,7 +33,7 @@ export const titleSpec: StructureSpec = {
|
|
|
34
33
|
[
|
|
35
34
|
schema.node(
|
|
36
35
|
'structure_header',
|
|
37
|
-
{ level: 3, number:
|
|
36
|
+
{ level: 3, number: number ?? 1, numberDisplayStyle: 'roman' },
|
|
38
37
|
schema.node('placeholder', {
|
|
39
38
|
placeholderText: translationWithDocLang(
|
|
40
39
|
PLACEHOLDERS.heading,
|
|
@@ -70,10 +69,7 @@ export const titleSpec: StructureSpec = {
|
|
|
70
69
|
selectionConfig,
|
|
71
70
|
};
|
|
72
71
|
},
|
|
73
|
-
|
|
74
|
-
const numberConverted = romanize(number);
|
|
75
|
-
return transaction.setNodeAttribute(pos + 1, 'number', numberConverted);
|
|
76
|
-
},
|
|
72
|
+
...getNumberUtils(1),
|
|
77
73
|
content: ({ pos, state }) => {
|
|
78
74
|
const node = unwrap(state.doc.nodeAt(pos));
|
|
79
75
|
return node.child(1).content;
|