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

[Bug] Brackets not rendered as checkbox but disappear (Vue 3 + gfm) #991

Closed
2 tasks done
kkalle opened this issue May 3, 2023 · 5 comments
Closed
2 tasks done

[Bug] Brackets not rendered as checkbox but disappear (Vue 3 + gfm) #991

kkalle opened this issue May 3, 2023 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@kkalle
Copy link

kkalle commented May 3, 2023

Initial checklist

  • I agree to follow the code of conduct
  • I searched issues and discussions and couldn’t find anything (or linked relevant results below)

Affected packages and versions

7.2.1

Link to runnable example

No response

Steps to reproduce

Code:

<!-- Milkdown.vue -->
<script setup>
import { Milkdown, useEditor } from "@milkdown/vue";
import { defaultValueCtx, Editor, rootCtx } from "@milkdown/core";
import { replaceAll } from "@milkdown/utils";
import { commonmark } from "@milkdown/preset-commonmark";
import { gfm } from "@milkdown/preset-gfm";
import { defineProps, watch } from "vue";
import "prosemirror-view/style/prosemirror.css";

const props = defineProps({
  markdown: {
    type: String,
    default: "",
  },
});

const editor = useEditor((root) => {
  return Editor.make()
    .config((ctx) => {
      ctx.set(rootCtx, root);
      ctx.set(defaultValueCtx, props.markdown);
    })
    .use(commonmark)
    .use(gfm);
});

</script>

<template>
  <Milkdown />
</template>

Type this in the editor:
- [ ] Task 1

Expected behavior

Show bullet point with checkbox and text "Task 1"

Actual behavior

Brackets [ ] disappear immediately after hitting space after the brackets. There is no checkbox.

HTML rendering changes to this:
<li data-item-type="task" data-label="•" data-list-type="bullet" data-spread="false" data-checked="false"><p>Task 1</p></li>

Runtime

Chrome

OS

macOS

Build and bundle tools

Vite

@kkalle kkalle added the bug Something isn't working label May 3, 2023
@kkalle kkalle changed the title [Bug] [Bug] Brackets not rendered as checkbox but disappear (Vue 3 + gfm) May 3, 2023
@Saul-Mirone
Copy link
Member

It's by design, you need to write your own node view renderer like what we did in documentation website.

@kkalle
Copy link
Author

kkalle commented May 3, 2023

OK, thanks @Saul-Mirone. Could you point me to the right place in the documentation, please? I could not find this in the docs.

@Saul-Mirone
Copy link
Member

https://github.com/Milkdown/website/blob/main/src/components/playground-editor/editor-component/ListItem.tsx

@Saul-Mirone
Copy link
Member

@knownasilya
Copy link

knownasilya commented Jul 26, 2023

Tried the provided code, nodeViewFactory is called, but nothing renders and the component passed is not in the DOM. Not sure what's up, using 7.2.4 for all deps. I'm doing this in React, not vue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants