Skip to content

Commit

Permalink
Merge pull request #435 from thematters/develop
Browse files Browse the repository at this point in the history
Release: v0.2.1-alpha.1
  • Loading branch information
robertu7 authored Jun 29, 2023
2 parents 7dfde1f + 6c4efbb commit 50bb0d7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@matters/matters-editor",
"version": "0.2.1-alpha.0",
"version": "0.2.1-alpha.1",
"description": "Editor for matters.news",
"author": "https://github.com/thematters",
"homepage": "https://github.com/thematters/matters-editor",
Expand Down
7 changes: 6 additions & 1 deletion src/editors/Article.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,17 @@ export const useArticleEdtor = ({
content,
placeholder,
mentionSuggestion,
maxCaptionLength,
...editorProps
}: UseArticleEditorProps) => {
const { extensions, ...restProps } = editorProps
const editor = useEditor({
extensions: [
...makeArticleEditorExtensions({ placeholder, mentionSuggestion }),
...makeArticleEditorExtensions({
placeholder,
mentionSuggestion,
maxCaptionLength,
}),
...(extensions || []),
],
content,
Expand Down
15 changes: 9 additions & 6 deletions src/editors/extensions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,19 @@ const baseArticleExtensions = (placeholder?: string) => [
export type MakeArticleEditorExtensionsProps = {
placeholder?: string
mentionSuggestion?: MentionSuggestion
maxCaptionLength?: number
}

export const makeArticleEditorExtensions = ({
placeholder,
mentionSuggestion,
maxCaptionLength,
}: MakeArticleEditorExtensionsProps) => {
const extensions = [
...baseArticleExtensions(placeholder),
FigureImage,
FigureAudio,
FigureEmbed,
FigureImage.configure({ maxCaptionLength }),
FigureAudio.configure({ maxCaptionLength }),
FigureEmbed.configure({ maxCaptionLength }),
]

if (mentionSuggestion) {
Expand All @@ -100,12 +102,13 @@ export const makeArticleEditorExtensions = ({
export const makeEditArticleEditorExtensions = ({
placeholder,
mentionSuggestion,
maxCaptionLength,
}: MakeArticleEditorExtensionsProps) => {
const extensions = [
...baseArticleExtensions(placeholder),
ReadOnlyFigureImage,
ReadOnlyFigureAudio,
ReadOnlyFigureEmbed,
ReadOnlyFigureImage.configure({ maxCaptionLength }),
ReadOnlyFigureAudio.configure({ maxCaptionLength }),
ReadOnlyFigureEmbed.configure({ maxCaptionLength }),
]

if (mentionSuggestion) {
Expand Down

0 comments on commit 50bb0d7

Please sign in to comment.