forked from tinymce/tinymce-code-tutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
Answers Tiny MCE tutorial #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
tiny-ben-tran
wants to merge
20
commits into
master
Choose a base branch
from
ben-answers
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
27ebeb5
Answers for a lot of questions
tiny-ben-tran 0e1cb5a
Added additional tests
tiny-ben-tran 93fa4fd
Added answer to part2ex5sugar
tiny-ben-tran 2553e7a
Fixed import
tiny-ben-tran 9e580b9
Added answer for part3ex1test
tiny-ben-tran 08ac634
Completed part3ex2test
tiny-ben-tran 72f924f
Use single quote and updated exercise3optiontest
tiny-ben-tran 8cd6478
Fixed according to feedbacks
tiny-ben-tran e35d46a
Second attempt at getProtocol
tiny-ben-tran db0c9a2
Second attempt on part3Ex2Test
tiny-ben-tran 6bb06d3
Added all toolbar options and default font to 14pt
tiny-ben-tran cf91310
Added custom button
tiny-ben-tran 0a14b66
Insert into editor
tiny-ben-tran e55e9ee
context tool bar using the existing buttons
tiny-ben-tran 1cbef4a
Added custom context button to strike red
tiny-ben-tran a99e5ed
Gather content of all editors
tiny-ben-tran 5bb6e34
Use autoresize plugin and set max height of content
tiny-ben-tran a4d9f6d
Apply style using inbuilt formatter
tiny-ben-tran f6a9605
Use formatter to apply style
tiny-ben-tran 873894a
Replaced decprecated methods
tiny-ben-tran File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,112 @@ | ||
| <!doctype html> | ||
| <html lang="en"> | ||
| <head> | ||
| <title>Integration</title> | ||
| <script src="https://cdn.tiny.cloud/1/b6r7yu1n19ibkha4z0s4gdvt0l7z2mc3dzlnc780ep0uuzks/tinymce/5/tinymce.min.js" referrerpolicy="origin"></script> | ||
| </head> | ||
| <body> | ||
| <textarea class='classic'></textarea> | ||
| <script> | ||
| tinymce.init({ | ||
| selector: '.classic', | ||
| content_style: 'body {font-size: 14pt;}', | ||
| plugins: 'table spellchecker fullscreen code print link image lists advlist wordcount autoresize', | ||
| menubar: 'file edit view insert format tools table', | ||
| formats: { | ||
| myred: { inline: 'span', styles: { color: 'red' } } | ||
| }, | ||
| menu: { | ||
| file: { title: 'File', items: 'newdocument restoredraft | preview | print ' }, | ||
| edit: { title: 'Edit', items: 'undo redo | cut copy paste | selectall | searchreplace' }, | ||
| view: { title: 'View', items: 'spellchecker | preview fullscreen' }, | ||
| insert: { title: 'Insert', items: 'inserttable' }, | ||
| format: { title: 'Format', items: 'bold italic underline strikethrough' }, | ||
| tools: { title: 'Tools', items: 'spellchecker' }, | ||
| table: { title: 'Table', items: 'inserttable | cell row column | tableprops deletetable' }, | ||
| }, | ||
| toolbar: 'undo redo | bold italic | alignleft aligncenter alignright alignjustify | fontselect fontsizeselect formatselect | bullist numlist outdent indent | link image | fullscreen wordcount code print | customToolBarButton', | ||
| max_height: 230, | ||
| setup: function (editor) { | ||
| editor.ui.registry.addButton('customToolBarButton', { | ||
| text: 'My Custom Button', | ||
| onAction: function () { | ||
| // alert('Button clicked!'); | ||
| tinymce.activeEditor.windowManager.open({ | ||
| title: 'Custom dialog', | ||
| body: { | ||
| type: 'panel', | ||
| items: [ | ||
| { | ||
| type: 'input', | ||
| name: 'customInput', | ||
| label: 'Please enter your fruit' | ||
| } | ||
| ] | ||
| }, | ||
| buttons: [ | ||
| { | ||
| type: 'submit', | ||
| text: 'Submit' | ||
| } | ||
| ], | ||
| onSubmit: function (dialogApi) { | ||
| editor.formatter.apply('myred'); | ||
| editor.execCommand('mceInsertContent', false, dialogApi.getData().customInput); | ||
| editor.formatter.remove('myred'); | ||
| dialogApi.close(); | ||
| } | ||
| }); | ||
| } | ||
| }); | ||
| } | ||
| }); | ||
| </script> | ||
|
|
||
| <h1>Inline editor</h1> | ||
| <form method='post'> | ||
| <div class='inlineEditor'></div> | ||
| </form> | ||
| <script> | ||
| tinymce.init({ | ||
| selector: '.inlineEditor', | ||
| inline: true, | ||
| formats: { | ||
| myred: { inline: 'span', styles: {color: 'red'}} | ||
| }, | ||
| placeholder: 'click here to edit .....', | ||
| setup: function (editor) { | ||
| // context button | ||
| editor.ui.registry.addButton('customStrikeButton', { | ||
| text: 'strike red', | ||
| icon: 'cancel', | ||
| tooltip: 'strike through and change colour to red', | ||
| onAction: function (_) { | ||
| editor.formatter.apply('strikethrough'); | ||
| editor.formatter.apply('myred'); | ||
| } | ||
| }); | ||
| // context tool bar | ||
| editor.ui.registry.addContextToolbar('imagealignment', { | ||
| predicate: function (node) { | ||
| return !editor.selection.isCollapsed(); | ||
| }, | ||
| items: 'bold italic underline customStrikeButton', | ||
| position: 'selection', | ||
| scope: 'editor' | ||
| }); | ||
| }, | ||
| }); | ||
| </script> | ||
|
|
||
| <h1>All editors</h1> | ||
| <button onclick='gatherAll()'>Collect all</button> | ||
| <div id='container' style='border: 1px solid; min-height: 400px;'> | ||
|
|
||
| </div> | ||
| <script> | ||
| function gatherAll() { | ||
| document.getElementById('container').innerHTML = tinymce.get(0).getContent() + '<br/>' + tinymce.get(1).getContent();; | ||
| } | ||
| </script> | ||
| </body> | ||
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't really do anything meaningful unless you're accepting content from outside of TypeScript, as you can't pass a mode that isn't defined in the
Modetype and if you're checking this it's somewhat defeating the point of using types. That said, you've still made a pure function here so its fine as that was the point of this exercise.