@lblod/ember-rdfa-editor-lblod-plugins 2.1.2 → 4.0.1

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.
Files changed (101) hide show
  1. package/.woodpecker/.release.yml +1 -1
  2. package/.woodpecker/.test-scenarios.yml +17 -0
  3. package/.woodpecker/.test.yml +5 -5
  4. package/CHANGELOG.md +61 -1
  5. package/README.md +184 -141
  6. package/addon/components/article-structure-plugin/article-structure-card.hbs +1 -3
  7. package/addon/components/article-structure-plugin/article-structure-card.ts +14 -8
  8. package/addon/components/article-structure-plugin/structure-card.hbs +9 -4
  9. package/addon/components/article-structure-plugin/structure-card.ts +19 -15
  10. package/addon/components/besluit-plugin/besluit-plugin-card.ts +8 -4
  11. package/addon/components/besluit-type-plugin/toolbar-dropdown.hbs +2 -2
  12. package/addon/components/besluit-type-plugin/toolbar-dropdown.ts +12 -10
  13. package/addon/components/citation-plugin/citation-card.hbs +4 -0
  14. package/addon/components/citation-plugin/citation-card.ts +42 -33
  15. package/addon/components/citation-plugin/citation-insert.ts +32 -37
  16. package/addon/components/import-snippet-plugin/card.ts +9 -6
  17. package/addon/components/rdfa-date-plugin/card.ts +16 -20
  18. package/addon/components/rdfa-date-plugin/insert.hbs +0 -9
  19. package/addon/components/rdfa-date-plugin/insert.ts +12 -20
  20. package/addon/components/roadsign-regulation-plugin/roadsign-regulation-card.ts +3 -3
  21. package/addon/components/roadsign-regulation-plugin/roadsigns-modal.ts +5 -4
  22. package/addon/components/roadsign-regulation-plugin/roadsigns-table.ts +1 -1
  23. package/addon/components/standard-template-plugin/card.ts +2 -2
  24. package/addon/components/standard-template-plugin/template-provider.ts +6 -5
  25. package/addon/components/table-of-contents-plugin/ember-nodes/table-of-contents.ts +1 -1
  26. package/addon/components/table-of-contents-plugin/toolbar-button.ts +45 -8
  27. package/addon/components/variable-plugin/insert-variable-card.hbs +23 -9
  28. package/addon/components/variable-plugin/insert-variable-card.ts +19 -14
  29. package/addon/components/variable-plugin/template-variable-card.hbs +1 -1
  30. package/addon/components/variable-plugin/template-variable-card.ts +10 -7
  31. package/addon/components/variable-plugin/variable.hbs +8 -3
  32. package/addon/models/instruction.ts +1 -1
  33. package/addon/models/measure.ts +1 -1
  34. package/addon/models/sign.ts +1 -1
  35. package/addon/plugins/article-structure-plugin/commands/move-selected-structure.ts +1 -1
  36. package/addon/plugins/article-structure-plugin/index.ts +2 -32
  37. package/addon/plugins/article-structure-plugin/structures/article-paragraph.ts +17 -8
  38. package/addon/plugins/article-structure-plugin/structures/article.ts +7 -3
  39. package/addon/plugins/article-structure-plugin/structures/chapter.ts +1 -1
  40. package/addon/plugins/article-structure-plugin/structures/section.ts +1 -1
  41. package/addon/plugins/article-structure-plugin/structures/structure-header.ts +7 -2
  42. package/addon/plugins/article-structure-plugin/structures/subsection.ts +1 -1
  43. package/addon/plugins/article-structure-plugin/structures/title.ts +1 -1
  44. package/addon/plugins/besluit-plugin/utils/get-title-for-decision.ts +3 -6
  45. package/addon/plugins/citation-plugin/index.ts +17 -55
  46. package/addon/plugins/citation-plugin/utils/cited-text.ts +5 -4
  47. package/addon/plugins/rdfa-date-plugin/index.ts +5 -28
  48. package/addon/plugins/rdfa-date-plugin/nodes/date.ts +1 -6
  49. package/addon/plugins/standard-template-plugin/index.ts +0 -6
  50. package/addon/plugins/standard-template-plugin/utils/nodes.ts +1 -1
  51. package/addon/plugins/table-of-contents-plugin/index.ts +0 -7
  52. package/addon/plugins/variable-plugin/utils/constants.ts +1 -0
  53. package/addon/services/roadsign-registry.ts +1 -1
  54. package/app/styles/article-structure-plugin.scss +7 -0
  55. package/app/styles/besluit-plugin.scss +4 -0
  56. package/app/styles/variable-plugin.scss +1 -1
  57. package/components/article-structure-plugin/article-structure-card.d.ts +4 -5
  58. package/components/article-structure-plugin/structure-card.d.ts +4 -6
  59. package/components/besluit-plugin/besluit-plugin-card.d.ts +3 -3
  60. package/components/besluit-type-plugin/toolbar-dropdown.d.ts +3 -3
  61. package/components/citation-plugin/citation-card.d.ts +7 -8
  62. package/components/citation-plugin/citation-insert.d.ts +5 -10
  63. package/components/import-snippet-plugin/card.d.ts +3 -3
  64. package/components/rdfa-date-plugin/card.d.ts +6 -11
  65. package/components/rdfa-date-plugin/insert.d.ts +6 -12
  66. package/components/roadsign-regulation-plugin/roadsign-regulation-card.d.ts +3 -3
  67. package/components/roadsign-regulation-plugin/roadsigns-modal.d.ts +2 -2
  68. package/components/standard-template-plugin/card.d.ts +3 -3
  69. package/components/standard-template-plugin/template-provider.d.ts +3 -3
  70. package/components/table-of-contents-plugin/ember-nodes/table-of-contents.d.ts +1 -1
  71. package/components/table-of-contents-plugin/toolbar-button.d.ts +3 -3
  72. package/components/variable-plugin/insert-variable-card.d.ts +7 -8
  73. package/components/variable-plugin/template-variable-card.d.ts +3 -3
  74. package/package.json +26 -29
  75. package/plugins/article-structure-plugin/index.d.ts +2 -3
  76. package/plugins/besluit-plugin/utils/get-title-for-decision.d.ts +3 -3
  77. package/plugins/citation-plugin/index.d.ts +2 -12
  78. package/plugins/rdfa-date-plugin/index.d.ts +5 -5
  79. package/plugins/rdfa-date-plugin/nodes/date.d.ts +1 -6
  80. package/plugins/standard-template-plugin/index.d.ts +0 -2
  81. package/plugins/table-of-contents-plugin/index.d.ts +0 -2
  82. package/plugins/table-of-contents-plugin/nodes/table-of-contents.d.ts +1 -1
  83. package/plugins/variable-plugin/nodes.d.ts +1 -1
  84. package/translations/en-US.yaml +63 -61
  85. package/translations/nl-BE.yaml +65 -59
  86. package/addon/components/variable-plugin/variable.ts +0 -262
  87. package/addon/plugins/besluit-plugin/index.ts +0 -6
  88. package/addon/plugins/besluit-type-plugin/index.ts +0 -6
  89. package/addon/plugins/citation-plugin/marks/citation.ts +0 -27
  90. package/addon/plugins/import-snippet-plugin.ts +0 -6
  91. package/addon/plugins/rdfa-date-plugin/nodes/index.ts +0 -1
  92. package/addon/plugins/roadsign-regulation-plugin/index.ts +0 -6
  93. package/addon/plugins/variable-plugin/index.ts +0 -16
  94. package/components/variable-plugin/variable.d.ts +0 -43
  95. package/plugins/besluit-plugin/index.d.ts +0 -2
  96. package/plugins/besluit-type-plugin/index.d.ts +0 -2
  97. package/plugins/citation-plugin/marks/citation.d.ts +0 -2
  98. package/plugins/import-snippet-plugin.d.ts +0 -2
  99. package/plugins/rdfa-date-plugin/nodes/index.d.ts +0 -1
  100. package/plugins/roadsign-regulation-plugin/index.d.ts +0 -2
  101. package/plugins/variable-plugin/index.d.ts +0 -3
