mirror of https://github.com/sylv/micro.git
Compare commits
5 Commits
1e8a2b64f4
...
26f6faf3de
Author | SHA1 | Date |
---|---|---|
ryan | 26f6faf3de | |
ryan | fe679ce54d | |
ryan | c4daa968c6 | |
ryan | 7bd3b8c7e1 | |
ryan | c320196ee8 |
|
@ -54,7 +54,9 @@ export class Invite {
|
|||
@Property({ persist: false })
|
||||
@Field(() => String)
|
||||
get url() {
|
||||
return `${config.rootHost.url}/${this.path}`;
|
||||
const url = new URL(config.rootHost.url);
|
||||
url.pathname = this.path;
|
||||
return url;
|
||||
}
|
||||
|
||||
[OptionalProps]: 'url' | 'path' | 'consumed' | 'expired' | 'createdAt' | 'skipVerification';
|
||||
|
|
|
@ -39,6 +39,7 @@ export const EmbedText = ({ data }: { data: Embeddable }) => {
|
|||
|
||||
EmbedText.embeddable = (data: Embeddable) => {
|
||||
if (data.type.startsWith('text/')) return true;
|
||||
if (data.type === 'application/json') return true;
|
||||
if (getFileLanguage(data.displayName)) return true;
|
||||
if (data.size > MAX_SIZE) return false;
|
||||
return false;
|
||||
|
|
|
@ -10,7 +10,7 @@ export const TextArea = React.forwardRef<HTMLTextAreaElement, TextAreaProps>(({
|
|||
return (
|
||||
<InputContainer className={className} maxHeight={false} childProps={delegated}>
|
||||
{({ childClasses, ...rest }) => {
|
||||
const classes = classNames(childClasses, 'h-[40vh]');
|
||||
const classes = classNames(childClasses, 'h-[50vh]');
|
||||
return <textarea {...rest} className={classes} ref={ref} />;
|
||||
}}
|
||||
</InputContainer>
|
||||
|
|
|
@ -20,33 +20,35 @@ export const SyntaxHighlighterControls = memo<SyntaxHighlighterControlsProps>(
|
|||
};
|
||||
|
||||
return (
|
||||
<div className="absolute right-0 top-0 flex items-center gap-2 z-10 bg-black bg-opacity-75 hover:bg-opacity-100 rounded-bl-lg pl-2 pb-2">
|
||||
<Menu as="div" className="relative">
|
||||
<Menu.Button className="text-xs flex items-center gap-1 text-gray-500 hover:text-white transition pt-2 ">
|
||||
{language} <ChevronDown className="h-4 w-4" />
|
||||
</Menu.Button>
|
||||
<Menu.Items className="absolute top-full mt-3 bg-gray-900 text-sm max-h-44 overflow-y-scroll text-xs right-0 rounded">
|
||||
{languages.map((language) => (
|
||||
<Menu.Item
|
||||
as="div"
|
||||
key={language.name}
|
||||
className="text-gray-400 hover:text-white transition cursor-pointer truncate px-3 py-1 hover:bg-gray-800"
|
||||
onClick={() => {
|
||||
onLanguageChange(language.key as Language);
|
||||
}}
|
||||
>
|
||||
{language.name}
|
||||
</Menu.Item>
|
||||
))}
|
||||
</Menu.Items>
|
||||
</Menu>
|
||||
<button
|
||||
type="button"
|
||||
className="text-xs text-gray-500 hover:text-white transition pr-3 pt-2"
|
||||
onClick={copyContent}
|
||||
>
|
||||
Copy
|
||||
</button>
|
||||
<div className="absolute right-0 top-0">
|
||||
<div className="fixed -translate-x-full flex items-center gap-2 z-10 bg-black bg-opacity-75 hover:bg-opacity-100 rounded-bl-lg pl-2 pb-2">
|
||||
<Menu as="div" className="relative">
|
||||
<Menu.Button className="text-xs flex items-center gap-1 text-gray-500 hover:text-white transition pt-2 ">
|
||||
{language} <ChevronDown className="h-4 w-4" />
|
||||
</Menu.Button>
|
||||
<Menu.Items className="absolute top-full mt-3 bg-gray-900 text-sm max-h-44 overflow-y-scroll text-xs right-0 rounded">
|
||||
{languages.map((language) => (
|
||||
<Menu.Item
|
||||
as="div"
|
||||
key={language.name}
|
||||
className="text-gray-400 hover:text-white transition cursor-pointer truncate px-3 py-1 hover:bg-gray-800"
|
||||
onClick={() => {
|
||||
onLanguageChange(language.key as Language);
|
||||
}}
|
||||
>
|
||||
{language.name}
|
||||
</Menu.Item>
|
||||
))}
|
||||
</Menu.Items>
|
||||
</Menu>
|
||||
<button
|
||||
type="button"
|
||||
className="text-xs text-gray-500 hover:text-white transition pr-3 pt-2"
|
||||
onClick={copyContent}
|
||||
>
|
||||
Copy
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -27,11 +27,11 @@ export const SyntaxHighlighter = memo<SyntaxHighlighterProps>(
|
|||
);
|
||||
|
||||
return (
|
||||
<pre className={containerClasses} style={style} {...rest}>
|
||||
<pre className={containerClasses} style={{ ...style, whiteSpace: 'nowrap', overflowX: 'auto' }} {...rest}>
|
||||
<SyntaxHighlighterControls language={language} onLanguageChange={setLanguage} content={children} />
|
||||
{tokens.map((line, index) => {
|
||||
const props = getLineProps({ line, key: index });
|
||||
const classes = classNames(props.className, 'table-row whitespace-pre-wrap');
|
||||
const classes = classNames(props.className, 'table-row');
|
||||
|
||||
return (
|
||||
// handled by getLineProps
|
||||
|
|
|
@ -24,7 +24,8 @@ export default function ViewPaste() {
|
|||
const [missingKey, setMissingKey] = useState(false);
|
||||
const pasteId = router.query.pasteId as string | undefined;
|
||||
const paste = useGetPasteQuery({
|
||||
skip: !confirmedBurn && (burnUnless === undefined || (burnUnless ? burnUnless !== user.data?.id : false)),
|
||||
skip:
|
||||
!pasteId || (!confirmedBurn && (burnUnless === undefined || (burnUnless ? burnUnless !== user.data?.id : false))),
|
||||
variables: {
|
||||
pasteId: pasteId!,
|
||||
},
|
||||
|
@ -122,7 +123,7 @@ export default function ViewPaste() {
|
|||
)}
|
||||
<Embed
|
||||
data={{
|
||||
type: paste.data.paste.type,
|
||||
type: 'text/plain',
|
||||
size: paste.data.paste.content.length,
|
||||
displayName: paste.data.paste.title ?? `${paste.data.paste.id}.${paste.data.paste.extension}`,
|
||||
content: { data: content, error: error },
|
||||
|
|
|
@ -102,7 +102,7 @@ export default function Paste() {
|
|||
title: undefined,
|
||||
content: '',
|
||||
encrypt: false,
|
||||
extension: 'md',
|
||||
extension: 'txt',
|
||||
burn: false,
|
||||
paranoid: false,
|
||||
hostname: undefined,
|
||||
|
|
|
@ -29,9 +29,3 @@
|
|||
background-color: rgba(0, 0, 0, 0);
|
||||
border-color: transparent;
|
||||
}
|
||||
|
||||
code[class*='language-'],
|
||||
pre[class*='language-'] {
|
||||
white-space: normal !important;
|
||||
word-break: break-word !important;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue