Coder Social home page Coder Social logo

koca / vue-prism-editor Goto Github PK

View Code? Open in Web Editor NEW
751.0 8.0 84.0 1.74 MB

A dead simple code editor with syntax highlighting and line numbers. 3kb/gz

Home Page: https://prism-editor.netlify.com

License: MIT License

JavaScript 8.11% HTML 1.50% Vue 5.86% CSS 6.79% TypeScript 77.74%
vue pwa prismjs editor component

vue-prism-editor's Introduction

Vue Prism Editor

Bundle size (minified + gzip) NPM Downloads Build Status Codecov Version MIT License

A dead simple code editor with syntax highlighting and line numbers. 3kb/z

prism-editor

Editor works both for Vue 2.x and Vue 3.x and you are currently on the branch that supports Vue 2.x. Go here for the Vue 3.x compatible version

Demo

prism-editor.netlify.com

Examples

Features

  • Code Editing
  • Modular syntax highlighting with third party library (not limited to prismjs)
  • Indent line or selected text by pressing tab key, with customizable indentation
  • Automatic indent on new lines
  • Wrap selected text in parens, brackets, or quotes
  • Undo / Redo whole words instead of letter by letter
  • Accessible, use Ctrl+Shift+M (Mac) / Ctrl+M to toggle capturing tab key
  • Works on mobile (thanks to textarea)
  • Auto resize
  • Line numbers
  • Match line numbers styles to the theme(optional)

Use Case

Several browser based code editors such as Ace, CodeMirror, Monaco etc. provide the ability to embed a full-featured code editor in your web page. However, if you just need a simple editor with syntax highlighting without any of the extra features, they can be overkill as they don't usually have a small bundle size footprint. This library aims to provide a simple code editor with syntax highlighting support without any of the extra features, perfect for simple embeds and forms where users can submit code.

Install

npm install vue-prism-editor

or

yarn add vue-prism-editor

Usage

You need to use the editor with a third party library which provides syntax highlighting. For example, it'll look like following with prismjs:

Register the component locally and use it (recommended)

<template>
  <prism-editor class="my-editor" v-model="code" :highlight="highlighter" line-numbers></prism-editor>
</template>

<script>
  // import Prism Editor
  import { PrismEditor } from 'vue-prism-editor';
  import 'vue-prism-editor/dist/prismeditor.min.css'; // import the styles somewhere

  // import highlighting library (you can use any library you want just return html string)
  import { highlight, languages } from 'prismjs/components/prism-core';
  import 'prismjs/components/prism-clike';
  import 'prismjs/components/prism-javascript';
  import 'prismjs/themes/prism-tomorrow.css'; // import syntax highlighting styles

  export default {
    components: {
      PrismEditor,
    },
    data: () => ({ code: 'console.log("Hello World")' }),
    methods: {
      highlighter(code) {
        return highlight(code, languages.js); // languages.<insert language> to return html with markup
      },
    },
  };
</script>

<style>
  /* required class */
  .my-editor {
    /* we dont use `language-` classes anymore so thats why we need to add background and text color manually */
    background: #2d2d2d;
    color: #ccc;

    /* you must provide font-family font-size line-height. Example: */
    font-family: Fira code, Fira Mono, Consolas, Menlo, Courier, monospace;
    font-size: 14px;
    line-height: 1.5;
    padding: 5px;
  }

  /* optional class for removing the outline */
  .prism-editor__textarea:focus {
    outline: none;
  }
</style>

Note that depending on your syntax highlighter, you might have to include additional CSS for syntax highlighting to work.

Or register the component globally

import { PrismEditor } from 'vue-prism-editor';
import 'vue-prism-editor/dist/prismeditor.min.css'; // import the styles
Vue.component('PrismEditor', PrismEditor);

Browser usage (for codepen etc.):

<script src="https://unpkg.com/[email protected].*"></script>

<!-- Prism Editor -->
<script src="https://unpkg.com/vue-prism-editor"></script>
<link rel="stylesheet" href="https://unpkg.com/vue-prism-editor/dist/prismeditor.min.css" />

<!-- custom highlighter: -->
<script src="https://unpkg.com/prismjs/prism.js"></script>
<link rel="stylesheet" href="https://unpkg.com/prismjs/themes/prism-tomorrow.css" />

