{"id":14990222,"url":"https://github.com/markcellus/content-editable","last_synced_at":"2025-12-12T05:54:25.026Z","repository":{"id":36981244,"uuid":"57386193","full_name":"markcellus/content-editable","owner":"markcellus","description":"An HTML element that makes its content editable","archived":false,"fork":false,"pushed_at":"2023-05-17T04:07:38.000Z","size":2149,"stargazers_count":23,"open_issues_count":6,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-12T02:06:17.617Z","etag":null,"topics":["contenteditable","customelement","inline-editing","input","textarea","webcomponent"],"latest_commit_sha":null,"homepage":"","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/markcellus.png","metadata":{"files":{"readme":"README.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-04-29T13:29:24.000Z","updated_at":"2024-03-20T15:10:09.000Z","dependencies_parsed_at":"2024-09-18T16:34:22.854Z","dependency_job_id":"a764fd1d-5486-4d5b-9f34-302f55eb6762","html_url":"https://github.com/markcellus/content-editable","commit_stats":{"total_commits":287,"total_committers":7,"mean_commits":41.0,"dds":0.5574912891986064,"last_synced_commit":"887b6de8774e26db4b4453e22adfd205ef8bf501"},"previous_names":["mkay581/editable-content","mkay581/inline-edit-js"],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markcellus%2Fcontent-editable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markcellus%2Fcontent-editable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markcellus%2Fcontent-editable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markcellus%2Fcontent-editable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/markcellus","download_url":"https://codeload.github.com/markcellus/content-editable/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248505862,"owners_count":21115354,"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":["contenteditable","customelement","inline-editing","input","textarea","webcomponent"],"created_at":"2024-09-24T14:19:44.114Z","updated_at":"2025-12-12T05:54:19.975Z","avatar_url":"https://github.com/markcellus.png","language":"TypeScript","readme":"[![Build Status](https://travis-ci.org/markcellus/content-editable.svg?branch=master)](https://travis-ci.org/markcellus/content-editable)\n[![npm version](https://badge.fury.io/js/content-editable.svg)](https://www.npmjs.com/package/content-editable)\n[![Coverage Status](https://coveralls.io/repos/github/markcellus/content-editable/badge.svg?branch=master)](https://coveralls.io/github/markcellus/content-editable?branch=master)\n\n# `\u003ccontent-editable\u003e`\n\nA custom element that makes its contents editable by changing itself into an text field, when a user clicks on it.\n\nThis library was created to support features missing in [the `contenteditable` property specification](https://html.spec.whatwg.org/multipage/interaction.html#contenteditable) and to alleviate its [inconsistent browser implementations](https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Editable_content#Differences_in_markup_generation).\n\n## Installation\n\n```bash\nnpm i content-editable\n```\n\n## Usage\n\n```html\n\u003cscript src=\"node_modules/content-editable/dist/content-editable.js\"\u003e\u003c/script\u003e\n\u003ccontent-editable\u003eChange Me\u003c/content-editable\u003e\n```\n\nThen, when clicking anywhere on the element, a text field will show allowing the user to change the text.\n\n## API\n\n### Attributes\n\n| Attribute   | Type      | Default | Description                                                                                                                    |\n| ----------- | --------- | ------- | ------------------------------------------------------------------------------------------------------------------------------ |\n| `readonly`  | `Boolean` | `false` | Whether the text should be editable or not.                                                                                    |\n| `multiline` | `Boolean` | `false` | Whether pressing enter should create a newline. If this is set to `true`, pressing enter will update the value to the new one. |\n\n### Events\n\nYou can listen in on when the text field contents have changed.\n\n```javascript\nconst element = document.querySelector('content-editable');\nelement.addEventListener('edit', (e) =\u003e {\n    console.log(e.target.innerHTML); // the new value\n    console.log(e.target.previousInnerHTML); // old value\n});\n```\n\n| Event  | Type          | Description                                                                                                                                                                                                                                                  |\n| ------ | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| `edit` | `CustomEvent` | Fired with a custom event when the text value has been successfully changed to a new value. The event `detail` will include both a `textContent` field that contains the updated value and a `previousTextContent` field that contains the last-known value. |\n\nOf course, all of the other [events supported by any HTMLElement](https://html.spec.whatwg.org/multipage/webappapis.html#globaleventhandlers) are still available.\n\n## Styling\n\nAn `editing` attribute is applied to the element when the text inside of the element is in focus. So you\ncan style based on this attribute. The following turns the element's background to `blue` when\nit is being edited.\n\n```css\ncontent-editable[editing] {\n    background-color: blue;\n}\n```\n\n#### Formatting whitespace\n\nIf you would like for line breaks or any other formatting to be respected, just apply `white-space` css property.\n\n```css\ncontent-editable {\n    white-space: pre;\n}\n```\n\n## Development\n\nRun tests\n\n```bash\nnpm test\n```\n\nRun static server in examples directory\n\n```bash\nnpm start\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarkcellus%2Fcontent-editable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarkcellus%2Fcontent-editable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarkcellus%2Fcontent-editable/lists"}