@raketa-builder/markdown-input 0.3.0 → 0.5.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/dist/index.js +34 -24
- package/package.json +1 -3
- package/src/MarkdownInput.js +11 -7
- package/src/index.js +1 -2
- package/src/toHTML.js +0 -19
package/dist/index.js
CHANGED
|
@@ -216,11 +216,11 @@ var require_dist = __commonJS({
|
|
|
216
216
|
var import_react3 = __toESM2(require("react"));
|
|
217
217
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
218
218
|
var Button = (_a) => {
|
|
219
|
-
var _b = _a, {
|
|
219
|
+
var _b = _a, { as = "button", size, variant, className } = _b, rest = __objRest2(_b, ["as", "size", "variant", "className"]);
|
|
220
|
+
const Component = as;
|
|
220
221
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
221
|
-
|
|
222
|
+
Component,
|
|
222
223
|
__spreadValues2({
|
|
223
|
-
type,
|
|
224
224
|
className: cn2(
|
|
225
225
|
"r-reset",
|
|
226
226
|
"r-reset-button",
|
|
@@ -229,7 +229,7 @@ var require_dist = __commonJS({
|
|
|
229
229
|
`r-button-${variant}`,
|
|
230
230
|
className
|
|
231
231
|
)
|
|
232
|
-
},
|
|
232
|
+
}, rest)
|
|
233
233
|
);
|
|
234
234
|
};
|
|
235
235
|
Button.defaultProps = {
|
|
@@ -282,8 +282,8 @@ var require_dist = __commonJS({
|
|
|
282
282
|
var import_react5 = __toESM2(require("react"));
|
|
283
283
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
284
284
|
var Input = (_a) => {
|
|
285
|
-
var _b = _a, { className } = _b,
|
|
286
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("input", __spreadValues2({ className: cn2("r-reset", "r-input", className) },
|
|
285
|
+
var _b = _a, { className } = _b, rest = __objRest2(_b, ["className"]);
|
|
286
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("input", __spreadValues2({ className: cn2("r-reset", "r-input", className) }, rest));
|
|
287
287
|
};
|
|
288
288
|
var Input_default = Input;
|
|
289
289
|
var import_react6 = __toESM2(require("react"));
|
|
@@ -391,18 +391,8 @@ var require_dist = __commonJS({
|
|
|
391
391
|
var import_react13 = __toESM2(require("react"));
|
|
392
392
|
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
393
393
|
var Stack = (_a) => {
|
|
394
|
-
var _b = _a, {
|
|
395
|
-
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
396
|
-
"div",
|
|
397
|
-
__spreadValues2({
|
|
398
|
-
style: {
|
|
399
|
-
justifyContent: h || "flex-start",
|
|
400
|
-
alignItems: v || "flex-start",
|
|
401
|
-
gap: g || "1em"
|
|
402
|
-
},
|
|
403
|
-
className: cn2("r-stack", className)
|
|
404
|
-
}, props)
|
|
405
|
-
);
|
|
394
|
+
var _b = _a, { className } = _b, props = __objRest2(_b, ["className"]);
|
|
395
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", __spreadValues2({ className: cn2("r-stack", className) }, props));
|
|
406
396
|
};
|
|
407
397
|
var Stack_default = Stack;
|
|
408
398
|
var import_react14 = __toESM2(require("react"));
|
|
@@ -464,11 +454,28 @@ var require_dist = __commonJS({
|
|
|
464
454
|
}, props)
|
|
465
455
|
);
|
|
466
456
|
};
|
|
457
|
+
var FooterBar = (_a) => {
|
|
458
|
+
var _b = _a, { className } = _b, props = __objRest2(_b, ["className"]);
|
|
459
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", __spreadValues2({ className: cn2("r-reset", "r-modal-footer-bar", className) }, props));
|
|
460
|
+
};
|
|
467
461
|
var Content = (_a) => {
|
|
468
462
|
var _b = _a, { className } = _b, props = __objRest2(_b, ["className"]);
|
|
469
463
|
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", __spreadValues2({ className: cn2("r-reset", "r-modal-content", className) }, props));
|
|
470
464
|
};
|
|
471
|
-
var Modal = (
|
|
465
|
+
var Modal = (_a) => {
|
|
466
|
+
var _b = _a, {
|
|
467
|
+
title,
|
|
468
|
+
children,
|
|
469
|
+
customWrapper,
|
|
470
|
+
FooterContent,
|
|
471
|
+
onClose
|
|
472
|
+
} = _b, rest = __objRest2(_b, [
|
|
473
|
+
"title",
|
|
474
|
+
"children",
|
|
475
|
+
"customWrapper",
|
|
476
|
+
"FooterContent",
|
|
477
|
+
"onClose"
|
|
478
|
+
]);
|
|
472
479
|
const handleKeyUp = ({ key }) => {
|
|
473
480
|
if (key === "Escape")
|
|
474
481
|
onClose();
|
|
@@ -479,15 +486,17 @@ var require_dist = __commonJS({
|
|
|
479
486
|
document.removeEventListener("keyup", handleKeyUp);
|
|
480
487
|
};
|
|
481
488
|
});
|
|
489
|
+
const ModalWrapper = customWrapper ? customWrapper : Wrapper;
|
|
482
490
|
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_react17.default.Fragment, { children: [
|
|
483
491
|
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Overlay, { onClick: onClose }),
|
|
484
|
-
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
492
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ModalWrapper, __spreadProps(__spreadValues2({}, rest), { children: /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(Inner, { children: [
|
|
485
493
|
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(TitleBar, { children: [
|
|
486
494
|
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Title, { children: title }),
|
|
487
495
|
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(CloseButton, { type: "button", onClick: onClose, children: "\xD7" })
|
|
488
496
|
] }),
|
|
489
|
-
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Content, { children })
|
|
490
|
-
|
|
497
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Content, { children }),
|
|
498
|
+
FooterContent && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(FooterBar, { children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(FooterContent, {}) })
|
|
499
|
+
] }) }))
|
|
491
500
|
] });
|
|
492
501
|
};
|
|
493
502
|
var Modal_default = Modal;
|
|
@@ -818,9 +827,10 @@ var toHTML_default = toHTML;
|
|
|
818
827
|
// src/MarkdownInput.js
|
|
819
828
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
820
829
|
var IconButton = (_a) => {
|
|
821
|
-
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
830
|
+
var _b = _a, { as = "button", className } = _b, props = __objRest(_b, ["as", "className"]);
|
|
831
|
+
const Component = as;
|
|
822
832
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
823
|
-
|
|
833
|
+
Component,
|
|
824
834
|
__spreadValues({
|
|
825
835
|
className: (0, import_ui.cn)("r-reset-button", "r-md-icon-btn", className)
|
|
826
836
|
}, props)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@raketa-builder/markdown-input",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"license": "MIT",
|
|
@@ -14,8 +14,6 @@
|
|
|
14
14
|
"react-dom": "18.2.0"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"markdown-it": "13.0.1",
|
|
18
|
-
"markdown-it-attrs": "4.1.4",
|
|
19
17
|
"ui": "*"
|
|
20
18
|
},
|
|
21
19
|
"devDependencies": {
|
package/src/MarkdownInput.js
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { FormGroup, Label, Textarea, Hint, cn } from "@raketa-builder/ui";
|
|
3
|
-
import toHTML from "
|
|
3
|
+
import { toHTML } from "@raketa-builder/support";
|
|
4
4
|
|
|
5
|
-
const IconButton = ({ className, ...props }) =>
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
)
|
|
5
|
+
const IconButton = ({ as = "button", className, ...props }) => {
|
|
6
|
+
const Component = as;
|
|
7
|
+
|
|
8
|
+
return (
|
|
9
|
+
<Component
|
|
10
|
+
className={cn("r-reset-button", "r-md-icon-btn", className)}
|
|
11
|
+
{...props}
|
|
12
|
+
/>
|
|
13
|
+
);
|
|
14
|
+
};
|
|
11
15
|
|
|
12
16
|
const TextareaWrapper = ({ className, ...props }) => (
|
|
13
17
|
<div className={cn("r-reset", "r-md-textarea", className)} {...props} />
|
package/src/index.js
CHANGED
package/src/toHTML.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import MarkdownIt from "markdown-it";
|
|
2
|
-
import markdownItAttrs from "markdown-it-attrs";
|
|
3
|
-
|
|
4
|
-
const parser = new MarkdownIt({
|
|
5
|
-
html: true,
|
|
6
|
-
breaks: true,
|
|
7
|
-
}).use(markdownItAttrs, {
|
|
8
|
-
// optional, these are default options
|
|
9
|
-
leftDelimiter: "{",
|
|
10
|
-
rightDelimiter: "}",
|
|
11
|
-
allowedAttributes: [], // empty array = all attributes are allowed
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
const toHTML = (string, inline = false) => {
|
|
15
|
-
if (!string) return;
|
|
16
|
-
return inline ? parser.renderInline(string) : parser.render(string);
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export default toHTML;
|