Skip to content

Commit

Permalink
feat: added ability to pass marks to updateAttributes method of React…
Browse files Browse the repository at this point in the history
…NodeView
  • Loading branch information
smsochneg committed Jan 25, 2024
1 parent 3a62b9b commit e5de73a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/react-utils/react-node-view.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';

import type {Node} from 'prosemirror-model';
import type {Mark, Node} from 'prosemirror-model';
import type {EditorView, NodeView, NodeViewConstructor} from 'prosemirror-view';
import {createPortal} from 'react-dom';

Expand All @@ -17,7 +17,7 @@ export const ReactNodeStopEventCn = 'prosemirror-stop-event';
export type ReactNodeViewProps<T extends object = {}> = {
dom: HTMLElement;
view: EditorView;
updateAttributes: (attrs: object) => void;
updateAttributes: (attrs: object, marks?: Mark[]) => void;
node: Node;
getPos: () => number | undefined;
serializer: Serializer;
Expand Down Expand Up @@ -94,15 +94,15 @@ export class ReactNodeView<T extends object = {}> implements NodeView {
return true;
}

updateAttributes(attributes: {}) {
updateAttributes(attributes: {}, marks: Mark[] = []) {
const pos = this.getPos();
if (pos === undefined) return;

const {tr} = this.view.state;
tr.setNodeMarkup(pos, undefined, {

Check failure on line 102 in src/react-utils/react-node-view.tsx

View workflow job for this annotation

GitHub Actions / Verify Files

Replace `pos,·undefined,` with `⏎············pos,⏎············undefined,⏎···········`
...this.node.attrs,

Check failure on line 103 in src/react-utils/react-node-view.tsx

View workflow job for this annotation

GitHub Actions / Verify Files

Insert `····`
...attributes,

Check failure on line 104 in src/react-utils/react-node-view.tsx

View workflow job for this annotation

GitHub Actions / Verify Files

Insert `····`
});
}, marks);

Check failure on line 105 in src/react-utils/react-node-view.tsx

View workflow job for this annotation

GitHub Actions / Verify Files

Replace `},·marks` with `····},⏎············marks,⏎········`
this.view.dispatch(tr);
}

Expand Down

0 comments on commit e5de73a

Please sign in to comment.