Skip to content

Commit

Permalink
Release (#1478)
Browse files Browse the repository at this point in the history
* fix: should allow different HTMLs sharing the same Id #1475 (#1476)

* fix: should allow different HTMLs sharing the same Id #1475

* chore: commmit changeset

* chore(release): bump version (#1477)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Aug 11, 2023
1 parent e971431 commit 801a998
Show file tree
Hide file tree
Showing 22 changed files with 115 additions and 24 deletions.
35 changes: 35 additions & 0 deletions __tests__/unit/display-objects/html.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,4 +180,39 @@ describe('HTML', () => {
expect($el.style.fontSize).toBe('16px');
expect($el.style.color).toBe('blue');
});

it('should allow different HTMLs sharing the same Id.', async () => {
const html1 = new HTML({
id: 'id',
style: {
x: 100,
y: 100,
width: 100,
height: 100,
innerHTML: '<h1>This is Title</h1>',
},
});
const html2 = new HTML({
id: 'id',
style: {
x: 100,
y: 100,
width: 100,
height: 100,
innerHTML: '<h1>This is Title</h1>',
},
});

await canvas.ready;
canvas.appendChild(html1);
canvas.appendChild(html2);

const $el1 = html1.getDomElement();
const $el2 = html2.getDomElement();
expect($el1.id).toBe('id');
expect($el2.id).toBe('id');
// unique id
expect($el1.dataset.id).toBe('g-html-' + html1.entity);
expect($el2.dataset.id).toBe('g-html-' + html2.entity);
});
});
7 changes: 7 additions & 0 deletions packages/g-canvas/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @antv/g-canvas

## 1.11.14

### Patch Changes

- Updated dependencies [ee64c46c]
- @antv/g-plugin-html-renderer@1.9.14

