Editor - Documentation | www.HtmlElements.com

Overview

Smart.Editor is a powerful HTML & Markdown Text Editor for Web Applications. It could be useful for applications like email client, blog edit or a simple web application for exchanging formatted documents within your company. Smart.Editor is a text editor with an intuitive user interface that is inspired by popular Editors such as Microsoft® Word, Google email client, etc.

Getting Started with Editor Web Component

Smart UI for Web Components is distributed as smart-webcomponents NPM package. You can also get the full download from our website with all demos from the Download page.

Setup the Editor

Smart UI for Web Components is distributed as smart-webcomponents NPM package

  1. Download and install the package.

    npm install smart-webcomponents

  2. Once installed, import the Editor module in your application.

    <script type="module" src="node_modules/smart-webcomponents/source/modules/smart.editor.js"></script>

  3. Adding CSS reference

    The smart.default.css CSS file should be referenced using following code.

    <link rel="stylesheet" type="text/css" href="node_modules/smart-webcomponents/source/styles/smart.default.css" />

  4. Add the Editor tag to your Web Page

    <smart-editor id="editor"></smart-editor>

  5. Create the Editor Component

    	<script type="module">
    		Smart('#editor', class {
    			get properties() {
    				return [object Object]
    			}
    		});
    	</script>	   
    		

    Another option is to create the Editor is by using the traditional Javascript way:
    	const editor = document.createElement('smart-editor');
    
    	editor.disabled = true;
    	document.body.appendChild(editor);
    		

    Smart framework provides a way to dynamically create a web component on demand from a DIV tag which is used as a host. The following imports the web component's module and creates it on demand, when the document is ready. The #editor is the ID of a DIV tag.

    	import "../../source/modules/smart.editor.js";
    
    	document.readyState === 'complete' ? init() : window.onload = init;
    
    	function init() { 
    		const editor = new Smart.Editor('#editor', [object Object]);
    	}
    	

  6. Open the page in your web server.

Create, Append, Remove, Get/Set Property, Invoke Method, Bind to Event


Create a new element:
	const editor = document.createElement('smart-editor');
	

Append it to the DOM:
	document.body.appendChild(editor);
	

Remove it from the DOM:
	editor.parentNode.removeChild(editor);
	

Set a property:
	editor.propertyName = propertyValue;
	

Get a property value:
	const propertyValue = editor.propertyName;
	

Invoke a method:
	editor.methodName(argument1, argument2);
	

Add Event Listener:
	const eventHandler = (event) => {
	   // your code here.
	};

	editor.addEventListener(eventName, eventHandler);
	

Remove Event Listener:
	editor.removeEventListener(eventName, eventHandler, true);
	

Using with Typescript

Smart Web Components package includes TypeScript definitions which enables strongly-typed access to the Smart UI Components and their configuration.

Inside the download package, the typescript directory contains .d.ts file for each web component and a smart.elements.d.ts typescript definitions file for all web components. Copy the typescript definitions file to your project and in your TypeScript file add a reference to smart.elements.d.ts

Read more about using Smart UI with Typescript.

Getting Started with Angular Editor Component

Setup Angular Environment

Angular provides the easiest way to set angular CLI projects using Angular CLI tool.

Install the CLI application globally to your machine.

npm install -g @angular/cli

Create a new Application

ng new smart-angular-editor

Navigate to the created project folder

cd smart-angular-editor

Setup the Editor

