@rathkit/rte-vue 0.1.0-alpha.4 → 0.2.0-beta.0

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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @rathkit/rte-vue
2
2
 
3
- > **Alpha** (0.1.0-alpha.0). Not for production: the APIs will change between releases. Published to the `next` tag only.
3
+ > **Beta.** Not for production yet: the APIs may still change between releases. Published to the `next` tag only.
4
4
 
5
5
  The editor for Vue: a component and composables over the headless layer. A ref changes only when the value it holds does.
6
6
 
package/dist/editor.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  import { type StandardOptions } from "@rathkit/rte-core/standard";
2
- export type RteOptions = Omit<StandardOptions, "element" | "html" | "readOnly">;
2
+ export type RteOptions = Omit<StandardOptions, "element" | "html" | "readOnly" | "disabled">;
3
3
  export declare const RteEditor: unknown;
package/dist/editor.js CHANGED
@@ -5,31 +5,32 @@ export const RteEditor = defineComponent({
5
5
  props: {
6
6
  defaultValue: { type: String, default: "" },
7
7
  readOnly: { type: Boolean, default: false },
8
+ disabled: { type: Boolean, default: false },
8
9
  label: { type: String, required: true },
9
10
  options: { type: Object, default: () => ({}) },
10
11
  },
11
- emits: ["change", "ready"],
12
+ emits: ["change", "ready", "focus", "blur", "selection"],
12
13
  setup(props, { emit, expose }) {
13
14
  const element = shallowRef(null);
14
15
  const editor = shallowRef(undefined);
15
16
  let stop = () => undefined;
16
17
  onMounted(() => {
17
- const made = createEditor({ ...props.options, element: element.value, html: props.defaultValue, readOnly: props.readOnly });
18
- let last = made.getHtml();
19
- const off = made.subscribe(() => {
20
- const html = made.getHtml();
21
- if (html === last)
22
- return;
23
- last = html;
24
- emit("change", html);
25
- });
26
- stop = () => { off(); made.destroy(); };
18
+ const made = createEditor({ ...props.options, element: element.value, html: props.defaultValue, readOnly: props.readOnly, disabled: props.disabled });
19
+ const offs = [
20
+ made.on("change", (html) => emit("change", html)),
21
+ made.on("focus", (e) => emit("focus", e)),
22
+ made.on("blur", (e) => emit("blur", e)),
23
+ made.on("selection", (selection) => emit("selection", selection)),
24
+ ];
25
+ stop = () => { for (const off of offs)
26
+ off(); made.destroy(); };
27
27
  editor.value = made;
28
28
  emit("ready", made);
29
29
  });
30
30
  onBeforeUnmount(() => { stop(); editor.value = undefined; });
31
31
  watch(() => props.readOnly, (readOnly) => editor.value?.setReadOnly(readOnly));
32
+ watch(() => props.disabled, (disabled) => editor.value?.setDisabled(disabled));
32
33
  expose({ editor });
33
- return () => h("div", { ref: element, "aria-label": props.label, "data-rk-surface": "" });
34
+ return () => h("div", { ref: element, "aria-label": props.label, "data-rte-surface": "" });
34
35
  },
35
36
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rathkit/rte-vue",
3
- "version": "0.1.0-alpha.4",
3
+ "version": "0.2.0-beta.0",
4
4
  "description": "The editor for Vue: a component and composables over the headless layer, with no editor or accessibility logic of its own.",
5
5
  "keywords": [
6
6
  "rich-text",
@@ -44,8 +44,8 @@
44
44
  }
45
45
  },
46
46
  "peerDependencies": {
47
- "@rathkit/rte-core": ">=0.1.0-alpha.4 <0.2.0",
48
- "@rathkit/rte-headless": ">=0.1.0-alpha.4 <0.2.0",
47
+ "@rathkit/rte-core": ">=0.2.0-beta.0 <0.3.0",
48
+ "@rathkit/rte-headless": ">=0.2.0-beta.0 <0.3.0",
49
49
  "vue": ">=3.4"
50
50
  },
51
51
  "peerDependenciesMeta": {