Skip to content

Commit c754d62

Browse files
committed
DOC-2635: Documentation Enhancements for Anchor Plugin.
1 parent c77eafc commit c754d62

File tree

3 files changed

+59
-3
lines changed

3 files changed

+59
-3
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<textarea id="anchor-demo">
2+
<h1>Anchor Plugin Demo</h1>
3+
4+
<p>
5+
This demo illustrates the functionality of the TinyMCE Anchor plugin. Anchors allow you to create internal links within your document that jump to specific locations.
6+
</p>
7+
8+
<h2>How to Insert an Anchor</h2>
9+
10+
<p>
11+
To insert an anchor at the cursor position:
12+
</p>
13+
14+
<ol>
15+
<li>Place your cursor where you want to insert the anchor</li>
16+
<li>Click the anchor button in the toolbar or use Insert → Anchor from the menu</li>
17+
<li>Enter a name for your anchor in the dialog box (e.g., "introduction")</li>
18+
<li>Click OK to insert the anchor</li>
19+
</ol>
20+
21+
<h2>How to Create Links to Anchors</h2>
22+
23+
<p>
24+
To create a link that jumps to an anchor:
25+
</p>
26+
27+
<ol>
28+
<li>Select the text you want to turn into a link</li>
29+
<li>Click the link button in the toolbar or use Insert → Link from the menu</li>
30+
<li>In the Insert/Edit Link dialog, click the "Anchors" dropdown list</li>
31+
<li>Select the anchor you want to link to from the dropdown</li>
32+
<li>Click Save to create the link</li>
33+
</ol>
34+
35+
<p>
36+
After creating anchors and links, you can test them by clicking on the links. The editor will automatically scroll to the anchor location in the document.
37+
</p>
38+
39+
</textarea>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
tinymce.init({
2+
selector: 'textarea#anchor-demo',
3+
height: 500,
4+
plugins: [
5+
"advlist", "anchor", "autolink", "charmap", "code", "fullscreen",
6+
"help", "image", "insertdatetime", "link", "lists", "media",
7+
"preview", "searchreplace", "table", "visualblocks",
8+
],
9+
toolbar: "anchor |undo redo | styles | bold italic underline strikethrough | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image",
10+
menubar: "file edit view insert format tools table help",
11+
content_style: 'body { font-family:Helvetica,Arial,sans-serif; font-size:16px }'
12+
});

modules/ROOT/pages/anchor.adoc

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,20 @@
77
This plugin adds an anchor/bookmark button to the toolbar that inserts an anchor at the editor's cursor insertion point. It also adds the menu item `+anchor+` under the `+Insert+` menu.
88

99
When a user clicks on the anchor button or menu item they will be prompted via a dialog box to enter a string. The string will be inserted into the HTML as an anchor id at the location of the cursor. For example, a user places their cursor at the beginning of "Hello World" and clicks on the anchor button and enters "start" in the dialog box. The resulting HTML will take the form of `+<p><a id="start"></a>Hello, World!</p>+`.
10+
== Interactive demo
11+
12+
liveDemo::anchor[]
1013

1114
== Basic setup
1215

1316
[source,js]
1417
----
1518
tinymce.init({
16-
selector: 'textarea', // change this value according to your HTML
17-
plugins: 'anchor',
18-
toolbar: 'anchor',
19+
selector: "textarea",
20+
plugins: [
21+
"anchor", "link", // Link plugin is required for linking to anchors
22+
],
23+
toolbar: "link | anchor",
1924
});
2025
----
2126

0 commit comments

Comments
 (0)