Smart UI for Angular is distributed as smart-webcomponents-angular NPM package

  1. Download and install the package.
    npm install smart-webcomponents-angular
  2. Once installed, import the EditorModule in your application root or feature module.

    app.module.ts

    import { NgModule } from '@angular/core';
    import { BrowserModule } from '@angular/platform-browser';
    
    import { EditorModule } from 'smart-webcomponents-angular/editor';
    
    import { AppComponent } from './app.component';
    
    @NgModule({
        declarations: [ AppComponent ],
        imports: [ BrowserModule, EditorModule ],
        bootstrap: [ AppComponent ],
    	entryComponents: [ AppComponent ]
    })
    
    export class AppModule { }
    	

  3. Adding CSS reference

    The following CSS file is available in ../node_modules/smart-webcomponents-angular/ package folder. This can be referenced in [src/styles.css] using following code.

    	@import 'smart-webcomponents-angular/source/styles/smart.default.css';

    Another way to achieve the same is to edit the angular.json file and in the styles add the style.

    	"styles": [
    		"node_modules/smart-webcomponents-angular/source/styles/smart.default.css"
    	]
    	
  4. Example


    app.component.html

     
    <smart-editor #editor id="editor" [toolbarItems]="toolbarItems">
        <div>
             <h2>What is Lorem Ipsum?</h2>
            <p><strong>Lorem Ipsum</strong> is simply dummy text of the printing and typesetting
                industry. Lorem Ipsum has been the industry's standard dummy text ever
                since the 1500s, when an unknown printer took a galley of type and scrambled
                it to make a type specimen book. It has survived not only five centuries,
                but also the leap into electronic typesetting, remaining essentially unchanged.
                It was popularised in the 1960s with the release of Letraset sheets containing
                Lorem Ipsum passages, and more recently with desktop publishing software
                like Aldus PageMaker including versions of Lorem Ipsum. <a href="www.htmlelements.com"
                title="Smart Elements">Smart Elements</a>
            </p>
            <table class="wd-Table">
                <thead>
                    <tr>
                        <th>First Name</th>
                        <th>Last Name</th>
                        <th>Email</th>
                        <th>Actions</th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td>Jane</td>
                        <td>Doe</td>
                        <td>sample@example.org</td>
                        <td><a href="#">View</a> - <a href="#">Edit</a> - <a href="#">Delete</a>
                        </td>
                    </tr>
                    <tr>
                        <td>Jane</td>
                        <td>Doe</td>
                        <td>sample@example.org</td>
                        <td><a href="#">View</a> - <a href="#">Edit</a> - <a href="#">Delete</a>
                        </td>
                    </tr>
                    <tr>
                        <td>Jane</td>
                        <td>Doe</td>
                        <td>sample@example.org</td>
                        <td><a href="#">View</a> - <a href="#">Edit</a> - <a href="#">Delete</a>
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
        <div>
             <h2>Why do we use it?</h2>
            <p>It is a long established fact that a reader will be distracted by the
                readable content of a page when looking at its layout. The point of using
                Lorem Ipsum is that it has a more-or-less normal distribution of letters,
                as opposed to using 'Content here, content here', making it look like readable
                English. Many desktop publishing packages and web page editors now use
                Lorem Ipsum as their default model text, and a search for 'lorem ipsum'
                will uncover many web sites still in their infancy. Various versions have
                evolved over the years, sometimes by accident, sometimes on purpose (injected
                humour and the like).</p>
            <p>
                <img src="./../../../src/images/Album.png" width="100px" height="100px"/>
            </p>
        </div>
        <br>
        <div>
             <h2>Where does it come from?</h2>
            <p>Contrary to popular belief, Lorem Ipsum is not simply random text. It
                has roots in a piece of classical Latin literature from 45 BC, making it
                over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney
                College in Virginia, looked up one of the more obscure Latin words, consectetur,
                from a Lorem Ipsum passage, and going through the cites of the word in
                classical literature, discovered the undoubtable source. Lorem Ipsum comes
                from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The
                Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a
                treatise on the theory of ethics, very popular during the Renaissance.
                The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from
                a line in section 1.10.32.</p>
            <p>The standard chunk of Lorem Ipsum used since the 1500s is reproduced below
                for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum
                et Malorum" by Cicero are also reproduced in their exact original form,
                accompanied by English versions from the 1914 translation by H. Rackham.</p>
        </div>
        <div>
             <h2>Where can I get some?</h2>
            <p>There are many variations of passages of Lorem Ipsum available, but the
                majority have suffered alteration in some form, by injected humour, or
                randomised words which don't look even slightly believable. If you are
                going to use a passage of Lorem Ipsum, you need to be sure there isn't
                anything embarrassing hidden in the middle of text. All the Lorem Ipsum
                generators on the Internet tend to repeat predefined chunks as necessary,
                making this the first true generator on the Internet. It uses a dictionary
                of over 200 Latin words, combined with a handful of model sentence structures,
                to generate Lorem Ipsum which looks reasonable. The generated Lorem Ipsum
                is therefore always free from repetition, injected humour, or non-characteristic
                words etc.</p>
        </div>
    </smart-editor>
    		

    app.component.ts

     
    ´╗┐import { Component, ViewChild, OnInit, AfterViewInit, ViewEncapsulation } from '@angular/core';
    import { EditorComponent } from 'smart-webcomponents-angular/editor';
    
    @Component({
        selector: 'app-root',
        templateUrl: './app.component.html',
        styleUrls: ['./app.component.css'],
        encapsulation: ViewEncapsulation.None
    })
    
    export class AppComponent implements AfterViewInit, OnInit {
        @ViewChild('editor', { read: EditorComponent, static: false }) editor: EditorComponent;
    
        toolbarItems: string[] = ['Bold', 'Italic', 'Underline', 'StrikeThrough',
            'FontName', 'FontSize', 'FontColor', 'BackgroundColor',
            'LowerCase', 'UpperCase', '|',
            'Formats', 'Alignment', 'OrderedList', 'UnorderedList',
            'Outdent', 'Indent', '|',
            'hyperlink', 'table', 'Image', '|', 'ClearFormat', 'Print',
            'SourceCode', 'splitmode', 'FullScreen', '|', 'Undo', 'Redo', 'subscript', 'superscript', 'delete'];
    
        ngOnInit(): void {
            // onInit code.
        }
    
        ngAfterViewInit(): void {
            // afterViewInit code.
            this.init();
        }
    
        init(): void {
            // init code.
            this.editor.expandToolbar();
        };
    }
    		

    app.module.ts

     
    import { NgModule } from '@angular/core';
    import { BrowserModule } from '@angular/platform-browser';
    
    import { EditorModule } from 'smart-webcomponents-angular/editor';
    
    import { AppComponent } from './app.component';
    
    @NgModule({
        declarations: [ AppComponent ],
        imports: [ BrowserModule, EditorModule ],
        bootstrap: [ AppComponent ],
    	entryComponents: [ AppComponent ]
    })
    
    export class AppModule { }
    		


