@lblod/ember-rdfa-editor-lblod-plugins 8.3.0 → 8.4.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.
package/CHANGELOG.md CHANGED
@@ -7,12 +7,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [8.4.1] - 2023-07-06
11
+
12
+ ### Fixed
13
+ - Fixed compatibility issue with ember 3.28 in number variable component
14
+
15
+ ## [8.4.0] - 2023-07-06
16
+
17
+ ### Changed
18
+
19
+ - revert editor bump to 4.0.0, bump to 3.10.0 instead
20
+ - Addition of document-title plugin
21
+
10
22
  ## [8.3.0] - 2023-07-06
11
23
  ### Added
12
24
  - Insert the snippet
13
-
14
- ### Added
15
25
  - Addition of a precompile step to woodpecker PR check
26
+
16
27
  ### Fixed
17
28
  - fix type error due to bad tsconfig
18
29
  ### Changed
@@ -542,7 +553,7 @@ add onclick handler to pencil icon in variable plugin
542
553
 
543
554
  # Changelog
544
555
 
545
- [unreleased]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v8.3.0...HEAD
556
+ [unreleased]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v8.4.1...HEAD
546
557
  [8.0.0]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v8.0.0...v8.0.1
547
558
  [8.0.0]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v7.1.0...v8.0.0
548
559
  [7.1.0]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v7.0.0...v7.1.0
@@ -558,6 +569,8 @@ add onclick handler to pencil icon in variable plugin
558
569
  [3.0.0]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v2.1.2...v3.0.0
559
570
  [2.1.2]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v2.1.1...v2.1.2
560
571
  [2.1.1]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v2.1.0...v2.1.1
572
+ [8.4.1]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v8.4.0...v8.4.1
573
+ [8.4.0]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v8.3.0...v8.4.0
561
574
  [8.3.0]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v8.2.2...v8.3.0
562
575
  [8.2.2]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v8.2.1...v8.2.2
563
576
  [8.2.1]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v8.2.0...v8.2.1
@@ -0,0 +1,5 @@
1
+ <AuList::Item>
2
+ <AuButton @icon="add" @iconAlignment="left" @skin="link" {{on 'click' this.insertTitle}} @disabled={{not this.canInsertTitle}}>
3
+ {{t "document-title-plugin.insert-title"}}
4
+ </AuButton>
5
+ </AuList::Item>
@@ -0,0 +1,41 @@
1
+ import Component from '@glimmer/component';
2
+ import { action } from '@ember/object';
3
+ import { inject as service } from '@ember/service';
4
+ import { SayController } from '@lblod/ember-rdfa-editor';
5
+ import IntlService from 'ember-intl/services/intl';
6
+ import insertDocumentTitle from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/document-title-plugin/commands/insert-document-title';
7
+
8
+ type Args = {
9
+ controller: SayController;
10
+ };
11
+ export default class InsertTitleCardComponent extends Component<Args> {
12
+ @service declare intl: IntlService;
13
+
14
+ @action
15
+ insertTitle() {
16
+ this.args.controller.doCommand(
17
+ insertDocumentTitle({
18
+ placeholder: this.intl.t(
19
+ 'document-title-plugin.document-title-placeholder'
20
+ ),
21
+ }),
22
+ {
23
+ view: this.args.controller.mainEditorView,
24
+ }
25
+ );
26
+ this.args.controller.focus();
27
+ }
28
+
29
+ get canInsertTitle() {
30
+ return this.args.controller.checkCommand(
31
+ insertDocumentTitle({
32
+ placeholder: this.intl.t(
33
+ 'document-title-plugin.document-title-placeholder'
34
+ ),
35
+ }),
36
+ {
37
+ view: this.args.controller.mainEditorView,
38
+ }
39
+ );
40
+ }
41
+ }
@@ -9,7 +9,7 @@ import {
9
9
  } from '@lblod/ember-rdfa-editor';
10
10
  import { action } from '@ember/object';
11
11
  import { tracked } from '@glimmer/tracking';
12
- import { service } from '@ember/service';
12
+ import { inject as service } from '@ember/service';
13
13
  import intlService from 'ember-intl/services/intl';
14
14
  import { localCopy } from 'tracked-toolbox';
