Skip to content

Commit

Permalink
Merge pull request #4583 from easyops-cn/steve/v3-refine-docs
Browse files Browse the repository at this point in the history
fix(): add textContent into props if brick has default slot
  • Loading branch information
qiaofengxi authored Dec 19, 2024
2 parents 05dcac8 + 79a40ec commit c169a27
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"@next-core/brick-container": "*",
"@next-core/brick-playground": "*",
"@next-core/test-next": "*",
"@types/doctrine": "^0.0.9",
"@types/fs-extra": "^9.0.13",
"@types/history": "^4.7.11",
"@types/inquirer": "^7.3.3",
Expand Down
31 changes: 31 additions & 0 deletions packages/build-next-bricks/src/makeBrickManifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,20 @@ export default function makeBrickManifest(name, alias, nodePath, source) {
}
break;
}
// 主动声明原生事件,例如 eo-button 构件的 click 事件
case "event": {
const match = tag.description.match(/^([-\w]+)\s+-\s+(.*)$/);
if (!match) {
throw new Error(
`Doc comment for event is invalid: '${tag.description}'`
);
}
manifest.events.push({
name: match[1],
description: match[2],
});
break;
}
case "insider": {
manifest.insider = true;
}
Expand All @@ -118,6 +132,23 @@ export default function makeBrickManifest(name, alias, nodePath, source) {
source
);

// 如果有默认插槽,代表有默认属性 textContent
const hasDefaultSlot = manifest.slots.some((slot) => !slot.name);
if (hasDefaultSlot) {
manifest.properties.push({
name: "textContent",
type: "string",
description: "文本内容",
});
manifest.types.properties.push({
name: "textContent",
annotation: {
type: "keyword",
value: "string",
},
});
}

return manifest;
}

Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2792,6 +2792,11 @@
dependencies:
"@types/node" "*"

"@types/doctrine@^0.0.9":
version "0.0.9"
resolved "https://registry.npmjs.org/@types/doctrine/-/doctrine-0.0.9.tgz#d86a5f452a15e3e3113b99e39616a9baa0f9863f"
integrity sha512-eOIHzCUSH7SMfonMG1LsC2f8vxBFtho6NGBznK41R84YzPuvSBzrhEps33IsQiOW9+VL6NQ9DbjQJznk/S4uRA==

"@types/estree@^1.0.5":
version "1.0.5"
resolved "https://registry.npmjs.org/@types/estree/-/estree-1.0.5.tgz#a6ce3e556e00fd9895dd872dd172ad0d4bd687f4"
Expand Down

0 comments on commit c169a27

Please sign in to comment.