Running the Angular application

After completing the steps required to render a Editor, run the following command to display the output in your web browser

ng serve
and open localhost:4200 in your favorite web browser.

Read more about using Smart UI for Angular: https://www.htmlelements.com/docs/angular-cli/.

Getting Started with React Editor Component

Setup React Environment

The easiest way to start with React is to use create-react-app. To scaffold your project structure, follow the installation instructions.

	npm install -g create-react-app
	create-react-app my-app
	cd my-app
	npm start
	

Preparation

Open src/App.js andsrc/App.css

  1. Remove everything inside the App div tag in src/App.js:
    <div className="App"> </div>
  2. Remove the logo.svg import
  3. Remove the contents of src/App.css
  4. Remove src/logo.svg

Setup the Editor

Smart UI for React is distributed as smart-webcomponents-react NPM package

  1. Download and install the package.
    npm install smart-webcomponents-react
  2. Once installed, import the React Editor Component and CSS files in your application and render it app.js

    import 'smart-webcomponents-react/source/styles/smart.default.css';
    import React from "react";
    import ReactDOM from "react-dom";
    import { Editor } from 'smart-webcomponents-react/editor';
    
    class App extends React.Component {
    	constructor(prop) {
    		super(prop);
    
    		this.editor = React.createRef();
    	}
    
    	toolbarItems = ['Bold', 'Italic', 'Underline', 'StrikeThrough',
    		'FontName', 'FontSize', 'FontColor', 'BackgroundColor',
    		'LowerCase', 'UpperCase', '|',
    		'Formats', 'Alignment', 'OrderedList', 'UnorderedList',
    		'Outdent', 'Indent', '|',
    		'hyperlink', 'table', 'Image', '|', 'ClearFormat', 'Print',
    		'SourceCode', 'splitmode', 'FullScreen', '|', 'Undo', 'Redo', 'subscript', 'superscript', 'delete'
    	];
    
    	init() {
    		this.editor.current.expandToolbar();
    	};
    
    	componentDidMount() {
    		this.init();
    	}
    
    	render() {
    		return (
    			<div>
    				<Editor ref={this.editor} id="editor" toolbarItems={this.toolbarItems}>
    					<div>
    						<h2>What is Lorem Ipsum?</h2>
    						<p><strong>Lorem Ipsum</strong> is simply dummy text of the printing and typesetting
    			                industry. Lorem Ipsum has been the industry's standard dummy text ever
    			                since the 1500s, when an unknown printer took a galley of type and scrambled
    			                it to make a type specimen book. It has survived not only five centuries,
    			                but also the leap into electronic typesetting, remaining essentially unchanged.
    			                It was popularised in the 1960s with the release of Letraset sheets containing
    			                Lorem Ipsum passages, and more recently with desktop publishing software
    			                like Aldus PageMaker including versions of Lorem Ipsum. <a href="www.htmlelements.com"
    								title="Smart Elements">Smart Elements</a>
    						</p>
    						<table className="wd-Table">
    							<thead>
    								<tr>
    									<th>First Name</th>
    									<th>Last Name</th>
    									<th>Email</th>
    									<th>Actions</th>
    								</tr>
    							</thead>
    							<tbody>
    								<tr>
    									<td>Jane</td>
    									<td>Doe</td>
    									<td>sample@example.org</td>
    									<td><a href="#">View</a> - <a href="#">Edit</a> - <a href="#">Delete</a>
    									</td>
    								</tr>
    								<tr>
    									<td>Jane</td>
    									<td>Doe</td>
    									<td>sample@example.org</td>
    									<td><a href="#">View</a> - <a href="#">Edit</a> - <a href="#">Delete</a>
    									</td>
    								</tr>
    								<tr>
    									<td>Jane</td>
    									<td>Doe</td>
    									<td>sample@example.org</td>
    									<td><a href="#">View</a> - <a href="#">Edit</a> - <a href="#">Delete</a>
    									</td>
    								</tr>
    							</tbody>
    						</table>
    					</div>
    					<div>
    						<h2>Why do we use it?</h2>
    						<p>It is a long established fact that a reader will be distracted by the
    						readable content of a page when looking at its layout. The point of using
    						Lorem Ipsum is that it has a more-or-less normal distribution of letters,
    						as opposed to using 'Content here, content here', making it look like readable
    						English. Many desktop publishing packages and web page editors now use
    						Lorem Ipsum as their default model text, and a search for 'lorem ipsum'
    						will uncover many web sites still in their infancy. Various versions have
    						evolved over the years, sometimes by accident, sometimes on purpose (injected
    			                humour and the like).</p>
    						<p>
    							<img src="./../../../src/images/Album.png" width="100px" height="100px" />
    						</p>
    					</div>
    					<br />
    					<div>
    						<h2>Where does it come from?</h2>
    						<p>Contrary to popular belief, Lorem Ipsum is not simply random text. It
    						has roots in a piece of classical Latin literature from 45 BC, making it
    						over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney
    						College in Virginia, looked up one of the more obscure Latin words, consectetur,
    						from a Lorem Ipsum passage, and going through the cites of the word in
    						classical literature, discovered the undoubtable source. Lorem Ipsum comes
    						from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The
    						Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a
    						treatise on the theory of ethics, very popular during the Renaissance.
    						The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from
    			                a line in section 1.10.32.</p>
    						<p>The standard chunk of Lorem Ipsum used since the 1500s is reproduced below
    						for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum
    						et Malorum" by Cicero are also reproduced in their exact original form,
    			                accompanied by English versions from the 1914 translation by H. Rackham.</p>
    					</div>
    					<div>
    						<h2>Where can I get some?</h2>
    						<p>There are many variations of passages of Lorem Ipsum available, but the
    						majority have suffered alteration in some form, by injected humour, or
    						randomised words which don't look even slightly believable. If you are
    						going to use a passage of Lorem Ipsum, you need to be sure there isn't
    						anything embarrassing hidden in the middle of text. All the Lorem Ipsum
    						generators on the Internet tend to repeat predefined chunks as necessary,
    						making this the first true generator on the Internet. It uses a dictionary
    						of over 200 Latin words, combined with a handful of model sentence structures,
    						to generate Lorem Ipsum which looks reasonable. The generated Lorem Ipsum
    						is therefore always free from repetition, injected humour, or non-characteristic
    			                words etc.</p>
    					</div>
    				</Editor>
    			</div>
    		);
    	}
    }
    
    ReactDOM.render(<App />, document.querySelector("#root"));
    
    export default App;
    	

