add codemirror edits

This commit is contained in:
Víctor Losada Hernández
2026-10-09 23:51:32 +02:00
parent bc4f314968
commit 9af8236cdb
3 changed files with 28 additions and 15 deletions
@@ -394,6 +394,8 @@ const CodeEditor = forwardRef(
undo : ()=>undo(viewRef.current), undo : ()=>undo(viewRef.current),
redo : ()=>redo(viewRef.current), redo : ()=>redo(viewRef.current),
find: () => openSearchPanel(viewRef.current),
historySize : ()=>{ historySize : ()=>{
const view = viewRef.current; const view = viewRef.current;
+25 -14
View File
@@ -11,12 +11,13 @@ import Account from './account.navitem.jsx';
const { both: RecentNavItem } = RecentNavItems; const { both: RecentNavItem } = RecentNavItems;
import Nav from './nav.jsx'; import Nav from './nav.jsx';
const Navbar = ({ children, brew, title = '', props }) => { const Navbar = ({ children, brew, editor, title = '', props }) => {
const version = global.version || '0.0.0'; const version = global.version || '0.0.0';
const isMac = navigator.platform.toUpperCase().includes('MAC'); const isMac = navigator.platform.toUpperCase().includes('MAC');
const mod = isMac ? '⌘' : 'Ctrl'; const mod = isMac ? '⌘' : 'Ctrl';
const isBrew = !!brew && brew.shareId; const isBrew = !!brew && brew.shareId;
const account = global.account; const account = global.account;
console.log(editor);
const slots = React.Children.toArray(children).reduce((acc, child) => { const slots = React.Children.toArray(children).reduce((acc, child) => {
if (React.isValidElement(child)) { if (React.isValidElement(child)) {
@@ -83,26 +84,36 @@ const Navbar = ({ children, brew, title = '', props }) => {
return ( return (
<Dropdown groupName={'Edit'} customTrigger={<>Edit</>} icon={null} key={'edit'}> <Dropdown groupName={'Edit'} customTrigger={<>Edit</>} icon={null} key={'edit'}>
<div className='nav-section'> <div className='nav-section'>
{slots.edit} {slots.edit?.props.children}
<Nav.item className='beta' kbd={mod + ' + z'} disabled={!isBrew}> <Nav.item onClick={()=>editor?.undo()} kbd={mod + ' + z'} disabled={!isBrew}>
Undo Undo
</Nav.item> </Nav.item>
<Nav.item className='beta' kbd={mod + ' + Shift + z'} disabled={!isBrew}> <Nav.item onClick={()=>editor?.redo()} kbd={mod + ' + Shift + z'} disabled={!isBrew}>
Redo Redo
</Nav.item> </Nav.item>
<Nav.item className='beta' kbd={mod + ' + x'} disabled={!isBrew}> <Nav.item onClick={()=>editor?.find()} kbd={mod + ' + f'} disabled={!isBrew}>
cut
</Nav.item>
<Nav.item className='beta' kbd={mod + ' + c'} disabled={!isBrew}>
copy
</Nav.item>
<Nav.item className='beta' kbd={mod + ' + v'} disabled={!isBrew}>
paste
</Nav.item>
<Nav.item className='beta' kbd={mod + ' + f'} disabled={!isBrew}>
Find / Replace Find / Replace
</Nav.item> </Nav.item>
<Nav.item onClick={()=>editor?.foldCode()} disabled={!isBrew}>
Fold all lines
</Nav.item>
<Nav.item onClick={()=>editor?.unfoldCode()} disabled={!isBrew}>
Unfold all lines
</Nav.item>
</div> </div>
{/*
<div className="nav-section">
<Nav.item onClick={()=>editor?.cut()} kbd={mod + ' + x'} disabled={!isBrew}>
cut
</Nav.item>
<Nav.item onClick={()=>editor?.copy()} kbd={mod + ' + c'} disabled={!isBrew}>
copy
</Nav.item>
<Nav.item onClick={()=>editor?.paste()} kbd={mod + ' + v'} disabled={!isBrew}>
paste
</Nav.item>
</div>
*/}
</Dropdown> </Dropdown>
); );
}; };
@@ -402,7 +402,7 @@ export default function useCommonEditPageFunctions(dependencies) {
<div className= {`${pageName} sitePage`}> <div className= {`${pageName} sitePage`}>
<Meta name='google-site-verification' content='NwnAQSSJZzAT7N-p5MY6ydQ7Njm67dtbu73ZSyE5Fy4' /> <Meta name='google-site-verification' content='NwnAQSSJZzAT7N-p5MY6ydQ7Njm67dtbu73ZSyE5Fy4' />
{(pageName == 'editPage') && <Meta name='robots' content='noindex, nofollow' />} {(pageName == 'editPage') && <Meta name='robots' content='noindex, nofollow' />}
<Navbar brew={currentBrew} account={global.account}> <Navbar brew={currentBrew} editor={editorRef.current} account={global.account}>
<Navbar.File> <Navbar.File>
{error {error
? (<ErrorNavItem error={error} clearError={clearError} />) : (<Dropdown className='save-menu' customTrigger={<>Save</>}> ? (<ErrorNavItem error={error} clearError={clearError} />) : (<Dropdown className='save-menu' customTrigger={<>Save</>}>