feat(form-decompile,form-compile): события ExtendedTooltip-компаньона (переиспользование механизма событий элемента)

ExtendedTooltip (companion = LabelDecoration) может нести <Events> (напр.
URLProcessing у hyperlink-подсказки — ОбработкаНавигационнойСсылки). Декомпилятор
ловил own-content (layout/оформление/флаги/hyperlink), но НЕ события → весь блок
Events LOST (топ list-iter: ExtendedTooltip>Events 492 impact). Был отложенный хвост
кластера ExtendedTooltip own-content.

Переиспользован механизм событий элемента: декомпилятор Get-Events → etObj['events'];
компилятор Emit-Events (typeKey 'label', после Title) + 'events' в companionStructKeys
(чтобы text+events шёл структурной веткой). Зеркало py. Round-trip формы
НастройкиИнтеграцииМаркетплейс/ФормаЭлемента бит-в-бит (3 ExtendedTooltip с URLProcessing).
Кейс input-fields (extendedTooltip +hyperlink +events URLProcessing) сертифицирован
в 1С. Регресс 43/43 (ps1+py).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Nick Shirokov
2026-06-11 20:46:20 +03:00
parent 32273d2be8
commit 9900f8f656
6 changed files with 18 additions and 9 deletions
@@ -1,4 +1,4 @@
# form-compile v1.120 — Compile 1C managed form from JSON or object metadata
# form-compile v1.121 — Compile 1C managed form from JSON or object metadata
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
param(
[string]$JsonPath,
@@ -2356,7 +2356,7 @@ function Emit-Events {
$script:companionStructKeys = @(
'width','autoMaxWidth','maxWidth','height','autoMaxHeight','maxHeight','verticalAlign','titleHeight',
'horizontalStretch','verticalStretch','horizontalAlign','groupHorizontalAlign','groupVerticalAlign',
'visible','hidden','enabled','disabled','hyperlink',
'visible','hidden','enabled','disabled','hyperlink','events',
'textColor','backColor','borderColor','font','border','цветтекста','цветфона','цветрамки','шрифт','рамка'
)
function Test-CompanionStructured {
@@ -2405,6 +2405,8 @@ function Emit-Companion {
Emit-Layout -el $content -indent $inner
Emit-Appearance -el $content -indent $inner -profile 'decoration'
if ($txtPresent) { Emit-CompanionTitle -content $content -indent $inner }
# События компаньона (ExtendedTooltip = LabelDecoration: напр. URLProcessing у hyperlink-подсказки)
Emit-Events -el $content -elementName $name -indent $inner -typeKey 'label'
} else {
Emit-CompanionTitle -content $content -indent $inner
}
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
# form-compile v1.120 — Compile 1C managed form from JSON or object metadata
# form-compile v1.121 — Compile 1C managed form from JSON or object metadata
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
import argparse
import copy
@@ -2391,7 +2391,7 @@ def resolve_ml_formatted(val):
COMPANION_STRUCT_KEYS = {
'width', 'autoMaxWidth', 'maxWidth', 'height', 'autoMaxHeight', 'maxHeight', 'verticalAlign', 'titleHeight',
'horizontalStretch', 'verticalStretch', 'horizontalAlign', 'groupHorizontalAlign', 'groupVerticalAlign',
'visible', 'hidden', 'enabled', 'disabled', 'hyperlink',
'visible', 'hidden', 'enabled', 'disabled', 'hyperlink', 'events',
'textColor', 'backColor', 'borderColor', 'font', 'border', 'цветтекста', 'цветфона', 'цветрамки', 'шрифт', 'рамка',
}
@@ -2420,6 +2420,8 @@ def emit_companion(lines, tag, name, indent, content=None):
emit_appearance(lines, content, inner, 'decoration')
if 'text' in content:
emit_companion_title(lines, content, inner)
# События компаньона (ExtendedTooltip = LabelDecoration: напр. URLProcessing у hyperlink-подсказки)
emit_events(lines, content, name, inner, 'label')
else:
emit_companion_title(lines, content, inner)
lines.append(f'{indent}</{tag}>')
@@ -1,4 +1,4 @@
# form-decompile v0.96 — Decompile 1C managed Form.xml to JSON DSL (draft)
# form-decompile v0.97 — Decompile 1C managed Form.xml to JSON DSL (draft)
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
# ВНИМАНИЕ: раундтрип не гарантируется. Навык исключён из авто-использования моделью.
param(
@@ -1895,8 +1895,7 @@ function Decompile-Element {
Add-Layout $obj $node
Add-GenericScalars $obj $node
# extendedTooltip: companion <ExtendedTooltip> (это LabelDecoration). Текст-форма (только <Title>) →
# строка/{text,formatted}. Own-content (layout/оформление/флаги/hyperlink) → объект { text?, … }.
# Events компаньона пока НЕ захватываем (хвост — требует имя-обработчик).
# строка/{text,formatted}. Own-content (layout/оформление/флаги/hyperlink/events) → объект { text?, … }.
$etNode = $node.SelectSingleNode("lf:ExtendedTooltip", $ns)
if ($etNode) {
$etTitle = $etNode.SelectSingleNode("lf:Title", $ns)
@@ -1908,6 +1907,8 @@ function Decompile-Element {
if ((Get-Child $etNode 'Visible') -eq 'false') { $etObj['hidden'] = $true }
if ((Get-Child $etNode 'Enabled') -eq 'false') { $etObj['disabled'] = $true }
if ((Get-Child $etNode 'Hyperlink') -eq 'true') { $etObj['hyperlink'] = $true }
# События компаньона (напр. URLProcessing у hyperlink-подсказки) — переиспользуем механизм событий элемента
$etEv = Get-Events $etNode $name; if ($etEv) { $etObj['events'] = $etEv }
if ($etObj.Count -gt 0) {
if ($null -ne $textVal) {
if ($textVal -is [System.Collections.IDictionary] -and $textVal.Contains('text')) { $etObj['text'] = $textVal['text']; if ($textVal['formatted']) { $etObj['formatted'] = $true } }