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

Update master to develop #442

Merged
merged 24 commits into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
31a3a6d
Merge pull request #209 from thematters/develop
robertu7 Aug 31, 2020
de4ab47
Merge pull request #245 from thematters/develop
devformatters Nov 9, 2020
8c4ddc3
Merge pull request #263 from thematters/develop
devformatters Jan 19, 2021
1e64aff
Merge pull request #275 from thematters/develop
robertu7 Feb 8, 2021
4118a9c
Merge pull request #280 from thematters/develop
devformatters Feb 22, 2021
fae2edb
Merge pull request #288 from thematters/develop
devformatters Mar 8, 2021
c004e66
Merge pull request #306 from thematters/develop
devformatters Apr 23, 2021
2596059
Merge pull request #383 from thematters/develop
tx0c Oct 13, 2021
177db9b
Merge pull request #386 from thematters/develop
tx0c Oct 18, 2021
87517f1
Merge a3d704c566dde32d0bd777ea2a9996a8b92de9eb into 177db9bff091350eb…
tx0c Dec 23, 2021
33ecca2
Merge 6fbc8d6aa86afc6c7e492f6d8e1e653198ffe3a4 into 87517f17365533609…
tx0c Dec 24, 2021
dd78e51
Merge pull request #408 from thematters/develop
robertu7 Dec 29, 2022
7b9f2eb
Merge pull request #415 from thematters/develop
robertu7 Dec 30, 2022
827b8c6
Merge pull request #418 from thematters/develop
robertu7 Jan 10, 2023
16bb41a
Merge pull request #420 from thematters/develop
robertu7 Jan 10, 2023
0796d35
Merge pull request #428 from thematters/develop
robertu7 May 22, 2023
2ae73ab
Merge pull request #430 from thematters/develop
robertu7 May 23, 2023
aa6949d
Merge pull request #431 from thematters/develop
robertu7 Jun 28, 2023
7dfde1f
Merge pull request #433 from thematters/develop
robertu7 Jun 29, 2023
50bb0d7
Merge pull request #435 from thematters/develop
robertu7 Jun 29, 2023
56b4ab6
Revert "Release: v0.2.1-alpha.1"
robertu7 Sep 13, 2023
32b9282
Merge pull request #440 from thematters/revert-435-develop
robertu7 Sep 13, 2023
547e70f
Revert "Release: v0.2.1-alpha.0"
robertu7 Sep 13, 2023
98a6b24
Merge pull request #441 from thematters/revert-433-develop
robertu7 Sep 13, 2023
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
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.1",
"version": "0.2.0",
"description": "Editor for matters.news",
"author": "https://github.com/thematters",
"homepage": "https://github.com/thematters/matters-editor",
Expand Down
7 changes: 1 addition & 6 deletions src/editors/Article.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,12 @@ export const useArticleEdtor = ({
content,
placeholder,
mentionSuggestion,
maxCaptionLength,
...editorProps
}: UseArticleEditorProps) => {
const { extensions, ...restProps } = editorProps
const editor = useEditor({
extensions: [
...makeArticleEditorExtensions({
placeholder,
mentionSuggestion,
maxCaptionLength,
}),
...makeArticleEditorExtensions({ placeholder, mentionSuggestion }),
...(extensions || []),
],
content,
Expand Down
30 changes: 1 addition & 29 deletions src/editors/extensions/figureAudio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,9 @@ declare module '@tiptap/core' {
}
}

type FigureAudioOptions = {
maxCaptionLength?: number
}

const pluginName = 'figureAudio'

export const FigureAudio = Node.create<FigureAudioOptions>({
export const FigureAudio = Node.create({
name: pluginName,
group: 'block',
content: 'text*',
Expand All @@ -60,12 +56,6 @@ export const FigureAudio = Node.create<FigureAudioOptions>({
// disallows all marks for figcaption
marks: '',

addOptions() {
return {
maxCaptionLength: undefined,
}
},

addAttributes() {
return {
src: {
Expand Down Expand Up @@ -223,24 +213,6 @@ export const FigureAudio = Node.create<FigureAudioOptions>({
return html
},
},
filterTransaction: (transaction, state) => {
// Nothing has changed, ignore it.
if (!transaction.docChanged || !this.options.maxCaptionLength) {
return true
}

try {
const anchorParent = transaction.selection.$anchor.parent
const figcaptionText = anchorParent.content.child(0).text || ''
if (figcaptionText.length > this.options.maxCaptionLength) {
return false
}
} catch (e) {
console.error(e)
}

return true
},
}),
]
},
Expand Down
32 changes: 3 additions & 29 deletions src/editors/extensions/figureEmbed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@ declare module '@tiptap/core' {
}
}

type FigureEmbedOptions = {
maxCaptionLength?: number
}

type NormalizeEmbedURLReturn = {
url: string
provider?:
Expand Down Expand Up @@ -253,7 +249,7 @@ const normalizeEmbedURL = (url: string): NormalizeEmbedURLReturn => {

const pluginName = 'figureEmbed'

export const FigureEmbed = Node.create<FigureEmbedOptions>({
export const FigureEmbed = Node.create({
name: pluginName,
group: 'block',
content: 'text*',
Expand All @@ -263,12 +259,6 @@ export const FigureEmbed = Node.create<FigureEmbedOptions>({
// disallows all marks for figcaption
marks: '',

addOptions() {
return {
maxCaptionLength: undefined,
}
},

addAttributes() {
return {
class: {
Expand Down Expand Up @@ -314,6 +304,8 @@ export const FigureEmbed = Node.create<FigureEmbedOptions>({
...(isCode ? [`embed-code`] : []),
].join(' ')

console.log({ url })

return [
'figure',
{ class: className, ...(provider ? { 'data-provider': provider } : {}) },
Expand Down Expand Up @@ -427,24 +419,6 @@ export const FigureEmbed = Node.create<FigureEmbedOptions>({
return html
},
},
filterTransaction: (transaction, state) => {
// Nothing has changed, ignore it.
if (!transaction.docChanged || !this.options.maxCaptionLength) {
return true
}

try {
const anchorParent = transaction.selection.$anchor.parent
const figcaptionText = anchorParent.content.child(0).text || ''
if (figcaptionText.length > this.options.maxCaptionLength) {
return false
}
} catch (e) {
console.error(e)
}

return true
},
}),
]
},
Expand Down
30 changes: 1 addition & 29 deletions src/editors/extensions/figureImage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,9 @@ declare module '@tiptap/core' {
}
}

type FigureImageOptions = {
maxCaptionLength?: number
}

const pluginName = 'figureImage'

export const FigureImage = Node.create<FigureImageOptions>({
export const FigureImage = Node.create({
name: pluginName,
group: 'block',
content: 'text*',
Expand All @@ -42,12 +38,6 @@ export const FigureImage = Node.create<FigureImageOptions>({
// disallows all marks for figcaption
marks: '',

addOptions() {
return {
maxCaptionLength: undefined,
}
},

addAttributes() {
return {
class: {
Expand Down Expand Up @@ -175,24 +165,6 @@ export const FigureImage = Node.create<FigureImageOptions>({
return html
},
},
filterTransaction: (transaction, state) => {
// Nothing has changed, ignore it.
if (!transaction.docChanged || !this.options.maxCaptionLength) {
return true
}

try {
const anchorParent = transaction.selection.$anchor.parent
const figcaptionText = anchorParent.content.child(0).text || ''
if (figcaptionText.length > this.options.maxCaptionLength) {
return false
}
} catch (e) {
console.error(e)
}

return true
},
}),
]
},
Expand Down
15 changes: 6 additions & 9 deletions src/editors/extensions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,19 +77,17 @@ 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.configure({ maxCaptionLength }),
FigureAudio.configure({ maxCaptionLength }),
FigureEmbed.configure({ maxCaptionLength }),
FigureImage,
FigureAudio,
FigureEmbed,
]

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

if (mentionSuggestion) {
Expand Down
1 change: 1 addition & 0 deletions src/editors/extensions/readOnlyFigureEmbed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ export const ReadOnlyFigureEmbed = Node.create({
...(isCode ? [`embed-code`] : []),
].join(' ')

console.log({ url })

return [
'figure',
Expand Down