@lblod/ember-rdfa-editor-lblod-plugins 1.0.0-beta.1 → 1.0.0-beta.2

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 (98) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/addon/components/article-structure-plugin/article-structure-card.hbs +3 -1
  3. package/addon/components/au-dropdown-pill.hbs +32 -0
  4. package/addon/components/au-dropdown-pill.ts +65 -0
  5. package/addon/components/besluit-type-plugin/toolbar-dropdown.ts +19 -12
  6. package/addon/components/citation-plugin/citation-card.ts +1 -1
  7. package/addon/components/citation-plugin/citation-insert.ts +1 -1
  8. package/addon/components/import-snippet-plugin/card.ts +8 -12
  9. package/addon/components/rdfa-date-plugin/card.hbs +28 -0
  10. package/addon/components/rdfa-date-plugin/card.ts +72 -38
  11. package/addon/components/rdfa-date-plugin/date-time-picker.ts +1 -0
  12. package/addon/components/rdfa-date-plugin/insert.hbs +2 -2
  13. package/addon/components/rdfa-date-plugin/insert.ts +14 -23
  14. package/addon/components/roadsign-regulation-plugin/roadsign-regulation-card.ts +24 -25
  15. package/addon/components/roadsign-regulation-plugin/roadsigns-modal.ts +36 -17
  16. package/addon/components/standard-template-plugin/template-provider.ts +54 -11
  17. package/addon/components/{insert-variable-plugin → variable-plugin}/insert-variable-card.hbs +4 -4
  18. package/addon/components/{insert-variable-plugin → variable-plugin}/insert-variable-card.ts +26 -35
  19. package/addon/components/{template-variable-plugin → variable-plugin}/template-variable-card.hbs +6 -6
  20. package/addon/components/variable-plugin/template-variable-card.ts +174 -0
  21. package/addon/components/variable-plugin/variable.hbs +4 -0
  22. package/addon/components/variable-plugin/variable.ts +250 -0
  23. package/addon/plugins/article-structure-plugin/commands/insert-structure.ts +4 -2
  24. package/addon/plugins/article-structure-plugin/index.ts +1 -1
  25. package/addon/plugins/article-structure-plugin/structures/article-paragraph.ts +6 -2
  26. package/addon/plugins/article-structure-plugin/structures/article.ts +1 -1
  27. package/addon/plugins/article-structure-plugin/structures/chapter.ts +1 -2
  28. package/addon/plugins/article-structure-plugin/structures/section.ts +1 -1
  29. package/addon/plugins/article-structure-plugin/structures/subsection.ts +1 -1
  30. package/addon/plugins/article-structure-plugin/structures/title.ts +1 -2
  31. package/addon/plugins/citation-plugin/index.ts +184 -113
  32. package/addon/plugins/rdfa-date-plugin/index.ts +42 -3
  33. package/addon/plugins/rdfa-date-plugin/nodes/date.ts +127 -0
  34. package/addon/plugins/rdfa-date-plugin/nodes/index.ts +1 -0
  35. package/addon/plugins/rdfa-date-plugin/utils.ts +10 -0
  36. package/addon/plugins/roadsign-regulation-plugin/nodes.ts +107 -0
  37. package/addon/plugins/standard-template-plugin/index.ts +26 -0
  38. package/addon/plugins/standard-template-plugin/utils/nodes.ts +366 -0
  39. package/addon/plugins/{insert-variable-plugin → variable-plugin}/index.ts +6 -1
  40. package/addon/plugins/variable-plugin/nodes.ts +137 -0
  41. package/addon/plugins/variable-plugin/utils/constants.ts +107 -0
  42. package/addon/plugins/{template-variable-plugin → variable-plugin}/utils/fetch-data.ts +41 -0
  43. package/addon/services/standard-template-plugin.ts +16 -12
  44. package/addon/utils/changed-descendants.ts +29 -0
  45. package/addon/utils/constants.ts +11 -0
  46. package/addon/utils/namespace.ts +42 -7
  47. package/app/components/au-dropdown-pill.js +1 -0
  48. package/app/components/{insert-variable-plugin → variable-plugin}/insert-variable-card.js +1 -1
  49. package/app/components/{template-variable-plugin → variable-plugin}/template-variable-card.js +1 -1
  50. package/app/components/variable-plugin/variable-edit-modal.js +1 -0
  51. package/app/components/variable-plugin/variable.js +1 -0
  52. package/app/styles/date-plugin.scss +17 -0
  53. package/app/styles/variable-plugin.scss +65 -0
  54. package/components/au-dropdown-pill.d.ts +19 -0
  55. package/components/au-native-input.d.ts +1 -1
  56. package/components/citation-plugin/citation-card.d.ts +1 -1
  57. package/components/rdfa-date-plugin/card.d.ts +14 -5
  58. package/components/rdfa-date-plugin/insert.d.ts +1 -2
  59. package/components/roadsign-regulation-plugin/roadsign-regulation-card.d.ts +1 -0
  60. package/components/roadsign-regulation-plugin/roadsigns-modal.d.ts +3 -0
  61. package/components/standard-template-plugin/template-provider.d.ts +6 -1
  62. package/components/{insert-variable-plugin → variable-plugin}/insert-variable-card.d.ts +3 -4
  63. package/components/{template-variable-plugin → variable-plugin}/template-variable-card.d.ts +8 -5
  64. package/components/variable-plugin/variable.d.ts +42 -0
  65. package/package.json +4 -4
  66. package/plugins/article-structure-plugin/commands/insert-structure.d.ts +2 -2
  67. package/plugins/article-structure-plugin/index.d.ts +1 -1
  68. package/plugins/citation-plugin/index.d.ts +11 -4
  69. package/plugins/rdfa-date-plugin/index.d.ts +13 -1
  70. package/plugins/rdfa-date-plugin/nodes/date.d.ts +9 -0
  71. package/plugins/rdfa-date-plugin/nodes/index.d.ts +1 -0
  72. package/plugins/rdfa-date-plugin/utils.d.ts +1 -0
  73. package/plugins/roadsign-regulation-plugin/nodes.d.ts +2 -0
  74. package/plugins/standard-template-plugin/index.d.ts +12 -0
  75. package/plugins/standard-template-plugin/utils/nodes.d.ts +12 -0
  76. package/plugins/{insert-variable-plugin → variable-plugin}/index.d.ts +1 -0
  77. package/plugins/variable-plugin/nodes.d.ts +2 -0
  78. package/plugins/variable-plugin/utils/constants.d.ts +9 -0
  79. package/plugins/{template-variable-plugin → variable-plugin}/utils/fetch-data.d.ts +5 -0
  80. package/services/standard-template-plugin.d.ts +9 -10
  81. package/translations/en-US.yaml +4 -3
  82. package/translations/nl-BE.yaml +5 -4
  83. package/utils/changed-descendants.d.ts +2 -0
  84. package/utils/constants.d.ts +5 -0
  85. package/utils/namespace.d.ts +8 -3
  86. package/addon/components/template-variable-plugin/template-variable-card.ts +0 -227
  87. package/addon/plugins/insert-variable-plugin/utils/constants.ts +0 -67
  88. package/addon/plugins/insert-variable-plugin/utils/fetch-data.ts +0 -41
  89. package/addon/plugins/rdfa-date-plugin/commands/index.ts +0 -1
  90. package/addon/plugins/rdfa-date-plugin/commands/modify-date.ts +0 -48
  91. package/addon/plugins/template-variable-plugin/index.ts +0 -6
  92. package/addon/plugins/template-variable-plugin/utils/constants.ts +0 -2
  93. package/plugins/insert-variable-plugin/utils/constants.d.ts +0 -7
  94. package/plugins/insert-variable-plugin/utils/fetch-data.d.ts +0 -5
  95. package/plugins/rdfa-date-plugin/commands/index.d.ts +0 -1
  96. package/plugins/rdfa-date-plugin/commands/modify-date.d.ts +0 -2
  97. package/plugins/template-variable-plugin/index.d.ts +0 -2
  98. package/plugins/template-variable-plugin/utils/constants.d.ts +0 -1
@@ -0,0 +1,42 @@
1
+ /**
2
+ *
3
+ * Based on the footnotes example from https://github.com/ProseMirror/website
4
+ *
5
+ * Copyright (C) 2015-2017 by Marijn Haverbeke <marijnh@gmail.com> and others
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in
14
+ * all copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+ * THE SOFTWARE.
23
+ */
24
+ import Component from '@glimmer/component';
25
+ import { RdfaEditorView, Schema, Transaction } from '@lblod/ember-rdfa-editor';
26
+ import { EmberNodeArgs } from '@lblod/ember-rdfa-editor/utils/ember-node';
27
+ import IntlService from 'ember-intl/services/intl';
28
+ export default class Variable extends Component<EmberNodeArgs> {
29
+ intl: IntlService;
30
+ innerView: RdfaEditorView | null;
31
+ contentWrapper: Element | null;
32
+ get outerView(): import("prosemirror-view").EditorView;
33
+ get node(): import("prosemirror-model").Node;
34
+ get pos(): number;
35
+ get htmlContent(): import("@ember/template/-private/handlebars").SafeString;
36
+ get schema(): Schema<"text" | "hard_break" | "date" | "invisible_rdfa" | "placeholder" | "paragraph" | "doc" | "block_rdfa" | "repaired_block", "em" | "link" | "strong" | "underline" | "inline_rdfa" | "strikethrough">;
37
+ onFocus(): void;
38
+ didInsertContentWrapper(target: Element): void;
39
+ onNodeUpdate(): void;
40
+ dispatchInner: (tr: Transaction) => void;
41
+ willDestroy(): void;
42
+ }
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.1",
3
+ "version": "1.0.0-beta.2",
4
4
  "description": "Ember addon providing lblod specific plugins for the ember-rdfa-editor",
