@yoopta/headings 1.9.8-rc → 1.9.10-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.d.ts +2 -2
- package/dist/index.js +1 -170
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { HeadingOne } from './ui/HeadingOne';
|
|
2
2
|
import { HeadingTwo } from './ui/HeadingTwo';
|
|
3
3
|
import { HeadingThree } from './ui/HeadingThree';
|
|
4
|
-
import {
|
|
4
|
+
import { YooEditor } from '@yoopta/editor';
|
|
5
5
|
import { HeadingOneElement, HeadingThreeElement, HeadingTwoElement } from './types';
|
|
6
6
|
declare module 'slate' {
|
|
7
7
|
interface CustomTypes {
|
|
8
|
-
Editor:
|
|
8
|
+
Editor: YooEditor;
|
|
9
9
|
Element: HeadingOneElement | HeadingTwoElement | HeadingThreeElement;
|
|
10
10
|
}
|
|
11
11
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,170 +1 @@
|
|
|
1
|
-
import
|
|
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 };
|
|
1
|
+
import{jsx as e}from"react/jsx-runtime";import{createYooptaPlugin as t,generateId as i,getElementClassname as n}from"@yoopta/editor";import{Transforms as a}from"slate";function r(e,t){void 0===t&&(t={});var i=t.insertAt;if(e&&"undefined"!=typeof document){var n=document.head||document.getElementsByTagName("head")[0],a=document.createElement("style");a.type="text/css","top"===i&&n.firstChild?n.insertBefore(a,n.firstChild):n.appendChild(a),a.styleSheet?a.styleSheet.cssText=e:a.appendChild(document.createTextNode(e))}}var o="w88lsSKp";r('.w88lsSKp{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}.w88lsSKp:hover .bxI8aAgg{opacity:1}.bxI8aAgg{align-items:center;color:#007aff;cursor:pointer;display:inline-flex;opacity:0;padding-left:.5rem}.bxI8aAgg:hover{text-decoration:underline}.bxI8aAgg:before{content:"#"}');const d=({attributes:t,children:i,element:a,HTMLAttributes:r})=>e("h1",Object.assign({id:a.id,draggable:!1},r,{className:n({element:a,HTMLAttributes:r,className:o})},t,{children:i}));d.displayName="HeadingOne";const s=t({type:"heading-one",renderer:e=>d,shortcut:["title","h1","heading one","#"],placeholder:"Heading 1",defineElement:()=>({id:i(),type:"heading-one",children:[{text:""}],nodeType:"block"}),createElement:(e,t)=>{var i;const n=Object.assign(Object.assign({},s.getPlugin.defineElement()),t);a.setNodes(e,n,{at:null===(i=e.selection)||void 0===i?void 0:i.anchor})},exports:{markdown:{serialize:(e,t)=>`# ${t}`},html:{serialize:(e,t)=>`<h1>${t}</h1>`,deserialize:{nodeName:"H1"}}},options:{anchor:"#",searchString:"h1 title",displayLabel:"Heading 1"}});var l="Lv0jMMCW";r('.Lv0jMMCW{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}.Lv0jMMCW:hover .Vt-SkjEH{opacity:1}.Vt-SkjEH{color:#007aff;opacity:0;padding-left:.5rem;transition:opacity .2s;user-select:none}.Vt-SkjEH:hover{text-decoration:underline}.Vt-SkjEH:before{content:"#"}');const c=({attributes:t,children:i,element:a,HTMLAttributes:r})=>e("h2",Object.assign({id:a.id,draggable:!1},r,{className:n({element:a,HTMLAttributes:r,className:l})},t,{children:i}));c.displayName="HeadingTwo";const p=t({type:"heading-two",renderer:e=>c,shortcut:["h2","subtitle","##"],placeholder:"Heading 2",defineElement:()=>({id:i(),type:"heading-two",children:[{text:""}],nodeType:"block"}),createElement:(e,t)=>{var i;const n=Object.assign(Object.assign({},p.getPlugin.defineElement()),t);a.setNodes(e,n,{at:null===(i=e.selection)||void 0===i?void 0:i.anchor})},exports:{markdown:{serialize:(e,t)=>`## ${t}`},html:{serialize:(e,t)=>`<h2>${t}</h2>`,deserialize:{nodeName:"H2"}}},options:{anchor:"#",searchString:"h2 subtitle",displayLabel:"Heading 2"}});var h="K-i6DlWD";r('.K-i6DlWD{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}.K-i6DlWD:hover .ur9rRlYI{opacity:1}.ur9rRlYI{color:#007aff;opacity:0;padding-left:.5rem;transition:opacity .2s;user-select:none}.ur9rRlYI:hover{text-decoration:underline}.ur9rRlYI:before{content:"#"}');const g=({attributes:t,children:i,element:a,HTMLAttributes:r})=>e("h3",Object.assign({id:a.id,draggable:!1},r,{className:n({element:a,HTMLAttributes:r,className:h})},t,{children:i}));g.displayName="HeadingThree";const m=t({type:"heading-three",renderer:e=>g,shortcut:["h3","subsubtitle","###"],placeholder:"Heading 3",defineElement:()=>({id:i(),type:"heading-three",children:[{text:""}],nodeType:"block"}),createElement:(e,t)=>{var i;const n=Object.assign(Object.assign({},m.getPlugin.defineElement()),t);a.setNodes(e,n,{at:null===(i=e.selection)||void 0===i?void 0:i.anchor})},exports:{markdown:{serialize:(e,t)=>`### ${t}`},html:{serialize:(e,t)=>`<h3>${t}</h3>`,deserialize:{nodeName:["H3","H4","H5","H6"]}}},options:{anchor:"#",searchString:"h3 subsubtitle small heading",displayLabel:"Heading 3"}}),b={HeadingOne:s,HeadingTwo:p,HeadingThree:m};export{s as HeadingOne,m as HeadingThree,p as HeadingTwo,b as default};
|
package/package.json
CHANGED