15
15
  import {
@@ -2,19 +2,13 @@ import {
2
2
  Command,
3
3
  Fragment,
4
4
  NodeSelection,
5
- NodeType,
6
- PNode,
7
- Schema,
8
- Selection,
9
5
  TextSelection,
10
6
  } from '@lblod/ember-rdfa-editor';
11
7
  import recalculateStructureNumbers from './recalculate-structure-numbers';
12
8
  import { StructureSpec } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/article-structure-plugin';
13
9
  import wrapStructureContent from './wrap-structure-content';
14
10
  import IntlService from 'ember-intl/services/intl';
15
- import { findNodes } from '@lblod/ember-rdfa-editor/utils/position-utils';
16
- import { containsOnlyPlaceholder } from '../utils/structure';
17
- import { findParentNodeOfType } from '@curvenote/prosemirror-utils';
11
+ import { findInsertionRange } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/_private/find-insertion-range';
18
12
 
19
13
  const insertStructure = (
20
14
  structureSpec: StructureSpec,
@@ -28,7 +22,7 @@ const insertStructure = (
28
22
  }
29
23
  const insertionRange = findInsertionRange({
30
24
  doc,
31
- selection,
25
+ $from: selection.$from,
32
26
  nodeType: schema.nodes[structureSpec.name],
33
27
  schema,
34
28
  limitTo: structureSpec.limitTo,
@@ -65,75 +59,4 @@ const insertStructure = (
65
59
  };
66
60
  };
67
61
 
68
- function findInsertionRange(args: {
69
- doc: PNode;
70
- selection: Selection;
71
- nodeType: NodeType;
72
- schema: Schema;
73
- limitTo?: string;
74
- }) {
75
- const { doc, selection, nodeType, schema, limitTo } = args;
76
- const { $from } = selection;
77
- for (let currentDepth = $from.depth; currentDepth >= 0; currentDepth--) {
78
- const currentAncestor = $from.node(currentDepth);
79
- const index = $from.index(currentDepth);
80
- if (currentAncestor.canReplaceWith(index, index, nodeType)) {
81
- if (containsOnlyPlaceholder(schema, currentAncestor)) {
82
- return { from: $from.start(currentDepth), to: $from.end(currentDepth) };
83
- } else {
84
- const insertPos = $from.after(currentDepth + 1);
85
- return { from: insertPos, to: insertPos };
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) {
101
- const node = doc.nodeAt(from);
102
- if (node) {
103
- if (node.canReplaceWith(node.childCount, node.childCount, nodeType)) {
104
- return true;
105
- }
106
- }
107
- }
108
- return false;
109
- };
110
- const nextContainerRange =
111
- findNodes({
112
- doc,
113
- start: selection.from,
114
- visitParentUpwards: true,
115
- reverse: false,
116
- filter: filterFunction,
117
- }).next().value ??
118
- findNodes({
119
- doc,
120
- start: selection.from,
121
- visitParentUpwards: true,
122
- reverse: true,
123
- filter: filterFunction,
124
- }).next().value;
125
- if (nextContainerRange) {
126
- const { from, to } = nextContainerRange;
127
- const containerNode = doc.nodeAt(from);
128
- if (containerNode) {
129
- if (containsOnlyPlaceholder(schema, containerNode)) {
130
- return { from: from + 1, to: to - 1 };
131
- } else {
132
- return { from: to - 1, to: to - 1 };
133
- }
134
- }
135
- }
136
- return null;
137
- }
138
-
139
62
  export default insertStructure;
@@ -0,0 +1,45 @@
1
+ import { Command } from '@lblod/ember-rdfa-editor';
2
+ import { findInsertionRange } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/_private/find-insertion-range';
3
+ import { v4 as uuid } from 'uuid';
4
+
5
+ interface InsertDocumentTitleArgs {
6
+ placeholder: string;
7
+ }
8
+ export default function insertDocumentTitle({
9
+ placeholder,
10
+ }: InsertDocumentTitleArgs): Command {
11
+ return function (state, dispatch) {
12
+ const { schema } = state;
13
+ const insertionRange = findInsertionRange({
14
+ doc: state.doc,
15
+ $from: state.doc.resolve(0),
16
+ nodeType: schema.nodes.document_title,
17
+ schema,
18
+ });
19
+ if (!insertionRange) {
20
+ return false;
21
+ }
22
+
23
+ if (dispatch) {
24
+ const tr = state.tr;
25
+ tr.replaceWith(
26
+ insertionRange.from,
27
+ insertionRange.to,
28
+ schema.node(
29
+ 'document_title',
30
+ { __rdfaId: uuid() },
31
+ schema.node(
32
+ 'paragraph',
33
+ null,
34
+ schema.node('placeholder', {
35
+ placeholderText: placeholder,
36
+ })
37
+ )
38
+ )
39
+ );
40
+ dispatch(tr);
41
+ }
42
+
43
+ return true;
44
+ };
45
+ }
@@ -0,0 +1,36 @@
1
+ import { NodeSpec, getRdfaAttrs, rdfaAttrs } from '@lblod/ember-rdfa-editor';
2
+
3
+ import { ELI } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/constants';
4
+
5
+ import { hasRDFaAttribute } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/namespace';
6
+
7
+ export const document_title: NodeSpec = {
8
+ content: 'paragraph{1}',
9
+ inline: false,
10
+ defining: true,
11
+ canSplit: false,
12
+ group: '',
13
+ attrs: {
14
+ ...rdfaAttrs,
15
+ property: {
16
+ default: 'eli:title',
17
+ },
18
+ datatype: {
19
+ default: 'xsd:string',
20
+ },
21
+ },
22
+ toDOM(node) {
23
+ return ['h4', node.attrs, 0];
24
+ },
25
+ parseDOM: [
26
+ {
27
+ tag: 'h1,h2,h3,h4,h5',
28
+ getAttrs(element: HTMLElement) {
29
+ if (hasRDFaAttribute(element, 'property', ELI('title'))) {
30
+ return getRdfaAttrs(element);
31
+ }
32
+ return false;
33
+ },
34
+ },
35
+ ],
36
+ };
@@ -0,0 +1 @@
1
+ export { document_title } from './document-title';
@@ -0,0 +1,77 @@
1
+ import { findParentNodeClosestToPos } from '@curvenote/prosemirror-utils';
2
+ import { NodeType, PNode, ResolvedPos, Schema } from '@lblod/ember-rdfa-editor';
3
+ import { containsOnlyPlaceholder } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/article-structure-plugin/utils/structure';
4
+ import { findNodes } from '@lblod/ember-rdfa-editor/utils/position-utils';
5
+
6
+ export function findInsertionRange(args: {
7
+ doc: PNode;
8
+ $from: ResolvedPos;
9
+ nodeType: NodeType;
10
+ schema: Schema;
11
+ limitTo?: string;
12
+ }) {
13
+ const { doc, $from, nodeType, schema, limitTo } = args;
14
+ for (let currentDepth = $from.depth; currentDepth >= 0; currentDepth--) {
15
+ const currentAncestor = $from.node(currentDepth);
16
+ const index = $from.index(currentDepth);
17
+ if (currentAncestor.canReplaceWith(index, index, nodeType)) {
18
+ if (containsOnlyPlaceholder(schema, currentAncestor)) {
19
+ return { from: $from.start(currentDepth), to: $from.end(currentDepth) };
20
+ } else {
21
+ const insertPos = $from.after(currentDepth + 1);
22
+ return { from: insertPos, to: insertPos };
23
+ }
24
+ }
25
+ }
26
+ const limitContainer = limitTo
27
+ ? findParentNodeClosestToPos(
28
+ $from,
29
+ (node) => node.type === schema.nodes[limitTo]
30
+ )
31
+ : null;
32
+
33
+ const limitContainerRange = limitContainer
34
+ ? {
35
+ from: limitContainer.pos,
36
+ to: limitContainer.pos + limitContainer.node.nodeSize,
37
+ }
38
+ : { from: 0, to: doc.nodeSize };
39
+ const filterFunction = ({ from, to }: { from: number; to: number }) => {
40
+ if (from >= limitContainerRange.from && to <= limitContainerRange.to) {
41
+ const node = doc.nodeAt(from);
42
+ if (node) {
43
+ if (node.canReplaceWith(node.childCount, node.childCount, nodeType)) {
44
+ return true;
45
+ }
46
+ }
47
+ }
48
+ return false;
49
+ };
50
+ const nextContainerRange =
51
+ findNodes({
52
+ doc,
53
+ start: $from.pos,
54
+ visitParentUpwards: true,
55
+ reverse: false,
56
+ filter: filterFunction,
57
+ }).next().value ??
58
+ findNodes({
59
+ doc,
60
+ start: $from.pos,
61
+ visitParentUpwards: true,
62
+ reverse: true,
63
+ filter: filterFunction,
64
+ }).next().value;
65
+ if (nextContainerRange) {
66
+ const { from, to } = nextContainerRange;
67
+ const containerNode = doc.nodeAt(from);
68
+ if (containerNode) {
69
+ if (containsOnlyPlaceholder(schema, containerNode)) {
70
+ return { from: from + 1, to: to - 1 };
71
+ } else {
72
+ return { from: to - 1, to: to - 1 };
73
+ }
74
+ }
75
+ }
76
+ return null;
77
+ }
@@ -0,0 +1 @@
1
+ export { default } from '@lblod/ember-rdfa-editor-lblod-plugins/components/document-title-plugin/insert-title-card';
@@ -0,0 +1,9 @@
1
+ [property='eli:title']:before {
2
+ content: 'Document-titel' !important;
3
+ }
4
+
5
+ [lang='en-US'] {
6
+ [property='eli:title']:before {
7
+ content: 'Document title' !important;
8
+ }
9
+ }
@@ -0,0 +1,12 @@
1
+ import Component from '@glimmer/component';
2
+ import { SayController } from '@lblod/ember-rdfa-editor';
3
+ import IntlService from 'ember-intl/services/intl';
4
+ type Args = {
5
+ controller: SayController;
6
+ };
7
+ export default class InsertTitleCardComponent extends Component<Args> {
8
+ intl: IntlService;
9
+ insertTitle(): void;
10
+ get canInsertTitle(): boolean;
11
+ }
12
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lblod/ember-rdfa-editor-lblod-plugins",
3
- "version": "8.3.0",
3
+ "version": "8.4.1",
4
4
  "description": "Ember addon providing lblod specific plugins for the ember-rdfa-editor",
5
5
  "keywords": [
6
6
  "ember-addon",
@@ -69,7 +69,7 @@
69
69
  "@embroider/test-setup": "^1.8.3",
70
70
  "@glimmer/component": "^1.1.2",
71
71
  "@glimmer/tracking": "^1.1.2",
72
- "@lblod/ember-rdfa-editor": "^4.0.0",
72
+ "@lblod/ember-rdfa-editor": "^3.10.0",
73
73
  "@rdfjs/types": "^1.1.0",
74
74
  "@release-it/keep-a-changelog": "^3.1.0",
75
75
  "@tsconfig/ember": "^1.0.1",
@@ -0,0 +1,6 @@
1
+ import { Command } from '@lblod/ember-rdfa-editor';
2
+ interface InsertDocumentTitleArgs {
3
+ placeholder: string;
4
+ }
5
+ export default function insertDocumentTitle({ placeholder, }: InsertDocumentTitleArgs): Command;
6
+ export {};
@@ -0,0 +1,2 @@
1
+ import { NodeSpec } from '@lblod/ember-rdfa-editor';
2
+ export declare const document_title: NodeSpec;
@@ -0,0 +1 @@
1
+ export { document_title } from './document-title';
@@ -179,6 +179,11 @@ date-plugin:
179
179
  required: 'This field cannot be empty'
180
180
  fractions: 'Fractions of a second, such as S or T, are not supported.'
181
181
  unknown: 'Invalid format'
182
+
183
+ document-title-plugin:
184
+ document-title-placeholder: Enter document title
185
+ insert-title: Insert document title
186
+
182
187
  variable:
183
188
  number:
184
189
  placeholder: number
@@ -184,6 +184,10 @@ date-plugin:
184
184
  fractions: "Fracties van seconden, zoals S en T, zijn niet ondersteund."
185
185
  unknown: "Ongeldig formaat"
186
186
 
187
+ document-title-plugin:
188
+ document-title-placeholder: Geef document-titel op
189
+ insert-title: Document-titel invoegen
190
+
187
191
  validation-plugin:
188
192
  default-fix-message: Oplossen
189
193
 
@@ -0,0 +1,11 @@
1
+ import { NodeType, PNode, ResolvedPos, Schema } from '@lblod/ember-rdfa-editor';
2
+ export declare function findInsertionRange(args: {
3
+ doc: PNode;
4
+ $from: ResolvedPos;
5
+ nodeType: NodeType;
6
+ schema: Schema;
7
+ limitTo?: string;
8
+ }): {
9
+ from: number;
10
+ to: number;
11
+ } | null;