Skip to content
Open
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
15 changes: 14 additions & 1 deletion packages/example/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
<input type="checkbox" name="ln" v-model="readonly" />
Readonly
</label>
<label for="ln" class="ml-4">
<input type="checkbox" name="ln" v-model="fixedHeight" />
Fixed Height
</label>
</div>
<div class="hero-info">
Documentation on
Expand All @@ -26,7 +30,7 @@
</header>
<main class="main max-w-lg mx-auto my-0 p-0">
<Editor
class="my-editor"
:class="editorClasses"
language="html"
v-model="code"
:highlight="highlight"
Expand Down Expand Up @@ -56,9 +60,15 @@ export default {
data: () => ({
lineNumbers: true,
readonly: false,
fixedHeight: false,
/* eslint-disable */
code: require('./example.js').default /* eslint-enable */,
}),
computed: {
editorClasses() {
return this.fixedHeight ? 'my-editor set-height' : 'my-editor';
},
},
methods: {
highlight(code) {
return highlight(
Expand Down Expand Up @@ -87,4 +97,7 @@ export default {
line-height: 1.5;
padding: 5px 10px;
}
.set-height {
height: 20em; /* 20 lines */
}
</style>
14 changes: 13 additions & 1 deletion packages/vue-prism-editor/src/Editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,18 @@ export const PrismEditor = Vue.extend({
},
});
const editorContainer = h('div', { staticClass: 'prism-editor__container' }, [textarea, preview]);
return h('div', { staticClass: 'prism-editor-wrapper' }, [this.lineNumbers && lineNumbers, editorContainer]);
return h(
'div',
{
on: {
click: (): void => {
const input = this.$refs.textarea as HTMLTextAreaElement;
input.focus();
},
},
staticClass: 'prism-editor-wrapper',
},
[this.lineNumbers && lineNumbers, editorContainer]
);
},
});