Socket
Socket
Sign inDemoInstall

@baianat/align

Package Overview
Dependencies
Maintainers
2
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@baianat/align

ES6 text editor


Version published
Weekly downloads
5
increased by25%
Maintainers
2
Weekly downloads
 
Created
Source

Align

ES6 Text editor

key features

  • Build using ES6 classes
  • Customizing using arry of settings
  • Built-in colorpicker to change font color

example

How to use

include necessary files

<head>
  <link rel="stylesheet" href="dist/css/align.css">
</head>
<body>
    ...
    <script type="text/javascript" src="dist/js/align.js"></script>
</body>

HTML markup

you need an div to render editor in it.

<div class="editor"></div>

<script>
  let myEditor = new Align('.editor', {
    defaultText: 'Hello there I\'m Baianat\'s editor!'
  });
</script>

You can also pass the element directly to the constructor

<div class="editor"></div>

<script>
  const div = document.querySelector('.editor');
  let myEditor = new Align(div, {
    defaultText: 'Hello there I\'m Baianat\'s editor!'
  });
</script>

to customize editor's styler commands, you can pass to commands key as array of commands as value.

let myEditor = new Align('.editor', {
  styler: {
    mode: 'default', // default or bubble
    commands: ['color', 'sperator', 'fontName', 'fontSize']
  }
});

list of all available commands

CommandDiscription
colorChanges a font color for the selection or at the insertion point
fontNameChanges the font name for the selection or at the insertion point
fontSizeChanges the font size for the selection or at the insertion point
boldToggles bold on/off for the selection or at the insertion point
italicToggles italics on/off for the selection or at the insertion point
underlineToggles underline on/off for the selection or at the insertion point
strikeThroughToggles strikethrough on/off for the selection or at the insertion point
removeFormatRemoves all formatting from the current selection
justifyLeftJustifies the selection or insertion point to the left
justifyCenterCenters the selection or insertion point
justifyRightRight-justifies the selection or the insertion point
justifyFullJustifies the selection or insertion point
h1Adds an HTML h1 tag around the line containing the current selection
h2Adds an HTML h2 tag around the line containing the current selection
blockquoteAdds an HTML blockquote tag around the line containing the current selection
pAdds an HTML p tag around the line containing the current selection
preAdds an HTML pre tag around the line containing the current selection and highlight it's script
addImageUpload image add inseart it
htmlToggles HTML on/off for all text
speratorUse for decorate to sperate commands

finally to get editor's content you can use content propertie

saveToDatabase(myEditor.content);

License

MIT

Copyright (c) 2017 Baianat

FAQs

Package last updated on 11 Jan 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc