@lblod/ember-rdfa-editor-lblod-plugins 39.1.1 → 39.1.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
|
+
## 39.1.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#687](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/687) [`e843838`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/e843838e191b369d8f6d0e5815456a30d530ac07) Thanks [@abeforgit](https://github.com/abeforgit)! - Fix location suggestions when a location placeholder is present in the doc
|
|
8
|
+
|
|
3
9
|
## 39.1.1
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
@@ -3,5 +3,9 @@ import { Area, Place } from './geo-helpers';
|
|
|
3
3
|
|
|
4
4
|
// For 2 addresses that are the same, the belgianAddressUri will be the same, regardless of how they were created
|
|
5
5
|
export function getLocationUri(location: Address | Place | Area) {
|
|
6
|
-
|
|
6
|
+
if ('belgianAddressUri' in location && location.belgianAddressUri) {
|
|
7
|
+
return location.belgianAddressUri;
|
|
8
|
+
} else {
|
|
9
|
+
return location.uri;
|
|
10
|
+
}
|
|
7
11
|
}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import { EditorState, type PNode } from '@lblod/ember-rdfa-editor';
|
|
1
|
+
import { Attrs, EditorState, type PNode } from '@lblod/ember-rdfa-editor';
|
|
2
2
|
import { ResolvedPNode } from '@lblod/ember-rdfa-editor/utils/_private/types';
|
|
3
|
+
import { Address } from '../plugins/location-plugin/_private/utils/address-helpers';
|
|
4
|
+
import { Area, Place } from '../plugins/location-plugin/utils/geo-helpers';
|
|
5
|
+
import { getLocationUri } from '../plugins/location-plugin/_private/utils/location-helpers';
|
|
3
6
|
|
|
4
7
|
type NodeMetadataType = {
|
|
5
8
|
[uri: string]: {
|
|
@@ -42,25 +45,41 @@ function getSuggestionScore(
|
|
|
42
45
|
|
|
43
46
|
return score;
|
|
44
47
|
}
|
|
48
|
+
type NodeWithLocAttrs = PNode & {
|
|
49
|
+
attrs: Attrs & { value: Address | Place | Area };
|
|
50
|
+
};
|
|
51
|
+
type ResolvedLocAttrsNode = ResolvedPNode & { value: NodeWithLocAttrs };
|
|
52
|
+
function isNodeWithLocAttrs(node: PNode): node is NodeWithLocAttrs {
|
|
53
|
+
const value = node.attrs.value;
|
|
54
|
+
if (value) {
|
|
55
|
+
if (getLocationUri(value)) {
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
45
61
|
|
|
46
62
|
export function getRankedPNodes(
|
|
47
63
|
state: EditorState,
|
|
48
64
|
nodeType: string,
|
|
49
|
-
getUri: (node:
|
|
65
|
+
getUri: (node: NodeWithLocAttrs) => string,
|
|
50
66
|
): {
|
|
51
67
|
node: ResolvedPNode;
|
|
52
68
|
score: number;
|
|
53
69
|
}[] {
|
|
54
70
|
const doc = state.doc;
|
|
55
|
-
const nodesWithDistance: { node:
|
|
71
|
+
const nodesWithDistance: { node: ResolvedLocAttrsNode; distance: number }[] =
|
|
72
|
+
[];
|
|
56
73
|
const selection = state.selection;
|
|
57
74
|
doc.descendants((node, pos) => {
|
|
58
75
|
if (node.type.name === nodeType) {
|
|
59
76
|
const distance = Math.abs(pos - selection.from);
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
77
|
+
if (isNodeWithLocAttrs(node)) {
|
|
78
|
+
nodesWithDistance.push({
|
|
79
|
+
node: { value: node, pos },
|
|
80
|
+
distance: distance,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
64
83
|
return false;
|
|
65
84
|
}
|
|
66
85
|
return true;
|
|
@@ -1,6 +1,14 @@
|
|
|
1
|
-
import { EditorState, type PNode } from '@lblod/ember-rdfa-editor';
|
|
1
|
+
import { Attrs, EditorState, type PNode } from '@lblod/ember-rdfa-editor';
|
|
2
2
|
import { ResolvedPNode } from '@lblod/ember-rdfa-editor/utils/_private/types';
|
|
3
|
-
|
|
3
|
+
import { Address } from '../plugins/location-plugin/_private/utils/address-helpers';
|
|
4
|
+
import { Area, Place } from '../plugins/location-plugin/utils/geo-helpers';
|
|
5
|
+
type NodeWithLocAttrs = PNode & {
|
|
6
|
+
attrs: Attrs & {
|
|
7
|
+
value: Address | Place | Area;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
export declare function getRankedPNodes(state: EditorState, nodeType: string, getUri: (node: NodeWithLocAttrs) => string): {
|
|
4
11
|
node: ResolvedPNode;
|
|
5
12
|
score: number;
|
|
6
13
|
}[];
|
|
14
|
+
export {};
|