create-nodality-vue 1.0.0-beta.3 → 1.0.0-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-nodality-vue",
3
- "version": "1.0.0-beta.3",
3
+ "version": "1.0.0-beta.5",
4
4
  "description": "A scaffolding tool for creating Vue.js projects integrated with Nodality.",
5
5
  "main": "bin/index.js",
6
6
  "bin": {
@@ -1,7 +1,5 @@
1
1
  <template>
2
- <div id="app">
3
2
  <HelloWorld :text="textInstance" v-model:msg="welcomeMessage" />
4
- </div>
5
3
  </template>
6
4
 
7
5
  <script>
@@ -1,40 +1,39 @@
1
- <template>
2
- <div>
3
- <input v-model="message" @input="updateText" placeholder="Edit me" />
4
- <div ref="renderedText" />
5
- </div>
6
- </template>
7
-
8
- <script>
9
- export default {
10
- props: {
11
- text: Object,
12
- msg: String,
13
- },
14
- data() {
15
- return {
16
- message: this.msg || "",
17
- };
18
- },
19
- watch: {
20
- message(newValue) {
21
- this.$emit("update:msg", newValue);
22
- },
23
- },
24
- mounted() {
25
- this.renderText();
26
- },
27
- updated() {
28
- this.renderText();
29
- },
30
- methods: {
31
- updateText(event) {
32
- this.text.set({ text: event.target.value }).render(this.$refs.renderedText);
33
- },
34
- renderText() {
35
- this.$refs.renderedText.innerHTML = "";
36
- this.text.render(this.$refs.renderedText);
37
- },
38
- },
39
- };
1
+ <script setup>
2
+ import { useTemplateRef, onMounted, defineProps, defineEmits, watch } from 'vue'
3
+ //import {Text} from "../lib/TextCopy.js";
4
+
5
+ // Define props to accept the msg value
6
+ const props = defineProps({
7
+ msg: String,
8
+ text: Object
9
+ })
10
+
11
+ const emit = defineEmits(['update:msg'])
12
+
13
+ // the first argument must match the ref value in the template
14
+ const input = useTemplateRef('my-input')
15
+ let mycomp = useTemplateRef('my-comp')
16
+
17
+ onMounted(() => {
18
+ input.value.focus()
19
+ let ela = props.text.render();//document.createElement("h1");
20
+ mycomp.value.appendChild(ela);
21
+ })
22
+
23
+ watch(() => props.msg, () => { // 12:21:57 Wow!!!
24
+
25
+ mycomp.value.innerHTML = ""; // Clear existing content
26
+ const element = props.text.render(); // Call the render method
27
+ mycomp.value.appendChild(element);
28
+ })
29
+
30
+ function updateMessage(event) {
31
+ emit('update:msg', event.target.value)
32
+ }
40
33
  </script>
34
+
35
+ <template>
36
+ <h2>Hello from static Vue</h2>
37
+ <input ref="my-input" :value="msg" @input="updateMessage" />
38
+ <div ref="my-comp"/>
39
+ </template>