@@ -1,18 +1,16 @@
1
1
  import Component from '@glimmer/component';
2
2
  import { action } from '@ember/object';
3
- import { ProseController } from '@lblod/ember-rdfa-editor/core/prosemirror';
3
+ import { SayController } from '@lblod/ember-rdfa-editor';
4
4
  import { NodeSelection } from '@lblod/ember-rdfa-editor';
5
- import { DateFormat } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/rdfa-date-plugin';
5
+ import {
6
+ DateFormat,
7
+ DateOptions,
8
+ } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/rdfa-date-plugin';
6
9
  import { Option } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/option';
7
10
 
8
11
  type Args = {
9
- controller: ProseController;
10
- widgetArgs: {
11
- options: {
12
- formats: [DateFormat];
13
- allowCustomFormat: boolean;
14
- };
15
- };
12
+ controller: SayController;
13
+ options: DateOptions;
16
14
  };
17
15
 
18
16
  export default class RdfaDatePluginInsertComponent extends Component<Args> {
@@ -25,26 +23,20 @@ export default class RdfaDatePluginInsertComponent extends Component<Args> {
25
23
  }
26
24
 
27
25
  get formats(): DateFormat[] {
28
- return this.args.widgetArgs.options.formats;
26
+ return this.args.options.formats;
29
27
  }
30
28
 
31
29
  get defaultDateFormat(): Option<string> {
32
30
  return this.formats[0].dateFormat;
33
31
  }
34
32
 
35
- get defaultDateTimeFormat(): Option<string> {
36
- return this.formats[0].dateTimeFormat;
37
- }
38
-
39
33
  @action
40
- insertDate(onlyDate: boolean) {
34
+ insertDate() {
41
35
  this.controller.withTransaction((tr) => {
42
36
  tr.replaceSelectionWith(
43
37
  this.schema.node('date', {
44
- onlyDate,
45
- format: onlyDate
46
- ? this.defaultDateFormat
47
- : this.defaultDateTimeFormat,
38
+ onlyDate: true,
39
+ format: this.defaultDateFormat,
48
40
  })
49
41
  );
50
42
  if (tr.selection.$anchor.nodeBefore) {
@@ -54,6 +46,6 @@ export default class RdfaDatePluginInsertComponent extends Component<Args> {
54
46
  tr.setSelection(new NodeSelection(resolvedPos));
55
47
  }
56
48
  return tr;
57
- }, true);
49
+ });
58
50
  }
59
51
  }
