@vizel/react 0.0.1-alpha.1 → 0.0.1-alpha.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.
Files changed (51) hide show
  1. package/dist/index.js +66 -58
  2. package/dist/index10.js +54 -4
  3. package/dist/index11.js +44 -171
  4. package/dist/index12.js +25 -21
  5. package/dist/index13.js +58 -74
  6. package/dist/index14.js +88 -8
  7. package/dist/index15.js +4 -78
  8. package/dist/index16.js +168 -107
  9. package/dist/index17.js +23 -35
  10. package/dist/index18.js +21 -5
  11. package/dist/index19.js +73 -65
  12. package/dist/index2.js +77 -24
  13. package/dist/index20.js +8 -91
  14. package/dist/index21.js +10 -4
  15. package/dist/index22.js +77 -35
  16. package/dist/index23.js +113 -31
  17. package/dist/index24.js +32 -47
  18. package/dist/index25.js +5 -29
  19. package/dist/index26.js +68 -7
  20. package/dist/index27.js +89 -50
  21. package/dist/index28.js +4 -11
  22. package/dist/index29.js +37 -3
  23. package/dist/index3.js +52 -11
  24. package/dist/index30.js +53 -20
  25. package/dist/index31.js +34 -2
  26. package/dist/index32.js +47 -9738
  27. package/dist/index33.js +29 -17015
  28. package/dist/index34.js +8 -2
  29. package/dist/index35.js +52 -7
  30. package/dist/index36.js +12 -2
  31. package/dist/index37.js +15 -2
  32. package/dist/index38.js +3 -222
  33. package/dist/index39.js +20 -224
  34. package/dist/index4.js +238 -54
  35. package/dist/index40.js +2 -2
  36. package/dist/index41.js +9742 -2
  37. package/dist/index42.js +17018 -0
  38. package/dist/index43.js +4 -0
  39. package/dist/index44.js +10 -0
  40. package/dist/index45.js +4 -0
  41. package/dist/index46.js +4 -0
  42. package/dist/index47.js +224 -0
  43. package/dist/index48.js +227 -0
  44. package/dist/index49.js +4 -0
  45. package/dist/index5.js +82 -55
  46. package/dist/index50.js +4 -0
  47. package/dist/index6.js +71 -46
  48. package/dist/index7.js +64 -26
  49. package/dist/index8.js +58 -59
  50. package/dist/index9.js +2 -91
  51. package/package.json +25 -31
