0.0.5 • Published 1 year ago

@x4kep211/vue-code-editor v0.0.5

Weekly downloads
-
License
-
Repository
-
Last release
1 year ago

Codemirror + Validation ( JSON / XML )

Work in progress... This project is created to help us validate XML or JSON scheme inside of Codemirror plugin.

Feat

  • Validate XML
  • Validate JSON
  • Export errors as a file

Installation

npm i @x4kep211/vue-code-editor

Set it as global component

import CodeEditor from "@x4kep211/vue-code-editor"
import "@x4kep211/vue-code-editor/dist/style.css"

const app = createApp(App);
app.use(CodeEditor)
app.mount('#app')

CodeEditor properties:

Available properties on plugin:

PropertiesShort descriptionValue typeExpected values
typeContent type to be validatedstringXML / JSON
schemaSchema to be used to validate contentstringJSON schema / XML schema
schemaTypeUsed as label for downloaded filestringPartners
contentContent to be validatedstringXML or JSON formatted content
languageContent type to be validatedstringEN / RS ( RS is default )

Example of invalid XML

<template>
  <code-editor :type="type" :content="content"></code-editor>
</template>

<script>

export default {
  data() {
    return {
      type: 'xml',
      content: `<?xml version="1.0" encoding="UTF-8" ?>
      <Partners>
        <Partner>
          <Nam>ldMsyR</Name>
          <Address>Test Adresa</Address>
          <BankAccount>000000000000963289</BankAccount>
          <Comment>Test Komentar</Comment>
        </Partner>
      </Partners><Partners>
        <Partner>
          <Nam>ldMsyR</Name>
          <Address>Test Adresa</Address>
          <BankAccount>000000000000963289</BankAccount>
          <Comment>Test Komentar</Comment>
        </Partner>
      </Partners><Partners>
        <Partner>
          <Nam>ldMsyR</Name>
          <Address>Test Adresa</Address>
          <BankAccount>000000000000963289</BankAccount>
          <Comment>Test Komentar</Comment>
        </Partner>
      </Partners><Partners>
        <Partner>
          <Nam>ldMsyR</Name>
          <Address>Test Adresa</Address>
          <BankAccount>000000000000963289</BankAccount>
          <Comment>Test Komentar</Comment>
        </Partner>
      </Partners><Partners>
        <Partner>
          <Nam>ldMsyR</Name>
          <Address>Test Adresa</Address>
          <BankAccount>000000000000963289</BankAccount>
          <Comment>Test Komentar</Comment>
        </Partner>
      </Partners><Partners>
        <Partner>
          <Nam>ldMsyR</Name>
          <Address>Test Adresa</Address>
          <BankAccount>000000000000963289</BankAccount>
          <Comment>Test Komentar</Comment>
        </Partner>
      </Partners><Partners>
        <Partner>
          <Nam>ldMsyR</Name>
          <Address>Test Adresa</Address>
          <BankAccount>000000000000963289</BankAccount>
          <Comment>Test Komentar</Comment>
        </Partner>
      </Partners>`,
    };
  },
};
</script>

Example of invalid JSON

<template>
  <code-editor :type="type" :content="content"></code-editor>
</template>

<script>

export default {
  data() {
    return {
      type: 'json',
      content: `[{
        "Name": "ldMsyR",
        "Address": "Test Adresa",
        "BankAccount": "000000000000963289",
        "Comment": "Test Komentar
      }]`,
    };
  },
};
</script>

TODO:

  • Translation XML (СРБ - ENG)
  • Translation JSON (СРБ - ENG)

Vue 3 + Vite

This template should help get you started developing with Vue 3 in Vite. The template uses Vue 3 <script setup> SFCs, check out the script setup docs to learn more.

Recommended IDE Setup