Running the React application

Start the app with
npm start
and open localhost:3000 in your favorite web browser to see the output.

Read more about using Smart UI for React: https://www.htmlelements.com/docs/react/.

Getting Started with Vue Editor Component


Setup Vue Environment

We will use vue-cli to get started. Let's install vue-cli

npm install -g @vue/cli

Then we can start creating our Vue.js projects with:

vue create my-project

Setup the Editor

Open the "my-project" folder and run:

npm install smart-webcomponents

Setup with Vue 3.x

  • Make Vue ignore custom elements defined outside of Vue (e.g., using the Web Components APIs). Otherwise, it will throw a warning about an Unknown custom element, assuming that you forgot to register a global component or misspelled a component name.

    Open src/main.js in your favorite text editor and change its contents to the following:

    main.js

    import { createApp } from 'vue'
    import App from './App.vue'
    
    const app = createApp(App)
    
    app.config.isCustomElement = tag => tag.startsWith('smart-');
    app.mount('#app')
    		
  • Open src/App.vue in your favorite text editor and change its contents to the following:

    App.vue

    <template>
      <div class="vue-root">
        <smart-editor id="editor">
          <div>
            <h2>What is Lorem Ipsum?</h2>
            <p>
              <strong>Lorem Ipsum</strong> is simply dummy text of the printing and
              typesetting industry. Lorem Ipsum has been the industry's standard
              dummy text ever since the 1500s, when an unknown printer took a galley
              of type and scrambled it to make a type specimen book. It has survived
              not only five centuries, but also the leap into electronic
              typesetting, remaining essentially unchanged. It was popularised in
              the 1960s with the release of Letraset sheets containing Lorem Ipsum
              passages, and more recently with desktop publishing software like
              Aldus PageMaker including versions of Lorem Ipsum.
              <a href="www.htmlelements.com" title="Smart Elements"
                >Smart Elements</a
              >
            </p>
            <table class="wd-Table">
              <thead>
                <tr>
                  <th>First Name</th>
                  <th>Last Name</th>
                  <th>Email</th>
                  <th>Actions</th>
                </tr>
              </thead>
              <tbody>
                <tr>
                  <td>Jane</td>
                  <td>Doe</td>
                  <td>sample@example.org</td>
                  <td>
                    <a href="#">View</a> - <a href="#">Edit</a> -
                    <a href="#">Delete</a>
                  </td>
                </tr>
                <tr>
                  <td>Jane</td>
                  <td>Doe</td>
                  <td>sample@example.org</td>
                  <td>
                    <a href="#">View</a> - <a href="#">Edit</a> -
                    <a href="#">Delete</a>
                  </td>
                </tr>
                <tr>
                  <td>Jane</td>
                  <td>Doe</td>
                  <td>sample@example.org</td>
                  <td>
                    <a href="#">View</a> - <a href="#">Edit</a> -
                    <a href="#">Delete</a>
                  </td>
                </tr>
              </tbody>
            </table>
          </div>
          <div>
            <h2>Why do we use it?</h2>
            <p>
              It is a long established fact that a reader will be distracted by the
              readable content of a page when looking at its layout. The point of
              using Lorem Ipsum is that it has a more-or-less normal distribution of
              letters, as opposed to using 'Content here, content here', making it
              look like readable English. Many desktop publishing packages and web
              page editors now use Lorem Ipsum as their default model text, and a
              search for 'lorem ipsum' will uncover many web sites still in their
              infancy. Various versions have evolved over the years, sometimes by
              accident, sometimes on purpose (injected humour and the like).
            </p>
            <p>
              <img
                src="./../../../src/images/Album.png"
                width="100"
                height="100"
              />
            </p>
          </div>
          <br />
          <div>
            <h2>Where does it come from?</h2>
            <p>
              Contrary to popular belief, Lorem Ipsum is not simply random text. It
              has roots in a piece of classical Latin literature from 45 BC, making
              it over 2000 years old. Richard McClintock, a Latin professor at
              Hampden-Sydney College in Virginia, looked up one of the more obscure
              Latin words, consectetur, from a Lorem Ipsum passage, and going
              through the cites of the word in classical literature, discovered the
              undoubtable source. Lorem Ipsum comes from sections 1.10.32 and
              1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and
              Evil) by Cicero, written in 45 BC. This book is a treatise on the
              theory of ethics, very popular during the Renaissance. The first line
              of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in
              section 1.10.32.
            </p>
            <p>
              The standard chunk of Lorem Ipsum used since the 1500s is reproduced
              below for those interested. Sections 1.10.32 and 1.10.33 from "de
              Finibus Bonorum et Malorum" by Cicero are also reproduced in their
              exact original form, accompanied by English versions from the 1914
              translation by H. Rackham.
            </p>
          </div>
          <div>
            <h2>Where can I get some?</h2>
            <p>
              There are many variations of passages of Lorem Ipsum available, but
              the majority have suffered alteration in some form, by injected
              humour, or randomised words which don't look even slightly believable.
              If you are going to use a passage of Lorem Ipsum, you need to be sure
              there isn't anything embarrassing hidden in the middle of text. All
              the Lorem Ipsum generators on the Internet tend to repeat predefined
              chunks as necessary, making this the first true generator on the
              Internet. It uses a dictionary of over 200 Latin words, combined with
              a handful of model sentence structures, to generate Lorem Ipsum which
              looks reasonable. The generated Lorem Ipsum is therefore always free
              from repetition, injected humour, or non-characteristic words etc.
            </p>
          </div>
        </smart-editor>
      </div>
    </template>
    
    <script>
    import { onMounted } from "vue";
    import "smart-webcomponents/source/styles/smart.default.css";
    import "smart-webcomponents/source/modules/smart.editor.js";
    
    export default {
      name: "app",
      setup() {
        onMounted(() => {
          window.Smart(
            "#editor",
            class {
              get properties() {
                return {
                  //Properties
                  toolbarItems: [
                    "Bold",
                    "Italic",
                    "Underline",
                    "StrikeThrough",
                    "FontName",
                    "FontSize",
                    "FontColor",
                    "BackgroundColor",
                    "LowerCase",
                    "UpperCase",
                    "|",
                    "Formats",
                    "Alignment",
                    "OrderedList",
                    "UnorderedList",
                    "Outdent",
                    "Indent",
                    "|",
                    "hyperlink",
                    "table",
                    "Image",
                    "|",
                    "ClearFormat",
                    "Print",
                    "SourceCode",
                    "splitmode",
                    "FullScreen",
                    "|",
                    "Undo",
                    "Redo",
                    "subscript",
                    "superscript",
                    "delete",
                  ],
                };
              }
            }
          );
    
          const editor = document.getElementById("editor");
          editor.expandToolbar();
        });
      },
    };
    </script>
    
    <style>
    html,
    body {
      width: 100%;
      height: 100%;
      margin: 0 auto;
    }
    
    .smart-editor {
      width: 100%;
      height: 100%;
    }
    
    .options {
      padding: 20px;
      background-color: rgba(191, 191, 191, 0.15);
      position: absolute;
      right: 0;
      top: 0;
      bottom: 0;
      width: 260px;
    }
    
    @media (max-width: 750px) {
      .options {
        position: relative;
        top: 30px;
        width: 240px;
        margin: 0 auto;
      }
    }
    
    #app,
    .vue-root {
      width: 100%;
      height: 100%;
    }
    </style>
    		
    We can now use the smart-editor with Vue 3. Data binding and event handlers will just work right out of the box.

