@yoopta/callout 1.9.11-rc → 1.9.12-rc
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 +74 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1 +1,74 @@
|
|
|
1
|
-
import{jsx
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { createYooptaPlugin, generateId, getElementClassname } from '@yoopta/editor';
|
|
3
|
+
import { Transforms } from 'slate';
|
|
4
|
+
|
|
5
|
+
function styleInject(css, ref) {
|
|
6
|
+
if ( ref === void 0 ) ref = {};
|
|
7
|
+
var insertAt = ref.insertAt;
|
|
8
|
+
|
|
9
|
+
if (!css || typeof document === 'undefined') { return; }
|
|
10
|
+
|
|
11
|
+
var head = document.head || document.getElementsByTagName('head')[0];
|
|
12
|
+
var style = document.createElement('style');
|
|
13
|
+
style.type = 'text/css';
|
|
14
|
+
|
|
15
|
+
if (insertAt === 'top') {
|
|
16
|
+
if (head.firstChild) {
|
|
17
|
+
head.insertBefore(style, head.firstChild);
|
|
18
|
+
} else {
|
|
19
|
+
head.appendChild(style);
|
|
20
|
+
}
|
|
21
|
+
} else {
|
|
22
|
+
head.appendChild(style);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (style.styleSheet) {
|
|
26
|
+
style.styleSheet.cssText = css;
|
|
27
|
+
} else {
|
|
28
|
+
style.appendChild(document.createTextNode(css));
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
var css_248z = ".Callout-module_callout{background:#f5f7f9;border-radius:5px;color:inherit;font-size:16px;letter-spacing:-.003em;line-height:28px;margin-bottom:4px;margin-left:0;margin-top:4px;padding:12px 14px;position:relative;width:100%}";
|
|
33
|
+
var s = {"callout":"Callout-module_callout"};
|
|
34
|
+
styleInject(css_248z);
|
|
35
|
+
|
|
36
|
+
const CalloutRender = ({ attributes, children, element, HTMLAttributes }) => {
|
|
37
|
+
return (jsx("div", Object.assign({ draggable: false }, HTMLAttributes, { className: getElementClassname({ element, HTMLAttributes, className: s.callout }) }, attributes, { children: children })));
|
|
38
|
+
};
|
|
39
|
+
CalloutRender.displayName = 'Callout';
|
|
40
|
+
const Callout = createYooptaPlugin({
|
|
41
|
+
type: 'callout',
|
|
42
|
+
renderer: (editor) => CalloutRender,
|
|
43
|
+
shortcut: '<',
|
|
44
|
+
defineElement: () => ({
|
|
45
|
+
id: generateId(),
|
|
46
|
+
type: 'callout',
|
|
47
|
+
children: [{ text: '' }],
|
|
48
|
+
nodeType: 'block',
|
|
49
|
+
}),
|
|
50
|
+
createElement: (editor, elementData) => {
|
|
51
|
+
var _a;
|
|
52
|
+
const node = Object.assign(Object.assign({}, Callout.getPlugin.defineElement()), elementData);
|
|
53
|
+
Transforms.setNodes(editor, node, {
|
|
54
|
+
at: (_a = editor.selection) === null || _a === void 0 ? void 0 : _a.anchor,
|
|
55
|
+
});
|
|
56
|
+
},
|
|
57
|
+
exports: {
|
|
58
|
+
markdown: {
|
|
59
|
+
serialize: (node, text) => `> ${text}`,
|
|
60
|
+
},
|
|
61
|
+
html: {
|
|
62
|
+
serialize: (node, children) => `<div style="background: #f5f7f9; border-radius: 5px; color: #292929; padding: 12px 14px">${children}</div>`,
|
|
63
|
+
deserialize: {
|
|
64
|
+
nodeName: 'BLOCKQUOTE',
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
options: {
|
|
69
|
+
searchString: 'callout',
|
|
70
|
+
displayLabel: 'Callout',
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
export { Callout as default };
|
package/package.json
CHANGED