{"id":22144962,"url":"https://github.com/jim/toupee","last_synced_at":"2025-06-18T00:35:26.705Z","repository":{"id":66404223,"uuid":"207042","full_name":"jim/toupee","owner":"jim","description":"a small WYSIWYG framework for jQuery (inspired by wysihat)","archived":false,"fork":false,"pushed_at":"2009-11-13T00:02:02.000Z","size":151,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-02T18:54:46.220Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"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/jim.png","metadata":{"files":{"readme":"README.markdown","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2009-05-21T18:52:33.000Z","updated_at":"2017-05-03T05:13:14.000Z","dependencies_parsed_at":"2023-02-20T03:30:37.737Z","dependency_job_id":null,"html_url":"https://github.com/jim/toupee","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jim/toupee","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jim%2Ftoupee","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jim%2Ftoupee/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jim%2Ftoupee/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jim%2Ftoupee/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jim","download_url":"https://codeload.github.com/jim/toupee/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jim%2Ftoupee/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260462893,"owners_count":23013201,"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-12-01T22:36:36.648Z","updated_at":"2025-06-18T00:35:21.691Z","avatar_url":"https://github.com/jim.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"Toupee\n=======\n\n#### A jQuery port of the WysiHat JavaScript framework\n\nToupee is heavily based on work by Joshua Peek and the other contributors to the WysiHat project (http://github.com/josh/wysihat).\n\n## Introduction\n\n\n### Building the project\n\nFrom inside the project directory, run the build script:\n\n    ./build\n    \nYou will have a new file at \u003ccode\u003edist/toupee.js\u003c/code\u003e. There isn't any minifying or obfuscation done, as I've found most projects have their own static asset compression strategy. [Feel free to add one](http://developer.yahoo.com/yui/compressor/).\n\n### Supported platforms\n\nThis is alpha quality software; use at your own risk. Toupee appears to work in:\n\n* Firefox 3\n* Safari 4 beta\n\nIt has *not* been examined in:\n\n* Microsoft Internet Explorer\n* Mozilla Firefox 2\n* Apple Safari 3\n* Opera\n* Google Chrome\n\n### Known shortcomings\n\n* The test suite hasn't been ported over yet\n* The selection and range components of WysiHat haven't been ported yet\n* Copy/Cut/Paste not yet implemented\n\n### Dependencies\n\n* jQuery 1.3.2\n\n## API\n\nToupee takes a somewhat different approach that WysiHat when it comes to code structure and extensibility. My goal is to leverage custom events to make Toupee as flexible as possible.\n\n### $$\n\nThere is a global utility method, \u003ccode\u003e$$\u003c/code\u003e for accessing a DOM element's jQuery data hash. This technique and code are lifted from an article by Yehuda Katz on [evented programming](http://yehudakatz.com/2009/04/20/evented-programming-with-jquery/).\n\n### Creating an editor\n\nTo create an instance of the Toupee editor, call \u003ccode\u003etoupee()\u003c/code\u003e on a jQuery object that contains \u003ccode\u003etextareas\u003c/code\u003e:\n\n    $('textarea').toupee();\n    \nThis method will return the first element's \u003ccode\u003eeditor\u003c/code\u003e instance, which can also be accessed using the aforementioned \u003ccode\u003e$$\u003c/code\u003e method:\n\n    $$(domNodeOrJQuery).editor;\n\nWhen a change is made by the user, the hidden textarea's content is updated. So form submissions should work as the did before enhancement.\n\nThe \u003ccode\u003eeditor\u003c/code\u003e has many useful methods.\n\n### How it works\n\nToupee, like most other WYSIWYG editors, uses an \u003ccode\u003eiframe\u003c/code\u003e with \u003ccode\u003edesignMode\u003c/code\u003e turned on. The original textarea is hidden, and it's contents are updated as changes are made to the content in the iframe. This may become a performance issue, at which point updating the textarea's content will be fired by the form's submission.\n\n### editor.bind(eventName, callback)\n\n\u003ccode\u003eeditor.bind\u003c/code\u003e is a convenience method for binding event listeners to the editor (actually, all events/listeners are fired on/attached to \u003ccode\u003eeditor.widget\u003c/code\u003e). Inside the callback, \u003ccode\u003ethis\u003c/code\u003e is a reference to \u003ccode\u003eeditor.widget\u003c/code\u003e.\n\nHere is how to create a button that will create a link when clicked:\n\n    $$(domNome).editor.bind('link.click.toupee', function(event, editor) {\n        var link = prompt('Please enter the URL to link to:');\n        if (link) {\n            editor.exec('createLink', link);\n        }\n    });\n    \n### editor.button(buttonName, options)\n\nCreates a new button in the toolbar, which will fire \u003ccode\u003ebuttonName.click.toupee\u003c/code\u003e on \u003ccode\u003eeditor.widget\u003c/code\u003e when clicked. This method and \u003ccode\u003eeditor.bind\u003c/code\u003e allow for the creation of custom toolbars.\n\n### editor.exec(commandName, optionalArgument)\n\nBasically a wrapper for \u003ccode\u003eexecCommand\u003c/code\u003e. For more info, see [Rich-Text Editing in Mozilla](https://developer.mozilla.org/en/Rich-Text_Editing_in_Mozilla).\n\n### editor.run(func1, func2, ...)\n\nSince all configuration is done by calling methods on an \u003ccode\u003eeditor\u003c/code\u003e instance, this method will call all argument functions, passing in the \u003ccode\u003eeditor\u003c/code\u003e. This allows for packaging a set of toolbar buttons or configurations into a function for easy reuse. See \u003ccode\u003etoupee.buttons.js\u003c/code\u003e for some examples.\n\n### editor.htmlContent()\n\nReturns the cleaned HTML content from the \u003ccode\u003eeditor\u003c/code\u003e.\n\n## Examples\n\nThere is a single example under `example/` to get you started.\n\n## License\n\nToupee, like WysiHat, is released under the MIT license.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjim%2Ftoupee","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjim%2Ftoupee","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjim%2Ftoupee/lists"}