@lblod/ember-rdfa-editor-lblod-plugins 26.0.1 → 26.0.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @lblod/ember-rdfa-editor-lblod-plugins
2
2
 
3
+ ## 26.0.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#511](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/511) [`4237506`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/4237506d5bd6659786a50a14b89a8febe590eedb) Thanks [@lagartoverde](https://github.com/lagartoverde)! - Implement new recreateUuids plugin
8
+
3
9
  ## 26.0.1
4
10
 
5
11
  ### Patch Changes
@@ -42,6 +42,7 @@ import {
42
42
  Place,
43
43
  } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/location-plugin/utils/geo-helpers';
44
44
  import { NodeContentsUtils } from './node-contents';
45
+ import { recreateVariableUris } from '../variable-plugin/utils/recreate-variable-uris';
45
46
 
46
47
  export interface LocationPluginConfig {
47
48
  defaultAddressUriRoot: string;
@@ -193,8 +194,7 @@ const emberNodeConfig = (config: LocationPluginConfig): EmberNodeConfig => ({
193
194
  group: 'inline variable',
194
195
  atom: true,
195
196
  editable: true,
196
- recreateUri: true,
197
- uriAttributes: ['variableInstance'],
197
+ recreateUriFunction: recreateVariableUris,
198
198
  draggable: false,
199
199
  needsFFKludge: true,
200
200
  selectable: true,
@@ -0,0 +1,36 @@
1
+ import { EXT } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/constants';
2
+ import { sayDataFactory } from '@lblod/ember-rdfa-editor/core/say-data-factory';
3
+ import { v4 as uuidv4 } from 'uuid';
4
+ import { Attrs } from '@lblod/ember-rdfa-editor';
5
+ import { getOutgoingTriple } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/namespace';
6
+
7
+ export function recreateVariableUris(nodeAttrs: Attrs) {
8
+ const attrs = { ...nodeAttrs };
9
+ if (
10
+ attrs.subject &&
11
+ (attrs.subject as string).includes(
12
+ 'http://data.lblod.info/mappings/--ref-uuid4-',
13
+ )
14
+ ) {
15
+ attrs.subject = `http://data.lblod.info/mappings/--ref-uuid4-${uuidv4()}`;
16
+ } else if (
17
+ attrs.subject &&
18
+ (attrs.subject as string).includes('http://data.lblod.info/mappings/')
19
+ ) {
20
+ attrs.subject = `http://data.lblod.info/mappings/${uuidv4()}`;
21
+ }
22
+ const instanceTriple = getOutgoingTriple(attrs, EXT('instance'));
23
+ if (!instanceTriple) return attrs;
24
+ let recreatedUri;
25
+ if (
26
+ instanceTriple.object.value.includes(
27
+ 'http://data.lblod.info/variables/--ref-uuid4-',
28
+ )
29
+ ) {
30
+ recreatedUri = `http://data.lblod.info/variables/--ref-uuid4-${uuidv4()}`;
31
+ } else {
32
+ recreatedUri = `http://data.lblod.info/variables/${uuidv4()}`;
33
+ }
34
+ instanceTriple.object = sayDataFactory.namedNode(recreatedUri);
35
+ return attrs;
36
+ }
@@ -52,6 +52,7 @@ import {
52
52
  parseLambert72GMLString,
53
53
  parseLambert72WKTString,
54
54
  } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/variable-plugin/utils/address-helpers';
55
+ import { recreateVariableUris } from '../utils/recreate-variable-uris';
55
56
 
56
57
  const rdfaAware = true;
57
58
 
@@ -387,7 +388,7 @@ const emberNodeConfig: EmberNodeConfig = {
387
388
  atom: true,
388
389
  editable: true,
389
390
  recreateUri: true,
390
- uriAttributes: ['variableInstance'],
391
+ recreateUriFunction: recreateVariableUris,
391
392
  draggable: false,
392
393
  needsFFKludge: true,
393
394
  selectable: true,
@@ -27,6 +27,7 @@ import type { ComponentLike } from '@glint/template';
27
27
  import { hasOutgoingNamedNodeTriple } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/namespace';
28
28
  import { renderRdfaAware } from '@lblod/ember-rdfa-editor/core/schema';
29
29
  import { sayDataFactory } from '@lblod/ember-rdfa-editor/core/say-data-factory';
30
+ import { recreateVariableUris } from '../utils/recreate-variable-uris';
30
31
 
31
32
  const CONTENT_SELECTOR = `span[property~='${EXT('content').prefixed}'],
32
33
  span[property~='${EXT('content').full}']`;
@@ -144,8 +145,7 @@ const emberNodeConfig: EmberNodeConfig = {
144
145
  group: 'inline variable',
145
146
  content: 'inline*',
146
147
  atom: true,
147
- recreateUri: true,
148
- uriAttributes: ['variableInstance'],
148
+ recreateUriFunction: recreateVariableUris,
149
149
  draggable: false,
150
150
  needsFFKludge: true,
151
151
  editable: true,
@@ -32,6 +32,7 @@ import {
32
32
  import VariableNodeViewComponent from '@lblod/ember-rdfa-editor-lblod-plugins/components/variable-plugin/variable/nodeview';
33
33
  import type { ComponentLike } from '@glint/template';
34
34
  import { renderRdfaAware } from '@lblod/ember-rdfa-editor/core/schema';
35
+ import { recreateVariableUris } from '../utils/recreate-variable-uris';
35
36
 
36
37
  const CONTENT_SELECTOR = `span[property~='${EXT('content').prefixed}'],
37
38
  span[property~='${EXT('content').full}']`;
@@ -163,8 +164,7 @@ const emberNodeConfig: EmberNodeConfig = {
163
164
  content: 'inline*',
164
165
  atom: true,
165
166
  editable: true,
166
- recreateUri: true,
167
- uriAttributes: ['variableInstance'],
167
+ recreateUriFunction: recreateVariableUris,
168
168
  draggable: false,
169
169
  needsFFKludge: true,
170
170
  selectable: true,
@@ -36,6 +36,7 @@ import {
36
36
  RdfaAttrs,
37
37
  renderRdfaAware,
38
38
  } from '@lblod/ember-rdfa-editor/core/schema';
39
+ import { recreateVariableUris } from '../utils/recreate-variable-uris';
39
40
 
40
41
  const TRANSLATION_FALLBACKS = {
41
42
  insertDate: 'Datum invoegen',
@@ -259,6 +260,7 @@ const emberNodeConfig = (options: DateOptions): EmberNodeConfig => ({
259
260
  selectable: true,
260
261
  draggable: false,
261
262
  atom: true,
263
+ recreateUriFunction: recreateVariableUris,
262
264
  defining: false,
263
265
  options,
264
266
  attrs: {
@@ -22,6 +22,7 @@ import {
22
22
  import { contentSpan } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/dom-output-spec-helpers';
23
23
  import NodeViewComponent from '@lblod/ember-rdfa-editor-lblod-plugins/components/variable-plugin/variable/nodeview';
24
24
  import type { ComponentLike } from '@glint/template';
25
+ import { recreateVariableUris } from '../utils/recreate-variable-uris';
25
26
 
26
27
  const CONTENT_SELECTOR = `span[property~='${EXT('content').prefixed}'],
27
28
  span[property~='${EXT('content').full}']`;
@@ -78,9 +79,8 @@ const emberNodeConfig: EmberNodeConfig = {
78
79
  group: 'inline variable',
79
80
  content: 'inline*',
80
81
  atom: true,
81
- recreateUri: true,
82
82
  selectable: true,
83
- uriAttributes: ['variableInstance'],
83
+ recreateUriFunction: recreateVariableUris,
84
84
  draggable: false,
85
85
  needsFFKludge: true,
86
86
  attrs: {
@@ -36,6 +36,7 @@ import type { ComponentLike } from '@glint/template';
36
36
  import { getTranslationFunction } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/translation';
37
37
  import { renderRdfaAware } from '@lblod/ember-rdfa-editor/core/schema';
38
38
  import { sayDataFactory } from '@lblod/ember-rdfa-editor/core/say-data-factory';
39
+ import { recreateVariableUris } from '../utils/recreate-variable-uris';
39
40
 
40
41
  const rdfaAware = true;
41
42
  const parseDOM: TagParseRule[] = [
@@ -171,8 +172,7 @@ const emberNodeConfig: EmberNodeConfig = {
171
172
  group: 'inline variable',
172
173
  content: 'inline*',
173
174
  atom: true,
174
- recreateUri: true,
175
- uriAttributes: ['variableInstance'],
175
+ recreateUriFunction: recreateVariableUris,
176
176
  editable: true,
177
177
  draggable: false,
178
178
  needsFFKludge: true,
@@ -20,6 +20,7 @@ import type { ComponentLike } from '@glint/template';
20
20
  import { hasOutgoingNamedNodeTriple } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/namespace';
21
21
  import { renderRdfaAware } from '@lblod/ember-rdfa-editor/core/schema';
22
22
  import { getTranslationFunction } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/translation';
23
+ import { recreateVariableUris } from '../utils/recreate-variable-uris';
23
24
 
24
25
  const TRANSLATION_FALLBACKS = {
25
26
  nodeview_placeholder: 'persoon',
@@ -105,8 +106,7 @@ const emberNodeConfig: EmberNodeConfig = {
105
106
  group: 'inline variable',
106
107
  content: 'inline*',
107
108
  atom: true,
108
- recreateUri: true,
109
- uriAttributes: ['variableInstance'],
109
+ recreateUriFunction: recreateVariableUris,
110
110
  draggable: false,
111
111
  needsFFKludge: true,
112
112
  editable: true,
@@ -27,6 +27,7 @@ import type { ComponentLike } from '@glint/template';
27
27
  import { hasOutgoingNamedNodeTriple } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/namespace';
28
28
  import { renderRdfaAware } from '@lblod/ember-rdfa-editor/core/schema';
29
29
  import { sayDataFactory } from '@lblod/ember-rdfa-editor/core/say-data-factory';
30
+ import { recreateVariableUris } from '../utils/recreate-variable-uris';
30
31
 
31
32
  const CONTENT_SELECTOR = `span[property~='${EXT('content').prefixed}'],
32
33
  span[property~='${EXT('content').full}']`;
@@ -125,8 +126,7 @@ const emberNodeConfig: EmberNodeConfig = {
125
126
  group: 'inline variable',
126
127
  content: 'inline*',
127
128
  atom: true,
128
- recreateUri: true,
129
- uriAttributes: ['variableInstance'],
129
+ recreateUriFunction: recreateVariableUris,
130
130
  draggable: false,
131
131
  needsFFKludge: true,
132
132
  editable: true,
@@ -0,0 +1,4 @@
1
+ import { Attrs } from '@lblod/ember-rdfa-editor';
2
+ export declare function recreateVariableUris(nodeAttrs: Attrs): {
3
+ [x: string]: any;
4
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lblod/ember-rdfa-editor-lblod-plugins",
3
- "version": "26.0.1",
3
+ "version": "26.0.2",
4
4
  "description": "Ember addon providing lblod specific plugins for the ember-rdfa-editor",
5
5
  "keywords": [
6
6
  "ember-addon",
@@ -105,7 +105,7 @@
105
105
  "@glint/template": "^1.4.0",
106
106
  "@graphy/content.ttl.write": "^4.3.7",
107
107
  "@graphy/memory.dataset.fast": "4.3.3",
108
- "@lblod/ember-rdfa-editor": "10.7.4",
108
+ "@lblod/ember-rdfa-editor": "10.8.0",
109
109
  "@rdfjs/types": "^1.1.0",
110
110
  "@release-it/keep-a-changelog": "^4.0.0",
111
111
  "@tsconfig/ember": "^3.0.8",
@@ -192,7 +192,7 @@
192
192
  "@appuniversum/ember-appuniversum": "^3.4.1",
193
193
  "@ember/string": "3.x",
194
194
  "@glint/template": "^1.4.0",
195
- "@lblod/ember-rdfa-editor": "^10.7.3",
195
+ "@lblod/ember-rdfa-editor": "^10.8.0",
196
196
  "ember-concurrency": "^3.1.0",
197
197
  "ember-element-helper": "^0.8.6",
198
198
  "ember-intl": "^7.0.0",
package/pnpm-lock.yaml CHANGED
@@ -169,8 +169,8 @@ importers:
169
169
  specifier: 4.3.3
170
170
  version: 4.3.3
171
171
  '@lblod/ember-rdfa-editor':
172
- specifier: 10.7.4
173
- version: 10.7.4(2ef3gpurqxbttnmniw6grhzpuy)
172
+ specifier: 10.8.0
173
+ version: 10.8.0(2ef3gpurqxbttnmniw6grhzpuy)
174
174
  '@rdfjs/types':
175
175
  specifier: ^1.1.0
176
176
  version: 1.1.0
@@ -1595,8 +1595,8 @@ packages:
1595
1595
  '@jridgewell/trace-mapping@0.3.25':
1596
1596
  resolution: {integrity: sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ==}
1597
1597
 
1598
- '@lblod/ember-rdfa-editor@10.7.4':
1599
- resolution: {integrity: sha512-jEoiLejODzYB8kbaxDoB0xRP1SAfOzgKv23ZmoRXKu6bodv+5Vx8+N2r4zYVseoz/ZR70vd3Ltr95Ja13OV7Uw==}
1598
+ '@lblod/ember-rdfa-editor@10.8.0':
1599
+ resolution: {integrity: sha512-Xmcs8+e5sC9aDKz6hB5PslIePKizvh294O9A1JpKx00TzZhIFVBZeyW2baKiBpKpMjR/SyXj4WyryUKLYDldWw==}
1600
1600
  engines: {node: 16.* || 18.* || >= 20}
1601
1601
  peerDependencies:
1602
1602
  '@appuniversum/ember-appuniversum': ^3.4.2
@@ -3900,8 +3900,8 @@ packages:
3900
3900
  resolution: {integrity: sha512-jnjyiM6eRyZl2H+W8Q/zLMA481hzi0eszAaBUzIVnmYVDBbnLxVNnfu1HgEBvCbL+71FrxMl3E6lpKH7Ge3OXA==}
3901
3901
  engines: {node: '>=0.4', npm: '>=1.2'}
3902
3902
 
3903
- dompurify@3.1.7:
3904
- resolution: {integrity: sha512-VaTstWtsneJY8xzy7DekmYWEOZcmzIe3Qb3zPd4STve1OBTa+e+WmS1ITQec1fZYXI3HCsOZZiSMpG6oxoWMWQ==}
3903
+ dompurify@3.2.0:
3904
+ resolution: {integrity: sha512-AMdOzK44oFWqHEi0wpOqix/fUNY707OmoeFDnbi3Q5I8uOpy21ufUA5cDJPr0bosxrflOVD/H2DMSvuGKJGfmQ==}
3905
3905
 
3906
3906
  dot-case@3.0.4:
3907
3907
  resolution: {integrity: sha512-Kv5nKlh6yRrdrGvxeJ2e5y2eRUpkUosIW4A2AS38zwSz27zu7ufDwQPi5Jhs3XAlGNetl3bmnGhQsMtkKJnj3w==}
@@ -6016,8 +6016,8 @@ packages:
6016
6016
  linkify-it@4.0.1:
6017
6017
  resolution: {integrity: sha512-C7bfi1UZmoj8+PQx22XyeXCuBlokoyWQL5pWSP+EI6nzRylyThouddufc2c1NDIcP9k5agmN9fLpA7VNJfIiqw==}
6018
6018
 
6019
- linkifyjs@4.1.3:
6020
- resolution: {integrity: sha512-auMesunaJ8yfkHvK4gfg1K0SaKX/6Wn9g2Aac/NwX+l5VdmFZzo/hdPGxEOETj+ryRa4/fiOPjeeKURSAJx1sg==}
6019
+ linkifyjs@4.1.4:
6020
+ resolution: {integrity: sha512-0/NxkHNpiJ0k9VrYCkAn9OtU1eu8xEr1tCCpDtSsVRm/SF0xAak2Gzv3QimSfgUgqLBCDlfhMbu73XvaEHUTPQ==}
6021
6021
 
6022
6022
  livereload-js@3.4.1:
6023
6023
  resolution: {integrity: sha512-5MP0uUeVCec89ZbNOT/i97Mc+q3SxXmiUGhRFOTmhrGPn//uWVQdCvcLJDy64MSBR5MidFdOR7B9viumoavy6g==}
@@ -10738,7 +10738,7 @@ snapshots:
10738
10738
  '@jridgewell/resolve-uri': 3.1.2
10739
10739
  '@jridgewell/sourcemap-codec': 1.4.15
10740
10740
 
10741
- '@lblod/ember-rdfa-editor@10.7.4(2ef3gpurqxbttnmniw6grhzpuy)':
10741
+ '@lblod/ember-rdfa-editor@10.8.0(2ef3gpurqxbttnmniw6grhzpuy)':
10742
10742
  dependencies:
10743
10743
  '@appuniversum/ember-appuniversum': 3.4.2(yenc6o4wruytt4u2jbwlbsqcl4)
10744
10744
  '@babel/core': 7.24.7
@@ -10761,7 +10761,7 @@ snapshots:
10761
10761
  common-tags: 1.8.2
10762
10762
  crypto-browserify: 3.12.0
10763
10763
  debug: 4.3.5
10764
- dompurify: 3.1.7
10764
+ dompurify: 3.2.0
10765
10765
  ember-auto-import: 2.7.4(@glint/template@1.4.0)(webpack@5.92.1)
10766
10766
  ember-changeset: 4.1.2(@glint/template@1.4.0)(webpack@5.92.1)
10767
10767
  ember-cli-babel: 8.2.0(@babel/core@7.24.7)
@@ -10778,7 +10778,7 @@ snapshots:
10778
10778
  handlebars-loader: 1.7.3(handlebars@4.7.8)
10779
10779
  iter-tools: 7.5.3
10780
10780
  js-beautify: 1.15.1
10781
- linkifyjs: 4.1.3
10781
+ linkifyjs: 4.1.4
10782
10782
  mdn-polyfills: 5.20.0
10783
10783
  process: 0.11.10
10784
10784
  prosemirror-commands: 1.6.2
@@ -13794,7 +13794,7 @@ snapshots:
13794
13794
 
13795
13795
  domain-browser@1.2.0: {}
13796
13796
 
13797
- dompurify@3.1.7: {}
13797
+ dompurify@3.2.0: {}
13798
13798
 
13799
13799
  dot-case@3.0.4:
13800
13800
  dependencies:
@@ -16977,7 +16977,7 @@ snapshots:
16977
16977
  dependencies:
16978
16978
  uc.micro: 1.0.6
16979
16979
 
16980
- linkifyjs@4.1.3: {}
16980
+ linkifyjs@4.1.4: {}
16981
16981
 
16982
16982
  livereload-js@3.4.1: {}
16983
16983
 
@@ -1,103 +0,0 @@
1
- import { v4 as uuidv4 } from 'uuid';
2
- import {
3
- Fragment,
4
- Slice,
5
- Node,
6
- Schema,
7
- ProsePlugin,
8
- } from '@lblod/ember-rdfa-editor';
9
-
10
- import { recreateUuidsOnPasteKey } from '@lblod/ember-rdfa-editor/plugins/recreateUuidsOnPaste';
11
- import { sayDataFactory } from '@lblod/ember-rdfa-editor/core/say-data-factory';
12
-
13
- import { EXT } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/constants';
14
- import { OutgoingTriple } from '@lblod/ember-rdfa-editor/core/rdfa-processor';
15
-
16
- const recreateUuidsOnPaste = new ProsePlugin({
17
- key: recreateUuidsOnPasteKey,
18
- props: {
19
- transformPasted(slice, view) {
20
- const schema = view.state.schema;
21
- return new Slice(
22
- recreateUuidsFromFragment(slice.content, schema),
23
- slice.openStart,
24
- slice.openEnd,
25
- );
26
- },
27
- },
28
- });
29
-
30
- function recreateUuidsFromFragment(fragment: Fragment, schema: Schema) {
31
- const newNodes: Node[] = [];
32
-
33
- fragment.forEach((node) => {
34
- const newNode = recreateUuidsOnNode(node, schema);
35
- newNodes.push(newNode);
36
- });
37
-
38
- return Fragment.fromArray(newNodes);
39
- }
40
-
41
- function recreateUuidsOnNode(node: Node, schema: Schema) {
42
- if (node.isText) {
43
- return node;
44
- }
45
-
46
- const children: Node[] = [];
47
-
48
- node.content.forEach((node) => {
49
- const child = recreateUuidsOnNode(node, schema);
50
- children.push(child);
51
- });
52
-
53
- const type = node.type;
54
- const spec = type.spec;
55
-
56
- const uriAttributes = spec['uriAttributes'];
57
-
58
- if (
59
- !spec['recreateUri'] ||
60
- !uriAttributes ||
61
- !Array.isArray(uriAttributes) ||
62
- !node.attrs['rdfaNodeType']
63
- ) {
64
- return schema.node(
65
- node.type,
66
- node.attrs,
67
- Fragment.fromArray(children),
68
- node.marks,
69
- );
70
- }
71
-
72
- const attrs = { ...node.attrs };
73
-
74
- attrs.properties = (attrs.properties as OutgoingTriple[]).map((prop) => {
75
- if (prop.predicate === EXT('instance').full) {
76
- let recreatedUri;
77
- if (
78
- prop.object.value.includes(
79
- 'http://data.lblod.info/variables/--ref-uuid4-',
80
- )
81
- ) {
82
- recreatedUri = `http://data.lblod.info/variables/--ref-uuid4-${uuidv4()}`;
83
- } else {
84
- recreatedUri = `http://data.lblod.info/variables/${uuidv4()}`;
85
- }
86
- return {
87
- predicate: prop.predicate,
88
- object: sayDataFactory.namedNode(recreatedUri),
89
- };
90
- }
91
-
92
- return prop;
93
- });
94
-
95
- return schema.node(
96
- node.type,
97
- attrs,
98
- Fragment.fromArray(children),
99
- node.marks,
100
- );
101
- }
102
-
103
- export default recreateUuidsOnPaste;
@@ -1,3 +0,0 @@
1
- import { ProsePlugin } from '@lblod/ember-rdfa-editor';
2
- declare const recreateUuidsOnPaste: ProsePlugin<any>;
3
- export default recreateUuidsOnPaste;