Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

atom-modal-views

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

atom-modal-views - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

spec/input-view-spec.js

7

CHANGELOG.md

@@ -0,1 +1,8 @@

## [1.0.1](https://github.com/UziTech/atom-modal-views/compare/v1.0.0...v1.0.1) (2020-08-19)
### Bug Fixes
* fix styles ([a9a2268](https://github.com/UziTech/atom-modal-views/commit/a9a2268862106c131bced99e42f477f15958dc91))
# 1.0.0 (2020-08-18)

@@ -2,0 +9,0 @@

2

package.json
{
"name": "atom-modal-views",
"version": "1.0.0",
"version": "1.0.1",
"description": "NPM Package Template",

@@ -5,0 +5,0 @@ "main": "src/index.js",

@@ -21,3 +21,3 @@ [![Actions Status](https://github.com/UziTech/atom-modal-views/workflows/tests/badge.svg)](https://github.com/UziTech/atom-modal-views/actions)

placeholder: "placeholder text",
value: "value text",
value: "initial value",
});

@@ -27,1 +27,10 @@

```
### Options
| Name | Default | Description |
|:------------|:-------:|:---------------------------------------------|
| title | `""` | Title inside `<h1>` tag |
| description | `""` | Description can contain markdown |
| placeholder | `""` | Placeholder text to show when input is empty |
| value | `""` | The initial value |

@@ -8,24 +8,26 @@ /** @babel */

const renderer = new marked.Renderer();
renderer.code = () => "";
renderer.blockquote = () => "";
renderer.heading = () => "";
renderer.html = () => "";
renderer.image = () => "";
renderer.list = () => "";
let oldView;
function markedCache(md) {
// eslint-disable-next-line eqeqeq
md = (md == null ? "" : String(md));
if (!this.cache) {
this.cache = {};
}
if (md) {
if (!this.cache[md]) {
this.cache[md] = marked(md, { renderer }).replace(/<p>(.*)<\/p>/, "$1").trim();
}
return this.cache[md];
if (!this.cache[md]) {
this.cache[md] = marked(md).trim();
}
return this.cache[md];
}
const defaults = {
title: "",
description: "",
placeholder: "",
value: "",
};
module.exports = class InputView {

@@ -38,21 +40,25 @@ constructor(props = {}) {

this.props = { ...props };
this.props = { ...defaults, ...props };
etch.initialize(this);
this.renderPromise = Promise.resolve();
this.element.addEventListener("focusout", (e) => this.didChangeFocus(e));
this.editor = this.refs.editor;
const editorElement = this.editor.getElement();
this.updateText();
for (const element of [this.element, ...this.element.querySelectorAll("*")]) {
element.addEventListener("blur", (e) => this.didChangeFocus(e));
if (this.props.value) {
this.editor.setText(this.props.value);
this.editor.selectAll();
}
this.panel = atom.workspace.addModalPanel({ item: this, autoFocus: true });
this.editor.selectAll();
const editorElement = atom.views.getView(this.editor);
this.disposables = new CompositeDisposable();
this.disposables.add(
this.editor.onDidStopChanging(() => this.didChangeValue()),
atom.commands.add(editorElement, "core:cancel", () => this.destroy()),
atom.commands.add(editorElement, "core:confirm", () => this.confirm()),
this.panel.onDidChangeVisible(v => this.didChangeVisibility(v)),
this.panel.onDidChangeVisible(visible => this.didChangeVisibility(visible)),
);

@@ -81,15 +87,17 @@

async update(props = {}) {
didChangeValue() {
this.props.value = this.editor.getText();
}
update(props = {}) {
this.props = { ...this.props, ...props };
await etch.update(this);
this.renderPromise = etch.update(this).then(() => {
if ("value" in props) {
this.editor.setText(props.value);
}
});
return this.renderPromise;
}
updateText() {
if (this.props.value) {
this.editor.setText(this.props.value);
delete this.props.value;
}
}
render() {

@@ -128,6 +136,7 @@ const description = markedCache(this.props.description);

async confirm() {
const gistId = this.editor.getText();
this.resolve(gistId);
this.didChangeValue();
const value = this.props.value;
this.resolve(value);
await this.destroy();
}
};
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