{"id":16994941,"url":"https://github.com/jackadams/meteor-editable-list","last_synced_at":"2025-04-12T05:26:28.300Z","repository":{"id":25273495,"uuid":"28699026","full_name":"JackAdams/meteor-editable-list","owner":"JackAdams","description":"An editable list widget for Meteor","archived":false,"fork":false,"pushed_at":"2022-11-22T07:59:41.000Z","size":63,"stargazers_count":15,"open_issues_count":3,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-26T00:51:17.700Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://editable-text-demo.meteor.com","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/JackAdams.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-01-02T00:06:04.000Z","updated_at":"2023-08-28T17:50:16.000Z","dependencies_parsed_at":"2023-01-14T02:26:48.659Z","dependency_job_id":null,"html_url":"https://github.com/JackAdams/meteor-editable-list","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/JackAdams%2Fmeteor-editable-list","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JackAdams%2Fmeteor-editable-list/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JackAdams%2Fmeteor-editable-list/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JackAdams%2Fmeteor-editable-list/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JackAdams","download_url":"https://codeload.github.com/JackAdams/meteor-editable-list/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248521277,"owners_count":21118042,"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":[],"created_at":"2024-10-14T03:47:07.667Z","updated_at":"2025-04-12T05:26:28.259Z","avatar_url":"https://github.com/JackAdams.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"Editable Lists for Meteor\n-------------------------\n\nThis package provides a widget for rendering the array (of strings) fields of documents as editable lists.\n\nExample app: [http://editable-text-demo.meteor.com](http://editable-text-demo.meteor.com) (the tags on posts are editable lists)\n\nExample app repo: [https://github.com/JackAdams/editable-text-demo](https://github.com/JackAdams/editable-text-demo)\n\nMinimal example app: [Meteorpad](http://meteorpad.com/pad/yM49AHwC3yYrYCEqs/editable-list)\n\n#### Quick Start\n\n\tmeteor add babrahams:editable-list\n\nYou can then drop an editable list widget into any Blaze template as follows:\n\n\t{{\u003e editableList collection=\"posts\" field=\"tags\"}}\n\t\nwhere \"posts\" is the name of the mongo collection and \"tags\" is the name of a document field for the `posts` collection (this field is an array of strings).\n\n`collection` and `field` are the only mandatory parameters.\n\nNote: The widget assumes that the data context is that of a single document from the `posts` collection (with _id value included).\n\nYou can also set the data context explicitly as follows:\n\n    {{\u003e editableList context=singlePostDocument collection=\"posts\" field=\"author\"}}\n\nwhere `singlePostDocument` can be a single post document already set in the current context, or provided by a template helper from the template that the widget was dropped into.\n\n(You can use `document`, `doc`, `object`, `obj`, `data` or `dataContext` instead of `context` - go with whichever you prefer.)\n\n#### Options\n\nThere are a number of parameters you can pass to the widget that affect its behaviour:\n\n`class=\"text-class\"` will change the class attribute of the `span` element (inside the `li` element) that wraps the text of a list item\n\n`style=dynamicStyle` can be used if you need to have more dynamic control over the style of the `span` elements wrapping editable list text (use a template helper to give the `dynamicStyle`) e.g.\n\t\n\tdynamicStyle : function() {\n\t  return 'color:' + Session.get('currentColor') + ';';\n\t} \n\nTo set a class/style on the `li` element of list items, use something like `liClass=\"my-list-item-class\"` or `liStyle=\"margin: 5px 5px 0 0;\"`. This is particularly useful for putting a margin on horizontal list items. (Don't set padding with these if you have a horizontal list -- it messes with the drag and drop. Set padding using `class=...` or `style=...`.)\n\nUse `editStyle` or `editClass` to style the `input` element used to edit a list item.\n\n`inputClass=\"input-class\"` will change the class attribute of the `input` element once the text is being edited\n\n`inputStyle=dynamicInputStyle` same as above, but for the `input` element used for adding list items\n\n`userCanEdit=userCanEdit` is a way to tell the widget whether the current user can edit the text or only view it (using a template helper) e.g.\n\t\n\tuserCanEdit : function() {\n\t  return this.user_id === Meteor.userId();\n\t}\n\n(Of course, to make this work, you'll have to save your documents with a `user_id` field that has a value equal to Meteor.userId() of the creator.)\n\n`placeholder=\"New post\"` will be the placeholder for the `input` element that allows users to enter new items into the list\n\n`saveOnFocusout=false` will prevent a particular widget instance from saving the text being edited on a `focusout` event (the default is to save the text, which can be changed via `EditableList.saveOnFocusout`)\n\n`trustHTML=true` will make a particular widget instance render its text as HTML (default is `false`, which can be changed via `EditableList.trustHTML`)\n\n`allowPasteMultiple=true` will mean that `\\n` separated items being pasted into the input box will automatically become separate items in the list\n\n`allowDuplicates=true` lets that user add items with identical text to the list (default is to not allow duplicates - i.e. use mongo's `$addToSet` rather than `$push`)\n\n`key=\"field-name\"` makes the widget assume that the `field` contains an array of objects rather than an array of strings; `field-name` is the field in the object whose (string) value gets edited; whole objects are removed from and/or added to the array by this widget, so be careful with this!\n\n#### Configuration\n\nYou can change the behaviour of the widget by setting certain properties of `EditableText`, which is a variable exposed by `babrahams:editable-text` which this package builds upon.\n\n#### Transactions\n\nThere is built-in support for the `babrahams:transactions` package, if you want everything to be undo/redo-able. To enable this:\n\n\tmeteor add babrahams:transactions\n\nand in your app (in some config file on both client and server), add:\n\n\tEditableText.useTransactions = true;\n\nOr if you only want transactions on particular instances of the widget, pass `useTransaction=true` or `useTransaction=false` to override the default that was set via `EditableText.useTransactions`, but this will only work if you also set `EditableText.clientControlsTransactions=true` (by default it is `false`). If you set the `EditableText.useTransactions` value on the server, without changing `EditableText.clientControlsTransactions`, it doesn't matter what you set on the client (or pass from the client), you will always get the behaviour as set on the server.\n\n__Note:__ you can set `objectTypeText=\"tag\"` to make the transaction description say \"added tag\" instead of \"added list item\". (Replace \"tag\" with the name of whatever type of item is in the list.)\n\n#### Security\n\nTo control whether certain users can edit text on certain documents/fields, you can (and _should_) overwrite the function `EditableText.userCanEdit` (which has the data used to initialize the widget as `this` and the document and collection as parameters).  e.g. (to only allow users to edit their own documents):\n\n\tEditableText.userCanEdit = function(doc,Collection) {\n\t  return doc.user_id === Meteor.userId();\n\t}\n\nSetting `EditableText.useMethods=false` will mean that all changes to documents are made on the client, so they are subject to the allow and deny rules you've defined for your collections.  In this case, it is a good idea to make the `EditableText.userCanEdit` function and your allow and deny functions share the same logic to the greatest degree possible.\n\n__Note:__ the default setting is `EditableText.useMethods=true`, meaning updates are processed server side and bypass your allow and deny rules. If you're happy with this (and you should be), then all you need to do for consistency between client and server permission checks is overwrite the `EditableText.userCanEdit` function in a file that is shared by both client and server.  Note again that this function receives the widget data context as `this` and the document and collection as the parameters.\n\n__Warning:__ if you set `EditableText.useMethods=false`, your data updates are being done on the client and you don't get html sanitization by default -- you'll have to sort this out or yourself via collection hooks or something. When `EditableText.useMethods=true` (the default setting) all data going into the database is passed through [htmlSantizer](https://github.com/punkave/sanitize-html).\n\n__Bigger warning:__ it doesn't really matter what you set `EditableText.useMethods` to -- you still need to lock down your collections using appropriate `allow` and `deny` rules. A malicious user can just type `EditableText.useMethods=false` into the browser console and this package will start making client side changes that are persisted or not entirely on the basis of your `allow` and `deny` rules.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjackadams%2Fmeteor-editable-list","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjackadams%2Fmeteor-editable-list","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjackadams%2Fmeteor-editable-list/lists"}