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

block node and createEditor #173

Open
wants to merge 42 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
9e69051
Add NewTopBlock
Yxwww Aug 19, 2022
c9add62
Add new top block nodeView
Yxwww Aug 22, 2022
03e44c4
Refactor schema naming
Yxwww Aug 23, 2022
7ef537f
Add redux state in new block
Yxwww Aug 24, 2022
caaf4ea
Use decoration for selected block state
Yxwww Aug 25, 2022
882181e
Add ctrl-enter handling for block nodes
Yxwww Aug 26, 2022
685bd0c
Add block nodeview click on to select the block node
Yxwww Aug 26, 2022
644d532
Improve block nodeview selection handling
Yxwww Aug 26, 2022
6a54b8d
Ignore Dropdown toggle mutations
Yxwww Aug 30, 2022
dd3e3c3
Fix ignoreMutation and toggleButonRef
Yxwww Aug 30, 2022
7a9a9a8
Click on block control ui should select block
Yxwww Aug 30, 2022
74cad98
Update demo body margin and padding to 0
Yxwww Aug 30, 2022
1f17b35
Add move block up and down behavior to block control
Yxwww Aug 31, 2022
72efb75
Add copy tex/markdown options
Yxwww Aug 31, 2022
171a678
Ignore dist type in tsconfig
Yxwww Sep 1, 2022
c0658c7
Add plugin to options
Yxwww Sep 2, 2022
c7613ae
Remove state plugin from getPlugins
Yxwww Sep 2, 2022
783e086
Improve split block
Yxwww Sep 6, 2022
a9664ac
Fix block schema
Yxwww Sep 6, 2022
1a7bab5
Add toHTMLAsNode
Yxwww Sep 6, 2022
9e5efca
Add block to id collision avoidance logic
Yxwww Sep 6, 2022
2dad6d2
Add createEditor
Yxwww Sep 8, 2022
d47d16f
Add redux integration to createEditor
Yxwww Sep 9, 2022
0e5f90a
Add registerEdtiorState to createEdtior
Yxwww Sep 9, 2022
b14dd8b
Improve block split
Yxwww Sep 10, 2022
cae44eb
Refactor schemas with parameterized nodeGroup
Yxwww Sep 13, 2022
35f3a61
Use article schema in createEditor
Yxwww Sep 13, 2022
a7a7a72
Revive tex and plaintext example in editor
Yxwww Sep 13, 2022
a9b1f4e
Improve editor demo list rendering
Yxwww Sep 13, 2022
82298dc
Change to use react-router v5
Yxwww Sep 13, 2022
c415856
Fix callout lift not working
Yxwww Sep 14, 2022
c32d120
Ensure code inlineAction to delete figure if it exists
Yxwww Sep 14, 2022
8b87566
Fix caption enter handling
Yxwww Sep 16, 2022
5063ba9
Add test to figcaption
Yxwww Sep 16, 2022
e24cd72
Export deleteNode pm utility
Yxwww Sep 21, 2022
60339cd
update yarn.lock
Yxwww Sep 21, 2022
b139110
Fix figure tests
Yxwww Sep 21, 2022
9a51eff
Fix schema
Yxwww Sep 21, 2022
410cfb5
Improve figure test stability
Yxwww Sep 21, 2022
79d53bb
Optionally turn off callout inline action
rowanc1 Sep 22, 2022
cd7df50
⌨️ Types linting
rowanc1 Sep 26, 2022
f1dbeb9
😎 Node selection if there is a node!
rowanc1 Sep 26, 2022
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
Prev Previous commit
Next Next commit
Add block nodeview click on to select the block node
Yxwww committed Aug 26, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 685bd0c5dd48c9bf1aefc78272963e915aade969
11 changes: 10 additions & 1 deletion packages/editor/src/prosemirror/plugins/state.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { findParentNodeOfTypeClosestToPos } from '@curvenote/prosemirror-utils';
import type { EditorState } from 'prosemirror-state';
import { Plugin, PluginKey } from 'prosemirror-state';
import { NodeSelection, Plugin, PluginKey } from 'prosemirror-state';
import { Decoration, DecorationSet } from 'prosemirror-view';

const key = new PluginKey('state');
@@ -43,6 +43,15 @@ export const statePlugin = (): Plugin => {
decorations(state) {
return this.getState(state).decorations;
},
handleClickOn(view, pos, node, nodePos, event, direct) {
// drect makes sure only directly clicking on a node to set the selection
if (direct && node.type.name === 'block' && !(event.target instanceof HTMLButtonElement)) {
view.dispatch(
view.state.tr.setSelection(new NodeSelection(view.state.doc.resolve(nodePos))),
);
return true; // prevent default from happening if returns true
}
},
handleDOMEvents: {
mouseover(this, view, event) {
// console.log('mouseenter', view.posAtDOM(event.target as HTMLElement, 0));