Compare commits
3 Commits
33d29252dc
...
3cd8cc54b7
| Author | SHA1 | Date |
|---|---|---|
|
|
3cd8cc54b7 | |
|
|
64ac6c4516 | |
|
|
8af559fe1c |
|
|
@ -23,7 +23,7 @@ export function CardLayer(props: CardLayerProps) {
|
||||||
const showBounds = () => props.store.state.isEditing;
|
const showBounds = () => props.store.state.isEditing;
|
||||||
|
|
||||||
function renderLayerContent(content: string) {
|
function renderLayerContent(content: string) {
|
||||||
const iconPath = resolvePath(props.store.state.cards.sourcePath, props.cardData.iconPath);
|
const iconPath = resolvePath(props.store.state.cards.sourcePath, props.cardData.iconPath ?? "./assets");
|
||||||
return parseMarkdown(processVariables(content, props.cardData, props.store.state.cards), iconPath) as string;
|
return parseMarkdown(processVariables(content, props.cardData, props.store.state.cards), iconPath) as string;
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,8 @@ customElement("md-dice", { key: "" }, (props, { element }) => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const handleRoll = () => {
|
const handleRoll = (e: MouseEvent) => {
|
||||||
|
e.preventDefault();
|
||||||
// 点击骰子图标:总是重 roll
|
// 点击骰子图标:总是重 roll
|
||||||
const rollResult = rollFormula(formula).result;
|
const rollResult = rollFormula(formula).result;
|
||||||
setResult(rollResult.total);
|
setResult(rollResult.total);
|
||||||
|
|
@ -65,7 +66,8 @@ customElement("md-dice", { key: "" }, (props, { element }) => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleTextClick = () => {
|
const handleTextClick = (e: MouseEvent) => {
|
||||||
|
e.preventDefault();
|
||||||
// 点击文本:总是重置为公式
|
// 点击文本:总是重置为公式
|
||||||
setResult(null);
|
setResult(null);
|
||||||
setIsRolled(false);
|
setIsRolled(false);
|
||||||
|
|
@ -80,17 +82,14 @@ customElement("md-dice", { key: "" }, (props, { element }) => {
|
||||||
return (
|
return (
|
||||||
<span class="inline-flex items-center px-1">
|
<span class="inline-flex items-center px-1">
|
||||||
<span
|
<span
|
||||||
onClick={(e) => {
|
onClick={handleTextClick}
|
||||||
e.preventDefault();
|
|
||||||
handleRoll();
|
|
||||||
}}
|
|
||||||
class="text-blue-600 hover:text-blue-800 cursor-pointer"
|
class="text-blue-600 hover:text-blue-800 cursor-pointer"
|
||||||
title={rollDetail() || "掷骰子"}
|
title={rollDetail() || "掷骰子"}
|
||||||
>
|
>
|
||||||
🎲
|
🎲
|
||||||
</span>
|
</span>
|
||||||
<a
|
<a
|
||||||
onClick={handleTextClick}
|
onClick={handleRoll}
|
||||||
class="cursor-pointer text-gray-700 hover:text-gray-900"
|
class="cursor-pointer text-gray-700 hover:text-gray-900"
|
||||||
title={isRolled() ? "点击重置为公式" : formula}
|
title={isRolled() ? "点击重置为公式" : formula}
|
||||||
>
|
>
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ const marked = new Marked()
|
||||||
renderer(token) {
|
renderer(token) {
|
||||||
if (!token.meta.name) {
|
if (!token.meta.name) {
|
||||||
const style = globalIconPrefix ? `style="--icon-src: url('${globalIconPrefix}/${token.text}.png')"` : '';
|
const style = globalIconPrefix ? `style="--icon-src: url('${globalIconPrefix}/${token.text}.png')"` : '';
|
||||||
return `<icon ${style} class="icon-${token.text}"></icon>`;
|
return `<icon ${style} class="icon-${token.text} ${token.attrs?.class || ""}"></icon>`;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,11 @@ icon, pull{
|
||||||
background-position: center;
|
background-position: center;
|
||||||
background-repeat: no-repeat;
|
background-repeat: no-repeat;
|
||||||
}
|
}
|
||||||
|
icon.mini{
|
||||||
|
width: 1em;
|
||||||
|
height: 1em;
|
||||||
|
vertical-align: bottom;
|
||||||
|
}
|
||||||
pull{
|
pull{
|
||||||
margin-right: -.5em;
|
margin-right: -.5em;
|
||||||
width: 0;
|
width: 0;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue