Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ZuiEditor frame #2543

Open
wants to merge 28 commits into
base: undocumented/bugs-in-zui-editor
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
599dde9
Press enter to apply href & link text (only if href is valid)
ziggabyte Feb 4, 2025
fb406c8
Padding and size for editor, borders for focused block.
ziggabyte Feb 5, 2025
744e7e1
Handle when the editor is focused and not.
ziggabyte Feb 5, 2025
ccdd955
Add alt and fileId attributes to ImageExtension.
ziggabyte Feb 6, 2025
39b3b5b
Create tested function to transform content of header and paragraph b…
ziggabyte Feb 7, 2025
85027c7
Create tested function to turn remirror editor content into our zetki…
ziggabyte Feb 8, 2025
c0e6a5b
Update a few types.
ziggabyte Feb 9, 2025
ab1cf4c
Create tested function to turn inline nodes into remirror format.
ziggabyte Feb 9, 2025
ce0ea57
Create tested function to turn zetkin block format into remirror bloc…
ziggabyte Feb 9, 2025
17c4edd
Create util type guard function.
ziggabyte Feb 9, 2025
e604510
Create tested function to determine block problems.
ziggabyte Feb 10, 2025
aedba68
Use math.random instead of crypto UUID.
ziggabyte Feb 12, 2025
37904d0
Rename function.
ziggabyte Feb 12, 2025
2f4e377
Make EmailOutline component that displays one list item per editor bl…
ziggabyte Feb 12, 2025
f9ef80a
Add test for default button text.
ziggabyte Feb 12, 2025
8fa8269
Gray background colour on item in outline that represents the current…
ziggabyte Feb 12, 2025
e987a12
Delete everything related to the old email editor.
ziggabyte Feb 12, 2025
bb72b3b
Update to use new editorBlockProblems function.
ziggabyte Feb 12, 2025
102e14a
Move the new editor into the Compose page.
ziggabyte Feb 12, 2025
783fbff
Remove tab used in development of new editor.
ziggabyte Feb 12, 2025
712be9c
Add border between the outline and editor.
ziggabyte Feb 13, 2025
cbd0af7
Show outline and message around blocks with errors.
ziggabyte Feb 13, 2025
91eb5e5
Take empty blocks into consideration when calculating problems.
ziggabyte Feb 13, 2025
ff5b453
Change icon in button block toolbar.
ziggabyte Feb 13, 2025
a4fc777
Fix growing container issue on block list items.
ziggabyte Feb 13, 2025
97881d6
Place selection outline underneath error outline.
ziggabyte Feb 13, 2025
712574d
Only show insert line if mouse is inside editor.
ziggabyte Feb 13, 2025
f530053
Update rpc function to use logic adjusted to new data format.
ziggabyte Feb 13, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
226 changes: 0 additions & 226 deletions src/features/emails/components/EmailEditor/EmailEditorFrontend.tsx

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,57 +1,83 @@
import { Crop75, Image as ImageIcon, Notes, Title } from '@mui/icons-material';
import { FC } from 'react';
import { OutputBlockData } from '@editorjs/editorjs';

import { BLOCK_TYPES } from 'features/emails/types';
import blockProblems from './utils/blockProblems';
import ButtonBlockListItem from './ButtonBlockListItem';
import HeaderBlockListItem from './HeaderBlockListItem';
import ImageBlockListItem from './ImageBlockListItem';
import TextBlockListItem from './TextBlockListItem';
import {
BlockKind,
EmailContentBlock,
EmailContentInlineNode,
InlineNodeKind,
} from 'features/emails/types';
import BlockListItemBase from './BlockListItemBase';
import editorBlockProblems from 'zui/ZUIEditor/utils/editorBlockProblems';
import { useMessages } from 'core/i18n';
import emailMessageIds from 'features/emails/l10n/messageIds';
import editorMessageIds from 'zui/l10n/messageIds';

interface BlockListItemProps {
block: OutputBlockData;
onChange: (newData: OutputBlockData['data']) => void;
readOnly: boolean;
block: EmailContentBlock;
selected: boolean;
}

const BlockListItem: FC<BlockListItemProps> = ({
block,
onChange,
readOnly,
selected,
}) => {
const problems = blockProblems(block);
const BlockListItem: FC<BlockListItemProps> = ({ block, selected }) => {
const emailMessages = useMessages(emailMessageIds);
const editorMessages = useMessages(editorMessageIds.editor);

if (block.type === BLOCK_TYPES.PARAGRAPH) {
const makeTitle = (nodes: EmailContentInlineNode[]): string => {
let text = '';
nodes.forEach((node) => {
if (node.kind == InlineNodeKind.STRING) {
text += node.value;
} else if (node.kind == InlineNodeKind.VARIABLE) {
text += emailMessages.editor.outline.variables[node.name]();
} else if ('content' in node) {
text += makeTitle(node.content);
}
});
return text;
};

if (block.kind === BlockKind.PARAGRAPH) {
const title = makeTitle(block.data.content);
const hasErrors = editorBlockProblems(block);
return (
<BlockListItemBase
hasErrors={hasErrors.length > 0}
icon={Notes}
selected={selected}
title={title}
/>
);
} else if (block.kind === BlockKind.HEADER) {
const title = makeTitle(block.data.content);
return (
<TextBlockListItem
data={block.data}
hasErrors={!!problems.length}
readOnly={readOnly}
<BlockListItemBase
hasErrors={false}
icon={Title}
selected={selected}
title={title}
/>
);
} else if (block.type === BLOCK_TYPES.HEADER) {
return <HeaderBlockListItem data={block.data} selected={selected} />;
} else if (block.type === BLOCK_TYPES.BUTTON) {
} else if (block.kind === BlockKind.BUTTON) {
const hasErrors = editorBlockProblems(
block,
editorMessages.extensions.button.defaultText()
);
return (
<ButtonBlockListItem
data={block.data}
hasErrors={!!problems.length}
onChange={onChange}
readOnly={readOnly}
<BlockListItemBase
hasErrors={hasErrors.length > 0}
icon={Crop75}
selected={selected}
title={block.data.text}
/>
);
} else {
//Is image block
return (
<ImageBlockListItem
data={block.data}
hasErrors={!!problems.length}
onChange={onChange}
readOnly={readOnly}
<BlockListItemBase
hasErrors={false}
icon={ImageIcon}
selected={selected}
title={block.data.alt}
/>
);
}
Expand Down
Loading
Loading