Skip to content

A bunch of fixes for the next branch #55

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

Merged
merged 4 commits into from
Oct 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion demo/CustomLayout.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<template functional>
<template>
<div class="preview-code">
<div>
<slot name="editor"></slot>
Expand Down
1 change: 1 addition & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const rootConfig = {
"prismjs/components/prism-javascript",
"prismjs/components/prism-jsx",
"@vue/compiler-core/dist/compiler-core.cjs",
"vue"
],
};

Expand Down
1 change: 1 addition & 0 deletions src/Editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ const highlight = (lang, jsxInExamples) => {

export default {
name: "VueLiveEditor",
inheritAttrs: false,
Copy link
Member

Choose a reason for hiding this comment

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

Just curious. Why was this one necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Otherwise the @change defined in VueLive.vue is inherited by PrismEditor component in Editor.vue. Then, when the editor value changes, it trigger the event twice; once by PrismEditor textarea (payload: Event, undesired) and once by the Editor (payload: code string, desired).

Copy link
Member

Choose a reason for hiding this comment

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

Oh !! good call.

components: { PrismEditor },
props: {
code: {
Expand Down
7 changes: 4 additions & 3 deletions src/VueLive.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
/>
</template>
<template v-slot:preview>
<!--
<!--
* Emitted every time the component rendered throws an error
* Catches runtime and compilation errors
* @event error
* @property { Error } - the error thrown
* @property { Error } - the error thrown
-->
<Preview
:key="codeKey"
Expand All @@ -41,6 +41,7 @@
</component>
</template>
<script>
import { markRaw } from "vue";
import hash from "hash-sum";

import Preview from "./Preview.vue";
Expand Down Expand Up @@ -145,7 +146,7 @@ export default {
model: this.code,
lang: "vue",
prismLang: "html",
VueLiveDefaultLayout,
VueLiveDefaultLayout: markRaw(VueLiveDefaultLayout),
/**
* this data only gets changed when changing language.
* it allows for copy and pasting without having the code
Expand Down
2 changes: 1 addition & 1 deletion src/VueLiveDefaultLayout.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<template functional>
<template>
<div class="VueLive-container">
<div class="VueLive-editor">
<slot name="editor" />
Expand Down