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

Switch between editor and preview #194

Open
merijnponzo opened this issue Mar 26, 2021 · 1 comment
Open

Switch between editor and preview #194

merijnponzo opened this issue Mar 26, 2021 · 1 comment

Comments

@merijnponzo
Copy link

In the current version both content and preview is shown.
It would be super nice if there would be an edit and preview button in the top toolbar of each block to switch between either editing, or previewing the content

@merijnponzo
Copy link
Author

merijnponzo commented Mar 27, 2021

And with an extra previewServerCallback for example onToggle
this would mean I can properly mount my Vue components
Now I use onChange and they are mounted on every change :-|

for example 'lzb.components.PreviewServerCallback.onToggle'
with a props.toggleMode = 'preview'

// lazyblocks components
const LazyblockComponents = ['tabs']
  wp.hooks.addAction(
    'lzb.components.PreviewServerCallback.onToggle',
    comp,
    function (props) {
      const el = document.getElementsByClassName(
        props.attributes.blockUniqueClass
      )
      if (el.length && props.toggleMode === 'preview' ) {
        const app = createApp({ template: preview[0].innerHTML })
        app.component('Tabs', Tabs)
        app.mount(preview[0])
      }
    })

Like this :-)
lazyblocks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant