{"id":20874989,"url":"https://github.com/servicestack/servicestack-editor","last_synced_at":"2025-12-29T01:23:30.846Z","repository":{"id":57140139,"uuid":"128116373","full_name":"ServiceStack/servicestack-editor","owner":"ServiceStack","description":"ServiceStack Markdown Editor for Vuetify","archived":false,"fork":false,"pushed_at":"2018-04-04T23:49:01.000Z","size":76,"stargazers_count":9,"open_issues_count":0,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-09T22:07:07.597Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Vue","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ServiceStack.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":"2018-04-04T20:13:32.000Z","updated_at":"2024-03-06T16:48:44.000Z","dependencies_parsed_at":"2022-09-05T01:30:28.773Z","dependency_job_id":null,"html_url":"https://github.com/ServiceStack/servicestack-editor","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ServiceStack%2Fservicestack-editor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ServiceStack%2Fservicestack-editor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ServiceStack%2Fservicestack-editor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ServiceStack%2Fservicestack-editor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ServiceStack","download_url":"https://codeload.github.com/ServiceStack/servicestack-editor/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243249011,"owners_count":20260768,"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-11-18T06:40:40.449Z","updated_at":"2025-12-29T01:23:30.814Z","avatar_url":"https://github.com/ServiceStack.png","language":"Vue","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @servicestack/editor\n\nServiceStack Markdown Editor is a developer-friendly Markdown Editor for Vuetify Apps which is optimized [GitHub Flavored Markdown](https://guides.github.com/features/mastering-markdown/) where it supports popular short-cuts for editing and documenting code like tab block un/indenting, single-line and code and comments blocks.\n\n![](https://i.imgur.com/YPlfplv.png)\n\n## Live Demo\n\nThis component was built for [techstacks.io](https://techstacks.io) website where it's used extensively for all posts, comments and anywhere else allowing rich markup using Markdown.\n\n## Install\n\n    $ npm install @servicestack/editor\n\n## Usage\n\nImport and register the Editor Vuetify component with your Vue Component to use it like a Vue Input Control, e.g:\n\n```html\n\u003ctemplate\u003e\n    \u003cEditor v-model=\"content\" label=\"Markdown\" /\u003e\n\u003c/template\u003e\n\n\u003cscript\u003e\nimport Editor from \"@servicestack/editor\";\n\nexport default {\n  components: { Editor },\n}\n\u003c/script\u003e\n```\n\nAs it's a wrapper around a [Vuetify text field](https://vuetifyjs.com/en/components/text-fields) it has access to a lot of the rich standard functionality available in Vuetify controls:\n\nVuetify properties:\n\n - `v-model`\n - `label`\n - `counter`\n - `rows`\n - `rules`\n - `errorMessages`\n - `autofocus`\n - `disabled`\n\nEditor properties:\n\n - `lang` - which language to use for syntax highlighting in code comment blocks\n\nEvents:\n\n - `@save`  - method to invoke when user clicks **Save** icon or `Ctrl+S` keyboard shortcut\n - `@close` - method to invoke when user presses the `ESC` key\n\n## Keyboard Shortcuts\n\nFor added productivity the Editor supports many of the popular Keyboard shortcuts in found in common IDEs:\n\n![](https://i.imgur.com/PXqkSuN.png)\n\n\u003e Note: pressing the shortcut multiple times toggles on/off the respective functionality\n\n## Example Usage\n\nThe [CommentEdit.vue](https://github.com/NetCoreApps/TechStacks/blob/master/src/TechStacks/src/components/CommentEdit.vue) \nshows a nice small and complete example of using the Editor for editing existing comments or submitting new ones. \n\nIt provides a user-friendly UX with declartive client and server-side validation where 'content' field validation errors\nshow up next to the Editor dialog whilst other errors are displayed in the FORM's `\u003cv-alert/\u003e` summary message.\n\nAnnotations were added to the implementation below to describe how the component works:\n\n```html\n\u003ctemplate\u003e\n    \u003cv-form v-model=\"valid\" ref=\"form\" lazy-validation\u003e\n        \u003cv-card\u003e\n            \u003cv-card-text\u003e\n                \u003cv-alert outline color=\"error\" icon=\"warning\" :value=\"errorMessage()\"\u003e\n                    {{ errorMessage() }}\n                \u003c/v-alert\u003e\n\n                \u003cEditor ref=\"editor\"\n                    label=\"Comment\"\n                    v-model=\"content\"\n                    :rows=\"6\"\n                    :counter=\"1000\"\n                    :rules=\"[ v =\u003e !v || v.length \u003c= 1000 || 'Max 1000 characters' ]\"\n                    :error-messages=\"errorResponse('content')\"\n                    :lang=\"csharp\"\n                    :autofocus=\"true\"\n                    @save=\"submit\"\n                    @close=\"reset()\"\n                /\u003e\n\n            \u003c/v-card-text\u003e\n            \u003cv-card-actions\u003e\n                \u003cv-layout\u003e\n                    \u003cv-btn flat @click=\"submit\"\u003eSubmit\u003c/v-btn\u003e\n                    \u003cv-btn v-if=\"replyId || comment\" flat @click=\"reset(false)\"\u003eClose\u003c/v-btn\u003e\n                \u003c/v-layout\u003e\n            \u003c/v-card-actions\u003e\n        \u003c/v-card\u003e\n    \u003c/v-form\u003e\n\u003c/template\u003e\n\n\u003cscript\u003e\nimport Editor from \"@servicestack/editor\";\nimport { mapGetters } from \"vuex\";\nimport { errorResponse } from \"@servicestack/client\";\nimport { createPostComment, updatePostComment } from \"~/shared/gateway\";\n\n// Editable comment fields\nconst comment = {\n    postId: null,\n    content: null\n};\n\nexport default {\n    components: { Editor },\n    props: ['post', 'comment', 'replyId', 'autofocus'],\n\n    methods: {\n        // Show top-level error messages or errors for the 'postId' field in the \u003cv-alert/\u003e summary dialog\n        errorMessage() {\n            return this.errorResponse() || this.errorResponse('postId'); \n        },\n\n        // Clear the form back to its original state\n        reset(added){\n            this.responseStatus = this.content = null;\n            this.valid = true;\n            this.$emit('done', added);\n        },\n\n        // Submit the comment to the server and overlay any error responses back on the form\n        async submit() {\n            if (this.$refs.form.validate()) { // Check if form passes all client validation rules\n                try {\n                    this.$store.commit('loading', true);  // indicate to the App that an API request is pending\n                    \n                    // If component was initialized with an existing `comment` update it, otherwise create anew\n                    const response = this.comment != null\n                        ? await updatePostComment(this.comment.id, this.post.id, this.content)\n                        : await createPostComment(this.postId, this.content, this.replyId);\n\n                    this.reset(true); // Clear the form back to a new state when successful\n\n                } catch(e) {\n                    this.valid = false;                          // mark this form as invalid\n                    this.responseStatus = e.responseStatus || e; // populate the server error response\n                } finally {\n                    this.$store.commit('loading', false); // indicate to the App that the API request is done\n                }\n            }\n        },\n        \n        // Register `errorResponse` function so it's available in the template\n        errorResponse, \n    },\n\n    // Initialize the component data from its properties\n    mounted() {\n        if (this.post) {\n            this.postId = this.post.id;\n        }\n        if (this.comment) {\n            this.content = this.comment.content;\n        }\n    },\n\n    data: () =\u003e ({\n        ...comment,           // Create reactive properties for all `comment` fields\n        valid: true,          // Holds whether the form is in an invalid state requiring user input to correct\n        responseStatus: null, // Captures the servers structured error response\n    }),\n}\n\u003c/script\u003e\n```\n\nThe `errorResponse` method from the [@servicestack/client](https://github.com/ServiceStack/servicestack-client) npm package is opinionated\nin handling ServiceStack's [structured API Response Errors](http://docs.servicestack.net/error-handling) but will work for any API returning\nthe simple error response schema below:\n\n```json\n{\n    \"errorCode\": \"ErrorCode\",\n    \"message\": \"Descriptive Summary Error Message\",\n    \"errors\": [\n        {\n            \"fieldName\": \"content\",\n            \"errorCode\": \"NotEmpty\",\n            \"message\": \"Descriptive Error Message for 'content' Field\"\n        }\n    ]\n}\n```\n\nWhich will check the components `this.responseStatus` property to return different error messages based on what field it was called with, e.g:\n\n```js\nerrorResponse()          //= Descriptive Summary Error Message\nerrorResponse('postId')  //= undefined\nerrorResponse('content') //= Descriptive Error Message for Field Error\n```\n\n## Feedback and Support\n\nServiceStack Customers can ask questions, report issues or submit feature requests from the [ServiceStack Community](https://techstacks.io/servicestack).\n\nIf you're not a Customer, please [ask Questions on StackOverflow](https://stackoverflow.com) with the `[servicestack]` hash tag.\n\nPull Requests for fixes and new features are welcome!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fservicestack%2Fservicestack-editor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fservicestack%2Fservicestack-editor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fservicestack%2Fservicestack-editor/lists"}