<style>
  .height-200{
    height: 200px  
  }
  
  .my-editor {
    /* we dont use `language-` classes anymore so thats why we need to add background and text color manually */
    background: #2d2d2d;
    color: #ccc;

    /* you must provide font-family font-size line-height. Example:*/
    font-family: Fira code, Fira Mono, Consolas, Menlo, Courier, monospace;
    font-size: 14px;
    line-height: 1.5;
    padding: 5px;
  }

  /* optional class for removing the outline */
  .prism-editor__textarea:focus {
    outline: none;
  }
</style>

<div id="app">
  <prism-editor class="my-editor height-200" v-model="code" :highlight="highlighter" line-numbers></prism-editor>
</div>

<script>
  new Vue({
    el: "#app",
    data: () => ({
      code: "console.log('hello world')"
    }),
    methods: {
      highlighter(code) {
        // js highlight example
        return Prism.highlight(code, Prism.languages.js, "js");
      }
    },
  })
</script>

Props

Name Type Default Options Description
v-model value string "" - Current value of the editor i.e. the code to display
highlight string => string - - Callback which will receive text to highlight. You'll need to return an HTML string with syntax highlighting using a library such as prismjs.
readonly Boolean false - Readonly
lineNumbers Boolean false - Whether to show line numbers. Default false
autoStyleLineNumbers Boolean true - Match line numbers text color to the theme. Default true
tabSize number 2 - The number of characters to insert when pressing tab key. For example, for 4 space indentation, tabSize will be 4 and insertSpaces will be true. Default: 2
insertSpaces boolean true - Whether to use spaces for indentation. Default: true. If you set it to false, you might also want to set tabSize to 1
ignoreTabKey boolean false - Whether the editor should ignore tab key presses so that keyboard users can tab past the editor. Users can toggle this behaviour using Ctrl+Shift+M (Mac) / Ctrl+M manually when this is false. Default: false

Events

Name Parameters Description
input (code) Fires when the code is changed.
keydown (event) This event is emitted when a keydown event happens in editor
keyup (event) This event is emitted when a keyup event happens in editor
click (event) This event is emitted when clicking anywhere in the editor
focus (event) This event is emitted when focus
blur (event) This event is emitted when blur

How it works

This part is taken from react-simple-code-editor

It works by overlaying a syntax highlighted <pre> block over a <textarea>. When you type, select, copy text etc., you interact with the underlying <textarea>, so the experience feels native. This is a very simple approach compared to other editors which re-implement the behaviour.

The syntax highlighting can be done by any third party library as long as it returns HTML and is fully controllable by the user.

The vanilla <textarea> doesn't support inserting tab characters for indentation, so we re-implement it by listening to keydown events and programmatically updating the text. One caveat with programmatically updating the text is that we lose the undo stack, so we need to maintain our own undo stack. As a result, we can also implement improved undo behaviour such as undoing whole words similar to editors like VSCode.

Limitations

Due to the way it works, it has certain limitations:

  • The syntax highlighted code cannot have different font family, font weight, font style, line height etc. for its content. Since the editor works by aligning the highlighted code over a <textarea>, changing anything that affects the layout can misalign it.
  • The custom undo stack is incompatible with undo/redo items browser's context menu. However, other full featured editors don't support browser's undo/redo menu items either.
  • The editor is not optimized for performance and large documents can affect the typing speed.
  • We hide text in the textarea using -webkit-text-fill-color: transparent, which works in all modern browsers (even non-webkit ones such as Firefox and Edge). On IE 10+, we use color: transparent which doesn't hide the cursor. Text may appear bolder in unsupported browsers.

Thanks

react-simple-code-editor

License

MIT

vue-prism-editor's People

Contributors

artn avatar elevatebart avatar jannejava avatar jefrydco avatar koca avatar lightninglord avatar tillsanders avatar wagslane avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vue-prism-editor's Issues

Critical Error in 1.0.1

Take a look at https://classroom.qvault.io/playground/go

Try to write code longer than ~26 lines. You will see that the cursor is no longer able to move downwards. Not sure what is causing this but I will likely have to rollback until a solution is pushed out

The problem is also present in your example: https://codesandbox.io/s/61yrlnlnmn
However, there it starts around line ~16

It's looking like it's dependent on the height of the <textarea>. It isn't resizing dynamically or something...

Shift+TAB support

Hey,

is there a possibility to add the feature of Shift+TAB? (One tab back)

Best wishes,
Dennis

Number tokens are strangely styled

