react-markdown-editor-lite
Version:
a light-weight Markdown editor based on React
119 lines (118 loc) • 4.42 kB
JavaScript
;
var __webpack_require__ = {};
(()=>{
__webpack_require__.n = (module)=>{
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
__webpack_require__.d(getter, {
a: getter
});
return getter;
};
})();
(()=>{
__webpack_require__.d = (exports1, definition)=>{
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
enumerable: true,
get: definition[key]
});
};
})();
(()=>{
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
})();
(()=>{
__webpack_require__.r = (exports1)=>{
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
value: 'Module'
});
Object.defineProperty(exports1, '__esModule', {
value: true
});
};
})();
var __webpack_exports__ = {};
__webpack_require__.r(__webpack_exports__);
__webpack_require__.d(__webpack_exports__, {
default: ()=>TabInsert
});
const external_react_namespaceObject = require("react");
var external_react_default = /*#__PURE__*/ __webpack_require__.n(external_react_namespaceObject);
const index_js_namespaceObject = require("../../components/DropList/index.js");
var index_js_default = /*#__PURE__*/ __webpack_require__.n(index_js_namespaceObject);
const Icon_index_js_namespaceObject = require("../../components/Icon/index.js");
var Icon_index_js_default = /*#__PURE__*/ __webpack_require__.n(Icon_index_js_namespaceObject);
const external_i18n_index_js_namespaceObject = require("../../i18n/index.js");
var external_i18n_index_js_default = /*#__PURE__*/ __webpack_require__.n(external_i18n_index_js_namespaceObject);
const external_Plugin_js_namespaceObject = require("../Plugin.js");
const external_TabMapList_js_namespaceObject = require("./TabMapList.js");
var external_TabMapList_js_default = /*#__PURE__*/ __webpack_require__.n(external_TabMapList_js_namespaceObject);
class TabInsert extends external_Plugin_js_namespaceObject.PluginComponent {
static pluginName = 'tab-insert';
static defaultConfig = {
tabMapValue: 1
};
handleKeyboard;
constructor(props){
super(props);
this.show = this.show.bind(this);
this.hide = this.hide.bind(this);
this.handleChangeMapValue = this.handleChangeMapValue.bind(this);
this.state = {
tabMapValue: this.getConfig('tabMapValue'),
show: false
};
this.handleKeyboard = {
key: 'Tab',
keyCode: 9,
aliasCommand: true,
withKey: [],
callback: ()=>this.editor.insertMarkdown('tab', {
tabMapValue: this.state.tabMapValue
})
};
}
show() {
this.setState({
show: true
});
}
hide() {
this.setState({
show: false
});
}
handleChangeMapValue(mapValue) {
this.setState({
tabMapValue: mapValue
});
}
componentDidMount() {
if (this.editorConfig.shortcuts) this.editor.onKeyboard(this.handleKeyboard);
}
componentWillUnmount() {
this.editor.offKeyboard(this.handleKeyboard);
}
render() {
return /*#__PURE__*/ external_react_default().createElement("span", {
className: "button button-type-header",
title: external_i18n_index_js_default().get('selectTabMap'),
onClick: this.show,
onMouseLeave: this.hide
}, /*#__PURE__*/ external_react_default().createElement(Icon_index_js_default(), {
type: "tab"
}), /*#__PURE__*/ external_react_default().createElement(index_js_default(), {
show: this.state.show,
onClose: this.hide
}, /*#__PURE__*/ external_react_default().createElement(external_TabMapList_js_default(), {
value: this.state.tabMapValue,
onSelectMapValue: this.handleChangeMapValue
})));
}
}
exports["default"] = __webpack_exports__["default"];
for(var __rspack_i in __webpack_exports__)if (-1 === [
"default"
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
Object.defineProperty(exports, '__esModule', {
value: true
});