Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
This repository hold the XML editing engine inspired by the [OpenSCD core](https://github.com/openscd/open-scd-core) and is following the newest agreed [OpenSCD Core API](https://github.com/OpenEnergyTools/open-scd-core/blob/main/API.md)

This repository hold the XML editing engine, following the newest agreed [OpenSCD Plugin API](https://github.com/openscd/oscd-api/blob/main/docs/plugin-api.md)

## Usage

You can either load and use the `handleEdit` function through npm or other content delivery networks. This function does manipulate a XMLDocument as per user intent through the edit as its input:

```ts
const removeNode: Remove = {node: toBeRemovedNode}
handleEdit(removeNode)
const removeNode: Remove = { node: toBeRemovedNode };
handleEdit(removeNode);
```

You can also use the exported `EditV2Editor` class which keeps track of an undo/redo
history. This class is a wrapper around the `handleEdit` function and provides
a more user-friendly API. The `EditV2Editor` class can be used as follows:

```ts
import { EditV2Editor } from '@omicronenergy/oscd-editor';
import { EditV2Editor } from '@openscd/oscd-editor';

const editor = new EditV2Editor();

const removeNode: Remove = {node: toBeRemovedNode}
const removeNode: Remove = { node: toBeRemovedNode };
editor.handleEdit(removeNode);

expect(toBeRemovedNode.parentNode).to.not.exist;
Expand All @@ -37,24 +36,23 @@ expect(toBeRemovedNode.parentNode).to.not.exist;

To scan the project for linting and formatting errors, run

>npm run lint
> npm run lint

To automatically fix linting and formatting errors, run

>npm run format
> npm run format

We use ESLint and Prettier for linting and formatting. Plugins for automatic formatting and linting during editing are available for vim, emacs, VSCode, and all popular IDEs.

## Testing with Web Test Runner

To execute a single test run:

>npm test
> npm test

To run the tests in interactive watch mode run:

>npm run test:watch

> npm run test:watch

# License

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@omicronenergy/oscd-editor",
"name": "@openscd/oscd-editor",
"description": "Function library for basic XML manipulations",
"license": "Apache-2.0",
"author": "OMICRON electronics GmbH",
Expand All @@ -12,7 +12,7 @@
],
"repository": {
"type": "git",
"url": "https://github.com/OMICRONEnergyOSS/oscd-editor.git"
"url": "https://github.com/openscd/oscd-editor.git"
},
"publishConfig": {
"access": "public"
Expand Down