Skip to content

Commit 888d94f

Browse files
authored
Merge pull request #359 from com-pas/chore/sync-with-upstream
chore: Sync with upstream open scd 0.38.0
2 parents a20d7ee + ae8bd71 commit 888d94f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+4706
-4310
lines changed

.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CHROME_PATH=

.github/workflows/build-project.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ on:
1515
jobs:
1616
build:
1717
name: Build
18-
runs-on: ubuntu-latest
18+
runs-on: ubuntu-22.04
1919
timeout-minutes: 45
2020

2121
steps:

.github/workflows/test-and-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ on: pull_request
33

44
jobs:
55
test-and-build:
6-
runs-on: ubuntu-latest
6+
runs-on: ubuntu-22.04
77
steps:
88
- name: Checkout
99
uses: actions/[email protected]

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88

99
jobs:
1010
test:
11-
runs-on: ubuntu-latest
11+
runs-on: ubuntu-22.04
1212
steps:
1313
- name: Checkout
1414
uses: actions/[email protected]

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,6 @@ node_modules/
2525
/lerna-debug.log
2626

2727
.nx/cache
28+
29+
# environment variables
30+
.env

.release-please-manifest.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"packages/openscd": "0.36.0",
3-
"packages/core": "0.1.3",
4-
".": "0.36.0"
2+
"packages/openscd": "0.37.0",
3+
"packages/core": "0.1.4",
4+
".": "0.38.0"
55
}

CHANGELOG.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,34 @@
11
# Changelog
22

