@crystaldesign/rtf-editor 24.12.0-beta.16
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/build/esm/index.js +69 -0
- package/build/types/index.d.ts +11 -0
- package/build/types/index.d.ts.map +1 -0
- package/package.json +23 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
import { useQuill } from 'react-quilljs';
|
|
3
|
+
import 'quill/dist/quill.snow.css';
|
|
4
|
+
import { QuillDeltaToHtmlConverter } from 'quill-delta-to-html';
|
|
5
|
+
import { jsx } from 'react/jsx-runtime';
|
|
6
|
+
|
|
7
|
+
(function() {
|
|
8
|
+
const env = {"STAGE":"production"};
|
|
9
|
+
try {
|
|
10
|
+
if (process) {
|
|
11
|
+
process.env = Object.assign({}, process.env);
|
|
12
|
+
Object.assign(process.env, env);
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
} catch (e) {} // avoid ReferenceError: process is not defined
|
|
16
|
+
globalThis.process = { env:env };
|
|
17
|
+
})();
|
|
18
|
+
|
|
19
|
+
var RTFEditor = function RTFEditor(_ref) {
|
|
20
|
+
var initialValue = _ref.initialValue,
|
|
21
|
+
onChange = _ref.onChange;
|
|
22
|
+
var modules = {
|
|
23
|
+
toolbar: [['bold', 'italic', 'underline', 'strike'], [{
|
|
24
|
+
align: []
|
|
25
|
+
}], [{
|
|
26
|
+
color: []
|
|
27
|
+
}, {
|
|
28
|
+
background: []
|
|
29
|
+
}], [{
|
|
30
|
+
list: 'ordered'
|
|
31
|
+
}, {
|
|
32
|
+
list: 'bullet'
|
|
33
|
+
}], [{
|
|
34
|
+
indent: '-1'
|
|
35
|
+
}, {
|
|
36
|
+
indent: '+1'
|
|
37
|
+
}], [{
|
|
38
|
+
size: ['small', false, 'large', 'huge']
|
|
39
|
+
}], [{
|
|
40
|
+
header: [1, 2, 3, 4, 5, 6, false]
|
|
41
|
+
}], ['link'], ['clean']]
|
|
42
|
+
};
|
|
43
|
+
var _useQuill = useQuill({
|
|
44
|
+
modules: modules
|
|
45
|
+
}),
|
|
46
|
+
quill = _useQuill.quill,
|
|
47
|
+
quillRef = _useQuill.quillRef;
|
|
48
|
+
useEffect(function () {
|
|
49
|
+
if (quill) {
|
|
50
|
+
quill.clipboard.dangerouslyPasteHTML(initialValue);
|
|
51
|
+
var handleTextChange = function handleTextChange() {
|
|
52
|
+
var content = quill.getContents();
|
|
53
|
+
var converter = new QuillDeltaToHtmlConverter(content.ops, {
|
|
54
|
+
inlineStyles: true
|
|
55
|
+
});
|
|
56
|
+
var html = converter.convert();
|
|
57
|
+
onChange(html);
|
|
58
|
+
};
|
|
59
|
+
quill.on('text-change', handleTextChange);
|
|
60
|
+
}
|
|
61
|
+
}, [quill]);
|
|
62
|
+
return /*#__PURE__*/jsx("div", {
|
|
63
|
+
children: /*#__PURE__*/jsx("div", {
|
|
64
|
+
ref: quillRef
|
|
65
|
+
})
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export { RTFEditor as default };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
import 'quill/dist/quill.snow.css';
|
|
4
|
+
interface RTFEditorProps {
|
|
5
|
+
initialValue: string;
|
|
6
|
+
onChange: (val: string) => void;
|
|
7
|
+
}
|
|
8
|
+
declare const RTFEditor: ({ initialValue, onChange }: RTFEditorProps) => JSX.Element;
|
|
9
|
+
export default RTFEditor;
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
11
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAEA,OAAO,2BAA2B,CAAC;AAGnC,UAAU,cAAc;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CACjC;AAED,QAAA,MAAM,SAAS,+BAAgC,cAAc,gBAmC5D,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@crystaldesign/rtf-editor",
|
|
3
|
+
"version": "24.12.0-beta.16",
|
|
4
|
+
"license": "COMMERCIAL",
|
|
5
|
+
"devDependencies": {
|
|
6
|
+
"@testing-library/jest-dom": "^5.15.0",
|
|
7
|
+
"@testing-library/react": "^12.1.2",
|
|
8
|
+
"react": "17.0.2",
|
|
9
|
+
"react-dom": "17.0.2"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"quill": "2.0.2",
|
|
13
|
+
"quill-delta-to-html": "0.12.1",
|
|
14
|
+
"react-quilljs": "2.0.4"
|
|
15
|
+
},
|
|
16
|
+
"peerDependencies": {
|
|
17
|
+
"react": "17.0.2",
|
|
18
|
+
"react-dom": "17.0.2"
|
|
19
|
+
},
|
|
20
|
+
"module": "build/esm/index.js",
|
|
21
|
+
"types": "./build/types/index.d.ts",
|
|
22
|
+
"gitHead": "c4637cc66f8e880e0a9a7f8d58ef21d7a8baf105"
|
|
23
|
+
}
|