Setup with Vue 2.x

  • Make Vue ignore custom elements defined outside of Vue (e.g., using the Web Components APIs). Otherwise, it will throw a warning about an Unknown custom element, assuming that you forgot to register a global component or misspelled a component name.

    Open src/main.js in your favorite text editor and change its contents to the following:

    main.js

    import Vue from 'vue'
    import App from './App.vue'
    
    Vue.config.productionTip = false
    Vue.config.ignoredElements = [
    'smart-editor'
    ]
    
    new Vue({
      render: h => h(App),
    }).$mount('#app')
  • Open src/App.vue in your favorite text editor and change its contents to the following:

    App.vue

    <template>
      <div class="vue-root">
        <smart-editor id="editor">
          <div>
            <h2>What is Lorem Ipsum?</h2>
            <p>
              <strong>Lorem Ipsum</strong> is simply dummy text of the printing and
              typesetting industry. Lorem Ipsum has been the industry's standard
              dummy text ever since the 1500s, when an unknown printer took a galley
              of type and scrambled it to make a type specimen book. It has survived
              not only five centuries, but also the leap into electronic
              typesetting, remaining essentially unchanged. It was popularised in
              the 1960s with the release of Letraset sheets containing Lorem Ipsum
              passages, and more recently with desktop publishing software like
              Aldus PageMaker including versions of Lorem Ipsum.
              <a href="www.htmlelements.com" title="Smart Elements"
                >Smart Elements</a
              >
            </p>
            <table class="wd-Table">
              <thead>
                <tr>
                  <th>First Name</th>
                  <th>Last Name</th>
                  <th>Email</th>
                  <th>Actions</th>
                </tr>
              </thead>
              <tbody>
                <tr>
                  <td>Jane</td>
                  <td>Doe</td>
                  <td>sample@example.org</td>
                  <td>
                    <a href="#">View</a> - <a href="#">Edit</a> -
                    <a href="#">Delete</a>
                  </td>
                </tr>
                <tr>
                  <td>Jane</td>
                  <td>Doe</td>
                  <td>sample@example.org</td>
                  <td>
                    <a href="#">View</a> - <a href="#">Edit</a> -
                    <a href="#">Delete</a>
                  </td>
                </tr>
                <tr>
                  <td>Jane</td>
                  <td>Doe</td>
                  <td>sample@example.org</td>
                  <td>
                    <a href="#">View</a> - <a href="#">Edit</a> -
                    <a href="#">Delete</a>
                  </td>
                </tr>
              </tbody>
            </table>
          </div>
          <div>
            <h2>Why do we use it?</h2>
            <p>
              It is a long established fact that a reader will be distracted by the
              readable content of a page when looking at its layout. The point of
              using Lorem Ipsum is that it has a more-or-less normal distribution of
              letters, as opposed to using 'Content here, content here', making it
              look like readable English. Many desktop publishing packages and web
              page editors now use Lorem Ipsum as their default model text, and a
              search for 'lorem ipsum' will uncover many web sites still in their
              infancy. Various versions have evolved over the years, sometimes by
              accident, sometimes on purpose (injected humour and the like).
            </p>
            <p>
              <img
                src="./../../../src/images/Album.png"
                width="100"
                height="100"
              />
            </p>
          </div>
          <br />
          <div>
            <h2>Where does it come from?</h2>
            <p>
              Contrary to popular belief, Lorem Ipsum is not simply random text. It
              has roots in a piece of classical Latin literature from 45 BC, making
              it over 2000 years old. Richard McClintock, a Latin professor at
              Hampden-Sydney College in Virginia, looked up one of the more obscure
              Latin words, consectetur, from a Lorem Ipsum passage, and going
              through the cites of the word in classical literature, discovered the
              undoubtable source. Lorem Ipsum comes from sections 1.10.32 and
              1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and
              Evil) by Cicero, written in 45 BC. This book is a treatise on the
              theory of ethics, very popular during the Renaissance. The first line
              of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in
              section 1.10.32.
            </p>
            <p>
              The standard chunk of Lorem Ipsum used since the 1500s is reproduced
              below for those interested. Sections 1.10.32 and 1.10.33 from "de
              Finibus Bonorum et Malorum" by Cicero are also reproduced in their
              exact original form, accompanied by English versions from the 1914
              translation by H. Rackham.
            </p>
          </div>
          <div>
            <h2>Where can I get some?</h2>
            <p>
              There are many variations of passages of Lorem Ipsum available, but
              the majority have suffered alteration in some form, by injected
              humour, or randomised words which don't look even slightly believable.
              If you are going to use a passage of Lorem Ipsum, you need to be sure
              there isn't anything embarrassing hidden in the middle of text. All
              the Lorem Ipsum generators on the Internet tend to repeat predefined
              chunks as necessary, making this the first true generator on the
              Internet. It uses a dictionary of over 200 Latin words, combined with
              a handful of model sentence structures, to generate Lorem Ipsum which
              looks reasonable. The generated Lorem Ipsum is therefore always free
              from repetition, injected humour, or non-characteristic words etc.
            </p>
          </div>
        </smart-editor>
      </div>
    </template>
    
    <script>
    import { onMounted } from "vue";
    import "smart-webcomponents/source/styles/smart.default.css";
    import "smart-webcomponents/source/modules/smart.editor.js";
    
    export default {
      name: "app",
       mounted: function() {
          window.Smart(
            "#editor",
            class {
              get properties() {
                return {
                  //Properties
                  toolbarItems: [
                    "Bold",
                    "Italic",
                    "Underline",
                    "StrikeThrough",
                    "FontName",
                    "FontSize",
                    "FontColor",
                    "BackgroundColor",
                    "LowerCase",
                    "UpperCase",
                    "|",
                    "Formats",
                    "Alignment",
                    "OrderedList",
                    "UnorderedList",
                    "Outdent",
                    "Indent",
                    "|",
                    "hyperlink",
                    "table",
                    "Image",
                    "|",
                    "ClearFormat",
                    "Print",
                    "SourceCode",
                    "splitmode",
                    "FullScreen",
                    "|",
                    "Undo",
                    "Redo",
                    "subscript",
                    "superscript",
                    "delete",
                  ],
                };
              }
            }
          );
    
          const editor = document.getElementById("editor");
          editor.expandToolbar();
        };
    };
    </script>
    
    <style>
    html,
    body {
      width: 100%;
      height: 100%;
      margin: 0 auto;
    }
    
    .smart-editor {
      width: 100%;
      height: 100%;
    }
    
    .options {
      padding: 20px;
      background-color: rgba(191, 191, 191, 0.15);
      position: absolute;
      right: 0;
      top: 0;
      bottom: 0;
      width: 260px;
    }
    
    @media (max-width: 750px) {
      .options {
        position: relative;
        top: 30px;
        width: 240px;
        margin: 0 auto;
      }
    }
    
    #app,
    .vue-root {
      width: 100%;
      height: 100%;
    }
    </style>
    		
    We can now use the smart-editor with Vue. Data binding and event handlers will just work right out of the box.
    We have bound the properties of the smart-editor to values in our Vue component.

Running the Vue application

Start the app with
npm run serve
and open localhost:8080 in your favorite web browser to see the output below:

Read more about using Smart UI for Vue: https://www.htmlelements.com/docs/vue/.