Skip to content

Commit

Permalink
v4.9.4 (#420)
Browse files Browse the repository at this point in the history
## Fixes

- [BUG] Depth issues with md serialize/deserialize #345
- onDestroy Event Not Firing on Delete in Image Extension #427
- [FEATURE] Update UI in TodoList #425
- [FEATURE] Add onPathChange prop to <YooptaEditor /> #422
- [FEATURE] Change text/bg colors with react-colorful picker for highlight mark  #419

## Contribution

Co-authored-by: Guillermo Loaysa <[email protected]>
Co-authored-by: Alexandru Golovatenco <[email protected]>
Co-authored-by: 5andu <[email protected]>
Co-authored-by: Vaishnav Deore <[email protected]>
  • Loading branch information
5 people authored Jan 1, 2025
1 parent 96fc42e commit f577dcc
Show file tree
Hide file tree
Showing 43 changed files with 638 additions and 433 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# Changelog

## [4.9.4] - 2025-01-01

### Added

- `Added color picker to highlight color`
- `Update UI for TodoList`
- `Added _onPathChange_ prop to <YooptaEditor />`

### Fixed

- `Fixed depth issues for Todo/Bulleted/Numbered lists`
- `Fixed indent for lists while serializing in markdown string`
- `Fixed firing _onDestroy_ event after delete block`

## [4.9.3] - 2024-12-27

### Added
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ type YooptaEditor = {
value?: YooptaContentValue;
/* Change handler */
onChange?: (value: YooptaContentValue, options: YooptaOnChangeOptions) => void;
/* Path change handler */
onPathChange?: (path: YooptaPath) => void;
/* autoFocus. [Default] - true */
autoFocus?: boolean;
/* className - class name */
Expand Down
4 changes: 4 additions & 0 deletions packages/core/editor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ type Props = {
/* Style CSS Object. [Default] - { width: 400, paddingBottom: 100 }
*/
style?: number | string;
/* Change handler */
onChange?: (value: YooptaContentValue, options: YooptaOnChangeOptions) => void;
/* Path change handler */
onPathChange?: (path: YooptaPath) => void;
};
```

Expand Down
2 changes: 1 addition & 1 deletion packages/core/editor/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@yoopta/editor",
"version": "4.9.3",
"version": "4.9.4",
"license": "MIT",
"private": false,
"main": "dist/index.js",
Expand Down
3 changes: 3 additions & 0 deletions packages/core/editor/src/YooptaEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export type YooptaEditorProps = {
marks?: YooptaMark<any>[];
value?: YooptaContentValue;
onChange?: (value: YooptaContentValue, options: YooptaOnChangeOptions) => void;
onPathChange?: (path: YooptaPath) => void;
autoFocus?: boolean;
className?: string;
selectionBoxRoot?: HTMLElement | React.MutableRefObject<HTMLElement | null> | false;
Expand Down Expand Up @@ -62,6 +63,7 @@ const YooptaEditor = ({
width,
style,
onChange,
onPathChange,
}: YooptaEditorProps) => {
const marks = useMemo(() => {
if (marksProps) return [FakeSelectionMark, ...marksProps];
Expand Down Expand Up @@ -99,6 +101,7 @@ const YooptaEditor = ({

const onEditorPathChange = useCallback((path: YooptaPath) => {
setStatePath(path);
onPathChange?.(path);
}, []);

const onValueChange = useCallback((value, options: YooptaOnChangeOptions) => {
Expand Down
4 changes: 4 additions & 0 deletions packages/core/editor/src/editor/blocks/deleteBlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ export function deleteBlock(editor: YooEditor, options: DeleteBlockOptions) {
const blockToDelete = editor.children[block.id];
const operations: YooptaOperation[] = [];

const plugin = editor.plugins[blockToDelete.type];
const { onDestroy } = plugin.events || {};
onDestroy?.(editor, blockToDelete.id);

operations.push({
type: 'delete_block',
block: blockToDelete,
Expand Down
1 change: 1 addition & 0 deletions packages/core/editor/src/parsers/getMarkdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export function serialize(editor: YooEditor, blocksData: YooptaBlockData[]) {
element,
// @ts-ignore - fixme
element.children.map((child) => child.text).join(''),
blockData.meta as YooptaBlockBaseMeta,
);
if (serialized) return serialized;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/core/exports/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@yoopta/exports",
"version": "4.9.3",
"version": "4.9.4",
"description": "Serialize/deserialize exports in different formats for Yoopta-Editor",
"author": "Darginec05 <[email protected]>",
"homepage": "https://github.com/Darginec05/Yoopta-Editor#readme",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { MARKDOWN_EDITOR_DEFAULT_VALUE } from './defaultEditorValue';
import CodeMirror, { BasicSetupOptions } from '@uiw/react-codemirror';
import { markdown as codemirrorMarkdown } from '@codemirror/lang-markdown';
import { vscodeDark } from '@uiw/codemirror-theme-vscode';
import jsBeatify from 'js-beautify';

const LANGUAGES_MAP = {
markdown: {
Expand All @@ -41,20 +40,15 @@ type ResultHTMLProps = {

const ResultMD = ({ editor, value }: ResultHTMLProps) => {
const [debounceValue] = useDebounce(value, 1000);
const [markdown, setHTML] = useState<string>('');
const [markdown, setMarkdown] = useState<string>('');

useEffect(() => {
const htmlString = editor.getMarkdown(debounceValue);
const beautifiedMD = jsBeatify.html_beautify(htmlString, {
indent_with_tabs: false,
indent_size: 2,
});

setHTML(beautifiedMD);
const mdString = editor.getMarkdown(debounceValue);
setMarkdown(mdString);
}, [debounceValue]);

const onChange = (value: string) => {
setHTML(value);
setMarkdown(value);
};

return (
Expand Down Expand Up @@ -116,14 +110,9 @@ const MarkdownPreview = () => {
};

const onCopy = () => {
const htmlString = editor.getMarkdown(value);
const beautifiedMD = jsBeatify.html_beautify(htmlString, {
indent_with_tabs: false,
indent_size: 2,
});

copy(beautifiedMD);
console.log(beautifiedMD);
const mdString = editor.getMarkdown(value);
copy(mdString);
console.log(mdString);
window.alert('Markdown content copied to clipboard or logged to console');
};

Expand All @@ -148,7 +137,9 @@ const MarkdownPreview = () => {
<Editor editor={editor} value={value} onChange={onChange} />

<div className="flex items-center space-x-2">
<Button onClick={onCopy}>Get markdown content</Button>
<Button type="button" onClick={onCopy}>
Get markdown content
</Button>
</div>
</div>
</TabsContent>
Expand All @@ -161,7 +152,9 @@ const MarkdownPreview = () => {
</div>
</div>
<div className="flex items-center space-x-2">
<Button onClick={onCopy}>Get markdown content</Button>
<Button type="button" onClick={onCopy}>
Get markdown content
</Button>
</div>
</div>
</TabsContent>
Expand All @@ -177,8 +170,10 @@ const MarkdownPreview = () => {
<div className="mt-[21px] min-h-[400px] rounded-md border bg-muted lg:min-h-[700px]" />
</div>
<div className="flex items-center space-x-2">
<Button onClick={onCopy}>Get markdown</Button>
<Button variant="secondary">
<Button type="button" onClick={onCopy}>
Get markdown
</Button>
<Button type="button" variant="secondary">
{/* @ts-ignore */}
<CounterClockwiseClockIcon className="h-4 w-4" />
</Button>
Expand Down
4 changes: 4 additions & 0 deletions packages/development/src/pages/dev/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import YooptaEditor, {
YooEditor,
YooptaBlockData,
YooptaContentValue,
YooptaPath,
} from '@yoopta/editor';
import { useEffect, useMemo, useRef, useState } from 'react';

Expand Down Expand Up @@ -794,6 +795,8 @@ const BasicExample = () => {
setValue(value);
};

const onPathChange = (path: YooptaPath) => {};

// useEffect(() => {
// editor.withoutSavingHistory(() => {
// const id = generateId();
Expand All @@ -819,6 +822,7 @@ const BasicExample = () => {
style={EDITOR_STYLE}
value={value}
onChange={onChange}
onPathChange={onPathChange}
/>
</div>
</>
Expand Down
15 changes: 10 additions & 5 deletions packages/development/src/utils/yoopta/plugins.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,17 @@ export const YOOPTA_PLUGINS = [
}),
Lists.NumberedList,
Lists.TodoList.extend({
elementProps: {
'todo-list': (props: TodoListElement['props']) => ({
...props,
checked: true,
}),
options: {
HTMLAttributes: {
spellCheck: false,
},
},
// elementProps: {
// 'todo-list': (props: TodoListElement['props']) => ({
// ...props,
// checked: true,
// }),
// },
}),
Embed,
Video.extend({
Expand Down
2 changes: 1 addition & 1 deletion packages/marks/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@yoopta/marks",
"version": "4.9.3",
"version": "4.9.4",
"description": "Marks for Yoopta Editor",
"author": "Darginec05 <[email protected]>",
"homepage": "https://github.com/Darginec05/Yoopta-Editor#readme",
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/accordion/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@yoopta/accordion",
"version": "4.9.3",
"version": "4.9.4",
"description": "Accordion plugin for Yoopta Editor",
"author": "Darginec05 <[email protected]>",
"homepage": "https://github.com/Darginec05/Yoopta-Editor#readme",
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/blockquote/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@yoopta/blockquote",
"version": "4.9.3",
"version": "4.9.4",
"description": "Blockquote plugin for Yoopta Editor",
"author": "Darginec05 <[email protected]>",
"homepage": "https://github.com/Darginec05/Yoopta-Editor#readme",
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/callout/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@yoopta/callout",
"version": "4.9.3",
"version": "4.9.4",
"description": "Callout plugin for Yoopta Editor",
"author": "Darginec05 <[email protected]>",
"homepage": "https://github.com/Darginec05/Yoopta-Editor#readme",
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/code/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@yoopta/code",
"version": "4.9.3",
"version": "4.9.4",
"description": "Code plugin with syntax highlighting for Yoopta Editor",
"author": "Darginec05 <[email protected]>",
"homepage": "https://github.com/Darginec05/Yoopta-Editor#readme",
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/divider/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@yoopta/divider",
"version": "4.9.3",
"version": "4.9.4",
"description": "Divider plugin for Yoopta Editor",
"author": "Darginec05 <[email protected]>",
"homepage": "https://github.com/Darginec05/Yoopta-Editor#readme",
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/embed/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@yoopta/embed",
"version": "4.9.3",
"version": "4.9.4",
"description": "Embed plugin for Yoopta Editor",
"author": "Darginec05 <[email protected]>",
"homepage": "https://github.com/Darginec05/Yoopta-Editor#readme",
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/file/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@yoopta/file",
"version": "4.9.3",
"version": "4.9.4",
"description": "File plugin for Yoopta Editor",
"author": "Darginec05 <[email protected]>",
"homepage": "https://github.com/Darginec05/Yoopta-Editor#readme",
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/headings/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@yoopta/headings",
"version": "4.9.3",
"version": "4.9.4",
"description": "Headings plugin for Yoopta Editor",
"author": "Darginec05 <[email protected]>",
"homepage": "https://github.com/Darginec05/Yoopta-Editor#readme",
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/image/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@yoopta/image",
"version": "4.9.3",
"version": "4.9.4",
"description": "Image plugin for Yoopta Editor",
"author": "Darginec05 <[email protected]>",
"homepage": "https://github.com/Darginec05/Yoopta-Editor#readme",
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/link/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@yoopta/link",
"version": "4.9.3",
"version": "4.9.4",
"description": "Link plugin for Yoopta Editor",
"author": "Darginec05 <[email protected]>",
"homepage": "https://github.com/Darginec05/Yoopta-Editor#readme",
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/lists/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@yoopta/lists",
"version": "4.9.3",
"version": "4.9.4",
"description": "Lists plugin for Yoopta Editor",
"author": "Darginec05 <[email protected]>",
"homepage": "https://github.com/Darginec05/Yoopta-Editor#readme",
Expand Down
Loading

0 comments on commit f577dcc

Please sign in to comment.