🚨 Active Supply Chain Attack:node-ipc Package Compromised.Learn More
Socket
Book a DemoSign in
Socket

@github/markdown-toolbar-element

Package Overview
Dependencies
Maintainers
20
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@github/markdown-toolbar-element - npm Package Compare versions

Comparing version
2.1.1
to
2.2.0
+52
-0
dist/index.js

@@ -42,2 +42,35 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {

const styles = new WeakMap();
const manualStyles = {
'header-1': { prefix: '# ' },
'header-2': { prefix: '## ' },
'header-3': { prefix: '### ' },
'header-4': { prefix: '#### ' },
'header-5': { prefix: '##### ' },
'header-6': { prefix: '###### ' },
bold: { prefix: '**', suffix: '**', trimFirst: true },
italic: { prefix: '_', suffix: '_', trimFirst: true },
quote: { prefix: '> ', multiline: true, surroundWithNewlines: true },
code: {
prefix: '`',
suffix: '`',
blockPrefix: '```',
blockSuffix: '```'
},
link: { prefix: '[', suffix: '](url)', replaceNext: 'url', scanFor: 'https?://' },
image: { prefix: '![', suffix: '](url)', replaceNext: 'url', scanFor: 'https?://' },
'unordered-list': {
prefix: '- ',
multiline: true,
unorderedList: true
},
'ordered-list': {
prefix: '1. ',
multiline: true,
orderedList: true
},
'task-list': { prefix: '- [ ] ', multiline: true, surroundWithNewlines: true },
mention: { prefix: '@', prefixSpace: true },
ref: { prefix: '#', prefixSpace: true },
strikethrough: { prefix: '~~', suffix: '~~', trimFirst: true }
};
class MarkdownButtonElement extends HTMLElement {

@@ -207,2 +240,15 @@ constructor() {

}
function applyFromToolbar(event) {
const { target, currentTarget } = event;
if (!(target instanceof HTMLElement))
return;
const mdButton = target.closest('[data-md-button]');
if (!mdButton || mdButton.closest('markdown-toolbar') !== currentTarget)
return;
const mdButtonStyle = target.getAttribute('data-md-button');
const style = manualStyles[mdButtonStyle];
if (!style)
return;
applyStyle(target, style);
}
class MarkdownToolbarElement extends HTMLElement {

@@ -216,2 +262,4 @@ connectedCallback() {

this.addEventListener('focus', onToolbarFocus, { once: true });
this.addEventListener('keydown', keydown(applyFromToolbar));
this.addEventListener('click', applyFromToolbar);
}

@@ -236,2 +284,4 @@ disconnectedCallback() {

return;
if (target.hasAttribute('data-no-focus'))
return;
target.removeAttribute('tabindex');

@@ -254,2 +304,4 @@ let tabindex = '0';

return;
if (toolbar.hasAttribute('data-no-focus'))
return;
const buttons = getButtons(toolbar);

@@ -256,0 +308,0 @@ const index = buttons.indexOf(event.target);

+2
-2
{
"name": "@github/markdown-toolbar-element",
"version": "2.1.1",
"version": "2.2.0",
"description": "Markdown formatting buttons for text inputs.",

@@ -40,3 +40,3 @@ "repository": "github/markdown-toolbar-element",

"karma-mocha-reporter": "^2.2.3",
"mocha": "^9.1.3",
"mocha": "^10.0.0",
"typescript": "^4.2.4"

@@ -43,0 +43,0 @@ },