{"id":20818126,"url":"https://github.com/satanpit/selection-observer","last_synced_at":"2025-05-07T14:07:29.739Z","repository":{"id":43989909,"uuid":"241602173","full_name":"Satanpit/selection-observer","owner":"Satanpit","description":"Selection Observer API","archived":false,"fork":false,"pushed_at":"2023-01-07T15:01:18.000Z","size":890,"stargazers_count":7,"open_issues_count":9,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-07T14:07:22.719Z","etag":null,"topics":["range","rangeapi","selection","wysiwyg"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Satanpit.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}},"created_at":"2020-02-19T11:14:05.000Z","updated_at":"2022-04-15T02:43:44.000Z","dependencies_parsed_at":"2023-02-07T11:46:31.322Z","dependency_job_id":null,"html_url":"https://github.com/Satanpit/selection-observer","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Satanpit%2Fselection-observer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Satanpit%2Fselection-observer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Satanpit%2Fselection-observer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Satanpit%2Fselection-observer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Satanpit","download_url":"https://codeload.github.com/Satanpit/selection-observer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252892503,"owners_count":21820648,"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":["range","rangeapi","selection","wysiwyg"],"created_at":"2024-11-17T21:45:37.164Z","updated_at":"2025-05-07T14:07:29.714Z","avatar_url":"https://github.com/Satanpit.png","language":"JavaScript","readme":"# Selection Observer\n\nThis is JavaScript library for tracking selection changes in the page,\nwe will using this for create wysiwyg editor or page builder.\n\nFor track selection library use\n[Range API](https://developer.mozilla.org/en-US/docs/Web/API/Range),\n[Selection API](https://developer.mozilla.org/en-US/docs/Web/API/Selection)\nand listen `selectionchange` and `pointerdown` events\n\n## Browsers support\n\n![Chrome](https://raw.githubusercontent.com/alrra/browser-logos/master/src/chrome/chrome_48x48.png) | ![Firefox](https://raw.githubusercontent.com/alrra/browser-logos/master/src/firefox/firefox_48x48.png) | ![Opera](https://raw.githubusercontent.com/alrra/browser-logos/master/src/opera/opera_48x48.png) | ![Safari](https://raw.githubusercontent.com/alrra/browser-logos/master/src/safari/safari_48x48.png) | ![IE](https://raw.githubusercontent.com/alrra/browser-logos/master/src/edge/edge_48x48.png)\n--- | --- | --- | --- | --- |\nLatest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | ? |\n\n## Installing\n\n```bash\nnpm install selection-observer\n```\n\n## Demo\n\n[Demo page](https://satanpit.github.io/selection-observer/)\n\n## Example\n\nListen all selection changes:\n\n```javascript\nimport { SelectionObserver } from 'selection-observer';\n\nconst observer = new SelectionObserver((entry) =\u003e {\n  console.log(entry);\n});\n\nobserver.observe(document.body);\n```\n\nListen only base element changes:\n\n```javascript\nimport { SelectionObserver } from 'selection-observer';\n\nconst observer = new SelectionObserver((entry) =\u003e {\n  console.log(entry);\n});\n\nobserver.observe(document.body, {\n  onlyElements: true,\n});\n```\n\n## API\n\nSelectionObserver interface:\n```typescript\ninterface SelectionObserver {\n  constructor(callback: (entry: SelectionObserverEntry) =\u003e void);\n  observe(target: Element, options?: SelectionObserverObserveOptions): void;\n  disconnect(target: Element): void;\n  unselectHandler(callback: ({ target: Element, oldTarget: Element }) =\u003e void): void;\n}\n```\n\nSelectionObserverEntry interface:\n```typescript\ninterface SelectionObserverEntry {\n  target: Element;\n  tag: string;\n  type: 'layer' | 'title' | 'list' | 'list-item' | 'line' | 'image' | 'paragraph' | 'code' | string;\n  selection: Selection;\n  range: Range;\n  getSelectedNodes: () =\u003e Node[];\n}\n```\n\nSelectionObserverObserveOptions interface:\n```typescript\ninterface SelectionObserverObserveOptions {\n  filter: (item: Element) =\u003e boolean;\n  ignoreMainContainer: boolean;\n  onlyElements: boolean;\n}\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsatanpit%2Fselection-observer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsatanpit%2Fselection-observer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsatanpit%2Fselection-observer/lists"}