Skip to content

Commit 07a2caf

Browse files
author
Farzad Hayat
authored
DOC-2480: Port to 6 Docs - Update svelte-quick-start.adoc to use Vite v5 (#3389)
* DOC-2480: Update svelte-quick-start.adoc to use Vite v5 * DOC-2480: Improve wording on the "replace src/App.svelte contents" step
1 parent 9c32600 commit 07a2caf

File tree

1 file changed

+81
-49
lines changed

1 file changed

+81
-49
lines changed

modules/ROOT/partials/integrations/svelte-quick-start.adoc

Lines changed: 81 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
The https://github.com/tinymce/tinymce-svelte[Official {productname} Svelte component] integrates {productname} into https://svelte.dev/[Svelte applications]. This procedure creates a basic Svelte application using the https://github.com/sveltejs/template[`+sveltejs/template+` project] adds a {productname} editor based using the {productname} Svelte integration.
1+
The https://github.com/tinymce/tinymce-svelte[Official {productname} Svelte component] integrates {productname} into https://svelte.dev/[Svelte applications]. This procedure creates a basic Svelte application containing a {productname} editor.
22

33
For examples of the {productname} integration, visit https://tinymce.github.io/tinymce-svelte/[the tinymce-svelte storybook].
44

@@ -8,21 +8,26 @@ This procedure requires https://nodejs.org/[Node.js (and npm)].
88

99
== Procedure
1010

11-
. Create a Svelte application using the https://github.com/sveltejs/template[Svelte template project], for example:
11+
. Use the https://github.com/vitejs/vite[Vite] package to create a new Svelte project named `+tinymce-svelte-demo+`, such as:
1212
+
1313
[source,sh]
1414
----
15-
npx degit sveltejs/template my-tiny-app
16-
cd my-tiny-app
15+
npm create vite@5 tinymce-svelte-demo -- --template svelte
16+
----
17+
. Change to the newly created directory.
18+
+
19+
[source,sh]
20+
----
21+
cd tinymce-svelte-demo
1722
----
1823

1924
ifeval::["{productSource}" == "package-manager"]
2025

2126
. Install the `+tinymce+` and the `+tinymce-svelte+` editor component, such as:
2227
+
23-
[source,sh]
28+
[source,sh,subs="attributes+"]
2429
----
25-
npm install tinymce @tinymce/tinymce-svelte
30+
npm install tinymce@^{productmajorversion} @tinymce/tinymce-svelte
2631
----
2732

2833
endif::[]
@@ -38,99 +43,127 @@ npm install @tinymce/tinymce-svelte
3843
endif::[]
3944
ifeval::["{productSource}" == "cloud"]
4045

41-
. Open `+src/App.svelte+` and add:
42-
* An `+import+` statement for the {productname} component.
43-
* The `+<Editor />+` as a placeholder for the editor.
46+
. Open `+src/App.svelte+` and replace the contents with:
4447
+
45-
For example:
46-
+
47-
_File:_ `+src/App.svelte+`
48-
+
49-
[source,html]
48+
[source,html,subs="+macros"]
5049
----
51-
<script lang="ts">
50+
<script>
5251
import Editor from '@tinymce/tinymce-svelte';
52+
let conf = {
53+
height: 500,
54+
menubar: false,
55+
plugins: [
56+
'advlist', 'autolink', 'lists', 'link', 'image', 'charmap',
57+
'anchor', 'searchreplace', 'visualblocks', 'code', 'fullscreen',
58+
'insertdatetime', 'media', 'table', 'preview', 'help', 'wordcount'
59+
],
60+
toolbar: 'undo redo | blocks | ' +
61+
'bold italic forecolor | alignleft aligncenter ' +
62+
'alignright alignjustify | bullist numlist outdent indent | ' +
63+
'removeformat | help',
64+
}
5365
</script>
5466
<main>
5567
<h1>Hello Tiny</h1>
5668
<Editor
57-
apiKey="your-tiny-cloud-api-key"
69+
apiKey='your-tiny-cloud-api-key'
70+
pass:a[channel='{productmajorversion}']
71+
value='<p>This is the initial content of the editor.</p>'
72+
{conf}
5873
/>
5974
</main>
6075
----
6176

6277
endif::[]
6378
ifeval::["{productSource}" == "package-manager"]
6479

65-
. Install the `+rollup-plugin-copy+` development dependency, such as:
80+
. Install the `+vite-plugin-static-copy+` development dependency, such as:
6681
+
6782
[source,sh]
6883
----
69-
npm install rollup-plugin-copy -D
84+
npm install -D vite-plugin-static-copy
7085
----
71-
. Open `+rollup.config.js+` and configure the rollup copy plugin `+rollup-plugin-copy+` to copy {productname} to the `+public/+` directory, such as:
86+
. Open `+vite.config.js+` and configure the `+vite-plugin-static-copy+` plugin to copy {productname} to the `+public/+` directory, such as:
7287
+
7388
[source,js]
7489
----
75-
/* Existing import statements */
76-
import copy from 'rollup-plugin-copy'
90+
import { defineConfig } from 'vite'
91+
import { svelte } from '@sveltejs/vite-plugin-svelte'
92+
import { viteStaticCopy } from 'vite-plugin-static-copy'
7793
78-
/* Skip to the export statement, `plugins` item and add `copy`*/
79-
export default {
80-
/* Existing key: values... */
94+
// https://vitejs.dev/config/
95+
export default defineConfig({
8196
plugins: [
82-
copy({
97+
viteStaticCopy({
8398
targets: [
84-
{ src: 'node_modules/tinymce/*', dest: 'public/tinymce' }
99+
{ src: 'node_modules/tinymce/*', dest: 'tinymce' }
85100
]
86101
}),
87-
/* More existing configuration... */
88-
]
89-
}
102+
svelte()
103+
],
104+
})
90105
----
91-
. Open `+src/App.svelte+` and add:
92-
* An `+import+` statement for the {productname} component.
93-
* The `+<Editor />+` as a placeholder for the editor.
94-
* The xref:svelte-ref.adoc#scriptsrc[`+scriptSrc+`] property for the `+Editor+` placeholder.
95-
+
96-
For example:
97-
+
98-
_File:_ `+src/App.svelte+`
106+
. Open `+src/App.svelte+` and replace the contents with:
99107
+
100108
[source,html]
101109
----
102-
<script lang="ts">
110+
<script>
103111
import Editor from '@tinymce/tinymce-svelte';
112+
let conf = {
113+
height: 500,
114+
menubar: false,
115+
plugins: [
116+
'advlist', 'autolink', 'lists', 'link', 'image', 'charmap',
117+
'anchor', 'searchreplace', 'visualblocks', 'code', 'fullscreen',
118+
'insertdatetime', 'media', 'table', 'preview', 'help', 'wordcount'
119+
],
120+
toolbar: 'undo redo | blocks | ' +
121+
'bold italic forecolor | alignleft aligncenter ' +
122+
'alignright alignjustify | bullist numlist outdent indent | ' +
123+
'removeformat | help',
124+
}
104125
</script>
105126
<main>
106127
<h1>Hello Tiny</h1>
107128
<Editor
129+
licenseKey='your-license-key'
108130
scriptSrc='tinymce/tinymce.min.js'
131+
value='<p>This is the initial content of the editor.</p>'
132+
{conf}
109133
/>
110134
</main>
111135
----
112136

113137
endif::[]
114138
ifeval::["{productSource}" == "zip"]
115139

116-
. Open `+src/App.svelte+` and add:
117-
* An `+import+` statement for the {productname} component.
118-
* The `+<Editor />+` as a placeholder for the editor.
119-
* The xref:svelte-ref.adoc#scriptsrc[`+scriptSrc+`] property for the `+Editor+` placeholder.
120-
+
121-
For example:
122-
+
123-
_File:_ `+src/App.svelte+`
140+
. Open `+src/App.svelte+` and replace the contents with:
124141
+
125142
[source,html]
126143
----
127-
<script lang="ts">
144+
<script>
128145
import Editor from '@tinymce/tinymce-svelte';
146+
let conf = {
147+
height: 500,
148+
menubar: false,
149+
plugins: [
150+
'advlist', 'autolink', 'lists', 'link', 'image', 'charmap',
151+
'anchor', 'searchreplace', 'visualblocks', 'code', 'fullscreen',
152+
'insertdatetime', 'media', 'table', 'preview', 'help', 'wordcount'
153+
],
154+
toolbar: 'undo redo | blocks | ' +
155+
'bold italic forecolor | alignleft aligncenter ' +
156+
'alignright alignjustify | bullist numlist outdent indent | ' +
157+
'removeformat | help',
158+
}
129159
</script>
130160
<main>
131161
<h1>Hello Tiny</h1>
132162
<Editor
133-
scriptSrc="/path/or/url/to/tinymce.min.js"
163+
licenseKey='your-license-key'
164+
scriptSrc='/path/or/url/to/tinymce.min.js'
165+
value='<p>This is the initial content of the editor.</p>'
166+
{conf}
134167
/>
135168
</main>
136169
----
@@ -145,7 +178,6 @@ endif::[]
145178
npm run dev
146179
----
147180
+
148-
This will start a local development server, accessible at http://localhost:8080.
149181
* To stop the development server, select on the command line or command prompt and press _Ctrl+C_.
150182

151183
== Next Steps

0 commit comments

Comments
 (0)