5
5
  "keywords": [
6
6
  "ember-addon",
@@ -38,6 +38,7 @@
38
38
  "@types/rdf-validate-shacl": "^0.4.0",
39
39
  "@types/rdfjs__parser-n3": "^1.1.5",
40
40
  "buffer": "^6.0.3",
41
+ "date-fns": "^2.29.3",
41
42
  "ember-auto-import": "^2.4.1",
42
43
  "ember-cli-babel": "^7.26.11",
43
44
  "ember-cli-htmlbars": "^6.0.1",
@@ -48,7 +49,6 @@
48
49
  "ember-resources": "^5.6.0",
49
50
  "fetch-sparql-endpoint": "^3.0.0",
50
51
  "process": "0.11.10",
51
- "prosemirror-state": "^1.4.2",
52
52
  "rdf-ext": "^2.1.0",
53
53
  "rdf-validate-shacl": "^0.4.5",
54
54
  "stream-browserify": "^3.0.0",
@@ -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.2",
65
+ "@lblod/ember-rdfa-editor": "^1.0.0-beta.5",
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.2",
147
+ "@lblod/ember-rdfa-editor": "^1.0.0-beta.5",
148
148
  "ember-concurrency": "^2.3.7"
149
149
  },
150
150
  "engines": {
@@ -1,5 +1,5 @@
1
- import { Command } from '@lblod/ember-rdfa-editor';
1
+ import { Command, Fragment } from '@lblod/ember-rdfa-editor';
2
2
  import { StructureSpec } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/article-structure-plugin';
3
3
  import IntlService from 'ember-intl/services/intl';
4
- declare const insertStructure: (structureSpec: StructureSpec, intl: IntlService) => Command;
4
+ declare const insertStructure: (structureSpec: StructureSpec, intl: IntlService, content?: Fragment) => Command;
5
5
  export default insertStructure;
@@ -1,6 +1,6 @@
1
1
  import { Fragment, PNode, Schema, WidgetSpec, EditorState } from '@lblod/ember-rdfa-editor';
2
2
  import IntlService from 'ember-intl/services/intl';
3
- import { Transaction } from 'prosemirror-state';
3
+ import { Transaction } from '@lblod/ember-rdfa-editor';
4
4
  export type SpecName = string;
5
5
  export type StructureSpec = {
6
6
  name: SpecName;
@@ -1,5 +1,4 @@
1
- import { Decoration, DecorationSet, EditorState, InlineDecorationSpec, MarkSpec, ProsePlugin, Schema, WidgetSpec } from '@lblod/ember-rdfa-editor';
2
- import { ProseStore } from '@lblod/ember-rdfa-editor/plugins/datastore';
1
+ import { Decoration, DecorationSet, EditorState, InlineDecorationSpec, MarkSpec, NodeType, ProsePlugin, Schema, WidgetSpec } from '@lblod/ember-rdfa-editor';
3
2
  export declare const CITATION_REGEX: RegExp;
4
3
  export type CitationSchema = Schema<string, 'citation'>;
5
4
  export interface CitationDecorationSpec extends InlineDecorationSpec {
@@ -24,8 +23,16 @@ export interface CitationPluginBundle {
24
23
  citation: MarkSpec;
25
24
  };
26
25
  }
27
- export interface CitationPluginConfig {
28
- activeIn?(state: EditorState, datastore: ProseStore): [number, number][];
26
+ export interface CitationPluginNodeConfig {
27
+ type: 'nodes';
28
+ regex?: RegExp;
29
+ activeInNodeTypes(schema: Schema, state: EditorState): Set<NodeType>;
29
30
  }
31
+ export interface CitationPluginRangeConfig {
32
+ type: 'ranges';
33
+ regex?: RegExp;
34
+ activeInRanges(state: EditorState): [number, number][];
35
+ }
36
+ export type CitationPluginConfig = CitationPluginNodeConfig | CitationPluginRangeConfig;
30
37
  export declare function setupCitationPlugin(config?: CitationPluginConfig): CitationPluginBundle;
31
38
  export {};
@@ -1,3 +1,15 @@
1
1
  import { WidgetSpec } from '@lblod/ember-rdfa-editor';
2
- export declare const rdfaDateCardWidget: WidgetSpec;
2
+ export declare const defaultDateFormats: DateFormat[];
3
+ export declare const rdfaDateCardWidget: (options?: DatePluginOptions) => WidgetSpec;
3
4
  export declare const rdfaDateInsertWidget: WidgetSpec;
5
+ export type DateFormat = {
6
+ label: string;
7
+ key: string;
8
+ dateFormat: string;
9
+ dateTimeFormat: string;
10
+ };
11
+ type DatePluginOptions = {
12
+ formats: DateFormat[];
13
+ allowCustomFormat: boolean;
14
+ };
15
+ export {};
@@ -0,0 +1,9 @@
1
+ import { NodeSpec } from '@lblod/ember-rdfa-editor';
2
+ export type DateOptions = {
3
+ placeholder: {
4
+ insertDate: string;
5
+ insertDateTime: string;
6
+ };
7
+ };
8
+ declare const date: (options: DateOptions) => NodeSpec;
9
+ export default date;
@@ -0,0 +1 @@
1
+ export { default as date, DateOptions } from './date';
@@ -0,0 +1 @@
1
+ export declare function formatDate(date: Date, format: string): string;
@@ -0,0 +1,2 @@
1
+ import { NodeSpec } from '@lblod/ember-rdfa-editor';
2
+ export declare const roadsign_regulation: NodeSpec;
@@ -1,2 +1,14 @@
1
1
  import { WidgetSpec } from '@lblod/ember-rdfa-editor';
2
2
  export declare const standardTemplateWidget: WidgetSpec;
3
+ export declare const besluitNodes: {
4
+ besluit: import("prosemirror-model").NodeSpec;
5
+ title: import("prosemirror-model").NodeSpec;
6
+ description: import("prosemirror-model").NodeSpec;
7
+ motivering: import("prosemirror-model").NodeSpec;
8
+ article_container: import("prosemirror-model").NodeSpec;
9
+ besluit_article: import("prosemirror-model").NodeSpec;
10
+ besluit_article_content: import("prosemirror-model").NodeSpec;
11
+ besluit_article_header: import("prosemirror-model").NodeSpec;
12
+ language_node: import("prosemirror-model").NodeSpec;
13
+ };
14
+ export declare const structureSpecs: import("../article-structure-plugin").StructureSpec[];
@@ -0,0 +1,12 @@
1
+ import { NodeSpec } from '@lblod/ember-rdfa-editor';
2
+ import { StructureSpec } from '../../article-structure-plugin';
3
+ export declare const title: NodeSpec;
4
+ export declare const description: NodeSpec;
5
+ export declare const motivering: NodeSpec;
6
+ export declare const article_container: NodeSpec;
7
+ export declare const besluit_article: NodeSpec;
8
+ export declare const besluitArticleStructure: StructureSpec;
9
+ export declare const besluit_article_header: NodeSpec;
10
+ export declare const besluit_article_content: NodeSpec;
11
+ export declare const besluit: NodeSpec;
12
+ export declare const language_node: NodeSpec;
@@ -1,2 +1,3 @@
1
1
  import { WidgetSpec } from '@lblod/ember-rdfa-editor';
2
2
  export declare function insertVariableWidget(options?: unknown): WidgetSpec;
3
+ export declare const templateVariableWidget: WidgetSpec;
@@ -0,0 +1,2 @@
1
+ export declare const variable: import("prosemirror-model").NodeSpec;
2
+ export declare const variableView: (controller: import("@lblod/ember-rdfa-editor/addon").ProseController) => import("prosemirror-view").NodeViewConstructor;
@@ -0,0 +1,9 @@
1
+ import { PNode, Schema } from '@lblod/ember-rdfa-editor';
2
+ import { CodeList } from './fetch-data';
3
+ export declare const MULTI_SELECT_CODELIST_TYPE = "http://lblod.data.gift/concepts/57C93E12-A02C-4D4B-8B95-666B6701286C";
4
+ export type VariableType = {
5
+ label: string;
6
+ fetchSubtypes?: (endpoint: string, publisher: string) => Promise<CodeList[]>;
7
+ constructor: (schema: Schema, endpoint?: string, selectedCodelist?: CodeList) => PNode;
8
+ };
9
+ export declare const DEFAULT_VARIABLE_TYPES: Record<string, VariableType>;
@@ -7,3 +7,8 @@ export type CodeListOption = {
7
7
  label?: string;
8
8
  };
9
9
  export declare function fetchCodeListOptions(endpoint: string, codelistUri: string): Promise<CodeListOptions>;
10
+ export type CodeList = {
11
+ uri?: string;
12
+ label?: string;
13
+ };
14
+ export declare function fetchCodeListsByPublisher(endpoint: string, publisher: string): Promise<CodeList[]>;
@@ -1,21 +1,20 @@
1
1
  import Store from '@ember-data/store';
2
- import { DS } from 'ember-data';
3
2
  import Service from '@ember/service';
4
3
  import { Task } from 'ember-concurrency';
5
4
  import TemplateModel from '../models/template';
6
5
  export default class StandardTemplatePluginService extends Service {
7
6
  store: Store;
8
- templates: DS.RecordArray<TemplateModel>;
7
+ templates: TemplateModel[];
9
8
  constructor();
10
- fetchTemplates: Task<DS.RecordArray<TemplateModel>, []>;
9
+ fetchTemplates: Task<TemplateModel[], []>;
11
10
  loadTemplates(): Promise<void>;
12
11
  /**
13
- Filter the valid templates for a context.
14
- @method templatesForContext
15
- @param {Array} Array of templates
16
- @param {Array} The path of rdfaContext objects from the root till the current context
17
- @return {Array} Array of templates (filtered)
18
- @private
19
- */
12
+ Filter the valid templates for a context.
13
+ @method templatesForContext
14
+ @param {Array} Array of templates
15
+ @param {Array} The path of rdfaContext objects from the root till the current context
16
+ @return {Array} Array of templates (filtered)
17
+ @private
18
+ */
20
19
  templatesForContext(templates: TemplateModel[], rdfaTypes: string[]): TemplateModel[];
21
20
  }
@@ -78,9 +78,10 @@ date-plugin:
78
78
  hours: "Hours"
79
79
  minutes: "Minutes"
80
80
  now: "Now"
81
- insert-variable-plugin:
82
- variable: Insert variable
81
+ variable-plugin:
82
+ insertVariable: Insert variable
83
83
  button: Insert
84
+ enterVariableValue: Select value
84
85
  article-structure-plugin:
85
86
  insert:
86
87
  paragraph: Insert paragraph
@@ -126,7 +127,7 @@ article-structure-plugin:
126
127
  section:
127
128
  heading: Insert section heading
128
129
  body: Insert section content
129
- subsection:
130
+ subsection:
130
131
  heading: Insert subsection heading
131
132
  body: Insert subsection content
132
133
  article:
@@ -79,9 +79,10 @@ date-plugin:
79
79
  hours: "Uur"
80
80
  minutes: "Minuten"
81
81
  now: "Nu"
82
- insert-variable-plugin:
83
- variable: Voeg variabele in
82
+ variable-plugin:
83
+ insertVariable: Voeg variabele in
84
84
  button: Voeg in
85
+ enterVariableValue: Selecteer waarde
85
86
  article-structure-plugin:
86
87
  insert:
87
88
  paragraph: Paragraaf invoegen
@@ -127,11 +128,11 @@ article-structure-plugin:
127
128
  section:
128
129
  heading: Voeg afdeling in
129
130
  body: Voeg inhoud afdeling in
130
- subsection:
131
+ subsection:
131
132
  heading: Voeg onderafdeling in
132
133
  body: Voeg inhoud onderafdeling in
133
134
  article:
134
135
  heading: Voeg artikel in
135
136
  body: Voeg inhoud artikel in
136
137
  paragraph:
137
- body: Voeg inhoud paragraaf in
138
+ body: Voeg inhoud paragraaf in
@@ -0,0 +1,2 @@
1
+ import { PNode } from '@lblod/ember-rdfa-editor';
2
+ export declare function changedDescendants(old: PNode, cur: PNode, offset: number, f: (node: PNode, pos: number) => void): void;
@@ -3,3 +3,8 @@ export declare const RDF: (s: string) => import("@lblod/ember-rdfa-editor-lblod-
3
3
  export declare const ELI: (s: string) => import("@lblod/ember-rdfa-editor-lblod-plugins/utils/namespace").Resource;
4
4
  export declare const XSD: (s: string) => import("@lblod/ember-rdfa-editor-lblod-plugins/utils/namespace").Resource;
5
5
  export declare const EXT: (s: string) => import("@lblod/ember-rdfa-editor-lblod-plugins/utils/namespace").Resource;
6
+ export declare const BESLUIT: (s: string) => import("@lblod/ember-rdfa-editor-lblod-plugins/utils/namespace").Resource;
7
+ export declare const PROV: (s: string) => import("@lblod/ember-rdfa-editor-lblod-plugins/utils/namespace").Resource;
8
+ export declare const SKOS: (s: string) => import("@lblod/ember-rdfa-editor-lblod-plugins/utils/namespace").Resource;
9
+ export declare const DCT: (s: string) => import("@lblod/ember-rdfa-editor-lblod-plugins/utils/namespace").Resource;
10
+ export declare const MOBILITEIT: (s: string) => import("@lblod/ember-rdfa-editor-lblod-plugins/utils/namespace").Resource;
@@ -1,6 +1,11 @@
1
- export type Resource = {
2
- prefixed: string;
1
+ import { PNode } from '@lblod/ember-rdfa-editor';
2
+ export declare class Resource {
3
3
  full: string;
4
- };
4
+ prefixed: string;
5
+ constructor(full: string, prefixed: string);
6
+ toString(): string;
7
+ }
5
8
  export declare function namespace(uri: string, prefix: string): (s: string) => Resource;
6
9
  export declare function hasRDFaAttribute(element: Element, attr: string, value: Resource): boolean;
10
+ export declare function pnodeHasRdfaAttribute(node: PNode, attr: string, value: Resource): boolean;
11
+ export declare function expandPrefixedString(base: string, prefix: string, stringToExpand: string): string;
@@ -1,227 +0,0 @@
1
- import Component from '@glimmer/component';
2
- import { tracked } from '@glimmer/tracking';
3
- import { action } from '@ember/object';
4
- import { getOwner } from '@ember/application';
5
- import { task } from 'ember-concurrency';
6
- import { ProseController } from '@lblod/ember-rdfa-editor/core/prosemirror';
7
- import { ProseStore } from '@lblod/ember-rdfa-editor/utils/datastore/prose-store';
8
- import { insertHtml } from '@lblod/ember-rdfa-editor/commands/insert-html-command';
9
- import { unwrap } from '@lblod/ember-rdfa-editor/utils/option';
10
- import { getAppliedMarks } from '@lblod/ember-rdfa-editor/plugins/datastore';
11
- import {
12
- CodeListOption,
13
- fetchCodeListOptions,
14
- } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/template-variable-plugin/utils/fetch-data';
15
- import { ZONAL_URI } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/roadsign-regulation-plugin/utils/constants';
16
- import { MULTI_SELECT_CODELIST_TYPE } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/template-variable-plugin/utils/constants';
17
-
18
- type Args = {
19
- controller: ProseController;
20
- };
21
- export default class EditorPluginsTemplateVariableCardComponent extends Component<Args> {
22
- @tracked variableOptions: CodeListOption[] = [];
23
- @tracked selectedVariable?: CodeListOption | CodeListOption[];
24
- @tracked showCard = false;
25
- @tracked multiSelect = false;
26
- mappingUri?: string;
27
- zonalLocationCodelistUri: string;
28
- endpoint: string;
29
- nonZonalLocationCodelistUri: string;
30
-
31
- constructor(parent: unknown, args: Args) {
32
- super(parent, args);
33
- const config = getOwner(this)?.resolveRegistration(
34
- 'config:environment'
35
- ) as {
36
- templateVariablePlugin: {
37
- zonalLocationCodelistUri: string;
38
- endpoint: string;
39
- nonZonalLocationCodelistUri: string;
40
- };
41
- };
42
- const pluginConfig = config.templateVariablePlugin;
43
- this.zonalLocationCodelistUri = pluginConfig.zonalLocationCodelistUri;
44
- this.endpoint = pluginConfig.endpoint;
45
- this.nonZonalLocationCodelistUri = pluginConfig.nonZonalLocationCodelistUri;
46
- }
47
-
48
- get controller() {
49
- return this.args.controller;
50
- }
51
-
52
- @action
53
- insert() {
54
- const { selection } = this.controller.state;
55
- if (!this.mappingUri || !this.selectedVariable) {
56
- return;
57
- }
58
- this.controller.datastore;
59
- const limitedDatastore = this.controller.datastore.limitToRange(
60
- this.controller.state,
61
- selection.from,
62
- selection.to
63
- );
64
- const insertRange = [
65
- ...limitedDatastore
66
- .match(`>${this.mappingUri}`, 'ext:content')
67
- .asObjectNodeMapping()
68
- .nodes(),
69
- ][0];
70
- if (!insertRange) {
71
- return;
72
- }
73
- const marks = getAppliedMarks(insertRange);
74
- let htmlToInsert: string;
75
- if (Array.isArray(this.selectedVariable)) {
76
- htmlToInsert = this.selectedVariable
77
- .map((variable) => variable.value)
78
- .join(', ');
79
- } else {
80
- htmlToInsert = unwrap(this.selectedVariable.value);
81
- }
82
- htmlToInsert = this.wrapVariableInHighlight(htmlToInsert);
83
- if (insertRange) {
84
- this.controller.doCommand(
85
- insertHtml(htmlToInsert, insertRange.from, insertRange.to, marks)
86
- );
87
- }
88
- }
89
-
90
- wrapVariableInHighlight(text: string) {
91
- return text.replace(
92
- /\$\{(.+?)\}/g,
93
- '<span class="mark-highlight-manual">${$1}</span>'
94
- );
95
- }
96
-
97
- @action
98
- selectionChanged() {
99
- this.showCard = false;
100
- this.selectedVariable = undefined;
101
- const { selection } = this.controller.state;
102
- const { from, to } = selection;
103
- const fullDatastore = this.controller.datastore;
104
- const limitedDatastore = this.controller.datastore.limitToRange(
105
- this.controller.state,
106
- from,
107
- to
108
- );
109
- const mapping = limitedDatastore
110
- .match(null, 'a', 'ext:Mapping')
111
- .asQuadResultSet()
112
- .single();
113
- if (mapping) {
114
- const mappingUri = mapping.subject.value;
115
- this.mappingUri = mappingUri;
116
- const mappingTypeTriple = fullDatastore
117
- .match(`>${mappingUri}`, 'dct:type')
118
- .asQuadResultSet()
119
- .single();
120
- if (mappingTypeTriple) {
121
- const mappingType = mappingTypeTriple.object.value;
122
- if (mappingType === 'codelist') {
123
- const codelistTriple = fullDatastore
124
- .match(`>${mappingUri}`, 'ext:codelist')
125
- .asQuadResultSet()
126
- .single();
127
- if (codelistTriple) {
128
- const codelistSource = this.getCodelistSource(
129
- fullDatastore,
130
- mappingUri
131
- );
132
- this.showCard = true;
133
- const codelistUri = codelistTriple.object.value;
134
- void this.fetchCodeListOptions.perform(codelistSource, codelistUri);
135
- }
136
- } else if (mappingType === 'location') {
137
- const codelistSource = this.getCodelistSource(
138
- fullDatastore,
139
- mappingUri
140
- );
141
- const measureTriple = limitedDatastore
142
- .match(
143
- null,
144
- 'a',
145
- '>https://data.vlaanderen.be/ns/mobiliteit#Mobiliteitsmaatregel'
146
- )
147
- .asQuadResultSet()
148
- .single();
149
- if (!measureTriple) {
150
- return;
151
- }
152
- const measureUri = measureTriple.subject.value;
153
- const zonalityTriple = fullDatastore
154
- .match(`>${measureUri}`, 'ext:zonality')
155
- .asQuadResultSet()
156
- .single();
157
- if (!zonalityTriple) {
158
- return;
159
- }
160
- const zonalityUri = zonalityTriple.object.value;
161
- if (zonalityUri === ZONAL_URI) {
162
- void this.fetchCodeListOptions.perform(
163
- codelistSource,
164
- this.zonalLocationCodelistUri,
165
- true
166
- );
167
- } else {
168
- void this.fetchCodeListOptions.perform(
169
- codelistSource,
170
- this.nonZonalLocationCodelistUri,
171
- true
172
- );
173
- }
174
- this.showCard = true;
175
- }
176
- }
177
- }
178
- }
179
-
180
- getCodelistSource(fullDatastore: ProseStore, mappingUri: string): string {
181
- const codelistSourceTriple = fullDatastore
182
- .match(`>${mappingUri}`, 'dct:source')
183
- .asQuadResultSet()
184
- .single();
185
-
186
- if (codelistSourceTriple) {
187
- return codelistSourceTriple.object.value;
188
- } else {
189
- return this.endpoint;
190
- }
191
- }
192
-
193
- @action
194
- updateVariable(variable: CodeListOption | CodeListOption[]) {
195
- this.selectedVariable = variable;
196
- }
197
-
198
- fetchCodeListOptions = task(
199
- async (endpoint: string, codelistUri: string, isLocation?: boolean) => {
200
- const { type, options } = await fetchCodeListOptions(
201
- endpoint,
202
- codelistUri
203
- );
204
- if (isLocation) {
205
- this.variableOptions = options.map((option) => ({
206
- label: option.label,
207
- value: this.wrapInLocation(unwrap(option.value)),
208
- }));
209
- } else {
210
- this.variableOptions = options;
211
- }
212
- if (type === MULTI_SELECT_CODELIST_TYPE) {
213
- this.multiSelect = true;
214
- } else {
215
- this.multiSelect = false;
216
- }
217
- }
218
- );
219
-
220
- wrapInLocation(value: string) {
221
- return `
222
- <span property="https://data.vlaanderen.be/ns/mobiliteit#plaatsbepaling">
223
- ${value}
224
- </span>
225
- `;
226
- }
227
- }
@@ -1,67 +0,0 @@
1
- import { CodeList, fetchCodeListsByPublisher } from './fetch-data';
2
-
3
- export type VariableType = {
4
- label: string;
5
- fetchSubtypes?: (endpoint: string, publisher: string) => Promise<CodeList[]>;
6
- template:
7
- | string
8
- | ((endpoint: string, selectedCodelist?: CodeList) => string);
9
- };
10
- export const DEFAULT_VARIABLE_TYPES: Record<string, VariableType> = {
11
- text: {
12
- label: 'text',
13
- template: `
14
- <span property="dct:type" content="text"></span>
15
- <span property="ext:content">
16
- <span class="mark-highlight-manual">\${text}</span>
17
- </span>
18
- `,
19
- },
20
- number: {
21
- label: 'number',
22
- template: `
23
- <span property="dct:type" content="number"></span>
24
- <span property="ext:content" datatype="xsd:integer">
25
- <span class="mark-highlight-manual">\${number}</span>
26
- </span>
27
- `,
28
- },
29
- date: {
30
- label: 'date',
31
- template: `
32
- <span property="dct:type" content="date"></span>
33
- <span property="ext:content" datatype="xsd:date">
34
- <span class="mark-highlight-manual">\${date}</span>
35
- </span>
36
- `,
37
- },
38
- location: {
39
- label: 'location',
40
- template: (endpoint: string) => `
41
- <span property="dct:type" content="location"></span>
42
- <span property="dct:source" resource="${endpoint}"></span>
43
- <span property="ext:content">
44
- <span class="mark-highlight-manual">\${location}</span>
45
- </span>
46
- `,
47
- },
48
- codelist: {
49
- label: 'codelist',
50
- fetchSubtypes: async (endpoint: string, publisher: string) => {
51
- const codelists = fetchCodeListsByPublisher(endpoint, publisher);
52
- return codelists;
53
- },
54
- template: (endpoint: string, selectedCodelist?: CodeList) => `
55
- <span property="ext:codelist" resource="${
56
- selectedCodelist?.uri ?? ''
57
- }"></span>
58
- <span property="dct:type" content="codelist"></span>
59
- <span property="dct:source" resource="${endpoint}"></span>
60
- <span property="ext:content">
61
- <span class="mark-highlight-manual">\${${
62
- selectedCodelist?.label ?? ''
63
- }}</span>
64
- </span>
65
- `,
66
- },
67
- };