## 1.11.13

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/g-canvas/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g-canvas",
"version": "1.11.13",
"version": "1.11.14",
"description": "A renderer implemented by Canvas 2D API",
"keywords": [
"antv",
Expand Down
7 changes: 7 additions & 0 deletions packages/g-canvaskit/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @antv/g-canvaskit

## 0.10.14

### Patch Changes

- Updated dependencies [ee64c46c]
- @antv/g-plugin-html-renderer@1.9.14

## 0.10.13

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/g-canvaskit/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g-canvaskit",
"version": "0.10.13",
"version": "0.10.14",
"description": "A renderer implemented by CanvasKit",
"keywords": [
"antv",
Expand Down
7 changes: 7 additions & 0 deletions packages/g-mobile-webgl/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @antv/g-mobile-webgl

## 0.9.16

### Patch Changes

- Updated dependencies [ee64c46c]
- @antv/g-plugin-html-renderer@1.9.14

## 0.9.15

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/g-mobile-webgl/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g-mobile-webgl",
"version": "0.9.15",
"version": "0.9.16",
"description": "A renderer implemented by WebGL1/2 in mobile environment",
"keywords": [
"antv",
Expand Down
6 changes: 6 additions & 0 deletions packages/g-plugin-gpgpu/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @antv/g-plugin-gpgpu

## 1.9.16

### Patch Changes

- @antv/g-webgpu@1.9.16

## 1.9.15

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/g-plugin-gpgpu/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g-plugin-gpgpu",
"version": "1.9.15",
"version": "1.9.16",
"description": "A G plugin for GPGPU based on WebGPU",
"keywords": [
"webgpu",
Expand Down
6 changes: 6 additions & 0 deletions packages/g-plugin-html-renderer/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @antv/g-plugin-html-renderer

## 1.9.14

### Patch Changes

- ee64c46c: Should allow different HTMLs sharing the same Id.

## 1.9.13

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/g-plugin-html-renderer/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g-plugin-html-renderer",
"version": "1.9.13",
"version": "1.9.14",
"description": "A G plugin for rendering HTML",
"keywords": [
"antv",
Expand Down
18 changes: 4 additions & 14 deletions packages/g-plugin-html-renderer/src/HTMLRenderingPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,6 @@ export class HTMLRenderingPlugin implements RenderingPlugin {
$el.remove();
this.context.nativeHTMLMap.delete($el);
}

// const existedId = this.getId(object);
// const $existedElement: HTMLElement | null = this.$camera.querySelector('#' + existedId);
// if ($existedElement) {
// this.$camera.removeChild($existedElement);
// }
}
};

Expand Down Expand Up @@ -166,10 +160,6 @@ export class HTMLRenderingPlugin implements RenderingPlugin {
});
}

private getId(object: DisplayObject) {
return object.id || HTML_PREFIX + object.entity;
}

private createCamera(camera: ICamera) {
const { document: doc, width, height } = this.context.config;
const $canvas =
Expand Down Expand Up @@ -209,15 +199,15 @@ export class HTMLRenderingPlugin implements RenderingPlugin {

private getOrCreateEl(object: DisplayObject) {
const { document: doc } = this.context.config;
const existedId = this.getId(object);

const uniqueHTMLId = `${HTML_PREFIX}${object.entity}`;
let $existedElement: HTMLElement | null = this.$camera.querySelector(
'#' + existedId,
`[data-id=${uniqueHTMLId}]`,
);
if (!$existedElement) {
$existedElement = (doc || document).createElement('div');
object.parsedStyle.$el = $existedElement;
$existedElement.id = existedId;
$existedElement.id = object.id || uniqueHTMLId;
$existedElement.dataset.id = uniqueHTMLId;

if (object.name) {
$existedElement.setAttribute('name', object.name);
Expand Down
6 changes: 6 additions & 0 deletions packages/g-plugin-rough-canvas-renderer/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @antv/g-plugin-rough-canvas-renderer

## 1.9.14

### Patch Changes

- @antv/g-canvas@1.11.14

## 1.9.13

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/g-plugin-rough-canvas-renderer/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g-plugin-rough-canvas-renderer",
"version": "1.9.13",
"version": "1.9.14",
"description": "A G plugin of renderer implementation with rough.js",
"keywords": [
"antv",
Expand Down
6 changes: 6 additions & 0 deletions packages/g-plugin-zdog-canvas-renderer/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @antv/g-plugin-zdog-canvas-renderer

## 1.2.14

### Patch Changes

- @antv/g-canvas@1.11.14

## 1.2.13

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/g-plugin-zdog-canvas-renderer/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g-plugin-zdog-canvas-renderer",
"version": "1.2.13",
"version": "1.2.14",
"description": "A G plugin of renderer implementation with Zdog",
"keywords": [
"antv",
Expand Down
7 changes: 7 additions & 0 deletions packages/g-web-components/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @antv/g-web-components

## 1.9.16

### Patch Changes

- @antv/g-canvas@1.11.14
- @antv/g-webgl@1.9.16

## 1.9.15

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/g-web-components/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g-web-components",
"version": "1.9.15",
"version": "1.9.16",
"description": "A declarative usage for G implemented with WebComponents",
"keywords": [
"antv",
Expand Down
7 changes: 7 additions & 0 deletions packages/g-webgl/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @antv/g-webgl

## 1.9.16

### Patch Changes

- Updated dependencies [ee64c46c]
- @antv/g-plugin-html-renderer@1.9.14

## 1.9.15

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/g-webgl/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g-webgl",
"version": "1.9.15",
"version": "1.9.16",
"description": "A renderer implemented by WebGL1/2",
"keywords": [
"antv",
Expand Down
7 changes: 7 additions & 0 deletions packages/g-webgpu/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @antv/g-webgpu

## 1.9.16

### Patch Changes

- Updated dependencies [ee64c46c]
- @antv/g-plugin-html-renderer@1.9.14

## 1.9.15

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/g-webgpu/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g-webgpu",
"version": "1.9.15",
"version": "1.9.16",
"description": "A renderer implemented by WebGPU",
"keywords": [
"antv",
Expand Down

0 comments on commit 801a998

Please sign in to comment.