@st1myl/entrl-react
Advanced tools
Comparing version 1.1.134 to 1.1.135
@@ -1,3 +0,3 @@ | ||
import React, { Component } from 'react'; | ||
import { EditorState } from 'draft-js'; | ||
import React, { Component } from "react"; | ||
import { EditorState } from "draft-js"; | ||
interface IProps { | ||
@@ -4,0 +4,0 @@ className?: string; |
@@ -17,6 +17,6 @@ "use strict"; | ||
const buttonValues = [ | ||
{ title: 'Strong Ctrl+B', className: 'descr-button-bold', style: 'BOLD' }, | ||
{ title: 'Italic Ctrl+I', className: 'descr-button-italic', style: 'ITALIC' }, | ||
{ title: 'Bulleted List Ctrl+U', className: 'descr-button-ulist', style: 'unordered-list-item' }, | ||
{ title: 'Numbered List Ctrl+O', className: 'descr-button-olist', style: 'ordered-list-item' } | ||
{ title: "Strong Ctrl+B", className: "descr-button-bold", style: "BOLD" }, | ||
{ title: "Italic Ctrl+I", className: "descr-button-italic", style: "ITALIC" }, | ||
{ title: "Bulleted List Ctrl+U", className: "descr-button-ulist", style: "unordered-list-item" }, | ||
{ title: "Numbered List Ctrl+O", className: "descr-button-olist", style: "ordered-list-item" } | ||
]; | ||
@@ -45,16 +45,19 @@ class Description extends react_1.Component { | ||
const newState = draft_js_1.RichUtils.handleKeyCommand(editorState, command); | ||
if (newState) | ||
if (newState) { | ||
this.handleChange(newState); | ||
} | ||
}; | ||
this._handleBeforeInput = () => { | ||
const currentContent = this.state.editorState.getCurrentContent(); | ||
const currentContentLength = currentContent.getPlainText('').length; | ||
if (currentContentLength > this.MAX_LENGTH - 1) | ||
return 'handled'; | ||
const currentContentLength = currentContent.getPlainText("").length; | ||
if (currentContentLength > this.MAX_LENGTH - 1) { | ||
return "handled"; | ||
} | ||
}; | ||
this._handlePastedText = (pastedText) => { | ||
const currentContent = this.state.editorState.getCurrentContent(); | ||
const currentContentLength = currentContent.getPlainText('').length; | ||
if (currentContentLength + pastedText.length > this.MAX_LENGTH) | ||
return 'handled'; | ||
const currentContentLength = currentContent.getPlainText("").length; | ||
if (currentContentLength + pastedText.length > this.MAX_LENGTH) { | ||
return "handled"; | ||
} | ||
}; | ||
@@ -65,6 +68,6 @@ } | ||
const contentState = this.state.editorState.getCurrentContent(); | ||
let className = 'RichEditor-editor'; | ||
let className = "RichEditor-editor"; | ||
if (!contentState.hasText()) { | ||
if (contentState.getBlockMap().first().getType() !== 'unstyled') { | ||
className += ' RichEditor-hidePlaceholder'; | ||
if (contentState.getBlockMap().first().getType() !== "unstyled") { | ||
className += " RichEditor-hidePlaceholder"; | ||
} | ||
@@ -84,3 +87,3 @@ } | ||
react_1.default.createElement("div", { className: "input-descr-textarea-counter" }, | ||
react_1.default.createElement("span", { className: classnames_1.default({ 'counter-max-value': contentState.getPlainText('').length === 4096 }) }, contentState.getPlainText('').length), | ||
react_1.default.createElement("span", { className: classnames_1.default({ "counter-max-value": contentState.getPlainText("").length === 4096 }) }, contentState.getPlainText("").length), | ||
"/", | ||
@@ -114,3 +117,3 @@ react_1.default.createElement("span", null, "4096"))), | ||
render() { | ||
return (react_1.default.createElement("li", { title: this.props.title, onMouseDown: this.onToggle, className: classnames_1.default('descr-button', this.props.className, { 'active': this.props.active }) }, | ||
return (react_1.default.createElement("li", { title: this.props.title, onMouseDown: this.onToggle, className: classnames_1.default("descr-button", this.props.className, { active: this.props.active }) }, | ||
react_1.default.createElement("span", null))); | ||
@@ -117,0 +120,0 @@ } |
@@ -1,3 +0,3 @@ | ||
import Description from './Description'; | ||
import Description from "./Description"; | ||
export default Description; | ||
//# sourceMappingURL=index.d.ts.map |
export { default as Header } from "./Header"; | ||
export { default as Nav } from './Nav'; | ||
export { default as Nav } from "./Nav"; | ||
export { default as GenericPortal } from "./GenericPortal"; | ||
export { default as Description } from './Description'; | ||
export { default as Tags } from './Tags'; | ||
export { default as Description } from "./Description"; | ||
export { default as Tags } from "./Tags"; | ||
//# sourceMappingURL=index.d.ts.map |
import { Component } from "react"; | ||
declare type NavProps = { | ||
interface NavProps { | ||
className?: string; | ||
items: string[]; | ||
}; | ||
declare type State = { | ||
} | ||
interface State { | ||
isClicked: boolean; | ||
idx: number; | ||
hidden: boolean; | ||
}; | ||
} | ||
declare class Nav extends Component<NavProps, State> { | ||
@@ -12,0 +12,0 @@ state: State; |
@@ -36,7 +36,7 @@ "use strict"; | ||
this.isScroll(); | ||
window.addEventListener('scroll', this.isScroll); | ||
window.addEventListener("scroll", this.isScroll); | ||
} | ||
render() { | ||
return (react_1.default.createElement("div", { className: classnames_1.default('nav', { 'active': !this.state.hidden }) }, | ||
react_1.default.createElement("div", { className: classnames_1.default('nav-wrapper', { 'closed': this.state.isClicked }) }, | ||
return (react_1.default.createElement("div", { className: classnames_1.default("nav", { active: !this.state.hidden }) }, | ||
react_1.default.createElement("div", { className: classnames_1.default("nav-wrapper", { closed: this.state.isClicked }) }, | ||
react_1.default.createElement("div", { className: "nav-head" }, | ||
@@ -46,3 +46,3 @@ react_1.default.createElement("h2", null, "\u041D\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u044F")), | ||
react_1.default.createElement("ul", null, this.props.items.map((name, key) => { | ||
return react_1.default.createElement("li", { key: key, onClick: () => this.isToggle(key), className: classnames_1.default({ 'active': this.state.idx === key }) }, name); | ||
return react_1.default.createElement("li", { key: key, onClick: () => this.isToggle(key), className: classnames_1.default({ active: this.state.idx === key }) }, name); | ||
})))))); | ||
@@ -49,0 +49,0 @@ } |
@@ -1,3 +0,3 @@ | ||
import Tags from './Tags'; | ||
import Tags from "./Tags"; | ||
export default Tags; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -1,3 +0,3 @@ | ||
import React, { Component } from 'react'; | ||
declare type State = { | ||
import React, { Component } from "react"; | ||
interface State { | ||
isStacked: boolean; | ||
@@ -7,7 +7,7 @@ isFocused: boolean; | ||
tags: string[]; | ||
}; | ||
declare type Props = { | ||
} | ||
interface Props { | ||
id?: string; | ||
className?: string; | ||
}; | ||
} | ||
declare class Tags extends Component<Props, State> { | ||
@@ -14,0 +14,0 @@ readonly input: React.RefObject<HTMLInputElement>; |
@@ -26,3 +26,3 @@ "use strict"; | ||
this.customFocus = () => { | ||
if (!(this.input.current.classList.contains('tags-editor-focused'))) { | ||
if (!(this.input.current.classList.contains("tags-editor-focused"))) { | ||
this.input.current.focus(); | ||
@@ -34,6 +34,6 @@ } | ||
//default | ||
input.style.width = '0px'; | ||
input.style.width = "0px"; | ||
input.style.width = `${input.scrollWidth + 16}px`; | ||
}; | ||
this.removeSpaces = e => this.setState({ inputValue: e.target.value.replace(/\s/g, '') }); | ||
this.removeSpaces = e => this.setState({ inputValue: e.target.value.replace(/\s/g, "") }); | ||
this.preventDefaultEnter = e => { | ||
@@ -46,3 +46,3 @@ const { tags } = this.state; | ||
this.setState({ tags: [...tags, value] }); | ||
this.setState({ inputValue: '' }); | ||
this.setState({ inputValue: "" }); | ||
} | ||
@@ -76,6 +76,6 @@ else if (tags.length === 8) { | ||
if (previousElement.children.length <= 3) { | ||
console.log('button', 'event', previousElement.children.length); | ||
console.log("button", "event", previousElement.children.length); | ||
previousElement.style.transform = `translateX(0)`; | ||
input.style.transform = `translateX(0)`; | ||
input.style.width = '100%'; | ||
input.style.width = "100%"; | ||
} | ||
@@ -104,3 +104,2 @@ else if (previousElement.children.length >= 4 && previousElement.clientWidth >= 500) { | ||
console.log(e.target); | ||
//TODO: translate on deleting tags | ||
this.isSubtracted(e.target.clientWidth); | ||
@@ -115,4 +114,4 @@ }; | ||
const { tags } = this.state; | ||
return (react_1.default.createElement("div", { className: classnames_1.default('tags', { 'tags-focused': this.state.isFocused }, { 'tags-stacked': this.state.isStacked }), onClick: this.customFocus }, | ||
react_1.default.createElement("div", { className: 'tags-editor' }, | ||
return (react_1.default.createElement("div", { className: classnames_1.default("tags", { "tags-focused": this.state.isFocused }, { "tags-stacked": this.state.isStacked }), onClick: this.customFocus }, | ||
react_1.default.createElement("div", { className: "tags-editor" }, | ||
react_1.default.createElement("div", { className: "tags-editor-set" }, tags.map((tag, idx) => { | ||
@@ -126,3 +125,3 @@ return (react_1.default.createElement("span", { className: "tags-editor-set-item", key: `set-item-${idx}`, onClick: e => { | ||
})), | ||
react_1.default.createElement("input", { ref: this.input, type: "text", id: this.props.id, value: this.state.inputValue, placeholder: tags.length > 0 ? ` ` : `Добавьте тег`, className: classnames_1.default('tags-editor-input', { 'tags-editor-input-active': tags.length > 0 }, this.props.className), onChange: e => { | ||
react_1.default.createElement("input", { ref: this.input, type: "text", id: this.props.id, value: this.state.inputValue, placeholder: tags.length > 0 ? ` ` : `Добавьте тег`, className: classnames_1.default("tags-editor-input", { "tags-editor-input-active": tags.length > 0 }, this.props.className), onChange: e => { | ||
this.removeSpaces(e); | ||
@@ -137,4 +136,4 @@ this.isSubtracted(); | ||
}, onKeyPress: e => this.preventDefaultEnter(e), onKeyDown: e => this.isBackSpace(e), autoComplete: "off", maxLength: 24 })), | ||
react_1.default.createElement("div", { className: 'tags-counter' }, | ||
react_1.default.createElement("span", { className: classnames_1.default({ 'tags-counter-max': tags.length === 8 }) }, tags.length), | ||
react_1.default.createElement("div", { className: "tags-counter" }, | ||
react_1.default.createElement("span", { className: classnames_1.default({ "tags-counter-max": tags.length === 8 }) }, tags.length), | ||
"/", | ||
@@ -141,0 +140,0 @@ react_1.default.createElement("span", null, "8")))); |
{ | ||
"name": "@st1myl/entrl-react", | ||
"author": "St1myL", | ||
"version": "1.1.134", | ||
"version": "1.1.135", | ||
"repository": "st1myl/entrl-react", | ||
@@ -32,3 +32,2 @@ "main": "./lib/index.js", | ||
"jest": "^24.7.1", | ||
"node-sass": "^4.11.0", | ||
"rimraf": "^2.6.3", | ||
@@ -35,0 +34,0 @@ "ts-jest": "^24.0.2", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
80568
12
583