3+
## [0.38.0](https://github.com/openscd/open-scd/compare/v0.37.1...v0.38.0) (2025-02-26)
4+
5+
6+
### Features
7+
8+
* change release please Workflow trigger ([#1624](https://github.com/openscd/open-scd/issues/1624)) ([53f24cb](https://github.com/openscd/open-scd/commit/53f24cbc9b2be8407aa1420b5665d2a09e9051ea))
9+
* update release please action ([#1635](https://github.com/openscd/open-scd/issues/1635)) ([06b8356](https://github.com/openscd/open-scd/commit/06b8356485940f2841b01293de5bea2a6fa1399d))
10+
11+
12+
### Bug Fixes
13+
14+
* inconsistent plugin activation behaviour caused by refactoring ([#1626](https://github.com/openscd/open-scd/issues/1626)) ([00c4dc0](https://github.com/openscd/open-scd/commit/00c4dc06f6d0cf1c39e4822a5b21d650d698785e))
15+
* update release please version to 0.37.2 ([#1632](https://github.com/openscd/open-scd/issues/1632)) ([a3d6d2f](https://github.com/openscd/open-scd/commit/a3d6d2f68952e98d62375b037b5b36bca63f325a))
16+
17+
## [0.37.1](https://github.com/openscd/open-scd/compare/v0.37.0...v0.37.1) (2025-02-04)
18+
19+
20+
### Features
21+
22+
* Programatic Plugin Activation ([#1611](https://github.com/openscd/open-scd/issues/1611)) ([d3b2a0a](https://github.com/openscd/open-scd/commit/d3b2a0a7b2d08d0ce5484567ebfe6c6d4e548c5e))
23+
24+
## [0.37.0](https://github.com/openscd/open-scd/compare/v0.36.0...v0.37.0) (2025-01-27)
25+
26+
27+
### Features
28+
29+
* Edit api v3 ([#1615](https://github.com/openscd/open-scd/issues/1615)) ([ce39e2b](https://github.com/openscd/open-scd/commit/ce39e2b7bfcda40659f36e40659b1efd571f2a53))
30+
* **monorepo:** Add contributing guide ([#1588](https://github.com/openscd/open-scd/issues/1588)) ([dd692a8](https://github.com/openscd/open-scd/commit/dd692a8d9784aaf5f8509fdad5298293195d1465))
31+
332
## [0.36.0](https://github.com/openscd/open-scd/compare/v0.35.0...v0.36.0) (2024-11-14)
433

534

packages/core/CONTRIBUTING.md renamed to CONTRIBUTING.md

Lines changed: 73 additions & 117 deletions
Large diffs are not rendered by default.

docs/core-api/edit-api.md

Lines changed: 113 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,123 @@
1-
# Edit Event API
1+
# Edit Event API v2
22

3-
Open SCD offers an API for editing the scd document which can be used with [Html Custom Events](https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/CustomEvent). The main Open SCD components listens to events of the type `oscd-edit`, applies the changes to the `doc` and updates the `editCount` property.
3+
Open SCD offers an API for editing the scd document which can be used with [Html Custom Events](https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/CustomEvent). The main Open SCD components listens to events of the type `oscd-edit-v2`, applies the changes to the `doc` and updates the `editCount` property.
44

55
The edits to the `doc` will be done in place, e.g. the `doc` changes but will keep the same reference. If your plugin needs to react to changes in the doc, you should listen to changes in the `editCount` property.
66

77
## Event factory
88

99
Open SCD core exports a factory function for edit events, so you do not have to build them manually.
1010

11+
```ts
12+
function newEditEventV2<E extends EditV2>(
13+
edit: E,
14+
options?: EditEventOptionsV2
15+
): EditEventV2
16+
17+
type EditV2 = InsertV2 | SetAttributesV2 | SetTextContentV2 | RemoveV2 | EditV2[];
18+
19+
interface EditEventOptionsV2 = {
20+
title?: string;
21+
squash?: boolean;
22+
createHistoryEntry?: boolean;
23+
};
24+
```
25+
26+
### EditEventOptionsV2
27+
28+
* `title` set a title to be shown in the history.
29+
* `squash` squash edit with previous history entry, this is useful if you want to create multiple edits based on an user action, but need the updated `doc` before applying each edit. Defaults to `false`.
30+
* `createHistoryEntry` decides whether a history for the `edit` should be created. Defaults to `true`.
31+
32+
### Insert
33+
34+
Insert events can be used to add new nodes or move existing nodes in the document. Since a node can only have one parent, using an insert on an existing node will replace it's previous parent with the new parent, essentially moving the node to a different position in the xml tree.
35+
36+
If the reference is not `null`, the node will be inserted before the reference node. The reference has to be a child node of the parent. And if the reference is `null` the node will be added as the last child of the parent.
37+
38+
```ts
39+
interface InsertV2 {
40+
parent: Node;
41+
node: Node;
42+
reference: Node | null;
43+
}
44+
```
45+
46+
### Remove
47+
48+
This event will remove the node from the document.
49+
50+
```ts
51+
interface RemoveV2 {
52+
node: Node;
53+
}
54+
```
55+
56+
### SetAttributes
57+
58+
Sets attributes for the element, can set both regular and namespaced attributes.
59+
60+
```ts
61+
interface SetAttributesV2 {
62+
element: Element;
63+
attributes: Partial<Record<string, string | null>>;
64+
attributesNS: Partial<Record<string, Partial<Record<string, string | null>>>>;
65+
}
66+
```
67+
68+
To set a namespaced attribute see the following example. Here we are setting the attribute `exa:type` for the namespace `https://example.com` to `secondary`.
69+
70+
```ts
71+
const setNamespacedAttributes: SetAttributesV2 = {
72+
element,
73+
attributes: {},
74+
attributesNS: {
75+
"https://example.com": {
76+
"exa:type": "secondary"
77+
}
78+
}
79+
}
80+
```
81+
82+
### SetTextContent
83+
84+
Sets the text content of the element, removes any other children. To remove text content you can pass `null` as value for `textContent`.
85+
86+
```ts
87+
interface SetTextContentV2 {
88+
element: Element;
89+
textContent: string;
90+
}
91+
```
92+
93+
### Complex edits
94+
95+
Complex edits can be used to apply multiple edits as a single event. This will create a single entry in the history. You can create complex edit events by passing an array of edit events to the `newEditEventV2` factory function.
96+
97+
```ts
98+
import { newEditEventV2 } from '@openscd/core';
99+
100+
const complexEditEvent = newEditEventV2([ insert, update, remove ]);
101+
102+
someComponent.dispatchEvent(complexEditEvent);
103+
104+
```
105+
106+
## History
107+
108+
All edit events with the option `createHistoryEntry` will create a history log entry and can be undone and redone through the history addon.
109+
110+
111+
# Archives
112+
113+
## Edit Event API v1 (deprecated)
114+
115+
The edit event API v1 is still available and listens to events of the type `oscd-edit`.
116+
117+
## Event factory
118+
119+
Open SCD core exports a factory function for edit events, so you do not have to build them manually.
120+
11121
```ts
12122
function newEditEvent<E extends Edit>(
13123
edit: E,
@@ -158,7 +268,7 @@ With open SCD version **v0.36.0** and higher some editor action features are no
158268

159269
---
160270

161-
# Archives - Editor Action API (deprecated)
271+
## Editor Action API (deprecated)
162272

163273
### Event factory
164274

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# ADR-0003 - Externalize OpenSCD core plugins
2+
3+
Date: 2024-11-19
4+
5+
## Status
6+
7+
Approved
8+
9+
## Context
10+
11+
For a better expandability we would like to extract all plugins in a new plugins repository.
12+
13+
## Decision
14+
15+
Following the architectural decision in [OpenSCD Theming](./../0001-ADR-Theming.md) we will extract all OpenSCD Core plugins to an external repository.
16+
Doing so OpenSCD Core will be streamlined and a clean interface and structure for plugins will be provided for custom extensions.
17+
Before extracting this plugins a shared UI-Components module will be extracted. This UI-Components provide reusable UI-Components based on [NX](https://nx.dev/) for faster development for OpenSCD Core and custom plugins. This new repository will be created as mono repository to facility the plugins development and simplify the release and deployment process.
18+
19+
Plugins will be moved to repository [OpenSCD official Plugins](https://github.com/openscd/oscd-official-plugins) and the release strategy is defined [here](./0004-openscd-release-and-deploy-strategy.md).
20+
As final task the current documentation will be added with a new section `How to add new and custom OpenSCD plugins` to support developers to follow the concept.
21+
22+
## Consequences
23+
24+
- Clean Code in OpenSCD Core
25+
- Clear architectural structure of plugins
26+
27+
- Building OpenSCD is more then building a simple repository
28+
- Clear path must be defined how to extend OpenSCD with custom plugins (full software cycle till deployment)
29+
- Release process for OpenSCD Core and OpenSCD official plugins
30+
31+
## Agreed procedure
32+
33+
- move the plugins without any components abstraction to the external plugins repository
34+
- copy all required dependencies regardless of code duplication
35+
- integrate the plugins as submodules within OpenSCD core in the pipeline
36+
- later on we can extract step by step for each plugin UI-Components

0 commit comments

Comments
 (0)