{"id":24379716,"url":"https://github.com/y-js/y-xml","last_synced_at":"2025-04-10T21:09:48.145Z","repository":{"id":27939762,"uuid":"31432313","full_name":"y-js/y-xml","owner":"y-js","description":"XML Type for Yjs","archived":false,"fork":false,"pushed_at":"2017-10-02T19:10:29.000Z","size":2201,"stargazers_count":12,"open_issues_count":0,"forks_count":2,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-04-10T21:09:41.693Z","etag":null,"topics":["yjs","yjs-type"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/y-js.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":"2015-02-27T18:06:42.000Z","updated_at":"2024-10-02T04:36:30.000Z","dependencies_parsed_at":"2022-08-20T06:20:47.342Z","dependency_job_id":null,"html_url":"https://github.com/y-js/y-xml","commit_stats":null,"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/y-js%2Fy-xml","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/y-js%2Fy-xml/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/y-js%2Fy-xml/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/y-js%2Fy-xml/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/y-js","download_url":"https://codeload.github.com/y-js/y-xml/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248298331,"owners_count":21080320,"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":["yjs","yjs-type"],"created_at":"2025-01-19T07:18:53.340Z","updated_at":"2025-04-10T21:09:48.130Z","avatar_url":"https://github.com/y-js.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# XML Type for [Yjs](https://github.com/y-js/yjs)\n\nShare XML documents with this type. You can also get a DOM representation of this shared Y.Xml type. Y.Xml does not yet support the full DOM specification. \n\n## Use it!\nRetrieve this with bower or npm.\n\n##### Bower\n```\nbower install y-xml --save\n```\n\n##### NPM\n```\nnpm install y-xml y-array y-map --save\n```\n\nThis type depends on [y-array](https://github.com/y-js/y-array), and [y-map](https://github.com/y-js/y-map). So you have to extend Yjs in the right order:\n\n```js\nvar Y = require('yjs')\nrequire('y-array')(Y)\nrequire('y-map')(Y)\nrequire('y-xml')(Y)\n```\n\n### Xml Object\n\n##### Create\nY.Xml expects a tagname, or a DOM Element as constructor argument. I.e.\n\n```js\nmap.set('myXmlType', Y.XmlElement('div'))\nmap.set('myOtherXmlType', Y.XmlElement(document.querySelector('div')))\nmap.set('myXmlFragment', Y.XmlFragment)\n```\n\nWhen creating a Y.Xml type on y.share, you can specify the tagname like this:\n```js\nY({\n  ..\n  share: {\n    xml: 'XmlElement(\"div\")'\n  }\n})\n```\n\n##### Reference\n\n*Y.XmlFragment* - A collection of nodes\n\n* bindToDom(dom)\n  * Bind the children of a dom element to the nodes of this XmlFragment. Useful if you don't want to share the attributes of the root node\n\n*Y.XmlElement*\n\n* .setDomFilter((domElement, attributeNames) =\u003e filteredAttributes)\n  * Filter out specific dom elements and attributes\n  * If `filteredAttributes` is null, the node will not be shared\n  * Attribute names that are in `attributeNames` but not in `filteredAttributes` will not be shared\n* .getDom()\n  * Returns a DOM Element\n* .insert(position, contents)\n  * Insert an array of children at a position\n* .insertDomElements(position, domElements)\n  * Insert an array of dom elements at a position\n* .delete(position, length)\n  * Delete children. The *length* parameter is optional and defaults to 1\n* .get(position)\n  * Retrieve a child at a position\n  * Returns a promise if the content is a Y.Xml type\n* .observe(function observer(events){..})\n  * The `observer` is called synchronously when something changed\n  * Throws *attributeChanged*, *attributeRemoved*, *childInserted*, and *childRemoved* events (`events[*].type`)\n  * If value is a Y.Xml type, `events[*].value` is a function that returns a promise for the type\n  * When employing the DOM binding, you may want to use DOM [MutationObserver](https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver) instead of `.observe(..)`\n* .getAttribute(name)\n  * Get a specific attribute\n* .setAttribute(name, value)\n  * Set a attribute. `value` must be of type string\n* .unobserve(f)\n  * Delete an observer\n\n## Changelog\n\n### 11.0.0\n* `contenteditable` is supported\n* Relies on Yjs@^13.0.0\n\n### 10.0.0\n* Retrieving the dom is a synchronous operation now\n* Relies on Yjs@^12.0.0\n\n## License\nYjs is licensed under the [MIT License](./LICENSE).\n\n\u003ckevin.jahns@rwth-aachen.de\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fy-js%2Fy-xml","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fy-js%2Fy-xml","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fy-js%2Fy-xml/lists"}