This commit is contained in:
Víctor Losada Hernández
2026-10-19 13:18:57 +02:00
parent 8cb8522635
commit 30fc8252a4
@@ -1,7 +1,6 @@
/* eslint-disable max-lines */ /* eslint-disable max-lines */
import '../uiEditor.less'; import '../uiEditor.less';
import React, {useState, useEffect} from 'react'; import React, { useState } from 'react';
import createReactClass from 'create-react-class';
import _ from 'lodash'; import _ from 'lodash';
import request from '../../utils/request-middleware.js'; import request from '../../utils/request-middleware.js';
import Combobox from '@components/combobox.jsx'; import Combobox from '@components/combobox.jsx';
@@ -20,27 +19,26 @@ const callIfExists = (val, fn, ...args)=>{
const MetadataEditor = ({ const MetadataEditor = ({
metadata = { metadata = {
editId: null, editId : null,
shareId: null, shareId : null,
title: '', title : '',
description: '', description : '',
thumbnail: '', thumbnail : '',
tags: [], tags : [],
published: false, published : false,
authors: [], authors : [],
renderer: 'legacy', renderer : 'legacy',
theme: '5ePHB', theme : '5ePHB',
lang: 'en', lang : 'en',
}, },
onChange = () => {}, onChange = ()=>{},
reportError = () => {}, reportError = ()=>{},
}, ...props) => { }, ...props)=>{
const [isOwner, setIsOwner] = useState(global.account?.username && global.account?.username === metadata?.authors[0]); const [isOwner, setIsOwner] = useState(global.account?.username && global.account?.username === metadata?.authors[0]);
const [showThumbnail, setShowThumbnail] = useState(true); const [showThumbnail, setShowThumbnail] = useState(true);
const toggleThumbnailDisplay = ()=>{ const toggleThumbnailDisplay = ()=>{
setShowThumbnail(!showThumbnail); setShowThumbnail(!showThumbnail);
}; };
@@ -96,7 +94,7 @@ const MetadataEditor = ({
onChange(metadata, 'theme'); onChange(metadata, 'theme');
}; };
const handleThemeWritein = (e) =>{ const handleThemeWritein = (e)=>{
const shareId = e.target.value.split('/').pop(); //Extract just the ID if a URL was pasted in const shareId = e.target.value.split('/').pop(); //Extract just the ID if a URL was pasted in
metadata.theme = shareId; metadata.theme = shareId;
@@ -329,7 +327,6 @@ const MetadataEditor = ({
</div>; </div>;
}; };
return ( return (
<div className='metadataEditor uiEditor'> <div className='metadataEditor uiEditor'>
<h1>Properties Editor</h1> <h1>Properties Editor</h1>
@@ -341,7 +338,7 @@ const MetadataEditor = ({
id='title_field' id='title_field'
className='value' className='value'
defaultValue={metadata.title} defaultValue={metadata.title}
onChange={(e) => handleFieldChange('title', e)} onChange={(e)=>handleFieldChange('title', e)}
/> />
</div> </div>
<fieldset className='field-group'> <fieldset className='field-group'>
@@ -352,7 +349,7 @@ const MetadataEditor = ({
id='description_field' id='description_field'
defaultValue={metadata.description} defaultValue={metadata.description}
className='value' className='value'
onChange={(e) => handleFieldChange('description', e)} onChange={(e)=>handleFieldChange('description', e)}
/> />
</div> </div>
<div className='field thumbnail'> <div className='field thumbnail'>
@@ -363,7 +360,7 @@ const MetadataEditor = ({
defaultValue={metadata.thumbnail} defaultValue={metadata.thumbnail}
placeholder='https://my.thumbnail.url' placeholder='https://my.thumbnail.url'
className='value' className='value'
onChange={(e) => handleFieldChange('thumbnail', e)} onChange={(e)=>handleFieldChange('thumbnail', e)}
/> />
<button <button
className='display' className='display'
@@ -386,7 +383,7 @@ const MetadataEditor = ({
placeholder='add tag' placeholder='add tag'
unique={true} unique={true}
values={metadata.tags} values={metadata.tags}
onChange={(e) => handleFieldChange('tags', e)} onChange={(e)=>handleFieldChange('tags', e)}
tooltip='You may start tags with "type", "system", "group" or "meta" followed by a colon ":", these will be colored in your userpage.' tooltip='You may start tags with "type", "system", "group" or "meta" followed by a colon ":", these will be colored in your userpage.'
/> />
</div> </div>
@@ -409,13 +406,13 @@ const MetadataEditor = ({
id='combobox-invited-authors' id='combobox-invited-authors'
label='invited authors' label='invited authors'
valuePatterns={/.+/} valuePatterns={/.+/}
validators={[(v) => !metadata.authors?.includes(v)]} validators={[(v)=>!metadata.authors?.includes(v)]}
placeholder='invite author' placeholder='invite author'
unique={true} unique={true}
tooltip={`Invited author usernames are case sensitive. tooltip={`Invited author usernames are case sensitive.
After adding an invited author, send them the edit link. There, they can choose to accept or decline the invitation.`} After adding an invited author, send them the edit link. There, they can choose to accept or decline the invitation.`}
values={metadata.invitedAuthors} values={metadata.invitedAuthors}
onChange={(e) => handleFieldChange('invitedAuthors', e)} onChange={(e)=>handleFieldChange('invitedAuthors', e)}
/> />
</div> </div>
</div> </div>