SHA256
Улучшить ссылки и прокрутку личных чатов
This commit is contained in:
@@ -70,7 +70,7 @@ export function tokenizeShineMessageLinks(text, options = {}) {
|
||||
return tokens;
|
||||
}
|
||||
|
||||
export function appendShineMessageLinks(root, text, { navigate, viewMode = 'thread', appendText } = {}) {
|
||||
export function appendShineMessageLinks(root, text, { navigate, onExternalLink, viewMode = 'thread', appendText } = {}) {
|
||||
for (const token of tokenizeShineMessageLinks(text, { viewMode })) {
|
||||
if (token.type === 'text') {
|
||||
if (typeof appendText === 'function') appendText(root, token.value);
|
||||
@@ -87,6 +87,12 @@ export function appendShineMessageLinks(root, text, { navigate, viewMode = 'thre
|
||||
}
|
||||
link.addEventListener('click', (event) => {
|
||||
event.stopPropagation();
|
||||
if (token.type === 'external' && typeof onExternalLink === 'function'
|
||||
&& event.button === 0 && !event.ctrlKey && !event.metaKey && !event.shiftKey && !event.altKey) {
|
||||
event.preventDefault();
|
||||
onExternalLink({ href: token.href, value: token.value });
|
||||
return;
|
||||
}
|
||||
if (token.type === 'internal' && typeof navigate === 'function'
|
||||
&& event.button === 0 && !event.ctrlKey && !event.metaKey && !event.shiftKey && !event.altKey) {
|
||||
event.preventDefault();
|
||||
|
||||
@@ -7,6 +7,16 @@ export function setSolanaCluster(value) {
|
||||
cluster = next;
|
||||
}
|
||||
export function getSolanaCluster() { return cluster; }
|
||||
export function makeSolanaExplorerTxUrl(signature, endpoint = '') {
|
||||
const cleanSignature = String(signature || '').trim();
|
||||
if (!cleanSignature) return '';
|
||||
const configured = getSolanaCluster();
|
||||
const source = String(endpoint || '').trim().toLowerCase();
|
||||
const network = configured || (source.includes('devnet') ? 'devnet' : source.includes('testnet') ? 'testnet' : 'mainnet-beta');
|
||||
const url = new URL(`https://explorer.solana.com/tx/${encodeURIComponent(cleanSignature)}`);
|
||||
if (network !== 'mainnet-beta') url.searchParams.set('cluster', network);
|
||||
return url.toString();
|
||||
}
|
||||
export function rpcEndpointFromShineHttp(httpBase) {
|
||||
const base = String(httpBase || '').trim();
|
||||
if (!/^https?:\/\//i.test(base)) throw new Error('SHiNE server HTTP address is unavailable');
|
||||
|
||||
Reference in New Issue
Block a user