Add nodeToXPath() to core — builds a unique XPath selector for any node by walking up the tree and using name predicates (or positional index when names collide among same-type siblings). Properly escapes names containing quotes using XPath concat() or double-quote delimiters. UI: "Copy node ID" and "Copy XPath" items in the canvas right-click "Copy/Paste as" submenu. Also i18n the entire submenu — all labels now use menuMessages with translations for de, es, fr, it, pl, ru, zh-CN. CLI: `open-pencil selection` command (app-mode only) returns selected nodes with id, name, type, size, and xpath. Connects to the running app via the automation WebSocket. Automation: new `selection` RPC handler that returns selected nodes with computed XPath selectors.
46 lines
1 KiB
TypeScript
Executable file
46 lines
1 KiB
TypeScript
Executable file
#!/usr/bin/env bun
|
|
import { defineCommand, runMain } from 'citty'
|
|
|
|
import analyze from './commands/analyze'
|
|
import convert from './commands/convert'
|
|
import evalCmd from './commands/eval'
|
|
import exportCmd from './commands/export'
|
|
import find from './commands/find'
|
|
import formats from './commands/formats'
|
|
import info from './commands/info'
|
|
import lint from './commands/lint'
|
|
import node from './commands/node'
|
|
import pages from './commands/pages'
|
|
import query from './commands/query'
|
|
import selection from './commands/selection'
|
|
import tree from './commands/tree'
|
|
import variables from './commands/variables'
|
|
|
|
const { version } = await import('../package.json')
|
|
|
|
const main = defineCommand({
|
|
meta: {
|
|
name: 'open-pencil',
|
|
description: 'OpenPencil CLI — inspect, export, and lint OpenPencil design documents',
|
|
version
|
|
},
|
|
subCommands: {
|
|
analyze,
|
|
convert,
|
|
eval: evalCmd,
|
|
export: exportCmd,
|
|
find,
|
|
formats,
|
|
info,
|
|
lint,
|
|
query,
|
|
node,
|
|
pages,
|
|
selection,
|
|
tree,
|
|
variables
|
|
}
|
|
})
|
|
|
|
void runMain(main)
|