@@ -2,7 +2,7 @@ import { findParentNode } from '@curvenote/prosemirror-utils';
2
2
  import { action } from '@ember/object';
3
3
  import Component from '@glimmer/component';
4
4
  import { tracked } from '@glimmer/tracking';
5
- import { ProseController } from '@lblod/ember-rdfa-editor/core/prosemirror';
5
+ import { SayController } from '@lblod/ember-rdfa-editor';
6
6
 
7
7
  /**
8
8
  * Card displaying a hint of the Date plugin
@@ -22,7 +22,7 @@ const acceptedTypes = [
22
22
  ];
23
23
 
24
24
  type Args = {
25
- controller: ProseController;
25
+ controller: SayController;
26
26
  };
27
27
 
28
28
  export default class RoadsignRegulationCard extends Component<Args> {
@@ -48,7 +48,7 @@ export default class RoadsignRegulationCard extends Component<Args> {
48
48
  }
49
49
 
50
50
  get showCard() {
51
- const selection = this.controller.state.selection;
51
+ const selection = this.controller.mainEditorState.selection;
52
52
  const besluitNode = findParentNode((node) => {
53
53
  if (node.type === this.schema.nodes['besluit']) {
54
54
  const rdfTypes = (node.attrs['typeof'] as string | undefined)?.split(
@@ -13,13 +13,13 @@ import {
13
13
  } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/roadsign-regulation-plugin/utils/constants';
14
14
  import RoadsignRegistryService from '@lblod/ember-rdfa-editor-lblod-plugins/services/roadsign-registry';
15
15
  import { assert } from '@ember/debug';
16
- import { unwrap } from '@lblod/ember-rdfa-editor/utils/option';
17
16
  import Measure from '@lblod/ember-rdfa-editor-lblod-plugins/models/measure';
18
- import { ProseController } from '@lblod/ember-rdfa-editor/core/prosemirror';
17
+ import { SayController } from '@lblod/ember-rdfa-editor';
19
18
  import { insertStructure } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/article-structure-plugin/commands';
20
19
  import { besluitArticleStructure } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/standard-template-plugin/utils/nodes';
21
20
  import IntlService from 'ember-intl/services/intl';
22
21
  import { ProseParser } from '@lblod/ember-rdfa-editor';
22
+ import { unwrap } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/option';
23
23
 
24
24
  const PAGE_SIZE = 10;
25
25
  const SIGN_TYPE_URI =
@@ -42,7 +42,7 @@ type Category = Option;
42
42
 
43
43
  type Args = {
44
44
  closeModal: () => void;
45
- controller: ProseController;
45
+ controller: SayController;
46
46
  };
47
47
 
48
48
  export default class RoadsignRegulationCard extends Component<Args> {
@@ -306,7 +306,8 @@ export default class RoadsignRegulationCard extends Component<Args> {
306
306
  }).content;
307
307
 
308
308
  this.args.controller.doCommand(
309
- insertStructure(besluitArticleStructure, this.intl, contentFragment)
309
+ insertStructure(besluitArticleStructure, this.intl, contentFragment),
310
+ { view: this.args.controller.mainEditorView }
310
311
  );
311
312
  this.args.closeModal();
312
313
  }
@@ -2,7 +2,7 @@ import { action } from '@ember/object';
2
2
  import Component from '@glimmer/component';
3
3
  import { tracked } from '@glimmer/tracking';
4
4
  import { getOwner } from '@ember/application';
5
- import { unwrap } from '@lblod/ember-rdfa-editor/utils/option';
5
+ import { unwrap } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/option';
6
6
 
7
7
  type Args = Record<string, never>;
8
8
  export default class RoadsignsTable extends Component<Args> {
@@ -1,8 +1,8 @@
1
1
  import Component from '@glimmer/component';
2
- import { ProseController } from '@lblod/ember-rdfa-editor/core/prosemirror';
2
+ import { SayController } from '@lblod/ember-rdfa-editor';
3
3
 
4
4
  type Args = {
5
- controller: ProseController;
5
+ controller: SayController;
6
6
  };
7
7
  export default class StandardTemplatePluginCardComponent extends Component<Args> {
8
8
  get controller() {
@@ -2,7 +2,7 @@ import Component from '@glimmer/component';
2
2
  import { action } from '@ember/object';
3
3
  import { inject as service } from '@ember/service';
4
4
  import StandardTemplatePluginService from '@lblod/ember-rdfa-editor-lblod-plugins/services/standard-template-plugin';
5
- import { ProseController } from '@lblod/ember-rdfa-editor/core/prosemirror';
5
+ import { SayController } from '@lblod/ember-rdfa-editor';
6
6
  import TemplateModel from '@lblod/ember-rdfa-editor-lblod-plugins/models/template';
7
7
  import { insertHtml } from '@lblod/ember-rdfa-editor/commands/insert-html-command';
8
8
  import instantiateUuids from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/standard-template-plugin/utils/instantiate-uuids';
@@ -14,7 +14,7 @@ import {
14
14
  } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/namespace';
15
15
 
16
16
  type Args = {
17
- controller: ProseController;
17
+ controller: SayController;
18
18
  };
19
19
 
20
20
  const HACKY_LOOKUP: Record<string, Resource> = {
@@ -65,7 +65,7 @@ export default class TemplateProviderComponent extends Component<Args> {
65
65
  }
66
66
 
67
67
  templateIsApplicable(template: TemplateModel) {
68
- const { $from } = this.controller.state.selection;
68
+ const { $from } = this.controller.mainEditorState.selection;
69
69
  const containsTypes =
70
70
  this.controller.externalContextStore
71
71
  .match(null, 'a')
@@ -95,7 +95,7 @@ export default class TemplateProviderComponent extends Component<Args> {
95
95
  @action
96
96
  async insert(template: TemplateModel) {
97
97
  await template.reload();
98
- const selection = this.controller.state.selection;
98
+ const selection = this.controller.mainEditorState.selection;
99
99
  let insertRange: { from: number; to: number } = selection;
100
100
  const { $from, $to } = selection;
101
101
  const isInPlaceholder =
@@ -119,7 +119,8 @@ export default class TemplateProviderComponent extends Component<Args> {
119
119
  instantiateUuids(template.body),
120
120
  insertRange.from,
121
121
  insertRange.to
122
- )
122
+ ),
123
+ { view: this.controller.mainEditorView }
123
124
  );
124
125
  }
125
126
  }
@@ -21,7 +21,7 @@ export default class TableOfContentsComponent extends Component<EmberNodeArgs> {
21
21
 
22
22
  get outline() {
23
23
  const entries = this.extractOutline({
24
- node: this.controller.state.doc,
24
+ node: this.controller.mainEditorState.doc,
25
25
  pos: -1,
26
26
  });
27
27
  return {
@@ -1,9 +1,9 @@
1
1
  import { action } from '@ember/object';
2
2
  import Component from '@glimmer/component';
3
- import { ProseController } from '@lblod/ember-rdfa-editor/core/prosemirror';
3
+ import { SayController } from '@lblod/ember-rdfa-editor';
4
4
 
5
5
  type Args = {
6
- controller: ProseController;
6
+ controller: SayController;
7
7
  };
8
8
 
9
9
  export default class TableOfContentsCardComponent extends Component<Args> {
@@ -17,7 +17,7 @@ export default class TableOfContentsCardComponent extends Component<Args> {
17
17
 
18
18
  get tableOfContentsRange() {
19
19
  let result: { from: number; to: number } | undefined;
20
- this.controller.state.doc.descendants((node, pos) => {
20
+ this.controller.mainEditorState.doc.descendants((node, pos) => {
21
21
  if (node.type === this.controller.schema.nodes['table_of_contents']) {
22
22
  result = { from: pos, to: pos + node.nodeSize };
23
23
  }
@@ -30,14 +30,51 @@ export default class TableOfContentsCardComponent extends Component<Args> {
30
30
  toggle() {
31
31
  if (this.tableOfContentsRange) {
32
32
  const { from, to } = this.tableOfContentsRange;
33
- this.controller.withTransaction((tr) => {
34
- return tr.deleteRange(from, to);
35
- });
33
+ this.controller.withTransaction(
34
+ (tr) => {
35
+ return tr.deleteRange(from, to);
36
+ },
37
+ { view: this.controller.mainEditorView }
38
+ );
36
39
  } else {
37
40
  const { schema } = this.controller;
38
- this.controller.withTransaction((tr) => {
39
- return tr.replaceRangeWith(0, 0, schema.node('table_of_contents'));
41
+ const state = this.controller.activeEditorState;
42
+ let replacePosition: number | undefined = undefined;
43
+ state.doc.descendants((node, pos, parent, index) => {
44
+ if (
45
+ replacePosition === undefined &&
46
+ state.doc.canReplaceWith(
47
+ index,
48
+ index,
49
+ schema.nodes['table_of_contents']
50
+ )
51
+ ) {
52
+ replacePosition = pos;
53
+ } else if (
54
+ index === state.doc.childCount - 1 &&
55
+ replacePosition === undefined &&
56
+ state.doc.canReplaceWith(
57
+ index + 1,
58
+ index + 1,
59
+ schema.nodes['table_of_contents']
60
+ )
61
+ ) {
62
+ replacePosition = pos + node.nodeSize;
63
+ }
64
+ return false;
40
65
  });
66
+ if (replacePosition !== undefined) {
67
+ this.controller.withTransaction(
68
+ (transaction) => {
69
+ return transaction.replaceWith(
70
+ replacePosition as number,
71
+ replacePosition as number,
72
+ schema.node('table_of_contents')
73
+ );
74
+ },
75
+ { view: this.controller.mainEditorView }
76
+ );
77
+ }
41
78
  }
42
79
  }
43
80
  }
@@ -1,8 +1,16 @@
1
1
  {{#if this.showCard}}
2
- <AuCard @flex={{true}} @divided={{true}} @isOpenInitially={{true}} @expandable={{true}} @shadow={{true}} @size="small" as |c|>
2
+ <AuCard
3
+ @flex={{true}}
4
+ @divided={{true}}
5
+ @isOpenInitially={{true}}
6
+ @expandable={{true}}
7
+ @shadow={{true}}
8
+ @size='small'
9
+ as |c|
10
+ >
3
11
  <c.header>
4
- <AuHeading @level="3" @skin="6">
5
- {{t "variable-plugin.insert-variable"}}
12
+ <AuHeading @level='3' @skin='6'>
13
+ {{t 'variable-plugin.insert-variable'}}
6
14
  </AuHeading>
7
15
  </c.header>
8
16
  <c.content>
@@ -11,7 +19,8 @@
11
19
  @searchEnabled={{false}}
12
20
  @options={{this.variablesArray}}
13
21
  @selected={{this.selectedVariable}}
14
- @onChange={{this.updateSelectedVariable}} as |variable|
22
+ @onChange={{this.updateSelectedVariable}}
23
+ as |variable|
15
24
  >
16
25
  {{variable.label}}
17
26
  </PowerSelect>
@@ -21,14 +30,19 @@
21
30
  @searchEnabled={{false}}
22
31
  @options={{this.subtypes}}
23
32
  @selected={{this.selectedSubtype}}
24
- @onChange={{this.updateSubtype}} as |subtype|
33
+ @onChange={{this.updateSubtype}}
34
+ as |subtype|
25
35
  >
26
36
  {{subtype.label}}
27
37
  </PowerSelect>
28
38
  {{/if}}
29
- <AuButton {{on 'click' this.insert}} @disabled={{or (not this.selectedVariable)
30
- (and this.hasSubtype (not this.selectedSubtype))}}>{{t
31
- "variable-plugin.button"}}</AuButton>
39
+ <AuButton
40
+ {{on 'click' this.insert}}
41
+ @disabled={{or
42
+ (not this.selectedVariable)
43
+ (and this.hasSubtype (not this.selectedSubtype))
44
+ }}
45
+ >{{t 'variable-plugin.button'}}</AuButton>
32
46
  </c.content>
33
47
  </AuCard>
34
- {{/if}}
48
+ {{/if}}
@@ -2,7 +2,7 @@ import Component from '@glimmer/component';
2
2
  import { tracked } from '@glimmer/tracking';
3
3
  import { action } from '@ember/object';
4
4
  import { task } from 'ember-concurrency';
5
- import { ProseController } from '@lblod/ember-rdfa-editor/core/prosemirror';
5
+ import { SayController } from '@lblod/ember-rdfa-editor';
6
6
  import {
7
7
  DEFAULT_VARIABLE_TYPES,
8
8
  VariableType,
@@ -11,13 +11,11 @@ import { CodeList } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/variabl
11
11
  import { findParentNodeOfType } from '@curvenote/prosemirror-utils';
12
12
  import { NodeSelection } from '@lblod/ember-rdfa-editor';
13
13
  type Args = {
14
- controller: ProseController;
15
- widgetArgs: {
16
- options: {
17
- publisher: string;
18
- variableTypes: (VariableType | string)[];
19
- defaultEndpoint: string;
20
- };
14
+ controller: SayController;
15
+ options: {
16
+ publisher: string;
17
+ variableTypes: (VariableType | string)[];
18
+ defaultEndpoint: string;
21
19
  };
22
20
  };
23
21
 
@@ -33,7 +31,7 @@ export default class EditorPluginsInsertCodelistCardComponent extends Component<
33
31
  constructor(parent: unknown, args: Args) {
34
32
  super(parent, args);
35
33
  const { publisher, variableTypes, defaultEndpoint } =
36
- this.args.widgetArgs.options || {};
34
+ this.args.options || {};
37
35
  this.publisher = publisher;
38
36
  this.endpoint = defaultEndpoint;
39
37
  const variableTypesSelectedByUser = variableTypes ?? [
@@ -62,19 +60,26 @@ export default class EditorPluginsInsertCodelistCardComponent extends Component<
62
60
  this.variablesArray = variablesArray;
63
61
  }
64
62
 
63
+ get controller() {
64
+ return this.args.controller;
65
+ }
66
+
65
67
  @action
66
68
  insert() {
67
69
  if (!this.selectedVariable) {
68
70
  return;
69
71
  }
70
72
  const node = this.selectedVariable.constructor(
71
- this.args.controller.schema,
73
+ this.controller.schema,
72
74
  this.endpoint,
73
75
  this.selectedSubtype
74
76
  );
75
- this.args.controller.withTransaction((tr) => {
76
- return tr.replaceSelectionWith(node);
77
- });
77
+ this.controller.withTransaction(
78
+ (tr) => {
79
+ return tr.replaceSelectionWith(node);
80
+ },
81
+ { view: this.controller.mainEditorView }
82
+ );
78
83
  }
79
84
 
80
85
  @action
@@ -109,7 +114,7 @@ export default class EditorPluginsInsertCodelistCardComponent extends Component<
109
114
  if (this.args.controller.inEmbeddedView) {
110
115
  return false;
111
116
  }
112
- const { selection } = this.args.controller.state;
117
+ const { selection } = this.args.controller.mainEditorState;
113
118
  if (
114
119
  selection instanceof NodeSelection &&
115
120
  selection.node.type === this.args.controller.schema.nodes.variable
@@ -1,4 +1,4 @@
1
- <div {{did-update this.selectionChanged @controller.state}}>
1
+ <div {{did-update this.selectionChanged @controller.mainEditorState}}>
2
2
  {{#if this.showCard}}
3
3
  <AuCard @flex={{true}} @divided={{true}} @isOpenInitially={{true}} @expandable={{true}} @shadow={{true}} @size="small" as |c|>
4
4
  <c.header>
@@ -3,8 +3,7 @@ import { tracked } from '@glimmer/tracking';
3
3
  import { action } from '@ember/object';
4
4
  import { getOwner } from '@ember/application';
5
5
  import { task } from 'ember-concurrency';
6
- import { ProseController } from '@lblod/ember-rdfa-editor/core/prosemirror';
7
- import { unwrap } from '@lblod/ember-rdfa-editor/utils/option';
6
+ import { SayController } from '@lblod/ember-rdfa-editor';
8
7
  import {
9
8
  CodeListOption,
10
9
  fetchCodeListOptions,
@@ -13,9 +12,10 @@ import { MULTI_SELECT_CODELIST_TYPE } from '@lblod/ember-rdfa-editor-lblod-plugi
13
12
  import { findParentNodeOfType } from '@curvenote/prosemirror-utils';
14
13
  import { NodeSelection, PNode, ProseParser } from '@lblod/ember-rdfa-editor';
15
14
  import { ZONAL_URI } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/roadsign-regulation-plugin/utils/constants';
15
+ import { unwrap } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/option';
16
16
 
17
17
  type Args = {
18
- controller: ProseController;
18
+ controller: SayController;
19
19
  };
20
20
  export default class EditorPluginsTemplateVariableCardComponent extends Component<Args> {
21
21
  @tracked variableOptions: CodeListOption[] = [];
@@ -74,9 +74,12 @@ export default class EditorPluginsTemplateVariableCardComponent extends Componen
74
74
  from: this.selectedVariable.pos + 1,
75
75
  to: this.selectedVariable.pos + this.selectedVariable.node.nodeSize - 1,
76
76
  };
77
- this.controller.withTransaction((tr) => {
78
- return tr.replaceWith(range.from, range.to, contentFragment);
79
- });
77
+ this.controller.withTransaction(
78
+ (tr) => {
79
+ return tr.replaceWith(range.from, range.to, contentFragment);
80
+ },
81
+ { view: this.controller.mainEditorView }
82
+ );
80
83
  }
81
84
 
82
85
  wrapVariableInHighlight(text: string) {
@@ -90,7 +93,7 @@ export default class EditorPluginsTemplateVariableCardComponent extends Componen
90
93
  selectionChanged() {
91
94
  this.showCard = false;
92
95
  this.selectedVariableOption = undefined;
93
- const { selection } = this.controller.state;
96
+ const { selection } = this.controller.mainEditorState;
94
97
  if (
95
98
  selection instanceof NodeSelection &&
96
99
  selection.node.type === this.controller.schema.nodes.variable
@@ -1,4 +1,9 @@
1
- <AuPill @icon="pencil" @iconAlignment="right" class="variable" {{on "click" this.onClick}}>
2
- <div {{did-insert this.didInsertContentWrapper}} {{did-update this.onNodeUpdate @node}}>
3
- </div>
1
+ <AuPill @icon="pencil" @iconAlignment="right" class="variable">
2
+ <EmberNode::EmbeddedEditor
3
+ @controller={{@controller}}
4
+ @node={{@node}}
5
+ @view={{@view}}
6
+ @getPos={{@getPos}}
7
+ @selected={{@selected}}
8
+ />
4
9
  </AuPill>
@@ -1,5 +1,5 @@
1
- import { unwrap } from '@lblod/ember-rdfa-editor/utils/option';
2
1
  import { IBindings } from 'fetch-sparql-endpoint';
2
+ import { unwrap } from '../utils/option';
3
3
 
4
4
  export default class Instruction {
5
5
  constructor(
@@ -1,6 +1,6 @@
1
1
  import { tracked } from '@glimmer/tracking';
2
- import { unwrap } from '@lblod/ember-rdfa-editor/utils/option';
3
2
  import { IBindings } from 'fetch-sparql-endpoint';
3
+ import { unwrap } from '../utils/option';
4
4
  import Sign from './sign';
5
5
 
6
6
  export default class Measure {
@@ -1,5 +1,5 @@
1
- import { unwrap } from '@lblod/ember-rdfa-editor/utils/option';
2
1
  import { IBindings } from 'fetch-sparql-endpoint';
2
+ import { unwrap } from '../utils/option';
3
3
 
4
4
  export default class Sign {
5
5
  constructor(
@@ -7,13 +7,13 @@ import {
7
7
  Selection,
8
8
  TextSelection,
9
9
  } from '@lblod/ember-rdfa-editor';
10
- import { unwrap } from '@lblod/ember-rdfa-editor/utils/option';
11
10
  import { ArticleStructurePluginOptions } from '..';
12
11
  import { findAncestorOfType } from '../utils/structure';
13
12
  import recalculateStructureNumbers from './recalculate-structure-numbers';
14
13
  import { findNodes } from '@lblod/ember-rdfa-editor/utils/position-utils';
15
14
  import IntlService from 'ember-intl/services/intl';
16
15
  import { findParentNodeOfType } from '@curvenote/prosemirror-utils';
16
+ import { unwrap } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/option';
17
17
  const moveSelectedStructure = (
18
18
  options: ArticleStructurePluginOptions,
19
19
  direction: 'up' | 'down',
@@ -1,13 +1,6 @@
1
- import {
2
- Fragment,
3
- PNode,
4
- Schema,
5
- WidgetSpec,
6
- EditorState,
7
- } from '@lblod/ember-rdfa-editor';
1
+ import { Fragment, PNode, Schema, EditorState } from '@lblod/ember-rdfa-editor';
8
2
  import IntlService from 'ember-intl/services/intl';
9
3
  import { Transaction } from '@lblod/ember-rdfa-editor';
10
- import { STRUCTURE_SPECS } from './structures';
11
4
 
12
5
  export type SpecName = string;
13
6
 
@@ -41,30 +34,7 @@ export type StructureSpec = {
41
34
  content?: (args: { pos: number; state: EditorState }) => Fragment;
42
35
  continuous: boolean;
43
36
  limitTo?: string;
37
+ noUnwrap?: boolean;
44
38
  };
45
39
 
46
40
  export type ArticleStructurePluginOptions = StructureSpec[];
47
-
48
- export const articleStructureInsertWidget: (
49
- options?: ArticleStructurePluginOptions
50
- ) => WidgetSpec = (options) => {
51
- return {
52
- componentName: 'article-structure-plugin/article-structure-card',
53
- desiredLocation: 'insertSidebar',
54
- widgetArgs: {
55
- options: options ?? STRUCTURE_SPECS,
56
- },
57
- };
58
- };
59
-
60
- export const articleStructureContextWidget: (
61
- options?: ArticleStructurePluginOptions
62
- ) => WidgetSpec = (options) => {
63
- return {
64
- componentName: 'article-structure-plugin/structure-card',
65
- desiredLocation: 'sidebar',
66
- widgetArgs: {
67
- options: options ?? STRUCTURE_SPECS,
68
- },
69
- };
70
- };
@@ -22,7 +22,8 @@ export const articleParagraphSpec: StructureSpec = {
22
22
  },
23
23
  remove: 'article-structure-plugin.remove.paragraph',
24
24
  },
25
- continuous: true,
25
+ continuous: false,
26
+ noUnwrap: true,
26
27
  constructor: ({ schema, number, intl }) => {
27
28
  const numberConverted = number?.toString() ?? '1';
28
29
  const node = schema.node(
@@ -31,9 +32,13 @@ export const articleParagraphSpec: StructureSpec = {
31
32
  resource: `http://data.lblod.info/paragraphs/${uuid()}`,
32
33
  number: numberConverted,
33
34
  },
34
- schema.node('placeholder', {
35
- placeholderText: intl?.t(PLACEHOLDERS.body),
36
- })
35
+ schema.node(
36
+ 'paragraph',
37
+ {},
38
+ schema.node('placeholder', {
39
+ placeholderText: intl?.t(PLACEHOLDERS.body),
40
+ })
41
+ )
37
42
  );
38
43
  return { node, selectionConfig: { relativePos: 1, type: 'node' } };
39
44
  },
@@ -47,7 +52,7 @@ const contentSelector = `span[property~='${SAY('body').prefixed}'],
47
52
  span[property~='${SAY('body').full}']`;
48
53
 
49
54
  export const article_paragraph: NodeSpec = {
50
- content: 'inline*',
55
+ content: 'paragraph*',
51
56
  inline: false,
52
57
  isolating: true,
53
58
  defining: true,
@@ -71,13 +76,17 @@ export const article_paragraph: NodeSpec = {
71
76
  typeof: node.attrs.typeof as string,
72
77
  resource: node.attrs.resource as string,
73
78
  },
74
- '$',
79
+ ['span', { contenteditable: false }, '§'],
75
80
  [
76
81
  'span',
77
- { property: ELI('number').prefixed, datatype: XSD('integer').prefixed },
82
+ {
83
+ property: ELI('number').prefixed,
84
+ datatype: XSD('integer').prefixed,
85
+ contenteditable: false,
86
+ },
78
87
  node.attrs.number,
79
88
  ],
80
- '. ',
89
+ ['span', { contenteditable: false }, '. '],
81
90
  ['span', { property: SAY('body').prefixed }, 0],
82
91
  ];
83
92
  },
@@ -6,13 +6,13 @@ import {
6
6
  getStructureHeaderAttrs,
7
7
  } from '../utils/structure';
8
8
  import { v4 as uuid } from 'uuid';
9
- import { unwrap } from '@lblod/ember-rdfa-editor/utils/option';
10
9
  import {
11
10
  ELI,
12
11
  EXT,
13
12
  SAY,
14
13
  XSD,
15
14
  } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/constants';
15
+ import { unwrap } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/option';
16
16
 
17
17
  const PLACEHOLDERS = {
18
18
  title: 'article-structure-plugin.placeholder.article.heading',
@@ -106,10 +106,14 @@ export const article_header: NodeSpec = {
106
106
  'Artikel ',
107
107
  [
108
108
  'span',
109
- { property: ELI('number').prefixed, datatype: XSD('string').prefixed },
109
+ {
110
+ property: ELI('number').prefixed,
111
+ datatype: XSD('string').prefixed,
112
+ contenteditable: false,
113
+ },
110
114
  node.attrs.number,
111
115
  ],
112
- ': ',
116
+ ['span', { contenteditable: false }, ': '],
113
117
  [
114
118
  'span',
115
119
  {