if (item.type === "user") {
return {
id: `@${item.username}`,
- text: item.username,
+ text: `@${item.username}`,
icon: item.avatarTag,
objectId: item.userID,
type: item.type,
} else {
return {
id: `@${item.name}`,
- text: item.name,
+ text: `@${item.name}`,
icon: '<fa-icon name="users"></fa-icon>',
objectId: item.groupID,
type: item.type,
}
// check if node is within a code element or link
- if ($this->hasCodeParent($node) || $this->hasLinkParent($node)) {
+ if ($this->hasCodeParent($node) || $this->hasLinkParent($node) || $this->hasMentionParent($node)) {
continue;
}
return false;
}
+ protected function hasMentionParent(\DOMText $text): bool
+ {
+ $parent = $text;
+ while ($parent = $parent->parentNode) {
+ if ($parent->nodeName !== 'woltlab-metacode') {
+ continue;
+ }
+
+ \assert($parent instanceof \DOMElement);
+ $type = $parent->getAttribute('data-name');
+ if ($type === 'user' || $type === 'group') {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
/**
* Uses string markers to replace the matched text. This process prevents multiple
* detections being applied to the same target and enables us to delay replacement.
background-color: var(--wcfSidebarBackground);
border-radius: 2px;
padding: 1px 5px;
+}
- &::before {
- content: "@";
- /* avoids breaks between the '@' and the username, but still allows
+.userMention::before {
+ content: "@";
+ /* avoids breaks between the '@' and the username, but still allows
wrapping inside the username itself */
- display: inline-block;
- }
+ display: inline-block;
}