{"id":20438450,"url":"https://github.com/tinymce/tinymce-swing-codesamples","last_synced_at":"2025-04-12T22:35:53.474Z","repository":{"id":40373863,"uuid":"175562745","full_name":"tinymce/tinymce-swing-codesamples","owner":"tinymce","description":"Code samples for the TinyMCE Swing Integration","archived":false,"fork":false,"pushed_at":"2022-11-11T01:18:37.000Z","size":87,"stargazers_count":4,"open_issues_count":1,"forks_count":3,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-26T16:39:12.645Z","etag":null,"topics":["java-swing","tinymce","tinymce-swing"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tinymce.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null}},"created_at":"2019-03-14T06:35:44.000Z","updated_at":"2022-12-11T16:18:34.000Z","dependencies_parsed_at":"2023-01-22T15:30:38.251Z","dependency_job_id":null,"html_url":"https://github.com/tinymce/tinymce-swing-codesamples","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/tinymce%2Ftinymce-swing-codesamples","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinymce%2Ftinymce-swing-codesamples/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinymce%2Ftinymce-swing-codesamples/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinymce%2Ftinymce-swing-codesamples/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tinymce","download_url":"https://codeload.github.com/tinymce/tinymce-swing-codesamples/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248642575,"owners_count":21138351,"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":["java-swing","tinymce","tinymce-swing"],"created_at":"2024-11-15T09:11:06.486Z","updated_at":"2025-04-12T22:35:53.454Z","avatar_url":"https://github.com/tinymce.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# TinyMCE in Swing: Code samples\n\nThese code samples can be used to easily start using TinyMCE in Swing through the TinyMCE Swing Integration.\nBe sure to obtain a copy of the Integration to start using TinyMCE as your new Rich Text Editor.\n\n## Getting Started\n\nThe following steps will guide you as you deploy the Tiny Swing Integration in your project and start using TinyMCE as your Rich Text Editor in Swing.\n\n### Prerequisites\n\nGet a copy of the TinyMCE-Swing Integration by contacting our [support team](https://support.tiny.cloud/).\n\n### Installing\n\nPut the `lib` directory of the TinyMCE Swing zip file into the top directory of this repository.\n\nAlso ensure that [Apache Ant](https://ant.apache.org/) is installed.\n\n### Running examples\n\nSee what examples are available by running `ant -projecthelp`\n```text\n12:33 $ ant -projecthelp\nBuildfile: \u003c...path...\u003e/tinymce-swing-codesamples/build.xml\n\n    Build and run code samples for \"TinyMCE for Swing\".\n  \nMain targets:\n\n clean                     Clean up.\n compile                   Compile the source.\n example-basic-cloud       Run the basic cloud example (requires setting API key).\n example-basic-embedded    Run the basic embedded example.\n example-basic-external    Run the basic external example (requires hosting TinyMCE).\n example-config-js         Run the example of configuring TinyMCE from a Javascript file.\n example-config-props      Run the example of configuring TinyMCE directly in Java.\n example-custom-protocol   Run the example of configuring a custom protocol handler.\n example-dialog            Run the example of accessing the editor from a dialog.\n example-events            Run the events example.\n example-image-handling    Run the example of a simple image upload handler.\n example-multiple-editors  Run the example of multiple editors.\nDefault target: example-basic-embedded\n ```\n\n Running an example simply requires specifying `ant \u003ctarget\u003e` where `\u003ctarget\u003e` is one of the `example-*` targets.\n \n For example:\n ```\n ant example-basic-embedded\n ```\n\n## Understanding these samples\n\nThese code samples showcase how to easily create and configure an editor in a couple of lines.\n\nIn order to create an editor you have to pass a configuration object with the editor details.\n\n```java\n// Create a embedded configuration\nfinal Config embeddedBased = Config.embedded();\n// Create a new editor with the default embedded configuration\nfinal TinyMCE editor = TinyMCE.futureEditor(embeddedBased).get();\n```\nThe configuration will specify where the TinyMCE editor will be loaded from. There are three options:\n\n- Cloud deployment - The editor is served by the Tiny CDN.\n- Embedded deployment - The editor is served by a custom protocol handler from the Jar.\n- External deployment - The editor is served externally by the user.\n\n### Cloud deployment\n\nCloud deployments download the editor code from the Tiny CDN. They require an API key and you can specify the channel of your deployment. The default channel is `stable`.\n\n```java\nfinal Config config = Config.cloud(\"\u003cmy-api-key\u003e\");\n```\n\n### Embedded deployment\n\nEmbedded deployments will use a custom protocol handler to serve the editor directly from the Jar. You don't have to provide any additional details as the Integration code comes with a prepackaged version of the editor.\n\n```java\nfinal Config config = Config.embedded();\n```\n\n### External deployment\n\nExternal deployments rely on the editor being available from an external source. It can be a local copy or a custom deployment available to the users.\n\n```java\nfinal Config config = Config.external(\"https://myserver/tiny/tinymce.min.js\");\n```\n\n### Getting the editor in Java\n\nThe editor loads asynchronously so getting a new instance of the editor will return a CompletableFuture that will be resolved when the editor is ready.\n\n```java\nfinal TinyMCE tinyMCE = TinyMCE.futureEditor(config).get();\ntinyMCE.setHtml(\"\u003cp\u003eHello World\u003c/p\u003e\");\n```\n\nor\n\n```java\nfinal CompletableFuture\u003cTinyMCE\u003e futureEditor = TinyMCE.futureEditor(config);\nfutureEditor.thenAccept(new Consumer\u003cTinyMCE\u003e() {\n  @Override\n  public void accept(TinyMCE tinyMCE) {\n    tinyMCE.setHtml(\"\u003cp\u003eHello World\u003c/p\u003e\");\n  }\n});\n```\n\n## Extending your editor\n\nThe TinyMCE editor can be customized via the configuration object to better suit particular use-cases.\n\nThe TinyMCE editor takes a Javascript object where each of its properties is a configuration option. The Integration allows users to programmatically provide a configuration or extend a configuration via Java.\n\n### JavaScript Configuration\n\nYou can provide a configuration as a Java String containing JavaScript code that, when eval'd will return a JavaScript object.\n\n```java\nfinal String configString = \"(function () { return { menubar: false, plugins: 'advlist autolink lists link image charmap print preview anchor', toolbar: 'undo redo | formatselect | bold italic backcolor | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | removeformat | help' }; })()\";\nfinal Config config = Config.embedded().setInitConf(configString);\nfinal TinyMCE editor = TinyMCE.futureEditor(config).get();\n```\n\n### Java Configuration\n\nAlternatively to providing a JavaScript configuration, a user may simply provide properties to the configuration.\n\n```java\nfinal Config config = Config.embedded()\n    .putProperty(\"menubar\", \"false\")\n    .putProperty(\"plugins\", \"advlist autolink lists link image anchor textcolor searchreplace visualblocks media table paste help wordcount\")\n    .putProperty(\"toolbar\", \"undo redo | formatselect | bold italic backcolor | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | removeformat | help\");\nfinal TinyMCE editor = TinyMCE.futureEditor(config).get();\n```\n\nPlugins can also be selected by adding plugins to be used by the editor.\n\n```java\nfinal Config config = Config.embedded().addPlugin(\"advlist\").addPlugin(\"lists\");\nfinal TinyMCE editor = TinyMCE.futureEditor(config).get();\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftinymce%2Ftinymce-swing-codesamples","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftinymce%2Ftinymce-swing-codesamples","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftinymce%2Ftinymce-swing-codesamples/lists"}