For some reason when I insert a number literal there is a strange styling artifact that messes up line spacing and making the number look abnormally large. (Note the coy theme is active, but this occurs on the default theme as well).

screenshot

Line numbers only partially showing

When packing the VuePrismEditor component into the body of a ExpansionPanel container the line numbers aren't properly showing when the expansion panel is initially collapsed.

Debugging the issue indicated that

this.lineNumbersHeight = getComputedStyle(this.$refs.pre).height;
is read while the DOM has not been updated yet and thus some delay is needed.

var csHeight = getComputedStyle(this.$refs.pre).height
if (csHeight=="auto") {
  window.setTimeout(() => {
    this.lineNumbersHeight = getComputedStyle(this.$refs.pre).height;
  }, 1);
} else {
      this.lineNumbersHeight = csHeight;
}

Seems to resolve the issue. Calling this.$nextTick() does not seem to work for me.

Can't focus on editor if value is ''

As title says, if the string value is '' i can't focus on the editor and edit whatever it has
However, if the value is for example '\n' i am able to focus and edit away

Any information i can give i will gladly

Press on keys like Ctrl, Alt, Shift must NOT emit 'change' event.

I am using your editor and it is good. Thanks for this component.
But encountered an issue with 'change' event. Event is emitted when you don't expect.

Steps:

  1. Create simple vue app with the only vue-prism-editor.
  2. Place cursor within editor.
  3. Press any of the following keys: Ctrl, Alt, Shift, Num Lock, Caps Lock, Insert, Home, End and other none-printable keys. Also if you press Ctrl+C.

Watch Events in Chrome extension for Vue.

Result:
vue-prism-editor emits 'change' event.

Expected result:
Change event is not emitted.

Could you please fix it because I need to track changes of the text in my App.
Right now I have to use workaround and compare text each time the change event is emitted.

Add a property to disable custom undo-stack

In my project I'm already using a custom undo-stack which is interfering with the one in vue-prism-editor. Could you add a property to disable the built-in custom undo-stack?

Pressing enter delays action by 1 key & input speed loses focus

I got it working and noticed that when I press enter it doesn't put my cursor on the next line until I press another key. This really throws me off.

Also typing really fast seems to mess up the editor and lose input focus. I was deleting a row of text and it stopped deleting and it was because I had to click on the editor again to re-focus. I tried just typing like I would normally code and it did the same thing. It seems you cannot type fast at all?

I'm testing on Firefox for both of these issues. Is there a potential fix?

Another text input on the same page loses focus

If I have a text input and prism editor on the same page, there are focus issues after entering text in prism editor. If I try to edit the text field, focus is forced back to prism editor after every keypress.

Demo side is down

The link to the demo site (prism-editor.netlify.com) is no longer available.

Is it possible to bind Ctrl+Enter to something?

Hi,

Is it possible through the current API to add a callback on a given key combination?
For example, since this is a code editor component Ctrl+Enter is very often used as a key
combination to run the code (in many applications).

Would something like this be possible in vue-prism-editor on vue-prism-editor'skeyup event?

Thanks,
Stefan

UPDATE:

Apparently it's possible to do that via an attribute like this v-on:keyup="keyUpHandler" but in the handler, it looks like e.preventDefault() isn't enough to stop the Enter key from going through.

Editor adds two lines on enter

I have been using this package with my Vue.TS application, I added a variable to my v-model, on pressing enter and then pressing backspace, instead of going to the previous state which should be "" in my variable, my variable now has 2 white-spaces with a line break, picture attached.

Github_issue

support v-model

Instead of :code and @change, could you support v-model by using value and @input ? or maybe :code.sync with code and @update:code ?

[ Build ] Rollup

I'm considering to switch to rollup instead of vue-cli. I've seen huge drop on file size. Like 3kb/gz. But had some issues.

wanna help? maybe @jefrydco ? :)

Syntax highlighting is not activated with prefilled code value

Hello, I have an issue with syntax highlighting

Scenario 1: Load Component with preset value of "code"
The preset value highlighted correctly, but all the changes are no highlighted

Scenario 1: Load Component with value of "code" of empty string or null
When null or empty string is set to the initial "code" - typing hew code get highlighted correctly

Please see the bug video:
https://d.pr/v/pTUlOT

Code to reproduce:

<!doctype html>

