Skip to content

WebTaleScriptから動的に、HTMLエレメントの追加 - #220

Merged
EndoHizumi merged 6 commits into
mainfrom
feature/append-dom-edit-tag
Jul 12, 2026
Merged

WebTaleScriptから動的に、HTMLエレメントの追加#220
EndoHizumi merged 6 commits into
mainfrom
feature/append-dom-edit-tag

Conversation

@EndoHizumi

Copy link
Copy Markdown
Owner

No description provided.

@EndoHizumi
EndoHizumi requested a review from Copilot July 12, 2026 05:07
@vercel

vercel Bot commented Jul 12, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
webtalekit-demo Error Error Jul 12, 2026 5:07am

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

WebTaleScript(WTS)から動的に任意のHTML要素を追加・削除できるようにし、クリックイベント(<onclick>)からシナリオ割り込み実行を可能にするための変更です。Core のコマンド拡張と、WTSノード→DOM変換ロジックの追加を通じて、ゲーム画面上のDOM操作をサポートしています。

Changes:

  • <add> / <remove> コマンドを Core に追加し、DOM要素の追加・削除・表示切替を管理する DomElementHandler を導入
  • <add> 配下のノードを DOM に再帰変換する convertNodesToDom を新規追加し、<onclick> によるクリック→シナリオ挿入を実装
  • Drawer.createDecoratedElement を static 化し、既存UI側の呼び出しも更新

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/core/nodeToDomConverter.ts WTSノード配列をDOMに変換し、<onclick> をクリックイベントとして解釈
src/core/domElementHandler.ts <add>/<remove> によるDOM要素の生成・管理・表示切替を提供
src/core/index.js Core のコマンドに add/remove を追加し、show/hide の dom モード対応を追加
src/core/drawer.ts createDecoratedElement を static に変更
src/core/defaultUIHandler.ts static 化に合わせて Drawer.createDecoratedElement 呼び出しへ更新
parser/checker.js add/remove/onclick の許可と属性定義を追加
package.json ビルド時コピーを shx 経由に変更し、依存を追加
example/src/scene/dialog.scene <add><onclick> の動作例を追加

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/core/index.js
import { generateStore } from '../utils/store'
import { EventBus } from '../utils/eventBus'
import { DefaultUIHandler } from './defaultUIHandler'
import { DomElementHandler } from './domElementHandler'
Comment on lines +69 to +80
// 5. type が KNOWN_ATTRIBUTES にない未知タグ -> HTML要素として処理
const element = document.createElement(type);

// type/content 以外の属性を setAttribute で透過。
// ただし属性名が on で始まるもの(onclick等の生JS属性)は透過せず console.warn を出して無視する
for (const [key, value] of Object.entries(attributes)) {
if (key.startsWith('on')) {
console.warn(`[nodeToDomConverter] Skipping prohibited attribute "${key}" on <${type}>`);
continue;
}
element.setAttribute(key, String(value));
}
Comment on lines +61 to +63
// @ts-ignore: KNOWN_ATTRIBUTES is from a JS file
const isKnownType = type in KNOWN_ATTRIBUTES;

Comment on lines +85 to +87
if (element) {
element.style.display = line.show === false ? 'none' : 'block';
} else {
Comment on lines +90 to +92
if (fallbackElement) {
fallbackElement.style.display = line.show === false ? 'none' : 'block';
} else {
Comment thread src/core/index.js
Comment on lines 434 to +442
async hideHandler(line) {
if (line.mode === 'dom') {
this.domElementHandler.setVisibility({
name: line.name,
show: false
})
return
}

@EndoHizumi EndoHizumi added this to the 0.3.0 - 舞踊 (BUYO) milestone Jul 12, 2026
@EndoHizumi EndoHizumi linked an issue Jul 12, 2026 that may be closed by this pull request
@EndoHizumi
EndoHizumi marked this pull request as ready for review July 12, 2026 09:07
@EndoHizumi
EndoHizumi merged commit 21d3e8e into main Jul 12, 2026
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

WebTaleScriptから動的に、HTMLエレメントの追加

2 participants