package/dist/index6.js CHANGED
@@ -1,52 +1,77 @@
1
- import { jsx as m } from "react/jsx-runtime";
2
- import { BubbleMenuPlugin as x } from "@vizel/core";
3
- import { useRef as f, useEffect as g } from "react";
4
- import { VizelBubbleMenuDefault as y } from "./index9.js";
5
- import { useVizelContextSafe as B } from "./index2.js";
6
- function S({
7
- editor: d,
8
- className: b,
9
- children: a,
10
- showDefaultMenu: p = !0,
11
- pluginKey: n = "vizelBubbleMenu",
12
- updateDelay: u = 100,
13
- shouldShow: l,
14
- enableEmbed: s
15
- }) {
16
- const v = B(), e = d ?? v?.editor ?? null, r = f(null), o = f(l);
17
- return o.current = l, g(() => {
18
- if (!(e && r.current))
19
- return;
20
- const w = x({
21
- pluginKey: n,
22
- editor: e,
23
- element: r.current,
24
- updateDelay: u,
25
- ...o.current && {
26
- shouldShow: ({ editor: t, from: z, to: h }) => o.current?.({ editor: t, from: z, to: h }) ?? !1
1
+ import { Mark as s, markPasteRule as r, markInputRule as a, mergeAttributes as n } from "@tiptap/core";
2
+ var i = /(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/, d = /(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g, o = /(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/, l = /(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g;
3
+ s.create({
4
+ name: "italic",
5
+ addOptions() {
6
+ return {
7
+ HTMLAttributes: {}
8
+ };
9
+ },
10
+ parseHTML() {
11
+ return [
12
+ {
13
+ tag: "em"
14
+ },
15
+ {
16
+ tag: "i",
17
+ getAttrs: (t) => t.style.fontStyle !== "normal" && null
18
+ },
19
+ {
20
+ style: "font-style=normal",
21
+ clearMark: (t) => t.type.name === this.name
27
22
  },
28
- options: {
29
- placement: "top"
23
+ {
24
+ style: "font-style=italic"
30
25
  }
31
- });
32
- e.registerPlugin(w);
33
- const i = e, c = (t) => {
34
- t.key === "Escape" && !i.view.state.selection.empty && (t.preventDefault(), i.commands.setTextSelection(i.view.state.selection.to));
26
+ ];
27
+ },
28
+ renderHTML({ HTMLAttributes: t }) {
29
+ return ["em", n(this.options.HTMLAttributes, t), 0];
30
+ },
31
+ addCommands() {
32
+ return {
33
+ setItalic: () => ({ commands: t }) => t.setMark(this.name),
34
+ toggleItalic: () => ({ commands: t }) => t.toggleMark(this.name),
35
+ unsetItalic: () => ({ commands: t }) => t.unsetMark(this.name)
35
36
  };
36
- return document.addEventListener("keydown", c), () => {
37
- e.unregisterPlugin(n), document.removeEventListener("keydown", c);
37
+ },
38
+ markdownTokenName: "em",
39
+ parseMarkdown: (t, e) => e.applyMark("italic", e.parseInline(t.tokens || [])),
40
+ renderMarkdown: (t, e) => `*${e.renderChildren(t)}*`,
41
+ addKeyboardShortcuts() {
42
+ return {
43
+ "Mod-i": () => this.editor.commands.toggleItalic(),
44
+ "Mod-I": () => this.editor.commands.toggleItalic()
38
45
  };
39
- }, [e, n, u]), e ? /* @__PURE__ */ m(
40
- "div",
41
- {
42
- ref: r,
43
- className: `vizel-bubble-menu ${b ?? ""}`,
44
- "data-vizel-bubble-menu": "",
45
- style: { visibility: "hidden" },
46
- children: a ?? (p && /* @__PURE__ */ m(y, { editor: e, ...s ? { enableEmbed: s } : {} }))
47
- }
48
- ) : null;
49
- }
46
+ },
47
+ addInputRules() {
48
+ return [
49
+ a({
50
+ find: i,
51
+ type: this.type
52
+ }),
53
+ a({
54
+ find: o,
55
+ type: this.type
56
+ })
57
+ ];
58
+ },
59
+ addPasteRules() {
60
+ return [
61
+ r({
62
+ find: d,
63
+ type: this.type
64
+ }),
65
+ r({
66
+ find: l,
67
+ type: this.type
68
+ })
69
+ ];
70
+ }
71
+ });
50
72
  export {
51
- S as VizelBubbleMenu
73
+ i as starInputRegex,
74
+ d as starPasteRegex,
75
+ o as underscoreInputRegex,
76
+ l as underscorePasteRegex
52
77
  };
package/dist/index7.js CHANGED
@@ -1,28 +1,66 @@
1
- import { jsx as l } from "react/jsx-runtime";
2
- function i({
3
- onClick: e,
4
- isActive: t = !1,
5
- disabled: a = !1,
6
- children: n,
7
- title: o,
8
- className: u,
9
- action: b
10
- }) {
11
- return /* @__PURE__ */ l(
12
- "button",
13
- {
14
- type: "button",
15
- onClick: e,
16
- disabled: a,
17
- "aria-pressed": t,
18
- className: `vizel-bubble-menu-button ${t ? "is-active" : ""} ${u ?? ""}`,
19
- title: o,
20
- "data-active": t || void 0,
21
- "data-action": b,
22
- children: n
23
- }
24
- );
25
- }
1
+ import { Mark as r, markPasteRule as s, markInputRule as n, mergeAttributes as a } from "@tiptap/core";
2
+ var i = /(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/, d = /(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g;
3
+ r.create({
4
+ name: "strike",
5
+ addOptions() {
6
+ return {
7
+ HTMLAttributes: {}
8
+ };
9
+ },
10
+ parseHTML() {
11
+ return [
12
+ {
13
+ tag: "s"
14
+ },
15
+ {
16
+ tag: "del"
17
+ },
18
+ {
19
+ tag: "strike"
20
+ },
21
+ {
22
+ style: "text-decoration",
23
+ consuming: !1,
24
+ getAttrs: (e) => e.includes("line-through") ? {} : !1
25
+ }
26
+ ];
27
+ },
28
+ renderHTML({ HTMLAttributes: e }) {
29
+ return ["s", a(this.options.HTMLAttributes, e), 0];
30
+ },
31
+ markdownTokenName: "del",
32
+ parseMarkdown: (e, t) => t.applyMark("strike", t.parseInline(e.tokens || [])),
33
+ renderMarkdown: (e, t) => `~~${t.renderChildren(e)}~~`,
34
+ addCommands() {
35
+ return {
36
+ setStrike: () => ({ commands: e }) => e.setMark(this.name),
37
+ toggleStrike: () => ({ commands: e }) => e.toggleMark(this.name),
38
+ unsetStrike: () => ({ commands: e }) => e.unsetMark(this.name)
39
+ };
40
+ },
41
+ addKeyboardShortcuts() {
42
+ return {
43
+ "Mod-Shift-s": () => this.editor.commands.toggleStrike()
44
+ };
45
+ },
46
+ addInputRules() {
47
+ return [
48
+ n({
49
+ find: i,
50
+ type: this.type
51
+ })
52
+ ];
53
+ },
54
+ addPasteRules() {
55
+ return [
56
+ s({
57
+ find: d,
58
+ type: this.type
59
+ })
60
+ ];
61
+ }
62
+ });
26
63
  export {
27
- i as VizelBubbleMenuButton
64
+ i as inputRegex,
65
+ d as pasteRegex
28
66
  };
package/dist/index8.js CHANGED
@@ -1,63 +1,62 @@
1
- import { jsxs as V, jsx as l } from "react/jsx-runtime";
2
- import { getVizelRecentColors as H, addVizelRecentColor as u, VIZEL_TEXT_COLORS as L, VIZEL_HIGHLIGHT_COLORS as O } from "@vizel/core";
3
- import { useState as h, useRef as E, useEffect as g, useCallback as I } from "react";
4
- import { VizelColorPicker as T } from "./index11.js";
5
- import { VizelIcon as C } from "./index14.js";
6
- function A({
7
- editor: o,
8
- type: e,
9
- colors: f,
10
- className: m,
11
- allowCustomColor: d = !0,
12
- showRecentColors: s = !0
13
- }) {
14
- const [r, c] = h(!1), [b, x] = h([]), a = E(null), v = f ?? (e === "textColor" ? L : O), i = e === "textColor" ? o.getAttributes("textStyle").color : o.getAttributes("highlight").color;
15
- g(() => {
16
- r && s && x(H(e));
17
- }, [r, s, e]);
18
- const p = I(
19
- (t) => {
20
- e === "textColor" ? t === "inherit" ? o.chain().focus().unsetColor().run() : (o.chain().focus().setColor(t).run(), u(e, t)) : t === "transparent" ? o.chain().focus().unsetHighlight().run() : (o.chain().focus().toggleHighlight({ color: t }).run(), u(e, t)), c(!1);
21
- },
22
- [o, e]
23
- );
24
- g(() => {
25
- const t = (k) => {
26
- a.current && !a.current.contains(k.target) && c(!1);
27
- };
28
- return r && document.addEventListener("mousedown", t), () => {
29
- document.removeEventListener("mousedown", t);
1
+ import { Mark as s, mergeAttributes as d } from "@tiptap/core";
2
+ s.create({
3
+ name: "underline",
4
+ addOptions() {
5
+ return {
6
+ HTMLAttributes: {}
30
7
  };
31
- }, [r]);
32
- const n = e === "textColor", z = n ? /* @__PURE__ */ l(C, { name: "textColor" }) : /* @__PURE__ */ l(C, { name: "highlighter" });
33
- return /* @__PURE__ */ V("div", { ref: a, className: `vizel-color-picker ${m ?? ""}`, "data-type": e, children: [
34
- /* @__PURE__ */ l(
35
- "button",
8
+ },
9
+ parseHTML() {
10
+ return [
36
11
  {
37
- type: "button",
38
- className: `vizel-bubble-menu-button vizel-color-picker-trigger ${i ? "has-color" : ""}`,
39
- onClick: () => c(!r),
40
- title: n ? "Text Color" : "Highlight",
41
- "data-action": e,
42
- style: n ? { color: i || "inherit" } : { "--highlight-color": i || "transparent" },
43
- children: z
44
- }
45
- ),
46
- r && /* @__PURE__ */ l("div", { className: "vizel-color-picker-dropdown", children: /* @__PURE__ */ l(
47
- T,
12
+ tag: "u"
13
+ },
48
14
  {
49
- colors: v,
50
- value: i,
51
- onChange: p,
52
- label: n ? "Text color palette" : "Highlight color palette",
53
- allowCustomColor: d,
54
- recentColors: b,
55
- showRecentColors: s,
56
- noneValues: n ? ["inherit"] : ["transparent"]
15
+ style: "text-decoration",
16
+ consuming: !1,
17
+ getAttrs: (e) => e.includes("underline") ? {} : !1
57
18
  }
58
- ) })
59
- ] });
60
- }
61
- export {
62
- A as VizelBubbleMenuColorPicker
63
- };
19
+ ];
20
+ },
21
+ renderHTML({ HTMLAttributes: e }) {
22
+ return ["u", d(this.options.HTMLAttributes, e), 0];
23
+ },
24
+ parseMarkdown(e, n) {
25
+ return n.applyMark(this.name || "underline", n.parseInline(e.tokens || []));
26
+ },
27
+ renderMarkdown(e, n) {
28
+ return `++${n.renderChildren(e)}++`;
29
+ },
30
+ markdownTokenizer: {
31
+ name: "underline",
32
+ level: "inline",
33
+ start(e) {
34
+ return e.indexOf("++");
35
+ },
36
+ tokenize(e, n, i) {
37
+ const r = /^(\+\+)([\s\S]+?)(\+\+)/.exec(e);
38
+ if (!r)
39
+ return;
40
+ const t = r[2].trim();
41
+ return {
42
+ type: "underline",
43
+ raw: r[0],
44
+ text: t,
45
+ tokens: i.inlineTokens(t)
46
+ };
47
+ }
48
+ },
49
+ addCommands() {
50
+ return {
51
+ setUnderline: () => ({ commands: e }) => e.setMark(this.name),
52
+ toggleUnderline: () => ({ commands: e }) => e.toggleMark(this.name),
53
+ unsetUnderline: () => ({ commands: e }) => e.unsetMark(this.name)
54
+ };
55
+ },
56
+ addKeyboardShortcuts() {
57
+ return {
58
+ "Mod-u": () => this.editor.commands.toggleUnderline(),
59
+ "Mod-U": () => this.editor.commands.toggleUnderline()
60
+ };
61
+ }
62
+ });
package/dist/index9.js CHANGED
@@ -1,91 +1,2 @@
1
- import { jsx as e, jsxs as u } from "react/jsx-runtime";
2
- import { useState as a } from "react";
3
- import { useVizelState as m } from "./index28.js";
4
- import { VizelBubbleMenuButton as t } from "./index7.js";
5
- import { VizelBubbleMenuColorPicker as o } from "./index8.js";
6
- import { VizelIcon as l } from "./index14.js";
7
- import { VizelLinkEditor as h } from "./index15.js";
8
- import { VizelNodeSelector as k } from "./index16.js";
9
- function z({
10
- editor: i,
11
- className: r,
12
- enableEmbed: n
13
- }) {
14
- m(() => i);
15
- const [s, c] = a(!1);
16
- return s ? /* @__PURE__ */ e(
17
- h,
18
- {
19
- editor: i,
20
- onClose: () => c(!1),
21
- ...n ? { enableEmbed: n } : {}
22
- }
23
- ) : /* @__PURE__ */ u("div", { className: `vizel-bubble-menu-toolbar ${r ?? ""}`, children: [
24
- /* @__PURE__ */ e(k, { editor: i }),
25
- /* @__PURE__ */ e(
26
- t,
27
- {
28
- action: "bold",
29
- onClick: () => i.chain().focus().toggleBold().run(),
30
- isActive: i.isActive("bold"),
31
- title: "Bold (Cmd+B)",
32
- children: /* @__PURE__ */ e(l, { name: "bold" })
33
- }
34
- ),
35
- /* @__PURE__ */ e(
36
- t,
37
- {
38
- action: "italic",
39
- onClick: () => i.chain().focus().toggleItalic().run(),
40
- isActive: i.isActive("italic"),
41
- title: "Italic (Cmd+I)",
42
- children: /* @__PURE__ */ e(l, { name: "italic" })
43
- }
44
- ),
45
- /* @__PURE__ */ e(
46
- t,
47
- {
48
- action: "strike",
49
- onClick: () => i.chain().focus().toggleStrike().run(),
50
- isActive: i.isActive("strike"),
51
- title: "Strikethrough",
52
- children: /* @__PURE__ */ e(l, { name: "strikethrough" })
53
- }
54
- ),
55
- /* @__PURE__ */ e(
56
- t,
57
- {
58
- action: "underline",
59
- onClick: () => i.chain().focus().toggleUnderline().run(),
60
- isActive: i.isActive("underline"),
61
- title: "Underline (Cmd+U)",
62
- children: /* @__PURE__ */ e(l, { name: "underline" })
63
- }
64
- ),
65
- /* @__PURE__ */ e(
66
- t,
67
- {
68
- action: "code",
69
- onClick: () => i.chain().focus().toggleCode().run(),
70
- isActive: i.isActive("code"),
71
- title: "Code (Cmd+E)",
72
- children: /* @__PURE__ */ e(l, { name: "code" })
73
- }
74
- ),
75
- /* @__PURE__ */ e(
76
- t,
77
- {
78
- action: "link",
79
- onClick: () => c(!0),
80
- isActive: i.isActive("link"),
81
- title: "Link (Cmd+K)",
82
- children: /* @__PURE__ */ e(l, { name: "link" })
83
- }
84
- ),
85
- /* @__PURE__ */ e(o, { editor: i, type: "textColor" }),
86
- /* @__PURE__ */ e(o, { editor: i, type: "highlight" })
87
- ] });
88
- }
89
- export {
90
- z as VizelBubbleMenuDefault
91
- };
1
+ import { initVizelIconRenderer as e } from "@vizel/core";
2
+ e();
package/package.json CHANGED
@@ -1,43 +1,29 @@
1
1
  {
2
2
  "name": "@vizel/react",
3
- "version": "0.0.1-alpha.1",
4
- "description": "React components for Vizel block-based Markdown editor",
5
- "keywords": [
6
- "react",
7
- "tiptap",
8
- "editor",
9
- "markdown",
10
- "wysiwyg",
11
- "rich-text",
12
- "block-editor"
13
- ],
14
- "license": "MIT",
15
- "author": "Seiji Kohara",
3
+ "version": "0.0.1-alpha.5",
4
+ "type": "module",
16
5
  "repository": {
17
6
  "type": "git",
18
- "url": "git+https://github.com/seijikohara/vizel.git",
7
+ "url": "https://github.com/seijikohara/vizel",
19
8
  "directory": "packages/react"
20
9
  },
21
- "homepage": "https://github.com/seijikohara/vizel",
22
- "bugs": "https://github.com/seijikohara/vizel/issues",
23
- "type": "module",
24
- "sideEffects": false,
25
- "engines": {
26
- "node": ">=18"
27
- },
28
- "main": "./dist/index.js",
29
- "module": "./dist/index.js",
30
- "types": "./dist/index.d.ts",
10
+ "main": "./src/index.ts",
11
+ "types": "./src/index.ts",
31
12
  "exports": {
32
13
  ".": {
33
- "types": "./dist/index.d.ts",
34
- "import": "./dist/index.js",
35
- "default": "./dist/index.js"
36
- },
37
- "./package.json": "./package.json"
14
+ "types": "./src/index.ts",
15
+ "import": "./src/index.ts"
16
+ }
38
17
  },
39
18
  "publishConfig": {
40
- "access": "public"
19
+ "main": "./dist/index.js",
20
+ "types": "./dist/index.d.ts",
21
+ "exports": {
22
+ ".": {
23
+ "types": "./dist/index.d.ts",
24
+ "import": "./dist/index.js"
25
+ }
26
+ }
41
27
  },
42
28
  "files": [
43
29
  "dist"
@@ -48,13 +34,21 @@
48
34
  },
49
35
  "dependencies": {
50
36
  "@iconify/react": "^6",
51
- "@vizel/core": "^0.0.1-alpha.1"
37
+ "@vizel/core": "^0.0.1-alpha.5"
52
38
  },
53
39
  "peerDependencies": {
54
40
  "react": "^19",
55
41
  "react-dom": "^19"
56
42
  },
57
43
  "devDependencies": {
44
+ "@tiptap/extension-bold": "^3",
45
+ "@tiptap/extension-code": "^3",
46
+ "@tiptap/extension-color": "^3",
47
+ "@tiptap/extension-highlight": "^3",
48
+ "@tiptap/extension-italic": "^3",
49
+ "@tiptap/extension-strike": "^3",
50
+ "@tiptap/extension-text-style": "^3",
51
+ "@tiptap/extension-underline": "^3",
58
52
  "@types/react": "^19",
59
53
  "@types/react-dom": "^19",
60
54
  "@vitejs/plugin-react": "^5",