@makeswift/runtime 0.10.2 → 0.10.4
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/dist/Box.cjs.js +1 -3
- package/dist/Box.cjs.js.map +1 -1
- package/dist/Box.es.js +2 -4
- package/dist/Box.es.js.map +1 -1
- package/dist/Button.cjs.js +5 -5
- package/dist/Button.es.js +6 -6
- package/dist/Carousel.cjs.js +4 -4
- package/dist/Carousel.es.js +5 -5
- package/dist/Countdown.cjs.js +3 -5
- package/dist/Countdown.cjs.js.map +1 -1
- package/dist/Countdown.es.js +4 -6
- package/dist/Countdown.es.js.map +1 -1
- package/dist/Divider.cjs.js +2 -4
- package/dist/Divider.cjs.js.map +1 -1
- package/dist/Divider.es.js +3 -5
- package/dist/Divider.es.js.map +1 -1
- package/dist/Embed.cjs.js +3 -1
- package/dist/Embed.cjs.js.map +1 -1
- package/dist/Embed.es.js +4 -2
- package/dist/Embed.es.js.map +1 -1
- package/dist/Form.cjs.js +15 -15
- package/dist/Form.cjs.js.map +1 -1
- package/dist/Form.es.js +7 -7
- package/dist/Image.cjs.js +13 -13
- package/dist/Image.cjs.js.map +1 -1
- package/dist/Image.es.js +13 -13
- package/dist/LiveProvider.cjs.js +2 -4
- package/dist/LiveProvider.cjs.js.map +1 -1
- package/dist/LiveProvider.es.js +4 -6
- package/dist/LiveProvider.es.js.map +1 -1
- package/dist/Navigation.cjs.js +13 -13
- package/dist/Navigation.cjs.js.map +1 -1
- package/dist/Navigation.es.js +13 -13
- package/dist/PreviewProvider.cjs.js +2 -4
- package/dist/PreviewProvider.cjs.js.map +1 -1
- package/dist/PreviewProvider.es.js +4 -6
- package/dist/PreviewProvider.es.js.map +1 -1
- package/dist/ReadOnlyText.cjs.js +8 -7
- package/dist/ReadOnlyText.cjs.js.map +1 -1
- package/dist/ReadOnlyText.es.js +5 -4
- package/dist/ReadOnlyText.es.js.map +1 -1
- package/dist/ReadOnlyTextV2.cjs.js +8 -61
- package/dist/ReadOnlyTextV2.cjs.js.map +1 -1
- package/dist/ReadOnlyTextV2.es.js +10 -63
- package/dist/ReadOnlyTextV2.es.js.map +1 -1
- package/dist/Root.cjs.js +2 -4
- package/dist/Root.cjs.js.map +1 -1
- package/dist/Root.es.js +3 -5
- package/dist/Root.es.js.map +1 -1
- package/dist/SocialLinks.cjs.js +7 -7
- package/dist/SocialLinks.cjs.js.map +1 -1
- package/dist/SocialLinks.es.js +8 -8
- package/dist/Video.cjs.js +3 -1
- package/dist/Video.cjs.js.map +1 -1
- package/dist/Video.es.js +4 -2
- package/dist/Video.es.js.map +1 -1
- package/dist/builder.cjs.js +3 -1
- package/dist/builder.cjs.js.map +1 -1
- package/dist/builder.es.js +3 -1
- package/dist/builder.es.js.map +1 -1
- package/dist/components.cjs.js +4 -4
- package/dist/components.es.js +4 -4
- package/dist/control-serialization.cjs.js +1 -0
- package/dist/control-serialization.cjs.js.map +1 -1
- package/dist/control-serialization.es.js +2 -1
- package/dist/control-serialization.es.js.map +1 -1
- package/dist/controls.cjs.js +5 -1
- package/dist/controls.cjs.js.map +1 -1
- package/dist/controls.es.js +4 -2
- package/dist/controls.es.js.map +1 -1
- package/dist/index.cjs.js +121 -257
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.cjs2.js +1 -0
- package/dist/index.cjs2.js.map +1 -1
- package/dist/index.cjs3.js +107 -21
- package/dist/index.cjs3.js.map +1 -1
- package/dist/index.cjs4.js +57 -16
- package/dist/index.cjs4.js.map +1 -1
- package/dist/index.cjs5.js +42 -81
- package/dist/index.cjs5.js.map +1 -1
- package/dist/index.cjs6.js +82 -17
- package/dist/index.cjs6.js.map +1 -1
- package/dist/index.cjs7.js +18 -377
- package/dist/index.cjs7.js.map +1 -1
- package/dist/index.cjs8.js +258 -181
- package/dist/index.cjs8.js.map +1 -1
- package/dist/index.cjs9.js +343 -0
- package/dist/index.cjs9.js.map +1 -0
- package/dist/index.es.js +126 -261
- package/dist/index.es.js.map +1 -1
- package/dist/index.es2.js +2 -1
- package/dist/index.es2.js.map +1 -1
- package/dist/index.es3.js +103 -22
- package/dist/index.es3.js.map +1 -1
- package/dist/index.es4.js +57 -16
- package/dist/index.es4.js.map +1 -1
- package/dist/index.es5.js +42 -80
- package/dist/index.es5.js.map +1 -1
- package/dist/index.es6.js +81 -17
- package/dist/index.es6.js.map +1 -1
- package/dist/index.es7.js +18 -371
- package/dist/index.es7.js.map +1 -1
- package/dist/index.es8.js +259 -182
- package/dist/index.es8.js.map +1 -1
- package/dist/index.es9.js +336 -0
- package/dist/index.es9.js.map +1 -0
- package/dist/main.cjs.js +3 -1
- package/dist/main.cjs.js.map +1 -1
- package/dist/main.es.js +3 -1
- package/dist/main.es.js.map +1 -1
- package/dist/next.cjs.js +3 -5
- package/dist/next.cjs.js.map +1 -1
- package/dist/next.es.js +4 -6
- package/dist/next.es.js.map +1 -1
- package/dist/prop-controllers.cjs.js +3 -1
- package/dist/prop-controllers.cjs.js.map +1 -1
- package/dist/prop-controllers.es.js +3 -1
- package/dist/prop-controllers.es.js.map +1 -1
- package/dist/react-page.cjs.js +499 -314
- package/dist/react-page.cjs.js.map +1 -1
- package/dist/react-page.es.js +498 -315
- package/dist/react-page.es.js.map +1 -1
- package/dist/react.cjs.js +3 -5
- package/dist/react.cjs.js.map +1 -1
- package/dist/react.es.js +3 -5
- package/dist/react.es.js.map +1 -1
- package/dist/slate.cjs.js +11 -8
- package/dist/slate.cjs.js.map +1 -1
- package/dist/slate.es.js +11 -9
- package/dist/slate.es.js.map +1 -1
- package/dist/toText.cjs.js +67 -0
- package/dist/toText.cjs.js.map +1 -0
- package/dist/toText.es.js +66 -0
- package/dist/toText.es.js.map +1 -0
- package/dist/types/src/components/builtin/Text/register.d.ts.map +1 -1
- package/dist/types/src/controls/control.d.ts +1 -1
- package/dist/types/src/controls/control.d.ts.map +1 -1
- package/dist/types/src/controls/rich-text/__test__/copy.test.d.ts +2 -0
- package/dist/types/src/controls/rich-text/__test__/copy.test.d.ts.map +1 -0
- package/dist/types/src/controls/rich-text/__test__/introspection.test.d.ts.map +1 -0
- package/dist/types/src/controls/rich-text/__test__/translation.test.d.ts.map +1 -0
- package/dist/types/src/controls/rich-text/copy.d.ts +4 -0
- package/dist/types/src/controls/rich-text/copy.d.ts.map +1 -0
- package/dist/types/src/controls/rich-text/index.d.ts +1 -0
- package/dist/types/src/controls/rich-text/index.d.ts.map +1 -1
- package/dist/types/src/controls/rich-text-v2/__test__/copy.test.d.ts +2 -0
- package/dist/types/src/controls/rich-text-v2/__test__/copy.test.d.ts.map +1 -0
- package/dist/types/src/controls/rich-text-v2/__test__/introspection.test.d.ts.map +1 -0
- package/dist/types/src/controls/rich-text-v2/copy.d.ts +4 -0
- package/dist/types/src/controls/rich-text-v2/copy.d.ts.map +1 -0
- package/dist/types/src/controls/rich-text-v2/index.d.ts +1 -0
- package/dist/types/src/controls/rich-text-v2/index.d.ts.map +1 -1
- package/dist/types/src/controls/rich-text-v2/rich-text-v2.d.ts +2 -4
- package/dist/types/src/controls/rich-text-v2/rich-text-v2.d.ts.map +1 -1
- package/dist/types/src/controls/rich-text-v2/translation.d.ts +1 -1
- package/dist/types/src/controls/rich-text-v2/translation.d.ts.map +1 -1
- package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/editable-text-v2.d.ts.map +1 -1
- package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/render-element.d.ts.map +1 -1
- package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/usePresetValue.d.ts +10 -0
- package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/usePresetValue.d.ts.map +1 -0
- package/dist/types/src/runtimes/react/controls/rich-text-v2/ReadOnlyTextV2.d.ts.map +1 -1
- package/dist/types/src/slate/BuilderPlugin/index.d.ts +2 -1
- package/dist/types/src/slate/BuilderPlugin/index.d.ts.map +1 -1
- package/dist/types/src/slate/InlineModePlugin/index.d.ts.map +1 -1
- package/dist/types/src/slate/InlinePlugin/index.d.ts +2 -2
- package/dist/types/src/slate/TextAlignPlugin/index.d.ts +3 -3
- package/dist/types/src/slate/TypographyPlugin/index.d.ts +3 -3
- package/dist/types/src/slate/index.d.ts +1 -0
- package/dist/types/src/slate/index.d.ts.map +1 -1
- package/dist/types/src/slate/utils/index.d.ts +2 -0
- package/dist/types/src/slate/utils/index.d.ts.map +1 -0
- package/dist/types/src/slate/utils/toText.d.ts +4 -0
- package/dist/types/src/slate/utils/toText.d.ts.map +1 -0
- package/package.json +1 -1
- package/dist/types/src/controls/rich-text/introspection.test.d.ts.map +0 -1
- package/dist/types/src/controls/rich-text/translation.test.d.ts.map +0 -1
- package/dist/types/src/controls/rich-text-v2/introspection.test.d.ts.map +0 -1
- /package/dist/types/src/controls/rich-text/{introspection.test.d.ts → __test__/introspection.test.d.ts} +0 -0
- /package/dist/types/src/controls/rich-text/{translation.test.d.ts → __test__/translation.test.d.ts} +0 -0
- /package/dist/types/src/controls/rich-text-v2/{introspection.test.d.ts → __test__/introspection.test.d.ts} +0 -0
package/dist/index.es5.js
CHANGED
|
@@ -1,85 +1,47 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
import { Node, Transforms, Text, Editor } from "slate";
|
|
2
|
+
import { ReactEditor } from "slate-react";
|
|
3
|
+
import { bS as ElementUtils } from "./react-page.es.js";
|
|
4
|
+
function withBuilder(editor) {
|
|
5
|
+
editor.resetValue = function(value) {
|
|
6
|
+
var _a;
|
|
7
|
+
const firstRootBlock = Node.has(editor, [0]) && Node.get(editor, [0]);
|
|
8
|
+
const textAlignOfFirstBlock = firstRootBlock && ElementUtils.isRootBlock(firstRootBlock) ? firstRootBlock.textAlign : void 0;
|
|
9
|
+
const typographyOfFirstText = (_a = Array.from(Node.texts(editor)).at(0)) == null ? void 0 : _a[0].typography;
|
|
10
|
+
ReactEditor.deselect(editor);
|
|
11
|
+
ReactEditor.blur(editor);
|
|
12
|
+
editor.children = value;
|
|
13
|
+
editor.onChange();
|
|
14
|
+
if (typographyOfFirstText) {
|
|
15
|
+
Transforms.setNodes(editor, { typography: typographyOfFirstText }, {
|
|
16
|
+
match: Text.isText,
|
|
17
|
+
at: {
|
|
18
|
+
anchor: Editor.start(editor, []),
|
|
19
|
+
focus: Editor.end(editor, [])
|
|
20
|
+
}
|
|
21
|
+
});
|
|
16
22
|
}
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const withLink = (editor) => {
|
|
25
|
-
const {
|
|
26
|
-
isInline
|
|
27
|
-
} = editor;
|
|
28
|
-
editor.isInline = (entry) => {
|
|
29
|
-
return ElementUtils.isInline(entry) && isInline(entry);
|
|
30
|
-
};
|
|
31
|
-
return editor;
|
|
32
|
-
};
|
|
33
|
-
function InlinePluginComponent({
|
|
34
|
-
element,
|
|
35
|
-
attributes,
|
|
36
|
-
children,
|
|
37
|
-
renderElement
|
|
38
|
-
}) {
|
|
39
|
-
var _a;
|
|
40
|
-
const linkStyle = useStyle({
|
|
41
|
-
textDecoration: "none"
|
|
42
|
-
});
|
|
43
|
-
switch (element.type) {
|
|
44
|
-
case InlineType.Link:
|
|
45
|
-
return /* @__PURE__ */ jsx(Link$1, __spreadProps(__spreadValues({}, attributes), {
|
|
46
|
-
link: (_a = element.link) != null ? _a : void 0,
|
|
47
|
-
className: cx(linkStyle, element.className),
|
|
48
|
-
children: renderElement({
|
|
49
|
-
element,
|
|
50
|
-
attributes,
|
|
51
|
-
children
|
|
52
|
-
})
|
|
53
|
-
}));
|
|
54
|
-
default:
|
|
55
|
-
return /* @__PURE__ */ jsx(Fragment, {
|
|
56
|
-
children: renderElement({
|
|
57
|
-
element,
|
|
58
|
-
attributes,
|
|
59
|
-
children
|
|
60
|
-
})
|
|
23
|
+
if (textAlignOfFirstBlock) {
|
|
24
|
+
Transforms.setNodes(editor, { textAlign: textAlignOfFirstBlock }, {
|
|
25
|
+
match: ElementUtils.isRootBlock,
|
|
26
|
+
at: {
|
|
27
|
+
anchor: Editor.start(editor, []),
|
|
28
|
+
focus: Editor.end(editor, [])
|
|
29
|
+
}
|
|
61
30
|
});
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
function LinkPlugin() {
|
|
65
|
-
return createRichTextV2Plugin({
|
|
66
|
-
control: {
|
|
67
|
-
definition: Link({
|
|
68
|
-
label: "On Click"
|
|
69
|
-
}),
|
|
70
|
-
onChange,
|
|
71
|
-
getValue,
|
|
72
|
-
getElementValue: (element) => {
|
|
73
|
-
return ElementUtils.isInline(element) && isLinkElement(element) ? element.link : void 0;
|
|
74
|
-
}
|
|
75
|
-
},
|
|
76
|
-
withPlugin: withLink,
|
|
77
|
-
renderElement: (renderElement) => (props) => {
|
|
78
|
-
return /* @__PURE__ */ jsx(InlinePluginComponent, __spreadProps(__spreadValues({}, props), {
|
|
79
|
-
renderElement
|
|
80
|
-
}));
|
|
81
31
|
}
|
|
82
|
-
}
|
|
32
|
+
};
|
|
33
|
+
editor.deselectAndBlur = function() {
|
|
34
|
+
ReactEditor.deselect(editor);
|
|
35
|
+
ReactEditor.blur(editor);
|
|
36
|
+
};
|
|
37
|
+
editor.focusAndSelectAll = function() {
|
|
38
|
+
ReactEditor.focus(editor);
|
|
39
|
+
Transforms.select(editor, {
|
|
40
|
+
anchor: Editor.start(editor, []),
|
|
41
|
+
focus: Editor.end(editor, [])
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
return editor;
|
|
83
45
|
}
|
|
84
|
-
export {
|
|
46
|
+
export { withBuilder as w };
|
|
85
47
|
//# sourceMappingURL=index.es5.js.map
|
package/dist/index.es5.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.es5.js","sources":["../src/slate/
|
|
1
|
+
{"version":3,"file":"index.es5.js","sources":["../src/slate/BuilderPlugin/index.ts"],"sourcesContent":["import { BaseEditor, Descendant, Editor, Transforms, Text, Node } from 'slate'\nimport { ReactEditor } from 'slate-react'\nimport { ElementUtils } from '../utils/element'\n\nexport interface BuilderEditor extends BaseEditor {\n focusAndSelectAll: () => void\n deselectAndBlur: () => void\n resetValue: (value: Descendant[]) => void\n}\n\nexport function withBuilder(editor: Editor) {\n editor.resetValue = function (value: Descendant[]) {\n const firstRootBlock = Node.has(editor, [0]) && Node.get(editor, [0])\n const textAlignOfFirstBlock =\n firstRootBlock && ElementUtils.isRootBlock(firstRootBlock)\n ? firstRootBlock.textAlign\n : undefined\n const typographyOfFirstText = Array.from(Node.texts(editor)).at(0)?.[0].typography\n\n ReactEditor.deselect(editor)\n ReactEditor.blur(editor)\n\n editor.children = value\n editor.onChange()\n\n if (typographyOfFirstText) {\n Transforms.setNodes(\n editor,\n { typography: typographyOfFirstText },\n {\n match: Text.isText,\n at: {\n anchor: Editor.start(editor, []),\n focus: Editor.end(editor, []),\n },\n },\n )\n }\n if (textAlignOfFirstBlock) {\n Transforms.setNodes(\n editor,\n { textAlign: textAlignOfFirstBlock },\n {\n match: ElementUtils.isRootBlock,\n at: {\n anchor: Editor.start(editor, []),\n focus: Editor.end(editor, []),\n },\n },\n )\n }\n }\n editor.deselectAndBlur = function () {\n ReactEditor.deselect(editor)\n ReactEditor.blur(editor)\n }\n\n editor.focusAndSelectAll = function () {\n ReactEditor.focus(editor)\n Transforms.select(editor, {\n anchor: Editor.start(editor, []),\n focus: Editor.end(editor, []),\n })\n }\n\n return editor\n}\n"],"names":[],"mappings":";;;AAUO,qBAAqB,QAAgB;AACnC,SAAA,aAAa,SAAU,OAAqB;;AACjD,UAAM,iBAAiB,KAAK,IAAI,QAAQ,CAAC,CAAC,CAAC,KAAK,KAAK,IAAI,QAAQ,CAAC,CAAC,CAAC;AACpE,UAAM,wBACJ,kBAAkB,aAAa,YAAY,c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
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
import { bS as ElementUtils, bv as createRichTextV2Plugin, aM as Link, bT as onChange, bU as getValue, bV as isLinkElement, Z as useStyle, bO as InlineType } from "./react-page.es.js";
|
|
21
|
+
import { L as Link$1 } from "./index.es3.js";
|
|
22
|
+
import { cx } from "@emotion/css";
|
|
23
|
+
import { jsx, Fragment } from "react/jsx-runtime";
|
|
24
|
+
const withLink = (editor) => {
|
|
25
|
+
const {
|
|
26
|
+
isInline
|
|
27
|
+
} = editor;
|
|
28
|
+
editor.isInline = (entry) => {
|
|
29
|
+
return ElementUtils.isInline(entry) && isInline(entry);
|
|
17
30
|
};
|
|
18
31
|
return editor;
|
|
32
|
+
};
|
|
33
|
+
function InlinePluginComponent({
|
|
34
|
+
element,
|
|
35
|
+
attributes,
|
|
36
|
+
children,
|
|
37
|
+
renderElement
|
|
38
|
+
}) {
|
|
39
|
+
var _a;
|
|
40
|
+
const linkStyle = useStyle({
|
|
41
|
+
textDecoration: "none"
|
|
42
|
+
});
|
|
43
|
+
switch (element.type) {
|
|
44
|
+
case InlineType.Link:
|
|
45
|
+
return /* @__PURE__ */ jsx(Link$1, __spreadProps(__spreadValues({}, attributes), {
|
|
46
|
+
link: (_a = element.link) != null ? _a : void 0,
|
|
47
|
+
className: cx(linkStyle, element.className),
|
|
48
|
+
children: renderElement({
|
|
49
|
+
element,
|
|
50
|
+
attributes,
|
|
51
|
+
children
|
|
52
|
+
})
|
|
53
|
+
}));
|
|
54
|
+
default:
|
|
55
|
+
return /* @__PURE__ */ jsx(Fragment, {
|
|
56
|
+
children: renderElement({
|
|
57
|
+
element,
|
|
58
|
+
attributes,
|
|
59
|
+
children
|
|
60
|
+
})
|
|
61
|
+
});
|
|
62
|
+
}
|
|
19
63
|
}
|
|
20
|
-
|
|
64
|
+
function LinkPlugin() {
|
|
65
|
+
return createRichTextV2Plugin({
|
|
66
|
+
control: {
|
|
67
|
+
definition: Link({
|
|
68
|
+
label: "On Click"
|
|
69
|
+
}),
|
|
70
|
+
onChange,
|
|
71
|
+
getValue,
|
|
72
|
+
getElementValue: (element) => {
|
|
73
|
+
return ElementUtils.isInline(element) && isLinkElement(element) ? element.link : void 0;
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
withPlugin: withLink,
|
|
77
|
+
renderElement: (renderElement) => (props) => {
|
|
78
|
+
return /* @__PURE__ */ jsx(InlinePluginComponent, __spreadProps(__spreadValues({}, props), {
|
|
79
|
+
renderElement
|
|
80
|
+
}));
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
export { LinkPlugin as L, withLink as w };
|
|
21
85
|
//# sourceMappingURL=index.es6.js.map
|
package/dist/index.es6.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.es6.js","sources":["../src/slate/
|
|
1
|
+
{"version":3,"file":"index.es6.js","sources":["../src/slate/LinkPlugin/index.tsx"],"sourcesContent":["import { Editor, Element } from 'slate'\nimport { RenderElement, createRichTextV2Plugin } from '../../controls/rich-text-v2/plugin'\nimport { Link } from '../../controls/link'\nimport { ElementUtils } from '../utils/element'\nimport { InlineType } from '../types'\nimport { RenderElementProps } from 'slate-react'\nimport { useStyle } from '../../runtimes/react/use-style'\nimport { Link as LinkComponent } from '../../components/shared/Link'\nimport { cx } from '@emotion/css'\nimport { isLinkElement } from './types'\nimport { onChange } from './onChange'\nimport { getValue } from './getValue'\n\nexport const withLink = (editor: Editor) => {\n const { isInline } = editor\n\n editor.isInline = entry => {\n return ElementUtils.isInline(entry) && isInline(entry)\n }\n\n return editor\n}\n\nfunction InlinePluginComponent({\n element,\n attributes,\n children,\n renderElement,\n}: RenderElementProps & { renderElement: RenderElement }) {\n const linkStyle = useStyle({ textDecoration: 'none' })\n switch (element.type) {\n case InlineType.Link:\n return (\n <LinkComponent\n {...attributes}\n link={element.link ?? undefined}\n className={cx(linkStyle, element.className)}\n >\n {renderElement({\n element,\n attributes,\n children,\n })}\n </LinkComponent>\n )\n\n default:\n return (\n <>\n {renderElement({\n element,\n attributes,\n children,\n })}\n </>\n )\n }\n}\n\nexport function LinkPlugin() {\n return createRichTextV2Plugin({\n control: {\n definition: Link({\n label: 'On Click',\n }),\n onChange,\n getValue,\n getElementValue: (element: Element) => {\n return ElementUtils.isInline(element) && isLinkElement(element) ? element.link : undefined\n },\n },\n withPlugin: withLink,\n renderElement: renderElement => props => {\n return <InlinePluginComponent {...props} renderElement={renderElement} />\n },\n })\n}\n"],"names":["withLink","editor","isInline","entry","ElementUtils","element","attributes","children","renderElement","linkStyle","useStyle","textDecoration","type","InlineType","Link","LinkComponent","link","undefined","cx","className","_Fragment","createRichTextV2Plugin","control","definition","label","onChange","getValue","getElementValue","isLinkElement","withPlugin","props"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;A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