<html lang="en">
<head>
    <meta charset="utf-8">

    <title>Vue editor debug</title>
    <meta name="description" content="The HTML5 Herald">
    <meta name="author" content="SitePoint">
    <!-- vue-prism-editor CSS -->
    <link rel="stylesheet" href="https://unpkg.com/vue-prism-editor/dist/VuePrismEditor.css">
    <link rel="stylesheet" href="https://unpkg.com/prismjs/themes/prism.css" />
</head>

<body>
<div id="app">
    <vue-prism-editor :code="code" language="js"></vue-prism-editor>
</div>
<!-- vue-prism-editor JavaScript -->
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script src="https://unpkg.com/prismjs"></script>
<script src="https://unpkg.com/vue-prism-editor"></script>


<!-- use -->
<script>
    Vue.component("vue-prism-editor", VuePrismEditor)
    new Vue({
        el: "#app",
        data: {
            code: "console.log('test')"
        }
    })
</script>
</body>
</html>

Line and code aren't aligned

I copied the code exactly as shown in the example,
but adding lineNumbers option breaks the view:

image

From code inspection, I noticed that the lineNumbers option adds a <div> which comes before the <pre> block.

I played with the styling a bit and adding position: absolute; to the <div> and some padding to the <pre> solved it.

I can do it in my css file (unless it is scoped), thought it'd be better if you could check what is the problem with what I experience :)

New line scroll bottom

When we add a new line it should scroll to bottom if the line is the last line on the screen

(2) issues compiling prismjs for PrismEditor component

If I add these tags to my html index file, it works!

  <link rel="stylesheet" href="<%= BASE_URL %>js/prismjs/prism.css" />
  <script src="<%= BASE_URL %>js/prismjs/prism.js"></script>

However css is broken for lineNumbers="true" just like this user experienced:
Issue #18 relevant

Like the README suggests, I should import the js and css into the global namespace for Vue. The previous user did this and said it would work. It doesn't for me. I get these compile errors for prism:

Failed to compile.

./src/js/prismjs/prism.js
Module Error (from ./node_modules/eslint-loader/index.js):

