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

fix: apply #5147 fix to marks and nodes #5156

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

nperez0111
Copy link
Contributor

@nperez0111 nperez0111 commented May 15, 2024

Changes Overview

As a follow up to #5147
In my previous PR, @634750802 reminded me that Nodes & Marks both have the configure method as well and have almost the exact same logic as extensions. So I applied the change to Nodes & Marks as well

Implementation Approach

See $5147

Testing Done

Ran all tests, everything looks good

Verification Steps

See above

Additional Notes

Checklist

  • I have renamed my PR according to the naming conventions. (e.g. feat: Implement new feature or chore(deps): Update dependencies)
  • My changes do not break the library.
  • I have added tests where applicable.
  • I have followed the project guidelines.
  • I have fixed any lint issues.

Related Issues

Copy link

netlify bot commented May 15, 2024

Deploy Preview for tiptap-embed ready!

Name Link
🔨 Latest commit ff30c34
🔍 Latest deploy log https://app.netlify.com/sites/tiptap-embed/deploys/6650751e7aca6d00087ee34c
😎 Deploy Preview https://deploy-preview-5156--tiptap-embed.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Comment on lines +50 to +64
// addProseMirrorPlugins() {
// console.log('custom', this, this.parent)
// return [
// ...this.parent(),
// ]
// },
})
.configure({ lowlight }),
.configure({ lowlight })
.extend({
addProseMirrorPlugins() {
return [
...this.parent(),
]
},
}),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will need to add more tests for this. Just wanted it out of my mind

@@ -181,7 +181,7 @@ export class ExtensionManager {
let defaultBindings: Record<string, () => boolean> = {}

// bind exit handling
if (extension.type === 'mark' && extension.config.exitable) {
if (extension.type === 'mark' && getExtensionField<AnyConfig['exitable']>(extension, 'exitable')) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per the observation by: #4191 (comment) we should not ever access extension.config to get a field, it needs to just be accessed through this helper that can resolve through inheritance

Comment on lines -239 to -260
/**
* This function extends the schema of the node.
* @example
* extendNodeSchema() {
* return {
* group: 'inline',
* selectable: false,
* }
* }
*/
extendNodeSchema?:
| ((
this: {
name: string
options: Options
storage: Storage
parent: ParentConfig<MarkConfig<Options, Storage>>['extendNodeSchema']
},
extension: Node,
) => Record<string, any>)
| null

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused on a mark

Comment on lines -261 to -283
/**
* This function extends the schema of the mark.
* @example
* extendMarkSchema() {
* return {
* group: 'inline',
* selectable: false,
* }
* }
*/
extendMarkSchema?:
| ((
this: {
name: string
options: Options
storage: Storage
parent: ParentConfig<NodeConfig<Options, Storage>>['extendMarkSchema']
editor?: Editor
},
extension: Node,
) => Record<string, any>)
| null

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused on a node

Comment on lines 459 to 463
const extension = this.extend({
addOptions() {
return mergeDeep(this.parent?.() || {}, options) as Options
},
})
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the secret sauce, a configure is just a short way of expressing additional options to be applied

@@ -23,6 +23,7 @@ import { mergeDeep } from './utilities/mergeDeep.js'

declare module '@tiptap/core' {
interface NodeConfig<Options = any, Storage = any> {
// @ts-ignore allow index signature
[key: string]: any
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I question this type, but we can leave it ignored for now

@@ -75,6 +75,7 @@ export function getSchemaByResolvedExtensions(extensions: Extensions, editor?: E
getExtensionField<NodeConfig['draggable']>(extension, 'draggable', context),
),
code: callOrReturn(getExtensionField<NodeConfig['code']>(extension, 'code', context)),
whitespace: callOrReturn(getExtensionField<NodeConfig['whitespace']>(extension, 'whitespace', context)),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whitespace was not being sent to the schema when it should have been, per: #4191 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Triage open
Development

Successfully merging this pull request may close these issues.

None yet

1 participant