@yoopta/headings 1.9.10-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 +170 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1 +1,170 @@
|
|
|
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$2 = ".HeadingOne-module_heading-one{color:inherit;font-size:30px;font-weight:600;letter-spacing:0;line-height:39px;margin-bottom:1px;margin-top:30px;padding-bottom:2px;padding-top:2px;position:relative;white-space:pre-wrap;word-break:break-word}.HeadingOne-module_heading-one:hover .HeadingOne-module_hashLink{opacity:1}.HeadingOne-module_hashLink{align-items:center;color:#007aff;cursor:pointer;display:inline-flex;opacity:0;padding-left:.5rem}.HeadingOne-module_hashLink:hover{text-decoration:underline}.HeadingOne-module_hashLink:before{content:\"#\"}";
|
|
33
|
+
var s$2 = {"heading-one":"HeadingOne-module_heading-one","hashLink":"HeadingOne-module_hashLink"};
|
|
34
|
+
styleInject(css_248z$2);
|
|
35
|
+
|
|
36
|
+
const HeadingOneRender = ({ attributes, children, element, HTMLAttributes, }) => {
|
|
37
|
+
return (jsx("h1", Object.assign({ id: element.id, draggable: false }, HTMLAttributes, { className: getElementClassname({ element, HTMLAttributes, className: s$2['heading-one'] }) }, attributes, { children: children })));
|
|
38
|
+
};
|
|
39
|
+
HeadingOneRender.displayName = 'HeadingOne';
|
|
40
|
+
const HeadingOne = createYooptaPlugin({
|
|
41
|
+
type: 'heading-one',
|
|
42
|
+
renderer: (editor) => HeadingOneRender,
|
|
43
|
+
shortcut: ['title', 'h1', 'heading one', '#'],
|
|
44
|
+
placeholder: 'Heading 1',
|
|
45
|
+
defineElement: () => ({
|
|
46
|
+
id: generateId(),
|
|
47
|
+
type: 'heading-one',
|
|
48
|
+
children: [{ text: '' }],
|
|
49
|
+
nodeType: 'block',
|
|
50
|
+
}),
|
|
51
|
+
createElement: (editor, elementData) => {
|
|
52
|
+
var _a;
|
|
53
|
+
const node = Object.assign(Object.assign({}, HeadingOne.getPlugin.defineElement()), elementData);
|
|
54
|
+
Transforms.setNodes(editor, node, {
|
|
55
|
+
at: (_a = editor.selection) === null || _a === void 0 ? void 0 : _a.anchor,
|
|
56
|
+
});
|
|
57
|
+
},
|
|
58
|
+
exports: {
|
|
59
|
+
markdown: {
|
|
60
|
+
serialize: (node, text) => `# ${text}`,
|
|
61
|
+
},
|
|
62
|
+
html: {
|
|
63
|
+
serialize: (node, children) => `<h1>${children}</h1>`,
|
|
64
|
+
deserialize: {
|
|
65
|
+
nodeName: 'H1',
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
options: {
|
|
70
|
+
anchor: '#',
|
|
71
|
+
searchString: 'h1 title',
|
|
72
|
+
displayLabel: 'Heading 1',
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
var css_248z$1 = ".HeadingTwo-module_heading-two{color:inherit;font-size:24px;font-weight:600;line-height:31px;margin-bottom:4px;margin-top:20px;padding-bottom:2px;padding-top:2px;position:relative;white-space:pre-wrap;word-break:break-word}.HeadingTwo-module_heading-two:hover .HeadingTwo-module_hashLink{opacity:1}.HeadingTwo-module_hashLink{color:#007aff;opacity:0;padding-left:.5rem;transition:opacity .2s;user-select:none}.HeadingTwo-module_hashLink:hover{text-decoration:underline}.HeadingTwo-module_hashLink:before{content:\"#\"}";
|
|
77
|
+
var s$1 = {"heading-two":"HeadingTwo-module_heading-two","hashLink":"HeadingTwo-module_hashLink"};
|
|
78
|
+
styleInject(css_248z$1);
|
|
79
|
+
|
|
80
|
+
const HeadingTwoRender = ({ attributes, children, element, HTMLAttributes, }) => {
|
|
81
|
+
return (jsx("h2", Object.assign({ id: element.id, draggable: false }, HTMLAttributes, { className: getElementClassname({ element, HTMLAttributes, className: s$1['heading-two'] }) }, attributes, { children: children })));
|
|
82
|
+
};
|
|
83
|
+
HeadingTwoRender.displayName = 'HeadingTwo';
|
|
84
|
+
const HeadingTwo = createYooptaPlugin({
|
|
85
|
+
type: 'heading-two',
|
|
86
|
+
renderer: (editor) => HeadingTwoRender,
|
|
87
|
+
shortcut: ['h2', 'subtitle', '##'],
|
|
88
|
+
placeholder: 'Heading 2',
|
|
89
|
+
defineElement: () => ({
|
|
90
|
+
id: generateId(),
|
|
91
|
+
type: 'heading-two',
|
|
92
|
+
children: [{ text: '' }],
|
|
93
|
+
nodeType: 'block',
|
|
94
|
+
}),
|
|
95
|
+
createElement: (editor, elementData) => {
|
|
96
|
+
var _a;
|
|
97
|
+
const node = Object.assign(Object.assign({}, HeadingTwo.getPlugin.defineElement()), elementData);
|
|
98
|
+
Transforms.setNodes(editor, node, {
|
|
99
|
+
at: (_a = editor.selection) === null || _a === void 0 ? void 0 : _a.anchor,
|
|
100
|
+
});
|
|
101
|
+
},
|
|
102
|
+
exports: {
|
|
103
|
+
markdown: {
|
|
104
|
+
serialize: (node, text) => `## ${text}`,
|
|
105
|
+
},
|
|
106
|
+
html: {
|
|
107
|
+
serialize: (node, children) => `<h2>${children}</h2>`,
|
|
108
|
+
deserialize: {
|
|
109
|
+
nodeName: 'H2',
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
options: {
|
|
114
|
+
anchor: '#',
|
|
115
|
+
searchString: 'h2 subtitle',
|
|
116
|
+
displayLabel: 'Heading 2',
|
|
117
|
+
},
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
var css_248z = ".HeadingThree-module_heading-three{color:inherit;font-size:20px;font-weight:600;line-height:26px;margin-bottom:4px;margin-top:16px;padding-bottom:2px;padding-top:2px;position:relative;white-space:pre-wrap;word-break:break-word}.HeadingThree-module_heading-three:hover .HeadingThree-module_hashLink{opacity:1}.HeadingThree-module_hashLink{color:#007aff;opacity:0;padding-left:.5rem;transition:opacity .2s;user-select:none}.HeadingThree-module_hashLink:hover{text-decoration:underline}.HeadingThree-module_hashLink:before{content:\"#\"}";
|
|
121
|
+
var s = {"heading-three":"HeadingThree-module_heading-three","hashLink":"HeadingThree-module_hashLink"};
|
|
122
|
+
styleInject(css_248z);
|
|
123
|
+
|
|
124
|
+
const HeadingThreeRender = ({ attributes, children, element, HTMLAttributes, }) => {
|
|
125
|
+
return (jsx("h3", Object.assign({ id: element.id, draggable: false }, HTMLAttributes, { className: getElementClassname({ element, HTMLAttributes, className: s['heading-three'] }) }, attributes, { children: children })));
|
|
126
|
+
};
|
|
127
|
+
HeadingThreeRender.displayName = 'HeadingThree';
|
|
128
|
+
const HeadingThree = createYooptaPlugin({
|
|
129
|
+
type: 'heading-three',
|
|
130
|
+
renderer: (editor) => HeadingThreeRender,
|
|
131
|
+
shortcut: ['h3', 'subsubtitle', '###'],
|
|
132
|
+
placeholder: 'Heading 3',
|
|
133
|
+
defineElement: () => ({
|
|
134
|
+
id: generateId(),
|
|
135
|
+
type: 'heading-three',
|
|
136
|
+
children: [{ text: '' }],
|
|
137
|
+
nodeType: 'block',
|
|
138
|
+
}),
|
|
139
|
+
createElement: (editor, elementData) => {
|
|
140
|
+
var _a;
|
|
141
|
+
const node = Object.assign(Object.assign({}, HeadingThree.getPlugin.defineElement()), elementData);
|
|
142
|
+
Transforms.setNodes(editor, node, {
|
|
143
|
+
at: (_a = editor.selection) === null || _a === void 0 ? void 0 : _a.anchor,
|
|
144
|
+
});
|
|
145
|
+
},
|
|
146
|
+
exports: {
|
|
147
|
+
markdown: {
|
|
148
|
+
serialize: (node, text) => `### ${text}`,
|
|
149
|
+
},
|
|
150
|
+
html: {
|
|
151
|
+
serialize: (node, children) => `<h3>${children}</h3>`,
|
|
152
|
+
deserialize: {
|
|
153
|
+
nodeName: ['H3', 'H4', 'H5', 'H6'],
|
|
154
|
+
},
|
|
155
|
+
},
|
|
156
|
+
},
|
|
157
|
+
options: {
|
|
158
|
+
anchor: '#',
|
|
159
|
+
searchString: 'h3 subsubtitle small heading',
|
|
160
|
+
displayLabel: 'Heading 3',
|
|
161
|
+
},
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
const Headings = {
|
|
165
|
+
HeadingOne,
|
|
166
|
+
HeadingTwo,
|
|
167
|
+
HeadingThree,
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
export { HeadingOne, HeadingThree, HeadingTwo, Headings as default };
|
package/package.json
CHANGED