@pecot/visual-mcp 1.2.0 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/plugin.json +1 -1
- package/README.md +35 -5
- package/assets/slidev/deck-lint.config.js +2 -2
- package/assets/slidev/deck-lint.env.config.js +2 -2
- package/assets/slidev/package.json +3 -3
- package/assets/slidev/runtime/package.json +1 -1
- package/assets/slidev/scripts/eslint/_shared/dist/lib/drawio-geometry.js +10 -10
- package/assets/slidev/scripts/eslint/_shared/dist/lib/text-measurer.d.ts +2 -2
- package/assets/slidev/scripts/eslint/_shared/dist/lib/text-measurer.js +4 -4
- package/assets/slidev/scripts/eslint/_shared/dist/tsconfig.tsbuildinfo +1 -1
- package/assets/slidev/scripts/eslint/_shared/lib/drawio-geometry.ts +10 -10
- package/assets/slidev/scripts/eslint/_shared/lib/text-measurer.ts +4 -4
- package/assets/slidev/scripts/eslint/slidev-pages-lint/dist/lib/rules/no-content-before-frontmatter.js +1 -1
- package/assets/slidev/scripts/eslint/slidev-pages-lint/dist/lib/rules/no-missing-marker-cell.js +4 -4
- package/assets/slidev/scripts/eslint/slidev-pages-lint/dist/lib/rules/no-missing-page.js +1 -1
- package/assets/slidev/scripts/eslint/slidev-pages-lint/dist/lib/rules/no-numeric-asset-prefix.js +1 -1
- package/assets/slidev/scripts/eslint/slidev-pages-lint/dist/lib/rules/no-numeric-filename-prefix.js +1 -1
- package/assets/slidev/scripts/eslint/slidev-pages-lint/dist/lib/rules/no-scaled-drawio.js +3 -3
- package/assets/slidev/scripts/eslint/slidev-pages-lint/dist/lib/rules/no-triple-hyphen-in-frontmatter.js +3 -3
- package/assets/slidev/scripts/eslint/slidev-pages-lint/dist/lib/rules/no-unknown-props.js +3 -3
- package/assets/slidev/scripts/eslint/slidev-pages-lint/dist/lib/rules/one-slide-per-file.js +1 -1
- package/assets/slidev/scripts/eslint/slidev-pages-lint/dist/lib/rules/require-matching-length.js +1 -1
- package/assets/slidev/scripts/eslint/slidev-pages-lint/dist/lib/rules/require-slides-entry.js +1 -1
- package/assets/slidev/scripts/eslint/slidev-pages-lint/dist/lib/rules/validate-clicks.js +7 -7
- package/assets/slidev/scripts/eslint/slidev-pages-lint/dist/tsconfig.tsbuildinfo +1 -1
- package/assets/slidev/scripts/eslint/slidev-pages-lint/lib/rules/no-content-before-frontmatter.ts +1 -1
- package/assets/slidev/scripts/eslint/slidev-pages-lint/lib/rules/no-missing-marker-cell.ts +4 -4
- package/assets/slidev/scripts/eslint/slidev-pages-lint/lib/rules/no-missing-page.ts +1 -1
- package/assets/slidev/scripts/eslint/slidev-pages-lint/lib/rules/no-numeric-asset-prefix.ts +1 -1
- package/assets/slidev/scripts/eslint/slidev-pages-lint/lib/rules/no-numeric-filename-prefix.ts +1 -1
- package/assets/slidev/scripts/eslint/slidev-pages-lint/lib/rules/no-scaled-drawio.ts +3 -3
- package/assets/slidev/scripts/eslint/slidev-pages-lint/lib/rules/no-triple-hyphen-in-frontmatter.ts +3 -3
- package/assets/slidev/scripts/eslint/slidev-pages-lint/lib/rules/no-unknown-props.ts +3 -3
- package/assets/slidev/scripts/eslint/slidev-pages-lint/lib/rules/one-slide-per-file.ts +1 -1
- package/assets/slidev/scripts/eslint/slidev-pages-lint/lib/rules/require-matching-length.ts +1 -1
- package/assets/slidev/scripts/eslint/slidev-pages-lint/lib/rules/require-slides-entry.ts +1 -1
- package/assets/slidev/scripts/eslint/slidev-pages-lint/lib/rules/validate-clicks.ts +7 -7
- package/assets/slidev/scripts/eslint/text-constraints/dist/lib/rules/max-chars.js +6 -6
- package/assets/slidev/scripts/eslint/text-constraints/dist/lib/rules/textlint-body.js +3 -3
- package/assets/slidev/scripts/eslint/text-constraints/dist/lib/rules/textlint.js +2 -2
- package/assets/slidev/scripts/eslint/text-constraints/dist/tsconfig.tsbuildinfo +1 -1
- package/assets/slidev/scripts/eslint/text-constraints/lib/rules/max-chars.ts +6 -6
- package/assets/slidev/scripts/eslint/text-constraints/lib/rules/textlint-body.ts +3 -3
- package/assets/slidev/scripts/eslint/text-constraints/lib/rules/textlint.ts +2 -2
- package/assets/slidev/scripts/eslint/validate-references/dist/index.js +1 -1
- package/assets/slidev/scripts/eslint/validate-references/dist/lib/semantic-validator.js +12 -12
- package/assets/slidev/scripts/eslint/validate-references/dist/tsconfig.tsbuildinfo +1 -1
- package/assets/slidev/scripts/eslint/validate-references/index.ts +1 -1
- package/assets/slidev/scripts/eslint/validate-references/lib/semantic-validator.ts +12 -12
- package/cli/dist/cli.js +8 -8
- package/cli/dist/commands/chromium/host-dependencies.js +3 -3
- package/cli/dist/commands/drawio/export.js +15 -15
- package/cli/dist/commands/drawio/theme.js +7 -7
- package/cli/dist/commands/drawio/url.js +14 -14
- package/cli/dist/commands/evidence-xlsx/create.js +11 -11
- package/cli/dist/commands/pptx-ooxml/preview.js +13 -13
- package/cli/dist/commands/slidev-project/create.js +12 -12
- package/cli/dist/commands/slidev-project/linked-theme.js +5 -5
- package/cli/dist/commands/slidev-project/lint.js +13 -13
- package/cli/dist/commands/slidev-project/sync.js +19 -19
- package/cli/dist/commands/slidev-project/theme.js +9 -9
- package/cli/dist/commands/slidev-to-pptx/convert.js +47 -47
- package/cli/dist/domain/_shared/text-check.js +2 -2
- package/cli/dist/domain/drawio/export.js +4 -4
- package/cli/dist/domain/drawio/label-text.js +1 -1
- package/cli/dist/domain/drawio/url.js +27 -27
- package/cli/dist/domain/evidence-xlsx/image-dimensions.js +14 -14
- package/cli/dist/domain/evidence-xlsx/layout.d.ts +2 -3
- package/cli/dist/domain/evidence-xlsx/ooxml.d.ts +1 -8
- package/cli/dist/domain/evidence-xlsx/ooxml.js +35 -24
- package/cli/dist/domain/evidence-xlsx/spec-schema.js +26 -26
- package/cli/dist/domain/pptx-ooxml/merge.js +3 -3
- package/cli/dist/domain/slidev-project/generated-files.d.ts +1 -1
- package/cli/dist/domain/slidev-project/generated-files.js +34 -34
- package/cli/dist/domain/slidev-project/initial-pages.js +4 -4
- package/cli/dist/domain/slidev-project/lint.js +11 -11
- package/cli/dist/domain/slidev-project/sync.js +13 -13
- package/cli/dist/domain/slidev-project/warnings.js +4 -4
- package/cli/dist/domain/slidev-theme/declaration.js +9 -9
- package/cli/dist/domain/slidev-theme/references.js +10 -10
- package/cli/dist/domain/slidev-theme/store-layout.js +6 -6
- package/cli/dist/domain/slidev-theme/talk-theme.js +13 -13
- package/cli/dist/domain/slidev-theme/theme-spec.js +5 -5
- package/cli/dist/domain/slidev-to-pptx/errors.js +3 -3
- package/cli/dist/infra/_shared/dependency-root.js +4 -4
- package/cli/dist/infra/_shared/patch-apply.js +6 -5
- package/cli/dist/infra/_shared/runtime-install.js +4 -3
- package/cli/dist/infra/_shared/slidev-bin.js +1 -1
- package/cli/dist/infra/drawio/icons.js +3 -3
- package/cli/dist/infra/drawio/pdf.js +1 -1
- package/cli/dist/infra/drawio/screenshot.js +10 -9
- package/cli/dist/infra/evidence-xlsx/workbook-writer.js +2 -2
- package/cli/dist/infra/playwright/chromium.js +4 -3
- package/cli/dist/infra/playwright/host-dependencies.js +8 -8
- package/cli/dist/infra/playwright/launch.js +5 -5
- package/cli/dist/infra/pptx-ooxml/soffice.js +2 -2
- package/cli/dist/infra/slidev-project/eslint-runner.js +10 -9
- package/cli/dist/infra/slidev-project/fs.js +6 -6
- package/cli/dist/infra/slidev-theme/store.js +18 -15
- package/cli/dist/infra/slidev-to-pptx/cache-store.js +6 -6
- package/cli/dist/infra/slidev-to-pptx/dom-converter.js +12 -12
- package/cli/dist/infra/slidev-to-pptx/pipeline.d.ts +1 -1
- package/cli/dist/infra/slidev-to-pptx/pipeline.js +54 -54
- package/cli/dist/infra/slidev-to-pptx/prerender-capture.js +14 -14
- package/cli/dist/infra/slidev-to-pptx/prerender.js +10 -10
- package/cli/dist/infra/slidev-to-pptx/runner.js +1 -0
- package/cli/dist/infra/slidev-to-pptx/scanner.js +10 -10
- package/cli/dist/infra/slidev-to-pptx/server.js +2 -2
- package/cli/dist/infra/slidev-to-pptx/single-pass-worker.js +39 -39
- package/cli/dist/infra/slidev-to-pptx/slide-worker.js +3 -3
- package/cli/dist/infra/slidev-to-pptx/visibility-helpers.js +8 -8
- package/cli/dist/mcp/dev-server-registry.js +10 -9
- package/cli/dist/mcp/queue.js +1 -1
- package/cli/dist/mcp/result.js +4 -4
- package/cli/dist/mcp/serve.js +1 -1
- package/cli/dist/mcp/server.js +2 -2
- package/cli/dist/mcp/tools/_shared.d.ts +1 -1
- package/cli/dist/mcp/tools/_shared.js +36 -37
- package/cli/dist/mcp/tools/drawio.js +22 -22
- package/cli/dist/mcp/tools/evidence.js +8 -8
- package/cli/dist/mcp/tools/setup.js +26 -26
- package/cli/dist/mcp/tools/slide-dev.js +20 -20
- package/cli/dist/mcp/tools/slide-page.js +36 -36
- package/cli/dist/mcp/tools/slide-theme.js +6 -6
- package/cli/dist/mcp/tools/slide.js +49 -49
- package/cli/dist/mcp/windows-path.js +8 -7
- package/cli/dist/node-runtime.d.ts +6 -1
- package/cli/dist/node-runtime.js +16 -8
- package/npm-shrinkwrap.json +25 -31
- package/package.json +2 -2
- package/vendor/text-rules/dist/source-hash +1 -1
package/README.md
CHANGED
|
@@ -26,7 +26,35 @@ MCP クライアントに 1 エントリ登録するだけで pecot-visual の
|
|
|
26
26
|
"mcpServers": {
|
|
27
27
|
"pecot-visual": {
|
|
28
28
|
"command": "npx",
|
|
29
|
-
"args": ["-y", "@pecot/visual-mcp"]
|
|
29
|
+
"args": ["-y", "--prefix=/", "@pecot/visual-mcp"]
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
`--prefix=/` は、pnpm の `devEngines` を宣言したリポジトリの中で起動しても止まらないようにするための指定です。
|
|
36
|
+
`--prefix` を付けないと、そのリポジトリを cwd にした npx が `EBADDEVENGINES` で止まります。
|
|
37
|
+
npm には devEngines の判定だけを外す公式の手段が無く、要望(npm/rfcs#830)は not_planned で閉じています。
|
|
38
|
+
|
|
39
|
+
パッケージは `--package=` ではなく、位置引数で渡してください。
|
|
40
|
+
`--package=` で渡すと、npm が `npm_config_package` をサーバの子プロセスに残します。
|
|
41
|
+
すると、テーマの依存の取得(pnpm と corepack のどちらも無いとき)が打つ npx が、これを読んで別のパッケージを実行します。
|
|
42
|
+
|
|
43
|
+
`--prefix=/` には次の副作用があります。
|
|
44
|
+
|
|
45
|
+
- 利用者のリポジトリの `.npmrc` を読まず、globalconfig も `/etc/npmrc` になる。registry・proxy・cafile は `~/.npmrc` に置く
|
|
46
|
+
- `npm_config_prefix=/` などの環境変数がサーバに引き継がれる。サーバの子で `npm i -g` を打つと `/lib/node_modules` を向く
|
|
47
|
+
|
|
48
|
+
`setup` は `npm install --prefix` で置き場を明示します。
|
|
49
|
+
テーマの依存の取得(pnpm)は、talk-dir を cwd か `--dir` で指します。どちらも、この副作用の影響を受けません。
|
|
50
|
+
|
|
51
|
+
この副作用を避けたいときは、先に `npm i -g @pecot/visual-mcp` で入れて、コマンドを直接登録します。
|
|
52
|
+
|
|
53
|
+
```json
|
|
54
|
+
{
|
|
55
|
+
"mcpServers": {
|
|
56
|
+
"pecot-visual": {
|
|
57
|
+
"command": "pecot-visual-mcp"
|
|
30
58
|
}
|
|
31
59
|
}
|
|
32
60
|
}
|
|
@@ -40,7 +68,7 @@ MCP クライアントに 1 エントリ登録するだけで pecot-visual の
|
|
|
40
68
|
"mcpServers": {
|
|
41
69
|
"pecot-visual": {
|
|
42
70
|
"command": "npx",
|
|
43
|
-
"args": ["-y", "@pecot/visual-mcp"],
|
|
71
|
+
"args": ["-y", "--prefix=/", "@pecot/visual-mcp"],
|
|
44
72
|
"env": { "PLUGIN_DATA": "/home/<user>/pecot-visual-data" }
|
|
45
73
|
}
|
|
46
74
|
}
|
|
@@ -54,7 +82,7 @@ Windows の MCP クライアントから使う場合は WSL2 経由で起動し
|
|
|
54
82
|
"mcpServers": {
|
|
55
83
|
"pecot-visual": {
|
|
56
84
|
"command": "wsl",
|
|
57
|
-
"args": ["npx", "-y", "@pecot/visual-mcp"]
|
|
85
|
+
"args": ["npx", "-y", "--prefix=/", "@pecot/visual-mcp"]
|
|
58
86
|
}
|
|
59
87
|
}
|
|
60
88
|
}
|
|
@@ -67,14 +95,14 @@ WSL 側に `PLUGIN_DATA` を渡すには、`env` を `args` に含めます。Wi
|
|
|
67
95
|
"mcpServers": {
|
|
68
96
|
"pecot-visual": {
|
|
69
97
|
"command": "wsl",
|
|
70
|
-
"args": ["env", "PLUGIN_DATA=/home/<user>/pecot-visual-data", "npx", "-y", "@pecot/visual-mcp"]
|
|
98
|
+
"args": ["env", "PLUGIN_DATA=/home/<user>/pecot-visual-data", "npx", "-y", "--prefix=/", "@pecot/visual-mcp"]
|
|
71
99
|
}
|
|
72
100
|
}
|
|
73
101
|
}
|
|
74
102
|
```
|
|
75
103
|
|
|
76
104
|
WSL 内の npx が非ログインシェルの PATH に無い場合は、次のように指定します。
|
|
77
|
-
`"args": ["-e", "bash", "-lc", "npx -y @pecot/visual-mcp"]`
|
|
105
|
+
`"args": ["-e", "bash", "-lc", "npx -y --prefix=/ @pecot/visual-mcp"]`
|
|
78
106
|
|
|
79
107
|
ツールのパス引数には `C:\...` と `\\wsl.localhost\<distro>\...` をそのまま渡せます。
|
|
80
108
|
変換の対象はツール引数のみです。spec ファイル等の中身に書かれたパスは変換しません。
|
|
@@ -129,6 +157,8 @@ Chromium を使うため `setup` が必要です。
|
|
|
129
157
|
|
|
130
158
|
`setup` が必要なツールを `setup` 前に呼ぶと、`setup` を案内する応答が返ります。`setup` を呼んでから再実行してください。
|
|
131
159
|
|
|
160
|
+
`EBADDEVENGINES` で止まるときは、登録の `args` に `--prefix=/` が付いているか確認してください。
|
|
161
|
+
|
|
132
162
|
## 版
|
|
133
163
|
|
|
134
164
|
npm の版は pecot-v(pecot-visual)プラグインの版と一致します。
|
|
@@ -38,8 +38,8 @@ export function defineDeckLintConfig({ referencesDirectories, panels, markerLayo
|
|
|
38
38
|
const isValid = Array.isArray(referencesDirectories) && isRecord(panels) && Array.isArray(markerLayouts) && isRecord(rules)
|
|
39
39
|
if (!isValid) {
|
|
40
40
|
throw new TypeError(
|
|
41
|
-
'defineDeckLintConfig
|
|
42
|
-
+ 'referencesDirectories
|
|
41
|
+
'invalid argument to defineDeckLintConfig '
|
|
42
|
+
+ '(fix: pass referencesDirectories and markerLayouts as arrays, and panels and rules as objects)',
|
|
43
43
|
)
|
|
44
44
|
}
|
|
45
45
|
const settings = { 'slidev-theme': { referencesDirectories, panels, markerLayouts } }
|
|
@@ -10,13 +10,13 @@ const ENV_NAME = 'PECOTV_DECK_LINT'
|
|
|
10
10
|
function readLintFromEnvironment() {
|
|
11
11
|
const text = process.env[ENV_NAME]
|
|
12
12
|
if (text === undefined || text === '') {
|
|
13
|
-
throw new Error(`${ENV_NAME}
|
|
13
|
+
throw new Error(`${ENV_NAME} is not set (fix: pass the lint value of slide theme --json as JSON)`)
|
|
14
14
|
}
|
|
15
15
|
try {
|
|
16
16
|
return JSON.parse(text)
|
|
17
17
|
}
|
|
18
18
|
catch (error) {
|
|
19
|
-
throw new Error(`${ENV_NAME}
|
|
19
|
+
throw new Error(`${ENV_NAME} is not valid JSON: ${error instanceof Error ? error.message : String(error)}`)
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
|
|
@@ -32,12 +32,12 @@
|
|
|
32
32
|
"c8": "^12.0.0",
|
|
33
33
|
"eslint": "^10.14.0",
|
|
34
34
|
"eslint-config-prettier": "^10.1.8",
|
|
35
|
-
"eslint-plugin-vue": "^10.12.
|
|
35
|
+
"eslint-plugin-vue": "^10.12.1",
|
|
36
36
|
"globals": "^17.14.0",
|
|
37
37
|
"jszip": "^3.10.2",
|
|
38
|
-
"playwright": "^1.
|
|
38
|
+
"playwright": "^1.65.0",
|
|
39
39
|
"typescript": "npm:@typescript/typescript6@^6.0.2",
|
|
40
|
-
"typescript-eslint": "^8.72.
|
|
40
|
+
"typescript-eslint": "^8.72.2",
|
|
41
41
|
"typescript7": "npm:typescript@^7.0.2",
|
|
42
42
|
"vue-eslint-parser": "^10.4.2",
|
|
43
43
|
"yaml": "^2.9.1"
|
|
@@ -127,7 +127,7 @@ function stripXmlComments(xml) {
|
|
|
127
127
|
*/
|
|
128
128
|
function scanCells(xml) {
|
|
129
129
|
if (typeof xml !== 'string' || xml.trim() === '') {
|
|
130
|
-
throw new DrawioGeometryError('empty-xml', 'draw.io
|
|
130
|
+
throw new DrawioGeometryError('empty-xml', 'draw.io XML is empty');
|
|
131
131
|
}
|
|
132
132
|
const source = stripXmlComments(xml);
|
|
133
133
|
const cells = [];
|
|
@@ -147,7 +147,7 @@ function scanCells(xml) {
|
|
|
147
147
|
if (closing) {
|
|
148
148
|
const top = stack.pop();
|
|
149
149
|
if (top?.name === 'diagram' && !top.hasChild && between.trim() !== '') {
|
|
150
|
-
throw new DrawioGeometryError('compressed', '
|
|
150
|
+
throw new DrawioGeometryError('compressed', 'compressed <diagram> is not supported (fix: turn off File > Properties > Compressed in draw.io and save)');
|
|
151
151
|
}
|
|
152
152
|
if (name === 'mxCell')
|
|
153
153
|
current = null;
|
|
@@ -161,12 +161,12 @@ function scanCells(xml) {
|
|
|
161
161
|
if (parent)
|
|
162
162
|
parent.hasChild = true;
|
|
163
163
|
if (name === 'object' || name === 'UserObject') {
|
|
164
|
-
throw new DrawioGeometryError('wrapped-cell',
|
|
164
|
+
throw new DrawioGeometryError('wrapped-cell', `cell wrapped in <${name}> is not supported; it is generated when a cell has properties or a link (fix: remove the properties so the cell is a plain mxCell)`);
|
|
165
165
|
}
|
|
166
166
|
if (name === 'diagram') {
|
|
167
167
|
diagramCount += 1;
|
|
168
168
|
if (diagramCount > 1) {
|
|
169
|
-
throw new DrawioGeometryError('multi-page', '
|
|
169
|
+
throw new DrawioGeometryError('multi-page', 'multi-page draw.io file is not supported (fix: use a file with one page)');
|
|
170
170
|
}
|
|
171
171
|
}
|
|
172
172
|
if (name === 'mxGraphModel')
|
|
@@ -219,7 +219,7 @@ function scanCells(xml) {
|
|
|
219
219
|
stack.push({ name, hasChild: false });
|
|
220
220
|
}
|
|
221
221
|
if (modelCount === 0) {
|
|
222
|
-
throw new DrawioGeometryError('no-model', 'draw.io
|
|
222
|
+
throw new DrawioGeometryError('no-model', 'draw.io XML has no <mxGraphModel>');
|
|
223
223
|
}
|
|
224
224
|
return cells;
|
|
225
225
|
}
|
|
@@ -332,20 +332,20 @@ export function parseDrawio(xml) {
|
|
|
332
332
|
export function resolveCellRect(model, cellId) {
|
|
333
333
|
const cell = model.byId.get(cellId);
|
|
334
334
|
if (!cell) {
|
|
335
|
-
throw new DrawioGeometryError('unknown-cell',
|
|
335
|
+
throw new DrawioGeometryError('unknown-cell', `cell not found in the diagram: ${cellId}`);
|
|
336
336
|
}
|
|
337
337
|
if (cell.edge) {
|
|
338
|
-
throw new DrawioGeometryError('edge-cell',
|
|
338
|
+
throw new DrawioGeometryError('edge-cell', `cell is an edge: ${cellId} (fix: give the ID of a vertex for the marker)`);
|
|
339
339
|
}
|
|
340
340
|
if (!cell.vertex) {
|
|
341
|
-
throw new DrawioGeometryError('not-vertex',
|
|
341
|
+
throw new DrawioGeometryError('not-vertex', `cell is not a vertex, such as a layer: ${cellId} (fix: give the ID of a vertex)`);
|
|
342
342
|
}
|
|
343
343
|
if (model.isHidden(cell)) {
|
|
344
|
-
throw new DrawioGeometryError('hidden-cell',
|
|
344
|
+
throw new DrawioGeometryError('hidden-cell', `cell is hidden (visible="0"): ${cellId}`);
|
|
345
345
|
}
|
|
346
346
|
const rect = model.vertexRect(cell);
|
|
347
347
|
if (!rect) {
|
|
348
|
-
throw new DrawioGeometryError('relative-cell',
|
|
348
|
+
throw new DrawioGeometryError('relative-cell', `cell is placed relative to its parent (relative="1"), so its position cannot be determined: ${cellId}`);
|
|
349
349
|
}
|
|
350
350
|
return { ...rect, crisp: crispOffsetOf(strokeOf(cell.style).width) };
|
|
351
351
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export declare function stripHtmlTags(text: string): string;
|
|
2
2
|
export declare function isFullWidth(codePoint: number): boolean;
|
|
3
3
|
export declare function fullWidthEquivalent(text: string): number;
|
|
4
|
-
export declare const BOLD_REQUIRED_MESSAGE = "
|
|
4
|
+
export declare const BOLD_REQUIRED_MESSAGE = "no bold emphasis on the key point (fix: wrap only the key point in <strong>\u2026</strong>; wrapping the whole text is not emphasis; <b> and Markdown ** are not allowed)";
|
|
5
5
|
export declare function hasBoldEmphasis(text: string): boolean;
|
|
6
|
-
export declare const EM_DISALLOWED_MESSAGE = "<em>
|
|
6
|
+
export declare const EM_DISALLOWED_MESSAGE = "<em> is not allowed; use <strong> for emphasis only (fix: remove <em> and keep the words)";
|
|
7
7
|
export declare function hasDisallowedEmTag(text: string): boolean;
|
|
8
8
|
export interface TextConstraint {
|
|
9
9
|
min_chars?: number;
|
|
@@ -29,7 +29,7 @@ export function fullWidthEquivalent(text) {
|
|
|
29
29
|
// 太字強調は <strong> のみを認める(テンプレートの強調規範を <strong> に一本化しており <b> は不可)。
|
|
30
30
|
// 属性付き・大文字タグは許容し、中身が空の <strong></strong> は強調とみなさない。
|
|
31
31
|
const STRONG_TAG_PATTERN = /<strong(?:\s[^>]*)?>([\s\S]*?)<\/strong\s*>/gi;
|
|
32
|
-
export const BOLD_REQUIRED_MESSAGE = '
|
|
32
|
+
export const BOLD_REQUIRED_MESSAGE = 'no bold emphasis on the key point (fix: wrap only the key point in <strong>…</strong>; wrapping the whole text is not emphasis; <b> and Markdown ** are not allowed)';
|
|
33
33
|
// 全文が strong に覆われていると強調の対比が消えるため、強調とみなさない。
|
|
34
34
|
// 複数の strong で分割して全文を覆うケースも同じ扱いにする。
|
|
35
35
|
export function hasBoldEmphasis(text) {
|
|
@@ -49,7 +49,7 @@ export function hasBoldEmphasis(text) {
|
|
|
49
49
|
}
|
|
50
50
|
// <em> は強調記法として不可(強調は <strong> のみ)。属性付き・大文字タグも検出する。
|
|
51
51
|
const EM_TAG_PATTERN = /<em(?:\s[^>]*)?>/i;
|
|
52
|
-
export const EM_DISALLOWED_MESSAGE = '<em>
|
|
52
|
+
export const EM_DISALLOWED_MESSAGE = '<em> is not allowed; use <strong> for emphasis only (fix: remove <em> and keep the words)';
|
|
53
53
|
export function hasDisallowedEmTag(text) {
|
|
54
54
|
if (typeof text !== 'string') {
|
|
55
55
|
return false;
|
|
@@ -67,7 +67,7 @@ export function validateText(text, constraint) {
|
|
|
67
67
|
if (minChars != null && fwe < minChars) {
|
|
68
68
|
errors.push({
|
|
69
69
|
type: 'minChars',
|
|
70
|
-
message: `${fwe}
|
|
70
|
+
message: `${fwe} chars (min: ${minChars})`,
|
|
71
71
|
actual: fwe,
|
|
72
72
|
limit: minChars,
|
|
73
73
|
});
|
|
@@ -76,7 +76,7 @@ export function validateText(text, constraint) {
|
|
|
76
76
|
if (maxChars != null && fwe > maxChars) {
|
|
77
77
|
errors.push({
|
|
78
78
|
type: 'maxChars',
|
|
79
|
-
message: `${fwe}
|
|
79
|
+
message: `${fwe} chars (max: ${maxChars})`,
|
|
80
80
|
actual: fwe,
|
|
81
81
|
limit: maxChars,
|
|
82
82
|
});
|