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

[Question] unfold 'details' container by default #291

Closed
pecliu opened this issue Nov 21, 2024 · 5 comments
Closed

[Question] unfold 'details' container by default #291

pecliu opened this issue Nov 21, 2024 · 5 comments
Labels
question Further information is requested wontfix This will not be worked on

Comments

@pecliu
Copy link

pecliu commented Nov 21, 2024

Clear and concise description of the problem

now,details' container in @vuepress/plugin-markdown-hint is folded by default

need config entrance to let it be fold by default

image

Suggested solution

need config entrance to let it be fold by default

Alternative

No response

Additional context

No response

@Mister-Hope
Copy link
Member

  1. If you are not a native English speaker, then providing a copy with mother language would be helpful in some cases.

  2. To let the container being expanded by default, adding the following snippets would be helpful:

// vuepress/client.ts
import { defineClientConfig, useRoute } from 'vuepress/client'

export default defineClientConfig({
  setup() {
    const route = useRoute()

    onMounted() {
      // Toggle all <details> open when path changes
      watch(() => route.path, () => {
        document.querySelectorAll('details').forEach((detail) => {
          detail.open = true
        })
      }, { immediate: true })
    })
  },
})

@Mister-Hope Mister-Hope added question Further information is requested wontfix This will not be worked on labels Nov 21, 2024
@Mister-Hope
Copy link
Member

Mister-Hope commented Nov 21, 2024

@pengzhanbo I don't think it's worthy to be further worked on, RFC here.

IMO, the goal of details is to hide some further explanations out of the main document to make the structure and content clean, while providing an easier way to access these further explanations rather than as attachement.

@pengzhanbo
Copy link
Member

@Mister-Hope I agree with this viewpoint. If the details container needs to be expanded by default, it indicates that what is required in this scenario is not the details container, but rather containers like tip/warning/caution/important.

@pecliu
Copy link
Author

pecliu commented Nov 21, 2024

  1. If you are not a native English speaker, then providing a copy with mother language would be helpful in some cases.
  2. To let the container being expanded by default, adding the following snippets would be helpful:
// vuepress/client.ts
import { defineClientConfig, useRoute } from 'vuepress/client'

export default defineClientConfig({
  setup() {
    const route = useRoute()

    onMounted() {
      // Toggle all <details> open when path changes
      watch(() => route.path, () => {
        document.querySelectorAll('details').forEach((detail) => {
          detail.open = true
        })
      }, { immediate: true })
    })
  },
})

tks, it works! it should be the code below:

  setup() {
    const route = useRoute()
    onMounted(() => {
      // Toggle all <details> open when path changes
      document.querySelectorAll('details').forEach((detail) => {
        detail.open = true
      })
      watch(() => route.path, () => {
        setTimeout(() => {
          document.querySelectorAll('details').forEach((detail) => {
            detail.open = true
          })
        }, 200)
      }, { immediate: true })
    })
  },

@Mister-Hope
Copy link
Member

werid, I think my code should work as I am already asking the watcher to run immediately.

@Mister-Hope Mister-Hope closed this as not planned Won't fix, can't repro, duplicate, stale Nov 21, 2024
@Mister-Hope Mister-Hope changed the title [Feature request] @vuepress/plugin-markdown-hint support 'details' container to unfold by default [Question] unfold 'details' container to by default Nov 21, 2024
@Mister-Hope Mister-Hope changed the title [Question] unfold 'details' container to by default [Question] unfold 'details' container by default Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

3 participants