{"id":15048699,"url":"https://github.com/kkfor/for-editor","last_synced_at":"2025-05-16T18:06:28.354Z","repository":{"id":47604904,"uuid":"162717730","full_name":"kkfor/for-editor","owner":"kkfor","description":"for-editor - A markdown editor based on React","archived":false,"fork":false,"pushed_at":"2021-08-22T11:19:13.000Z","size":303,"stargazers_count":403,"open_issues_count":38,"forks_count":76,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-05-16T18:05:57.748Z","etag":null,"topics":["component","editor","javascript","markdown","markdown-editor","react"],"latest_commit_sha":null,"homepage":"https://md.kkfor.com/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kkfor.png","metadata":{"files":{"readme":"README.EN.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-12-21T13:31:55.000Z","updated_at":"2025-01-25T09:41:24.000Z","dependencies_parsed_at":"2022-09-11T19:00:55.140Z","dependency_job_id":null,"html_url":"https://github.com/kkfor/for-editor","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kkfor%2Ffor-editor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kkfor%2Ffor-editor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kkfor%2Ffor-editor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kkfor%2Ffor-editor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kkfor","download_url":"https://codeload.github.com/kkfor/for-editor/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254582904,"owners_count":22095518,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["component","editor","javascript","markdown","markdown-editor","react"],"created_at":"2024-09-24T21:15:27.176Z","updated_at":"2025-05-16T18:06:28.315Z","avatar_url":"https://github.com/kkfor.png","language":"TypeScript","readme":"# for-editor\n\n\u003e for-editor-A markdown editor based on React\n\n- [demo](https://md.kkfor.com)\n- [github](https://github.com/kkfor/for-editor)\n\n### Install\n\n```js\nnpm install for-editor -S\n```\n\n### Use\n\n```js\nimport React, { Component } from 'react'\nimport ReactDOM from 'react-dom'\nimport Editor from 'for-editor'\n\nclass App extends Component {\n  constructor() {\n    super()\n    this.state = {\n      value: ''\n    }\n  }\n\n  handleChange(value) {\n    this.setState({\n      value\n    })\n  }\n\n  render() {\n    const { value } = this.state\n    return \u003cEditor value={value} onChange={() =\u003e this.handleChange()} /\u003e\n  }\n}\n\nReactDOM.render(\u003cApp /\u003e, document.getElementById('root'))\n```\n\n### Api\n\n#### props\n\n| name        | type    | default                     | description                                                                                            |\n| ----------- | ------- | --------------------------- | ------------------------------------------------------------------------------------------------------ |\n| value       | String  | -                           | value                                                                                                  |\n| language    | String  | zh-CN                       | Language switch, zh-CN: Simplified Chinese, en: English                                                |\n| placeholder | String  | Begin editing...            | The default prompt text when the textarea is empty                                                     |\n| lineNum     | Boolean | true                        | Show lineNum                                                                                           |\n| style       | Object  | -                           | editor styles                                                                                          |\n| height      | String  | 600px                       | editor height                                                                                          |\n| preview     | Boolean | false                       | preview switch                                                                                         |\n| expand      | Boolean | false                       | fullscreen switch                                                                                      |\n| subfield    | Boolean | false                       | true: Double columns - Edit preview same screen(notice: preview: true), Single Columns - otherwise not |\n| toolbar     | Object  | As in the following example | toolbars                                                                                               |\n\n```js\n/*\n  The default toolbar properties are all true,\n  You can customize the object to cover them.\n  eg: {\n    h1: true,\n    code: true,\n    preview: true,\n  }\n  At this point, the toolbar only displays the three function keys.\n  notice: Toolbar will be hidden when empty object.\n */\n\ntoolbar: {\n  h1: true,\n  h2: true,\n  h3: true,\n  h4: true,\n  img: true,\n  link: true,\n  code: true,\n  preview: true,\n  expand: true,\n  /* v0.0.9 */\n  undo: true,\n  redo: true,\n  save: true,\n  /* v0.2.3 */\n  subfield: true\n}\n```\n\n#### events\n\n| name     | params        | default | description                                 |\n| -------- | ------------- | ------- | ------------------------------------------- |\n| onChange | String: value | -       | Edit area change callback event             |\n| onSave   | String: value | -       | Ctrl+s and click save button callback event |\n| addImg   | File: file    | -       | upload image callback event                 |\n\n##### upload image\n\n```js\nclass App extends Component {\n  constructor() {\n    super()\n    this.state = {\n      value: ''\n    }\n    this.$vm = React.createRef()\n  }\n\n  handleChange(value) {\n    this.setState({\n      value\n    })\n  }\n\n  addImg($file) {\n    this.$vm.current.$img2Url($file.name, 'file_url')\n    console.log($file)\n  }\n\n  render() {\n    const { value } = this.state\n\n    return (\n      \u003cEditor\n        ref={this.$vm}\n        value={value}\n        addImg={($file) =\u003e this.addImg($file)}\n        onChange={(value) =\u003e this.handleChange(value)}\n      /\u003e\n    )\n  }\n}\n```\n\n#### hot key\n\n| name   | description |\n| ------ | ----------- |\n| tab    | two space   |\n| ctrl+s | save        |\n| ctrl+z | undo        |\n| ctrl+y | redo        |\n\n### Update\n\n- [Update Log](./doc/UPDATELOG.md)\n\n# Licence\n\nfor-editor is [MIT Licence](./LICENSE).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkkfor%2Ffor-editor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkkfor%2Ffor-editor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkkfor%2Ffor-editor/lists"}