@lblod/ember-rdfa-editor-lblod-plugins 1.0.0-beta.2 → 1.0.0-beta.4
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 +19 -0
- package/addon/components/besluit-plugin/besluit-plugin-card.hbs +6 -18
- package/addon/components/besluit-plugin/besluit-plugin-card.ts +7 -16
- package/addon/components/variable-plugin/variable.hbs +1 -1
- package/addon/components/variable-plugin/variable.ts +12 -0
- package/addon/plugins/article-structure-plugin/commands/insert-structure.ts +25 -10
- package/addon/plugins/article-structure-plugin/commands/move-selected-structure.ts +41 -21
- package/addon/plugins/article-structure-plugin/index.ts +1 -1
- package/addon/plugins/besluit-plugin/commands/index.ts +0 -3
- package/addon/plugins/besluit-plugin/commands/insert-title.ts +29 -54
- package/addon/plugins/besluit-plugin/index.ts +0 -5
- package/addon/plugins/standard-template-plugin/utils/nodes.ts +8 -7
- package/app/styles/besluit-plugin.scss +3 -0
- package/app/styles/variable-plugin.scss +1 -0
- package/components/au-native-input.d.ts +1 -1
- package/components/besluit-plugin/besluit-plugin-card.d.ts +3 -3
- package/components/variable-plugin/variable.d.ts +2 -1
- package/package.json +3 -3
- package/plugins/article-structure-plugin/commands/move-selected-structure.d.ts +10 -3
- package/plugins/article-structure-plugin/index.d.ts +1 -0
- package/plugins/besluit-plugin/commands/index.d.ts +0 -3
- package/plugins/besluit-plugin/commands/insert-title.d.ts +3 -2
- package/plugins/besluit-plugin/index.d.ts +0 -1
- package/translations/en-US.yaml +3 -7
- package/translations/nl-BE.yaml +3 -7
- package/addon/components/au-dropdown-pill.hbs +0 -32
- package/addon/components/au-dropdown-pill.ts +0 -65
- package/addon/components/besluit-plugin/besluit-context-card.hbs +0 -44
- package/addon/components/besluit-plugin/besluit-context-card.ts +0 -138
- package/addon/plugins/besluit-plugin/commands/get-article-nodes-for-besluit.ts +0 -30
- package/addon/plugins/besluit-plugin/commands/insert-article.ts +0 -70
- package/addon/plugins/besluit-plugin/commands/move-article.ts +0 -69
- package/addon/plugins/besluit-plugin/commands/recalculate-article-numbers.ts +0 -44
- package/app/components/au-dropdown-pill.js +0 -1
- package/components/au-dropdown-pill.d.ts +0 -19
- package/components/besluit-plugin/besluit-context-card.d.ts +0 -24
- package/plugins/besluit-plugin/commands/get-article-nodes-for-besluit.d.ts +0 -5
- package/plugins/besluit-plugin/commands/insert-article.d.ts +0 -3
- package/plugins/besluit-plugin/commands/move-article.d.ts +0 -2
- package/plugins/besluit-plugin/commands/recalculate-article-numbers.d.ts +0 -2
package/CHANGELOG.md
CHANGED
|
@@ -12,6 +12,25 @@
|
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
|
|
15
|
+
|
|
16
|
+
## 1.0.0-beta.4 (2023-01-24)
|
|
17
|
+
|
|
18
|
+
#### :bug: Bug Fix
|
|
19
|
+
* [#72](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/72) Enable word-break as break-all on variable contenteditable ([@elpoelma](https://github.com/elpoelma))
|
|
20
|
+
* [#71](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/71) Avoid writing out p tags for nodes different than paragraph ([@elpoelma](https://github.com/elpoelma))
|
|
21
|
+
|
|
22
|
+
#### :house: Internal
|
|
23
|
+
* [#73](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/73) Make besluit title optional ([@elpoelma](https://github.com/elpoelma))
|
|
24
|
+
|
|
25
|
+
#### Committers: 1
|
|
26
|
+
- Elena Poelman ([@elpoelma](https://github.com/elpoelma))
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
## 1.0.0-beta.3 (2023-01-23)
|
|
30
|
+
|
|
31
|
+
add onclick handler to pencil icon in variable plugin
|
|
32
|
+
|
|
33
|
+
|
|
15
34
|
## 1.0.0-beta.2 (2023-01-23)
|
|
16
35
|
|
|
17
36
|
#### :boom: Breaking Change
|
|
@@ -1,20 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
@skin="link"
|
|
6
|
-
@disabled={{this.hasTitle}}
|
|
7
|
-
{{on 'click' this.insertTitle}}>
|
|
1
|
+
{{#if this.canInsertTitle}}
|
|
2
|
+
<AuAlert class="title-alert" @skin="warning" @closable={{false}} @icon="alert-triangle" @title={{t "besluit-plugin.missing-title-warning"}}>
|
|
3
|
+
<AuButton @iconAlignment="left" @skin="link-secondary" @disabled={{not this.canInsertTitle}} {{on 'click'
|
|
4
|
+
this.insertTitle}}>
|
|
8
5
|
{{t "besluit-plugin.insert.decision-title"}}
|
|
9
6
|
</AuButton>
|
|
10
|
-
</
|
|
11
|
-
|
|
12
|
-
<AuButton
|
|
13
|
-
@icon="add"
|
|
14
|
-
@iconAlignment="left"
|
|
15
|
-
@skin="link"
|
|
16
|
-
@disabled={{this.disableArticleInsert}}
|
|
17
|
-
{{on "click" this.insertArticle}}>
|
|
18
|
-
{{t "besluit-plugin.insert.article"}}
|
|
19
|
-
</AuButton>
|
|
20
|
-
</AuList::Item>
|
|
7
|
+
</AuAlert>
|
|
8
|
+
{{/if}}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import Component from '@glimmer/component';
|
|
2
2
|
import { action } from '@ember/object';
|
|
3
|
-
import {
|
|
4
|
-
insertTitle,
|
|
5
|
-
insertArticle,
|
|
6
|
-
} from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/besluit-plugin/commands';
|
|
3
|
+
import { insertTitle } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/besluit-plugin/commands';
|
|
7
4
|
import { ProseController } from '@lblod/ember-rdfa-editor';
|
|
5
|
+
import { inject as service } from '@ember/service';
|
|
6
|
+
import IntlService from 'ember-intl/services/intl';
|
|
8
7
|
|
|
9
8
|
type Args = {
|
|
10
9
|
controller: ProseController;
|
|
11
10
|
};
|
|
12
11
|
|
|
13
12
|
export default class BesluitPluginCardComponent extends Component<Args> {
|
|
13
|
+
@service declare intl: IntlService;
|
|
14
14
|
get controller() {
|
|
15
15
|
return this.args.controller;
|
|
16
16
|
}
|
|
@@ -18,23 +18,14 @@ export default class BesluitPluginCardComponent extends Component<Args> {
|
|
|
18
18
|
focus() {
|
|
19
19
|
this.controller.focus();
|
|
20
20
|
}
|
|
21
|
-
@action
|
|
22
|
-
insertArticle() {
|
|
23
|
-
this.controller.checkAndDoCommand(insertArticle(this.controller, ''));
|
|
24
|
-
this.focus();
|
|
25
|
-
}
|
|
26
21
|
|
|
27
22
|
@action
|
|
28
23
|
insertTitle() {
|
|
29
|
-
this.controller.doCommand(insertTitle(this.
|
|
24
|
+
this.controller.doCommand(insertTitle(this.intl));
|
|
30
25
|
this.focus();
|
|
31
26
|
}
|
|
32
27
|
|
|
33
|
-
get
|
|
34
|
-
return
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
get disableArticleInsert() {
|
|
38
|
-
return !this.controller.checkCommand(insertArticle(this.controller, ''));
|
|
28
|
+
get canInsertTitle() {
|
|
29
|
+
return this.controller.checkCommand(insertTitle(this.intl));
|
|
39
30
|
}
|
|
40
31
|
}
|
|
@@ -38,6 +38,7 @@ import {
|
|
|
38
38
|
RdfaEditorView,
|
|
39
39
|
redo,
|
|
40
40
|
Schema,
|
|
41
|
+
Selection,
|
|
41
42
|
splitBlock,
|
|
42
43
|
StepMap,
|
|
43
44
|
Transaction,
|
|
@@ -145,6 +146,17 @@ export default class Variable extends Component<EmberNodeArgs> {
|
|
|
145
146
|
this.outerView.dispatch(outerSelectionTr);
|
|
146
147
|
}
|
|
147
148
|
|
|
149
|
+
@action
|
|
150
|
+
onClick() {
|
|
151
|
+
if (this.innerView && !this.innerView.hasFocus()) {
|
|
152
|
+
this.innerView.focus();
|
|
153
|
+
const tr = this.innerView.state.tr;
|
|
154
|
+
const selection = Selection.atEnd(tr.doc);
|
|
155
|
+
tr.setSelection(selection);
|
|
156
|
+
this.innerView.dispatch(tr);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
148
160
|
@action
|
|
149
161
|
didInsertContentWrapper(target: Element) {
|
|
150
162
|
this.contentWrapper = target;
|
|
@@ -14,6 +14,7 @@ import wrapStructureContent from './wrap-structure-content';
|
|
|
14
14
|
import IntlService from 'ember-intl/services/intl';
|
|
15
15
|
import { findNodes } from '@lblod/ember-rdfa-editor/utils/position-utils';
|
|
16
16
|
import { containsOnlyPlaceholder } from '../utils/structure';
|
|
17
|
+
import { findParentNodeOfType } from '@curvenote/prosemirror-utils';
|
|
17
18
|
|
|
18
19
|
const insertStructure = (
|
|
19
20
|
structureSpec: StructureSpec,
|
|
@@ -22,14 +23,18 @@ const insertStructure = (
|
|
|
22
23
|
): Command => {
|
|
23
24
|
return (state, dispatch) => {
|
|
24
25
|
const { schema, selection, doc } = state;
|
|
26
|
+
if (wrapStructureContent(structureSpec, intl)(state, dispatch)) {
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
25
29
|
const insertionRange = findInsertionRange({
|
|
26
30
|
doc,
|
|
27
31
|
selection,
|
|
28
32
|
nodeType: schema.nodes[structureSpec.name],
|
|
29
33
|
schema,
|
|
34
|
+
limitTo: structureSpec.limitTo,
|
|
30
35
|
});
|
|
31
36
|
if (!insertionRange) {
|
|
32
|
-
return
|
|
37
|
+
return false;
|
|
33
38
|
}
|
|
34
39
|
if (dispatch) {
|
|
35
40
|
const { node: newStructureNode, selectionConfig } =
|
|
@@ -65,8 +70,9 @@ function findInsertionRange(args: {
|
|
|
65
70
|
selection: Selection;
|
|
66
71
|
nodeType: NodeType;
|
|
67
72
|
schema: Schema;
|
|
73
|
+
limitTo?: string;
|
|
68
74
|
}) {
|
|
69
|
-
const { doc, selection, nodeType, schema } = args;
|
|
75
|
+
const { doc, selection, nodeType, schema, limitTo } = args;
|
|
70
76
|
const { $from } = selection;
|
|
71
77
|
for (let currentDepth = $from.depth; currentDepth >= 0; currentDepth--) {
|
|
72
78
|
const currentAncestor = $from.node(currentDepth);
|
|
@@ -80,21 +86,30 @@ function findInsertionRange(args: {
|
|
|
80
86
|
}
|
|
81
87
|
}
|
|
82
88
|
}
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
+
const limitContainer = limitTo
|
|
90
|
+
? findParentNodeOfType(schema.nodes[limitTo])(selection)
|
|
91
|
+
: null;
|
|
92
|
+
|
|
93
|
+
const limitContainerRange = limitContainer
|
|
94
|
+
? {
|
|
95
|
+
from: limitContainer.pos,
|
|
96
|
+
to: limitContainer.pos + limitContainer.node.nodeSize,
|
|
97
|
+
}
|
|
98
|
+
: { from: 0, to: doc.nodeSize };
|
|
99
|
+
const filterFunction = ({ from, to }: { from: number; to: number }) => {
|
|
100
|
+
if (from >= limitContainerRange.from && to <= limitContainerRange.to) {
|
|
89
101
|
const node = doc.nodeAt(from);
|
|
90
102
|
if (node) {
|
|
91
103
|
if (node.canReplaceWith(node.childCount, node.childCount, nodeType)) {
|
|
92
104
|
return true;
|
|
93
105
|
}
|
|
94
106
|
}
|
|
95
|
-
return false;
|
|
96
107
|
}
|
|
97
|
-
|
|
108
|
+
return false;
|
|
109
|
+
};
|
|
110
|
+
const nextContainerRange =
|
|
111
|
+
findNodes(doc, selection.from, true, false, filterFunction).next().value ??
|
|
112
|
+
findNodes(doc, selection.from, true, true, filterFunction).next().value;
|
|
98
113
|
if (nextContainerRange) {
|
|
99
114
|
const { from, to } = nextContainerRange;
|
|
100
115
|
const containerNode = doc.nodeAt(from);
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
NodeType,
|
|
5
5
|
PNode,
|
|
6
6
|
Schema,
|
|
7
|
+
Selection,
|
|
7
8
|
TextSelection,
|
|
8
9
|
} from '@lblod/ember-rdfa-editor';
|
|
9
10
|
import { unwrap } from '@lblod/ember-rdfa-editor/utils/option';
|
|
@@ -12,6 +13,7 @@ import { findAncestorOfType } from '../utils/structure';
|
|
|
12
13
|
import recalculateStructureNumbers from './recalculate-structure-numbers';
|
|
13
14
|
import { findNodes } from '@lblod/ember-rdfa-editor/utils/position-utils';
|
|
14
15
|
import IntlService from 'ember-intl/services/intl';
|
|
16
|
+
import { findParentNodeOfType } from '@curvenote/prosemirror-utils';
|
|
15
17
|
const moveSelectedStructure = (
|
|
16
18
|
options: ArticleStructurePluginOptions,
|
|
17
19
|
direction: 'up' | 'down',
|
|
@@ -24,21 +26,24 @@ const moveSelectedStructure = (
|
|
|
24
26
|
if (!currentStructure || currentStructure.pos === -1) {
|
|
25
27
|
return false;
|
|
26
28
|
}
|
|
27
|
-
const
|
|
29
|
+
const currentStructureSpec = unwrap(
|
|
30
|
+
options.find((spec) => spec.name === currentStructure.node.type.name)
|
|
31
|
+
);
|
|
32
|
+
const insertionRange = calculateInsertionRange({
|
|
28
33
|
doc,
|
|
29
|
-
currentStructure.pos,
|
|
30
|
-
currentStructure.node.type,
|
|
34
|
+
pos: currentStructure.pos,
|
|
35
|
+
nodeType: currentStructure.node.type,
|
|
36
|
+
selection: state.selection,
|
|
31
37
|
direction,
|
|
32
|
-
schema
|
|
33
|
-
|
|
38
|
+
schema,
|
|
39
|
+
limitTo: currentStructureSpec.limitTo,
|
|
40
|
+
});
|
|
34
41
|
if (insertionRange === null || insertionRange === undefined) {
|
|
35
42
|
return false;
|
|
36
43
|
}
|
|
37
44
|
const isNodeSelection = selection instanceof NodeSelection;
|
|
38
45
|
const relativeSelectionOffset = selection.from - currentStructure.pos;
|
|
39
|
-
|
|
40
|
-
options.find((spec) => spec.name === currentStructure.node.type.name)
|
|
41
|
-
);
|
|
46
|
+
|
|
42
47
|
if (dispatch) {
|
|
43
48
|
const transaction = state.tr;
|
|
44
49
|
transaction.delete(
|
|
@@ -75,13 +80,16 @@ const moveSelectedStructure = (
|
|
|
75
80
|
};
|
|
76
81
|
};
|
|
77
82
|
|
|
78
|
-
export function calculateInsertionRange(
|
|
79
|
-
doc: PNode
|
|
80
|
-
pos: number
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
83
|
+
export function calculateInsertionRange(args: {
|
|
84
|
+
doc: PNode;
|
|
85
|
+
pos: number; // position of structure we want to move
|
|
86
|
+
selection: Selection;
|
|
87
|
+
nodeType: NodeType;
|
|
88
|
+
direction: 'up' | 'down';
|
|
89
|
+
schema: Schema;
|
|
90
|
+
limitTo?: string;
|
|
91
|
+
}): { from: number; to: number } | null {
|
|
92
|
+
const { doc, pos, selection, nodeType, direction, schema, limitTo } = args;
|
|
85
93
|
const resolvedPosition = doc.resolve(pos);
|
|
86
94
|
const containerNode = resolvedPosition.parent;
|
|
87
95
|
const index = resolvedPosition.index();
|
|
@@ -93,17 +101,29 @@ export function calculateInsertionRange(
|
|
|
93
101
|
const position = resolvedPosition.posAtIndex(index + 2);
|
|
94
102
|
return { from: position, to: position };
|
|
95
103
|
} else {
|
|
104
|
+
const limitContainer = limitTo
|
|
105
|
+
? findParentNodeOfType(schema.nodes[limitTo])(selection)
|
|
106
|
+
: null;
|
|
107
|
+
|
|
108
|
+
const limitContainerRange = limitContainer
|
|
109
|
+
? {
|
|
110
|
+
from: limitContainer.pos,
|
|
111
|
+
to: limitContainer.pos + limitContainer.node.nodeSize,
|
|
112
|
+
}
|
|
113
|
+
: { from: 0, to: doc.nodeSize };
|
|
96
114
|
const containerRange = findNodes(
|
|
97
115
|
doc,
|
|
98
116
|
pos,
|
|
99
117
|
true,
|
|
100
118
|
direction === 'up',
|
|
101
|
-
({ from }) => {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
119
|
+
({ from, to }) => {
|
|
120
|
+
if (from >= limitContainerRange.from && to <= limitContainerRange.to) {
|
|
121
|
+
const node = doc.nodeAt(from);
|
|
122
|
+
if (node && node !== containerNode) {
|
|
123
|
+
const indexToTest = direction === 'up' ? node.childCount : 0;
|
|
124
|
+
if (node.canReplaceWith(indexToTest, indexToTest, nodeType)) {
|
|
125
|
+
return true;
|
|
126
|
+
}
|
|
107
127
|
}
|
|
108
128
|
}
|
|
109
129
|
return false;
|
|
@@ -13,7 +13,6 @@ export type SpecName = string;
|
|
|
13
13
|
|
|
14
14
|
export type StructureSpec = {
|
|
15
15
|
name: SpecName;
|
|
16
|
-
// context: SpecName[];
|
|
17
16
|
translations: {
|
|
18
17
|
insert: string;
|
|
19
18
|
move: {
|
|
@@ -41,6 +40,7 @@ export type StructureSpec = {
|
|
|
41
40
|
}) => Transaction;
|
|
42
41
|
content?: (args: { pos: number; state: EditorState }) => Fragment;
|
|
43
42
|
continuous: boolean;
|
|
43
|
+
limitTo?: string;
|
|
44
44
|
};
|
|
45
45
|
|
|
46
46
|
export type ArticleStructurePluginOptions = StructureSpec[];
|
|
@@ -1,65 +1,40 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
TextSelection,
|
|
5
|
-
} from '@lblod/ember-rdfa-editor';
|
|
6
|
-
import { insertHtml } from '@lblod/ember-rdfa-editor/commands/insert-html-command';
|
|
1
|
+
import { findParentNodeOfType } from '@curvenote/prosemirror-utils';
|
|
2
|
+
import { Command, NodeSelection } from '@lblod/ember-rdfa-editor';
|
|
3
|
+
import IntlService from 'ember-intl/services/intl';
|
|
7
4
|
|
|
8
|
-
export default function insertTitle(
|
|
9
|
-
controller: ProseController,
|
|
10
|
-
title: string
|
|
11
|
-
): Command {
|
|
5
|
+
export default function insertTitle(intl: IntlService): Command {
|
|
12
6
|
return function (state, dispatch) {
|
|
13
|
-
const selection =
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
selection.from,
|
|
17
|
-
selection.to
|
|
18
|
-
);
|
|
19
|
-
|
|
20
|
-
const besluit = [
|
|
21
|
-
...limitedDatastore
|
|
22
|
-
.match(null, 'a', 'besluit:Besluit')
|
|
23
|
-
.asSubjectNodeMapping(),
|
|
24
|
-
][0];
|
|
25
|
-
|
|
26
|
-
const besluitRange = besluit?.nodes[0];
|
|
27
|
-
|
|
28
|
-
if (!besluit || !besluitRange) {
|
|
7
|
+
const { selection, schema } = state;
|
|
8
|
+
const besluit = findParentNodeOfType(schema.nodes.besluit)(selection);
|
|
9
|
+
if (!besluit) {
|
|
29
10
|
return false;
|
|
30
11
|
}
|
|
31
|
-
|
|
32
|
-
const titleQuad = controller.datastore
|
|
33
|
-
.match(
|
|
34
|
-
`>${besluit.term.value}`,
|
|
35
|
-
'>http://data.europa.eu/eli/ontology#title'
|
|
36
|
-
)
|
|
37
|
-
.asQuadResultSet()
|
|
38
|
-
.first();
|
|
39
|
-
if (titleQuad) {
|
|
12
|
+
if (!besluit.node.canReplaceWith(0, 0, schema.nodes.title)) {
|
|
40
13
|
return false;
|
|
41
14
|
}
|
|
42
15
|
|
|
43
16
|
if (dispatch) {
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
)
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
17
|
+
const tr = state.tr;
|
|
18
|
+
tr.insert(
|
|
19
|
+
besluit.pos + 1,
|
|
20
|
+
schema.node(
|
|
21
|
+
'title',
|
|
22
|
+
null,
|
|
23
|
+
schema.node(
|
|
24
|
+
'paragraph',
|
|
25
|
+
null,
|
|
26
|
+
schema.node('placeholder', {
|
|
27
|
+
placeholderText: intl.t(
|
|
28
|
+
'besluit-plugin.placeholder.decision-title'
|
|
29
|
+
),
|
|
30
|
+
})
|
|
31
|
+
)
|
|
32
|
+
)
|
|
33
|
+
);
|
|
34
|
+
// Select placeholder in title
|
|
35
|
+
const selection = new NodeSelection(tr.doc.resolve(besluit.pos + 3));
|
|
36
|
+
tr.setSelection(selection);
|
|
37
|
+
dispatch(tr);
|
|
63
38
|
}
|
|
64
39
|
|
|
65
40
|
return true;
|
|
@@ -2,10 +2,5 @@ import { WidgetSpec } from '@lblod/ember-rdfa-editor';
|
|
|
2
2
|
|
|
3
3
|
export const besluitPluginCardWidget: WidgetSpec = {
|
|
4
4
|
componentName: 'besluit-plugin/besluit-plugin-card',
|
|
5
|
-
desiredLocation: 'insertSidebar',
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
export const besluitContextCardWidget: WidgetSpec = {
|
|
9
|
-
componentName: 'besluit-plugin/besluit-context-card',
|
|
10
5
|
desiredLocation: 'sidebar',
|
|
11
6
|
};
|
|
@@ -58,11 +58,11 @@ export const description: NodeSpec = {
|
|
|
58
58
|
},
|
|
59
59
|
},
|
|
60
60
|
toDOM(node) {
|
|
61
|
-
return ['
|
|
61
|
+
return ['div', node.attrs, 0];
|
|
62
62
|
},
|
|
63
63
|
parseDOM: [
|
|
64
64
|
{
|
|
65
|
-
tag: 'p',
|
|
65
|
+
tag: 'div,p',
|
|
66
66
|
getAttrs(element: HTMLElement) {
|
|
67
67
|
if (hasRDFaAttribute(element, 'property', ELI('description'))) {
|
|
68
68
|
return getRdfaAttrs(element);
|
|
@@ -87,11 +87,11 @@ export const motivering: NodeSpec = {
|
|
|
87
87
|
},
|
|
88
88
|
},
|
|
89
89
|
toDOM(node) {
|
|
90
|
-
return ['
|
|
90
|
+
return ['div', node.attrs, 0];
|
|
91
91
|
},
|
|
92
92
|
parseDOM: [
|
|
93
93
|
{
|
|
94
|
-
tag: 'div
|
|
94
|
+
tag: 'div',
|
|
95
95
|
getAttrs(element: HTMLElement) {
|
|
96
96
|
if (hasRDFaAttribute(element, 'property', BESLUIT('motivering'))) {
|
|
97
97
|
return getRdfaAttrs(element);
|
|
@@ -177,6 +177,7 @@ export const besluitArticleStructure: StructureSpec = {
|
|
|
177
177
|
},
|
|
178
178
|
remove: 'article-structure-plugin.remove.article',
|
|
179
179
|
},
|
|
180
|
+
limitTo: 'besluit',
|
|
180
181
|
constructor: ({ schema, number, content, intl }) => {
|
|
181
182
|
const numberConverted = number?.toString() ?? '1';
|
|
182
183
|
const node = schema.node(
|
|
@@ -235,7 +236,7 @@ export const besluit_article_header: NodeSpec = {
|
|
|
235
236
|
delete toplevelAttrs.number;
|
|
236
237
|
delete toplevelAttrs.datatype;
|
|
237
238
|
return [
|
|
238
|
-
'
|
|
239
|
+
'div',
|
|
239
240
|
toplevelAttrs,
|
|
240
241
|
'Artikel ',
|
|
241
242
|
[
|
|
@@ -247,7 +248,7 @@ export const besluit_article_header: NodeSpec = {
|
|
|
247
248
|
},
|
|
248
249
|
parseDOM: [
|
|
249
250
|
{
|
|
250
|
-
tag: 'p',
|
|
251
|
+
tag: 'p,div',
|
|
251
252
|
getAttrs(element: HTMLElement) {
|
|
252
253
|
const numberNode = element.querySelector(
|
|
253
254
|
`span[property~='${ELI('number').prefixed}'],
|
|
@@ -295,7 +296,7 @@ export const besluit_article_content: NodeSpec = {
|
|
|
295
296
|
|
|
296
297
|
export const besluit: NodeSpec = {
|
|
297
298
|
group: 'block',
|
|
298
|
-
content: 'block*title
|
|
299
|
+
content: 'block*title?block*description?block*motivering?block*',
|
|
299
300
|
inline: false,
|
|
300
301
|
attrs: {
|
|
301
302
|
...rdfaAttrs,
|
|
@@ -10,7 +10,7 @@ interface Args {
|
|
|
10
10
|
}
|
|
11
11
|
export default class AuNativeInput extends Component<Args> {
|
|
12
12
|
constructor(owner: unknown, args: Args);
|
|
13
|
-
get width(): "
|
|
13
|
+
get width(): "au-c-input--block" | "";
|
|
14
14
|
get iconAlignment(): "" | "au-c-input-wrapper--left" | "au-c-input-wrapper--right";
|
|
15
15
|
get error(): "" | "au-c-input--error";
|
|
16
16
|
get warning(): "" | "au-c-input--warning";
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import Component from '@glimmer/component';
|
|
2
2
|
import { ProseController } from '@lblod/ember-rdfa-editor';
|
|
3
|
+
import IntlService from 'ember-intl/services/intl';
|
|
3
4
|
type Args = {
|
|
4
5
|
controller: ProseController;
|
|
5
6
|
};
|
|
6
7
|
export default class BesluitPluginCardComponent extends Component<Args> {
|
|
8
|
+
intl: IntlService;
|
|
7
9
|
get controller(): ProseController;
|
|
8
10
|
focus(): void;
|
|
9
|
-
insertArticle(): void;
|
|
10
11
|
insertTitle(): void;
|
|
11
|
-
get
|
|
12
|
-
get disableArticleInsert(): boolean;
|
|
12
|
+
get canInsertTitle(): boolean;
|
|
13
13
|
}
|
|
14
14
|
export {};
|
|
@@ -33,8 +33,9 @@ export default class Variable extends Component<EmberNodeArgs> {
|
|
|
33
33
|
get node(): import("prosemirror-model").Node;
|
|
34
34
|
get pos(): number;
|
|
35
35
|
get htmlContent(): import("@ember/template/-private/handlebars").SafeString;
|
|
36
|
-
get schema(): Schema<"text" | "hard_break" | "date" | "invisible_rdfa" | "
|
|
36
|
+
get schema(): Schema<"text" | "hard_break" | "date" | "invisible_rdfa" | "paragraph" | "placeholder" | "doc" | "block_rdfa" | "repaired_block", "em" | "strong" | "link" | "underline" | "inline_rdfa" | "strikethrough">;
|
|
37
37
|
onFocus(): void;
|
|
38
|
+
onClick(): void;
|
|
38
39
|
didInsertContentWrapper(target: Element): void;
|
|
39
40
|
onNodeUpdate(): void;
|
|
40
41
|
dispatchInner: (tr: Transaction) => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lblod/ember-rdfa-editor-lblod-plugins",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.4",
|
|
4
4
|
"description": "Ember addon providing lblod specific plugins for the ember-rdfa-editor",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ember-addon",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"@embroider/test-setup": "^1.6.0",
|
|
63
63
|
"@glimmer/component": "^1.1.2",
|
|
64
64
|
"@glimmer/tracking": "^1.1.2",
|
|
65
|
-
"@lblod/ember-rdfa-editor": "^1.0.0-beta.
|
|
65
|
+
"@lblod/ember-rdfa-editor": "^1.0.0-beta.6",
|
|
66
66
|
"@rdfjs/types": "^1.1.0",
|
|
67
67
|
"@release-it-plugins/lerna-changelog": "^5.0.0",
|
|
68
68
|
"@tsconfig/ember": "^1.0.1",
|
|
@@ -144,7 +144,7 @@
|
|
|
144
144
|
},
|
|
145
145
|
"peerDependencies": {
|
|
146
146
|
"@appuniversum/ember-appuniversum": "^2.2.0",
|
|
147
|
-
"@lblod/ember-rdfa-editor": "^1.0.0-beta.
|
|
147
|
+
"@lblod/ember-rdfa-editor": "^1.0.0-beta.6",
|
|
148
148
|
"ember-concurrency": "^2.3.7"
|
|
149
149
|
},
|
|
150
150
|
"engines": {
|
|
@@ -1,9 +1,16 @@
|
|
|
1
|
-
import { Command, NodeType, PNode, Schema } from '@lblod/ember-rdfa-editor';
|
|
1
|
+
import { Command, NodeType, PNode, Schema, Selection } from '@lblod/ember-rdfa-editor';
|
|
2
2
|
import { ArticleStructurePluginOptions } from '..';
|
|
3
3
|
import IntlService from 'ember-intl/services/intl';
|
|
4
4
|
declare const moveSelectedStructure: (options: ArticleStructurePluginOptions, direction: 'up' | 'down', intl: IntlService) => Command;
|
|
5
|
-
export declare function calculateInsertionRange(
|
|
6
|
-
|
|
5
|
+
export declare function calculateInsertionRange(args: {
|
|
6
|
+
doc: PNode;
|
|
7
|
+
pos: number;
|
|
8
|
+
selection: Selection;
|
|
9
|
+
nodeType: NodeType;
|
|
10
|
+
direction: 'up' | 'down';
|
|
11
|
+
schema: Schema;
|
|
12
|
+
limitTo?: string;
|
|
13
|
+
}): {
|
|
7
14
|
from: number;
|
|
8
15
|
to: number;
|
|
9
16
|
} | null;
|
|
@@ -34,6 +34,7 @@ export type StructureSpec = {
|
|
|
34
34
|
state: EditorState;
|
|
35
35
|
}) => Fragment;
|
|
36
36
|
continuous: boolean;
|
|
37
|
+
limitTo?: string;
|
|
37
38
|
};
|
|
38
39
|
export type ArticleStructurePluginOptions = StructureSpec[];
|
|
39
40
|
export declare const articleStructureInsertWidget: (options?: ArticleStructurePluginOptions) => WidgetSpec;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import { Command
|
|
2
|
-
|
|
1
|
+
import { Command } from '@lblod/ember-rdfa-editor';
|
|
2
|
+
import IntlService from 'ember-intl/services/intl';
|
|
3
|
+
export default function insertTitle(intl: IntlService): Command;
|
package/translations/en-US.yaml
CHANGED
|
@@ -57,15 +57,11 @@ besluit-type-plugin:
|
|
|
57
57
|
error-first-body: "An error occured while fetching the decision types. Try again later. If this problem persists, please contact"
|
|
58
58
|
error-rest-body: ". For more specific details about this problem, inspect the browser console."
|
|
59
59
|
besluit-plugin:
|
|
60
|
-
|
|
61
|
-
title: Edit decision
|
|
60
|
+
missing-title-warning: This decision is missing a title
|
|
62
61
|
insert:
|
|
63
|
-
article: Insert article
|
|
64
62
|
decision-title: Insert decision title
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
article-up: Move article up
|
|
68
|
-
article-down: Move article down
|
|
63
|
+
placeholder:
|
|
64
|
+
decision-title: Insert decision title
|
|
69
65
|
date-plugin:
|
|
70
66
|
insert:
|
|
71
67
|
date: "Insert date"
|
package/translations/nl-BE.yaml
CHANGED
|
@@ -57,15 +57,11 @@ besluit-type-plugin:
|
|
|
57
57
|
error-first-body: "Er was een probleem bij het ophalen van de besluittypes. Probeer later opnieuw. Bij blijvende problemen, contacteer"
|
|
58
58
|
error-rest-body: ". Voor meer specifieke details, controleer de console in de browser."
|
|
59
59
|
besluit-plugin:
|
|
60
|
-
|
|
61
|
-
title: Artikels bewerken
|
|
60
|
+
missing-title-warning: Dit besluit heeft geen titel
|
|
62
61
|
insert:
|
|
63
|
-
article: Voeg artikel in
|
|
64
62
|
decision-title: Voeg besluittitel in
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
article-up: Artikel naar boven verplaatsen
|
|
68
|
-
article-down: Artikel naar beneden verplaatsen
|
|
63
|
+
placeholder:
|
|
64
|
+
decision-title: Geef titel besluit op
|
|
69
65
|
date-plugin:
|
|
70
66
|
insert:
|
|
71
67
|
date: "Datum invoegen"
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
<div class="au-c-dropdown" ...attributes>
|
|
2
|
-
<AuPill
|
|
3
|
-
@skin={{this.skin}}
|
|
4
|
-
@size={{@size}}
|
|
5
|
-
@actionIcon={{this.icon}}
|
|
6
|
-
@iconAlignment={{this.iconAlignment}}
|
|
7
|
-
@hideText={{@hideText}}
|
|
8
|
-
aria-haspopup="true"
|
|
9
|
-
aria-expanded="{{if this.dropdownOpen 'true' 'false'}}"
|
|
10
|
-
@onClickAction={{this.toggleDropdown}}
|
|
11
|
-
data-test-dropdown-button
|
|
12
|
-
data-au-dropdown-toggle
|
|
13
|
-
>
|
|
14
|
-
<span class="au-c-dropdown__name" data-test-dropdown-title>
|
|
15
|
-
{{@title}}
|
|
16
|
-
</span>
|
|
17
|
-
</AuPill>
|
|
18
|
-
<div
|
|
19
|
-
class="au-c-dropdown__menu {{this.alignment}} {{if this.dropdownOpen 'is-visible'}}"
|
|
20
|
-
role="menu"
|
|
21
|
-
tabindex="-1"
|
|
22
|
-
{{focus-trap
|
|
23
|
-
isActive=this.dropdownOpen
|
|
24
|
-
shouldSelfFocus=true
|
|
25
|
-
focusTrapOptions=(hash
|
|
26
|
-
clickOutsideDeactivates=this.clickOutsideDeactivates
|
|
27
|
-
)
|
|
28
|
-
}}
|
|
29
|
-
>
|
|
30
|
-
{{yield}}
|
|
31
|
-
</div>
|
|
32
|
-
</div>
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import Component from '@glimmer/component';
|
|
2
|
-
import { action } from '@ember/object';
|
|
3
|
-
import { tracked } from '@glimmer/tracking';
|
|
4
|
-
|
|
5
|
-
type Args = {
|
|
6
|
-
alignment: 'left' | 'right';
|
|
7
|
-
icon: string;
|
|
8
|
-
iconAlignment: 'left' | 'right';
|
|
9
|
-
skin?: string;
|
|
10
|
-
};
|
|
11
|
-
export default class AuDropdownPill extends Component<Args> {
|
|
12
|
-
@tracked dropdownOpen = false;
|
|
13
|
-
|
|
14
|
-
@action
|
|
15
|
-
openDropdown() {
|
|
16
|
-
this.dropdownOpen = true;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
@action
|
|
20
|
-
closeDropdown() {
|
|
21
|
-
this.dropdownOpen = false;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
@action
|
|
25
|
-
toggleDropdown() {
|
|
26
|
-
this.dropdownOpen = !this.dropdownOpen;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
@action
|
|
30
|
-
clickOutsideDeactivates(event: InputEvent) {
|
|
31
|
-
const toggleButton = document.querySelector('[data-au-dropdown-toggle]');
|
|
32
|
-
const isClosedByToggleButton = toggleButton?.contains(
|
|
33
|
-
event.target as HTMLInputElement
|
|
34
|
-
);
|
|
35
|
-
|
|
36
|
-
if (!isClosedByToggleButton) {
|
|
37
|
-
this.closeDropdown();
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return true;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// Dropdown alignment
|
|
44
|
-
get alignment() {
|
|
45
|
-
if (this.args.alignment == 'left') return 'au-c-dropdown__menu--left';
|
|
46
|
-
if (this.args.alignment == 'right') return 'au-c-dropdown__menu--right';
|
|
47
|
-
return '';
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
get skin() {
|
|
51
|
-
return this.args.skin || 'default';
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// Set default button icon
|
|
55
|
-
get icon() {
|
|
56
|
-
if (this.args.icon) return this.args.icon;
|
|
57
|
-
else return 'chevron-down';
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// Set default icon alignment
|
|
61
|
-
get iconAlignment() {
|
|
62
|
-
if (this.args.iconAlignment) return this.args.iconAlignment;
|
|
63
|
-
else return 'right';
|
|
64
|
-
}
|
|
65
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
{{#if this.activeArticle}}
|
|
2
|
-
<AuCard
|
|
3
|
-
@shadow={{true}}
|
|
4
|
-
@size="flush" as |c|>
|
|
5
|
-
<c.header class="au-u-hidden-visually">
|
|
6
|
-
<AuHeading @level="3" @skin="6">
|
|
7
|
-
{{t "besluit-plugin.card.title"}}
|
|
8
|
-
</AuHeading>
|
|
9
|
-
</c.header>
|
|
10
|
-
<c.content class="au-c-content--small">
|
|
11
|
-
<AuList @divider={{true}} class="au-u-padding-top-tiny au-u-padding-bottom-tiny">
|
|
12
|
-
<AuList::Item>
|
|
13
|
-
<AuButton
|
|
14
|
-
@icon="bin"
|
|
15
|
-
@iconAlignment="left"
|
|
16
|
-
@skin="link"
|
|
17
|
-
{{on 'click' this.deleteArticle}}>
|
|
18
|
-
{{t "besluit-plugin.action.delete-article"}}
|
|
19
|
-
</AuButton>
|
|
20
|
-
</AuList::Item>
|
|
21
|
-
<AuList::Item>
|
|
22
|
-
<AuButton
|
|
23
|
-
@icon="nav-up"
|
|
24
|
-
@iconAlignment="left"
|
|
25
|
-
@skin="link"
|
|
26
|
-
@disabled={{this.disableMoveUp}}
|
|
27
|
-
{{on 'click' this.moveUpArticle}}>
|
|
28
|
-
{{t "besluit-plugin.action.article-up"}}
|
|
29
|
-
</AuButton>
|
|
30
|
-
</AuList::Item>
|
|
31
|
-
<AuList::Item>
|
|
32
|
-
<AuButton
|
|
33
|
-
@icon="nav-down"
|
|
34
|
-
@iconAlignment="left"
|
|
35
|
-
@skin="link"
|
|
36
|
-
@disabled={{this.disableMoveDown}}
|
|
37
|
-
{{on 'click' this.moveDownArticle}}>
|
|
38
|
-
{{t "besluit-plugin.action.article-down"}}
|
|
39
|
-
</AuButton>
|
|
40
|
-
</AuList::Item>
|
|
41
|
-
</AuList>
|
|
42
|
-
</c.content>
|
|
43
|
-
</AuCard>
|
|
44
|
-
{{/if}}
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
import Component from '@glimmer/component';
|
|
2
|
-
import { tracked } from '@glimmer/tracking';
|
|
3
|
-
import { action } from '@ember/object';
|
|
4
|
-
import {
|
|
5
|
-
moveArticle,
|
|
6
|
-
recalculateArticleNumbers,
|
|
7
|
-
} from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/besluit-plugin/commands';
|
|
8
|
-
import { ResolvedPNode } from '@lblod/ember-rdfa-editor/plugins/datastore';
|
|
9
|
-
import { ProseController } from '@lblod/ember-rdfa-editor';
|
|
10
|
-
|
|
11
|
-
interface Args {
|
|
12
|
-
controller: ProseController;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export default class BesluitContextCardComponent extends Component<Args> {
|
|
16
|
-
@tracked articleElement?: ResolvedPNode;
|
|
17
|
-
|
|
18
|
-
constructor(parent: unknown, args: Args) {
|
|
19
|
-
super(parent, args);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
get controller() {
|
|
23
|
-
return this.args.controller;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
get doc() {
|
|
27
|
-
return this.controller.state.doc;
|
|
28
|
-
}
|
|
29
|
-
focus() {
|
|
30
|
-
this.controller.focus();
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
@action
|
|
34
|
-
deleteArticle() {
|
|
35
|
-
if (this.activeArticle && this.besluitURI) {
|
|
36
|
-
const { from, to } = this.activeArticle.range;
|
|
37
|
-
this.controller.withTransaction((tr) => {
|
|
38
|
-
return tr.delete(from, to);
|
|
39
|
-
});
|
|
40
|
-
this.focus();
|
|
41
|
-
recalculateArticleNumbers(this.controller, this.besluitURI);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
@action
|
|
46
|
-
moveUpArticle() {
|
|
47
|
-
if (this.besluitURI && this.activeArticle) {
|
|
48
|
-
this.controller.doCommand(
|
|
49
|
-
moveArticle(
|
|
50
|
-
this.controller,
|
|
51
|
-
this.besluitURI,
|
|
52
|
-
this.activeArticle.uri,
|
|
53
|
-
true
|
|
54
|
-
)
|
|
55
|
-
);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
@action
|
|
60
|
-
moveDownArticle() {
|
|
61
|
-
if (this.besluitURI && this.activeArticle) {
|
|
62
|
-
this.controller.doCommand(
|
|
63
|
-
moveArticle(
|
|
64
|
-
this.controller,
|
|
65
|
-
this.besluitURI,
|
|
66
|
-
this.activeArticle.uri,
|
|
67
|
-
false
|
|
68
|
-
)
|
|
69
|
-
);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
get disableMoveUp() {
|
|
74
|
-
if (this.besluitURI && this.activeArticle) {
|
|
75
|
-
return !this.controller.checkCommand(
|
|
76
|
-
moveArticle(
|
|
77
|
-
this.controller,
|
|
78
|
-
this.besluitURI,
|
|
79
|
-
this.activeArticle.uri,
|
|
80
|
-
true
|
|
81
|
-
)
|
|
82
|
-
);
|
|
83
|
-
}
|
|
84
|
-
return true;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
get disableMoveDown() {
|
|
88
|
-
if (this.besluitURI && this.activeArticle) {
|
|
89
|
-
return !this.controller.checkCommand(
|
|
90
|
-
moveArticle(
|
|
91
|
-
this.controller,
|
|
92
|
-
this.besluitURI,
|
|
93
|
-
this.activeArticle.uri,
|
|
94
|
-
false
|
|
95
|
-
)
|
|
96
|
-
);
|
|
97
|
-
}
|
|
98
|
-
return true;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
get besluitURI() {
|
|
102
|
-
const { from, to } = this.controller.state.selection;
|
|
103
|
-
|
|
104
|
-
const limitedDatastore = this.controller.datastore.limitToRange(
|
|
105
|
-
this.controller.state,
|
|
106
|
-
from,
|
|
107
|
-
to
|
|
108
|
-
);
|
|
109
|
-
return limitedDatastore
|
|
110
|
-
.match(null, 'a', 'besluit:Besluit')
|
|
111
|
-
.asQuadResultSet()
|
|
112
|
-
.first()?.subject.value;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
get activeArticle() {
|
|
116
|
-
if (this.besluitURI) {
|
|
117
|
-
const { from, to } = this.controller.state.selection;
|
|
118
|
-
|
|
119
|
-
const limitedDatastore = this.controller.datastore.limitToRange(
|
|
120
|
-
this.controller.state,
|
|
121
|
-
from,
|
|
122
|
-
to
|
|
123
|
-
);
|
|
124
|
-
const dsResult = [
|
|
125
|
-
...limitedDatastore
|
|
126
|
-
.match(null, 'a', 'besluit:Artikel')
|
|
127
|
-
.asSubjectNodeMapping(),
|
|
128
|
-
][0];
|
|
129
|
-
if (dsResult) {
|
|
130
|
-
return {
|
|
131
|
-
uri: dsResult.term.value,
|
|
132
|
-
range: dsResult.nodes[0],
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { ProseController } from '@lblod/ember-rdfa-editor';
|
|
2
|
-
import { unwrap } from '@lblod/ember-rdfa-editor/utils/option';
|
|
3
|
-
|
|
4
|
-
export default function getArticleNodesForBesluit(
|
|
5
|
-
controller: ProseController,
|
|
6
|
-
besluitUri?: string
|
|
7
|
-
) {
|
|
8
|
-
if (!besluitUri) {
|
|
9
|
-
const selection = controller.state.selection;
|
|
10
|
-
besluitUri = controller.datastore
|
|
11
|
-
.limitToRange(controller.state, selection.from, selection.to)
|
|
12
|
-
.match(null, 'a', 'besluit:Besluit')
|
|
13
|
-
.asQuadResultSet()
|
|
14
|
-
.first()?.subject.value;
|
|
15
|
-
}
|
|
16
|
-
if (!besluitUri) {
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
const articles = controller.datastore
|
|
20
|
-
.match(`>${besluitUri}`, 'eli:has_part')
|
|
21
|
-
.asObjectNodeMapping();
|
|
22
|
-
return [
|
|
23
|
-
...articles.map((article) => {
|
|
24
|
-
return {
|
|
25
|
-
uri: article.term.value,
|
|
26
|
-
range: unwrap(article.nodes.shift()),
|
|
27
|
-
};
|
|
28
|
-
}),
|
|
29
|
-
];
|
|
30
|
-
}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { v4 as uuid } from 'uuid';
|
|
2
|
-
import { insertHtml } from '@lblod/ember-rdfa-editor/commands/insert-html-command';
|
|
3
|
-
import { ProseController, TextSelection } from '@lblod/ember-rdfa-editor';
|
|
4
|
-
import { Command } from '@lblod/ember-rdfa-editor';
|
|
5
|
-
import recalculateArticleNumbers from './recalculate-article-numbers';
|
|
6
|
-
|
|
7
|
-
export default function insertArticle(
|
|
8
|
-
controller: ProseController,
|
|
9
|
-
articleContent: string
|
|
10
|
-
): Command {
|
|
11
|
-
return function (_state, dispatch) {
|
|
12
|
-
const selection = controller.state.selection;
|
|
13
|
-
const limitedDatastore = controller.datastore.limitToRange(
|
|
14
|
-
controller.state,
|
|
15
|
-
selection.from,
|
|
16
|
-
selection.to
|
|
17
|
-
);
|
|
18
|
-
const besluitSubject = limitedDatastore
|
|
19
|
-
.match(null, 'a', '>http://data.vlaanderen.be/ns/besluit#Besluit')
|
|
20
|
-
.asQuadResultSet()
|
|
21
|
-
.first()?.subject;
|
|
22
|
-
|
|
23
|
-
if (!besluitSubject) {
|
|
24
|
-
return false;
|
|
25
|
-
}
|
|
26
|
-
const containerRange = [
|
|
27
|
-
...controller.datastore
|
|
28
|
-
.match(besluitSubject, 'prov:value')
|
|
29
|
-
.asPredicateNodeMapping(),
|
|
30
|
-
][0].nodes[0];
|
|
31
|
-
|
|
32
|
-
if (!containerRange) {
|
|
33
|
-
return false;
|
|
34
|
-
}
|
|
35
|
-
if (dispatch) {
|
|
36
|
-
const range = {
|
|
37
|
-
from: containerRange.to - 1,
|
|
38
|
-
to: containerRange.to - 1,
|
|
39
|
-
};
|
|
40
|
-
const articleUri = `http://data.lblod.info/artikels/${uuid()}`;
|
|
41
|
-
const articleHtml = `
|
|
42
|
-
<div property="eli:has_part" prefix="mobiliteit: https://data.vlaanderen.be/ns/mobiliteit#" typeof="besluit:Artikel" resource="${articleUri}">
|
|
43
|
-
<div>
|
|
44
|
-
Artikel
|
|
45
|
-
<span property="eli:number" datatype="xsd:string">
|
|
46
|
-
<span class="mark-highlight-manual">nummer</span>
|
|
47
|
-
</span></div>
|
|
48
|
-
<span style="display:none;" property="eli:language" resource="http://publications.europa.eu/resource/authority/language/NLD" typeof="skos:Concept"> </span>
|
|
49
|
-
<div property="prov:value" datatype="xsd:string">
|
|
50
|
-
${
|
|
51
|
-
articleContent
|
|
52
|
-
? articleContent
|
|
53
|
-
: '<span class="mark-highlight-manual">Voer inhoud in</span>'
|
|
54
|
-
}
|
|
55
|
-
</div>
|
|
56
|
-
</div>
|
|
57
|
-
`;
|
|
58
|
-
controller.doCommand(insertHtml(articleHtml, range.from, range.to));
|
|
59
|
-
recalculateArticleNumbers(controller, besluitSubject.value);
|
|
60
|
-
controller.withTransaction((tr) => {
|
|
61
|
-
const selection = TextSelection.near(
|
|
62
|
-
controller.state.doc.resolve(range.from)
|
|
63
|
-
);
|
|
64
|
-
return tr.setSelection(selection).scrollIntoView();
|
|
65
|
-
});
|
|
66
|
-
controller.focus();
|
|
67
|
-
}
|
|
68
|
-
return true;
|
|
69
|
-
};
|
|
70
|
-
}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Command,
|
|
3
|
-
ProseController,
|
|
4
|
-
Selection,
|
|
5
|
-
TextSelection,
|
|
6
|
-
} from '@lblod/ember-rdfa-editor';
|
|
7
|
-
import recalculateArticleNumbers from './recalculate-article-numbers';
|
|
8
|
-
import { ResolvedPNode } from '@lblod/ember-rdfa-editor/plugins/datastore';
|
|
9
|
-
import { unwrap } from '@lblod/ember-rdfa-editor/utils/option';
|
|
10
|
-
import getArticleNodesForBesluit from './get-article-nodes-for-besluit';
|
|
11
|
-
|
|
12
|
-
export default function moveArticleCommand(
|
|
13
|
-
controller: ProseController,
|
|
14
|
-
besluitUri: string,
|
|
15
|
-
articleUri: string,
|
|
16
|
-
moveUp: boolean
|
|
17
|
-
): Command {
|
|
18
|
-
return (_state, dispatch) => {
|
|
19
|
-
const articles = getArticleNodesForBesluit(controller, besluitUri);
|
|
20
|
-
if (!articles) {
|
|
21
|
-
return false;
|
|
22
|
-
}
|
|
23
|
-
const articleIndex = articles.findIndex(({ uri }) => uri === articleUri);
|
|
24
|
-
|
|
25
|
-
if (
|
|
26
|
-
articleIndex === -1 ||
|
|
27
|
-
(moveUp && articleIndex === 0) ||
|
|
28
|
-
(!moveUp && articleIndex === articles.length - 1)
|
|
29
|
-
) {
|
|
30
|
-
return false;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
if (dispatch) {
|
|
34
|
-
let articleA: ResolvedPNode;
|
|
35
|
-
let articleB: ResolvedPNode;
|
|
36
|
-
|
|
37
|
-
if (moveUp) {
|
|
38
|
-
articleA = unwrap(articles[articleIndex - 1]).range;
|
|
39
|
-
articleB = unwrap(articles[articleIndex]).range;
|
|
40
|
-
} else {
|
|
41
|
-
articleA = unwrap(articles[articleIndex]).range;
|
|
42
|
-
articleB = unwrap(articles[articleIndex + 1]).range;
|
|
43
|
-
}
|
|
44
|
-
const articleBNode = unwrap(controller.state.doc.nodeAt(articleB.from));
|
|
45
|
-
controller.withTransaction((tr) => {
|
|
46
|
-
tr.delete(articleB.from, articleB.to);
|
|
47
|
-
return tr.replaceRangeWith(articleA.from, articleA.from, articleBNode);
|
|
48
|
-
});
|
|
49
|
-
recalculateArticleNumbers(controller, besluitUri);
|
|
50
|
-
let selection: Selection;
|
|
51
|
-
if (moveUp) {
|
|
52
|
-
selection = TextSelection.near(
|
|
53
|
-
controller.state.doc.resolve(articleA.from)
|
|
54
|
-
);
|
|
55
|
-
} else {
|
|
56
|
-
selection = TextSelection.near(
|
|
57
|
-
controller.state.doc.resolve(
|
|
58
|
-
articleA.from + articleB.to - articleB.from
|
|
59
|
-
)
|
|
60
|
-
);
|
|
61
|
-
}
|
|
62
|
-
controller.withTransaction((tr) => {
|
|
63
|
-
return tr.setSelection(selection);
|
|
64
|
-
});
|
|
65
|
-
controller.focus();
|
|
66
|
-
}
|
|
67
|
-
return true;
|
|
68
|
-
};
|
|
69
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { ProseController } from '@lblod/ember-rdfa-editor';
|
|
2
|
-
import { unwrap } from '@lblod/ember-rdfa-editor/utils/option';
|
|
3
|
-
import getArticleNodesForBesluit from './get-article-nodes-for-besluit';
|
|
4
|
-
|
|
5
|
-
export default function recalculateArticleNumbers(
|
|
6
|
-
controller: ProseController,
|
|
7
|
-
besluitUri: string
|
|
8
|
-
) {
|
|
9
|
-
const articles = getArticleNodesForBesluit(controller, besluitUri);
|
|
10
|
-
if (articles) {
|
|
11
|
-
for (let i = 0; i < articles.length; i++) {
|
|
12
|
-
const article = unwrap(articles[i]);
|
|
13
|
-
replaceNumberIfNeeded(controller, article, i);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function replaceNumberIfNeeded(
|
|
19
|
-
controller: ProseController,
|
|
20
|
-
article: { uri: string; range: { from: number; to: number } },
|
|
21
|
-
index: number
|
|
22
|
-
) {
|
|
23
|
-
const articleNumberObject = [
|
|
24
|
-
...controller.datastore
|
|
25
|
-
.match(`>${article.uri}`, '>http://data.europa.eu/eli/ontology#number')
|
|
26
|
-
.asObjectNodeMapping(),
|
|
27
|
-
][0];
|
|
28
|
-
if (!articleNumberObject) {
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
const articleNumber = Number(articleNumberObject.term.value);
|
|
32
|
-
const articleNumberRange = unwrap(articleNumberObject.nodes[0]);
|
|
33
|
-
const articleNumberExpected = index + 1;
|
|
34
|
-
|
|
35
|
-
if (articleNumber !== articleNumberExpected) {
|
|
36
|
-
controller.withTransaction((tr) => {
|
|
37
|
-
return tr.insertText(
|
|
38
|
-
articleNumberExpected.toString(),
|
|
39
|
-
articleNumberRange.from,
|
|
40
|
-
articleNumberRange.to
|
|
41
|
-
);
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from '@lblod/ember-rdfa-editor-lblod-plugins/components/au-dropdown-pill';
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import Component from '@glimmer/component';
|
|
2
|
-
type Args = {
|
|
3
|
-
alignment: 'left' | 'right';
|
|
4
|
-
icon: string;
|
|
5
|
-
iconAlignment: 'left' | 'right';
|
|
6
|
-
skin?: string;
|
|
7
|
-
};
|
|
8
|
-
export default class AuDropdownPill extends Component<Args> {
|
|
9
|
-
dropdownOpen: boolean;
|
|
10
|
-
openDropdown(): void;
|
|
11
|
-
closeDropdown(): void;
|
|
12
|
-
toggleDropdown(): void;
|
|
13
|
-
clickOutsideDeactivates(event: InputEvent): boolean;
|
|
14
|
-
get alignment(): "au-c-dropdown__menu--left" | "au-c-dropdown__menu--right" | "";
|
|
15
|
-
get skin(): string;
|
|
16
|
-
get icon(): string;
|
|
17
|
-
get iconAlignment(): "left" | "right";
|
|
18
|
-
}
|
|
19
|
-
export {};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import Component from '@glimmer/component';
|
|
2
|
-
import { ResolvedPNode } from '@lblod/ember-rdfa-editor/plugins/datastore';
|
|
3
|
-
import { ProseController } from '@lblod/ember-rdfa-editor';
|
|
4
|
-
interface Args {
|
|
5
|
-
controller: ProseController;
|
|
6
|
-
}
|
|
7
|
-
export default class BesluitContextCardComponent extends Component<Args> {
|
|
8
|
-
articleElement?: ResolvedPNode;
|
|
9
|
-
constructor(parent: unknown, args: Args);
|
|
10
|
-
get controller(): ProseController;
|
|
11
|
-
get doc(): import("prosemirror-model").Node;
|
|
12
|
-
focus(): void;
|
|
13
|
-
deleteArticle(): void;
|
|
14
|
-
moveUpArticle(): void;
|
|
15
|
-
moveDownArticle(): void;
|
|
16
|
-
get disableMoveUp(): boolean;
|
|
17
|
-
get disableMoveDown(): boolean;
|
|
18
|
-
get besluitURI(): string | undefined;
|
|
19
|
-
get activeArticle(): {
|
|
20
|
-
uri: string;
|
|
21
|
-
range: ResolvedPNode;
|
|
22
|
-
} | undefined;
|
|
23
|
-
}
|
|
24
|
-
export {};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { ProseController } from '@lblod/ember-rdfa-editor';
|
|
2
|
-
export default function getArticleNodesForBesluit(controller: ProseController, besluitUri?: string): {
|
|
3
|
-
uri: string;
|
|
4
|
-
range: import("@lblod/ember-rdfa-editor/addon/plugins/datastore").TextPNode | import("@lblod/ember-rdfa-editor/addon/plugins/datastore").ElementPNode;
|
|
5
|
-
}[] | undefined;
|