C:\Users\Proto\Code\OpenNetBattleWebDashboard\open_net_battle_dashboard\src\js\prismjs\prism.js
   3:100   error  'WorkerGlobalScope' is not defined                                         no-undef
   3:771   error  Do not access Object.prototype method 'hasOwnProperty' from target object  no-prototype-builtins
   3:1040  error  Unexpected comma in middle of array                                        no-sparse-arrays
   3:1589  error  Do not access Object.prototype method 'hasOwnProperty' from target object  no-prototype-builtins
   3:1633  error  Do not access Object.prototype method 'hasOwnProperty' from target object  no-prototype-builtins
   3:1666  error  Do not access Object.prototype method 'hasOwnProperty' from target object  no-prototype-builtins
   3:1865  error  Do not access Object.prototype method 'hasOwnProperty' from target object  no-prototype-builtins
   3:2457  error  Expected a conditional expression and instead saw an assignment            no-cond-assign
   3:3819  error  Do not access Object.prototype method 'hasOwnProperty' from target object  no-prototype-builtins
   3:4660  error  'w' is already defined                                                     no-redeclare
   3:4708  error  'A' is already defined                                                     no-redeclare
   3:4720  error  'w' is already defined                                                     no-redeclare
   3:4736  error  'P' is already defined                                                     no-redeclare
   3:5206  error  Expected a conditional expression and instead saw an assignment            no-cond-assign
   5:1376  error  Unnecessary escape character: \[                                           no-useless-escape
   6:572   error  Unnecessary escape character: \[                                           no-useless-escape
   9:469   error  Do not access Object.prototype method 'hasOwnProperty' from target object  no-prototype-builtins
   9:508   error  'e' is already defined                                                     no-redeclare
   9:517   error  Do not access Object.prototype method 'hasOwnProperty' from target object  no-prototype-builtins
  11:1542  error  Empty block statement                                                      no-empty
  12:294   error  Expected a conditional expression and instead saw an assignment            no-cond-assign

Here's the .vue file where I try to import the vanilla js

<template>
    <PrismEditor language="lua" code="blah blah blah" lineNumbers/>
</template>

<script>
import '@/js/prismjs/prism'
import '@/js/prismjs/prism.css'

import PrismEditor from 'vue-prism-editor'

export default {
    name: "CodeEditPage",
    components: { PrismEditor }
}

Issue 2. If I use a data variable for code property that is empty then it also crashes:

property `code` expected type String. code="[Object object]" expected code=[Object object]

Here's the .vue file where this happens

<template>
    <PrismEditor language="lua" :code="source" lineNumbers/>
</template>

<script>
import '@/js/prismjs/prism'
import '@/js/prismjs/prism.css'

import PrismEditor from 'vue-prism-editor'

export default {
    name: "CodeEditPage",
    components: { PrismEditor },
    data() {
        return { source: { type: String, default: "" } }
   }
}

Code highlight doesn't update unless a model is linked

Hello, I was testing this package and I found it quite interesting, however, I found a issue, which happens in the main demo too. If I update the code, aka, type a new one in the window, the new code won't have a new highlight. If I set a default code, it will have the highlight.

However, if I link it to a data model, the highlight works just fine. Below I gave some snippets.

Also, if that's expected, just ignore me :-P

Browser: Firefox 68.0.1
example code:
With this code the highlight doesn't work

Vue.use(BootstrapVue);
Vue.component("prism-editor", VuePrismEditor);

var default_app = new Vue({el: "#app"});
<prism-editor emit-events line-numbers language="js"></prism-editor>

With this code, the highlight work just fine.

Vue.use(BootstrapVue);
Vue.component("prism-editor", VuePrismEditor);

var default_app = new Vue({
    el: "#app",
    data: {
        code: ""
    }
});
<prism-editor v-model="code" emit-events line-numbers language="js"></prism-editor>

Also, if you want a complete working code can be found in my package:
https://github.com/Cerberus1746/PandaCoreData/tree/development/panda_core_data/ui

Does this allow for custom events?

                    <vue-prism-editor
                        autocorrect="off"
                        autocapitalize="off"
                        spellcheck="false"
                        rows="8"
                        :code="model.content"
                        v-on:drop="onDrop($event)"
                        v-on:dragover="onDragOver($event)"
                        v-model="model.content"
                        :lineNumbers="false"
                        :autoStyleLineNumbers="false"
                        :emitEvents="true"
                        :language="'bash'"></vue-prism-editor>

Does vue-prism-editor allow for the v-on:drop attributes? I'm trying to attach an event to the contentEditable pre element, but this does not seem to work.

Firefox version is broken

Hi are you aware that this component barly functions in Firefox, and it's exibiting strange behaviour. I'm using it for my CMS: https://www.youtube.com/watch?v=O-fO41eOp6o

Is there a chance you could take a look at this and see what's going crazy in FF? You can test it right in your demo links since the issue is there right when you start using it in FF.

Any similar projects?

This is very cool!

I LOVE that this works on mobile due simply to contenteditable.

Are there any other efforts to make a contenteditable code editor that you know of?

(I see react-live is covering a textarea with a pre, which isn't quite the same.)

Pressing space key between .token.punctuation shows &nbsp; [language="twig"]

Problem:

When changing completed code in the editor, pressing the space key changes to nbsp;

If I just type from the beginning, there is no problem.... but if I edit something present, or stub out a placeholder, then the problem can be reproduced.

Sample Implementation:

<prism-editor :code="advanced_statement" @change="handlePrismChange" language="twig"></prism-editor>

Visual:
image

Current Workaround:

handlePrismChange(code) {
    this.advanced_statement = code.replace('&nbsp;', ' ');
}

Tab size should not be hardcoded

It would be awesome if the tab character (currently hardcoded to 2 spaces) was configurable via props. I'm using this for Go code and I need actual tabs.

Feature request: Format code

Hi, first of all great plugin! The example was really helpful for getting started.

I was curious if there's a way to trigger a code formatting action? When I paste code into a vue-prism-editor textarea, I'd like it to format the code, remove whitespace, etc. This would be similar to clicking "tidy" in Codepen or "format" in VSCode.

If this is outside the scope of the project, it would be great to be able to easily add plugins like normalize-whitespace. I know plugins are not currently supported.

It breaks if initiated with null value

Error in getter for watcher "content": "TypeError: Cannot read property 'length' of null"

If I have a nullable css column in database and user does not input any css with first save, upon reloading the editor breaks because it tries to read the length of null. Can you fix this? I have a css field that user may or may not add some css to, the column is nullable, I can't force the user to enter css, and if they do not, your component breaks when they reload the page and data is read from the database.

found in
---> at Editor.vue

I just follow your installin instrugctions, but I got Prism is not define, what's wrong?

vue.esm.js?efeb:1897 ReferenceError: Prism is not defined at prism (VuePrismEditor.common.js?6d1d:2110) at VueComponent.content (VuePrismEditor.common.js?6d1d:2380) at Watcher.get (vue.esm.js?efeb:4482) at Watcher.evaluate (vue.esm.js?efeb:4587) at VueComponent.computedGetter [as content] (vue.esm.js?efeb:4839) at VueComponent.eval (vue.esm.js?efeb:512) at Watcher.get (vue.esm.js?efeb:4482) at new Watcher (vue.esm.js?efeb:4471) at VueComponent.Vue.$watch (vue.esm.js?efeb:4949) at createWatcher (vue.esm.js?efeb:4909)

Prism is not defined

Hello,

i wanted to use your editor in my project but i have this error : Prism is not defined. I provide you a screenshot about the error:

image

I'm using Nuxt.js ("nuxt": "^2.10.1",).

I followed your recommanded example :

<template>
  <prism-editor :code="code" language="js"></prism-editor>
</template>

<script>
import PrismEditor from 'vue-prism-editor'
export default {
  components: {
    PrismEditor
  }
}
</script>

What i made wrong ?

Edit:

I thought it could be a ssr render error so i add client-only tags in my template and i also have the error client side :

image

Thank you :)

Clear editor history?

Hi there,

I use this library to render an editor in a single page app. The editor renders code in a pop-up for editing. On the first page load, Undo/Redo works fine, but if I close the pop-up and render a different piece of code the Undo history is there for my previous rendered code (causing an Undo to revert to the other codebase).

So I'd like to know how I can programmatically clear the Undo/Redo history, so we get a new history for each rendering of the editor.

Thanks!

"Line numbers" breaks in production (Nuxt)

Hi, I was running vue-prism-editor v0.5.1 with Nuxt (v2.12.2), and when I deployed my app (SSR mode, running both nuxt build and nuxt start), I noticed that the editor broke :
image

However, when I'm in development mode (nuxt), it works just fine.
image

I updated to 0.6.1, and the issue is still the same.

Highlighting doesn't seem to work.

Hello,

I'm loving the plugin. I instantly got PrismJS working in my vue project. Seems to work well with SSR too.

But I'm having trouble getting the highlighting to work. I added PrismJS, VuePrismEditor, and the css-files from both. I even tried different themes, they definitly getting loaded, but the highlighting stays off. Also the markup only shows me:
image

I am able to switch the language, and the according classes are changing also. But not inside the

 - There it always says class="language-text".

Since I'm getting no errors which I could debug I'm a little helpless. Can you point me in the right direction?

Best wishes,
Dennis

Adding theme binding

Hi,

Can you please add option to set the theme of the editor?
Prismjs gives builtin themes as shown in their site,
can you add something like :theme="themes option" so that theme change is supported?

Thanks in advance

After a change to content, editor loses language.

Great tool !! Thank you.

Just a little minor quirk.
On load, the DOM looks like this:

<pre spellcheck="false" autocapitalize="off" autocomplete="off" autocorrect="off" data-gramm="false" class="prism-editor__code  language-html" style="border-top-left-radius: 0px; border-bottom-left-radius: 0px;" contenteditable="true">
  <code class=" language-html">
  <!-- My Code -->
  </code>
</pre>

as soon as I start typing in the editor, the language-html class of <code> is dropped. This would not be an issue if vuepress was counting on this class for its styling of vue code.

I will try to find the cause.

Md support

Html and js works fine. But there is not md-support:
<prism-editor v-model="post.content" language="md" :lineNumbers="true" :readonly="false"></prism-editor>

Model doesn't update on cmd + x

If I cut marked text by pressing cmd + x the model does not get updated. Deleting the marked text by pressing backspace works though.

The code:

<prism-editor
  v-model="stylesModel"
  language="css"
/>

I'm using the latest version 0.6.1.

vue-prism-editor:1 Uncaught ReferenceError: global is not defined

Hi,
i am getting following error .
i am new to web development. can you please help to figure out the issue.

vue-prism-editor:1 Uncaught ReferenceError: global is not defined at vue-prism-editor:1
i am using direct from browser.

<script src="https://unpkg.com/vue-prism-editor"></script>

Regards
Krishna

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.