Skip to content

Commit

Permalink
fix: πŸ› input chip disappeared in bind mode
Browse files Browse the repository at this point in the history
βœ… Closes: #513
  • Loading branch information
Saul-Mirone committed May 17, 2022
1 parent 84aa915 commit 53d4cfc
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 144 deletions.
4 changes: 2 additions & 2 deletions examples/collaboration/main.ts
Expand Up @@ -3,7 +3,7 @@
import { defaultValueCtx, Editor, rootCtx } from '@milkdown/core';
import { collaborative, collabServiceCtx } from '@milkdown/plugin-collaborative';
import { math } from '@milkdown/plugin-math';
import { commonmark } from '@milkdown/preset-commonmark';
import { gfm } from '@milkdown/preset-gfm';
import { nord } from '@milkdown/theme-nord';
import { WebsocketProvider } from 'y-websocket';
import { Doc } from 'yjs';
Expand Down Expand Up @@ -37,7 +37,7 @@ async function main() {
ctx.set(defaultValueCtx, markdown);
})
.use(nord)
.use(commonmark)
.use(gfm)
.use(math)
.use(collaborative)
.create();
Expand Down
1 change: 1 addition & 0 deletions examples/collaboration/package.json
Expand Up @@ -12,6 +12,7 @@
"@milkdown/core": "workspace:*",
"@milkdown/prose": "workspace:*",
"@milkdown/preset-commonmark": "workspace:*",
"@milkdown/preset-gfm": "workspace:*",
"@milkdown/theme-nord": "workspace:*",
"@milkdown/plugin-math": "workspace:*",
"@milkdown/plugin-collaborative": "workspace:*",
Expand Down
4 changes: 1 addition & 3 deletions packages/plugin-math/src/math-inline/index.ts
Expand Up @@ -173,9 +173,7 @@ export const mathInline = createNode<string, Options>((utils, options) => {
});
if (!inputChipRenderer) return {};
const shouldDisplay = (view: EditorView) => {
return Boolean(
view.hasFocus() && type && findSelectedNodeOfType(view.state.selection, type),
);
return Boolean(type && findSelectedNodeOfType(view.state.selection, type));
};
const getCurrentLink = (view: EditorView) => {
const result = findSelectedNodeOfType(view.state.selection, type);
Expand Down
7 changes: 2 additions & 5 deletions packages/preset-gfm/src/footnote/definition.ts
Expand Up @@ -135,11 +135,8 @@ export const footnoteDefinition = createNode((utils) => {
isBindMode: true,
});
if (!inputChipRenderer) return {};
const shouldDisplay = (view: EditorView) => {
return Boolean(
view.hasFocus() && type && findSelectedNodeOfType(view.state.selection, type),
);
};
const shouldDisplay = (view: EditorView) =>
Boolean(type && findSelectedNodeOfType(view.state.selection, type));
const getCurrentLabel = (view: EditorView) => {
const result = findSelectedNodeOfType(view.state.selection, type);
if (!result) return;
Expand Down
5 changes: 2 additions & 3 deletions packages/preset-gfm/src/footnote/reference.ts
Expand Up @@ -125,9 +125,8 @@ export const footnoteReference = createNode((utils) => {
isBindMode: true,
});
if (!inputChipRenderer) return [];
const shouldDisplay = (view: EditorView) => {
return Boolean(view.hasFocus() && type && findSelectedNodeOfType(view.state.selection, type));
};
const shouldDisplay = (view: EditorView) =>
Boolean(type && findSelectedNodeOfType(view.state.selection, type));
const getCurrentLabel = (view: EditorView) => {
const result = findSelectedNodeOfType(view.state.selection, type);
if (!result) return;
Expand Down

1 comment on commit 53d4cfc

@vercel
Copy link

@vercel vercel bot commented on 53d4cfc May 17, 2022

Choose a reason for hiding this comment

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

Please sign in to comment.