tiptap-essentials 1.2.0 → 2.0.0-beta.1

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/README.md ADDED
@@ -0,0 +1,18 @@
1
+ # tiptap-essentials
2
+
3
+ Tiptap's extensions as one, `TiptapEssentials`, and the nodes they lack.
4
+
5
+ - `npm install`, then `npm run build`, writes `dist/`
6
+ - `npm test` runs the tests
7
+ - `npm run write-samples -- <dir>` writes each sample to `<dir>`, a file
8
+ each, with the version they are from
9
+ - `npm pack` writes the tarball an app tries an unpublished change from,
10
+ each try a prerelease of its own:
11
+ `npm version prerelease --preid beta --no-git-tag-version`, the flag
12
+ keeping `npm version` from committing and tagging
13
+ - A prerelease is the tarball an app passed on, published as it is once its
14
+ version is committed: `npm publish <tarball> --tag beta`. `npm version`
15
+ run again would publish the next number, or stop at the try's uncommitted
16
+ change
17
+ - A release: `npm version major|minor|patch`, then `npm publish`, which
18
+ builds and tests first
@@ -0,0 +1,4 @@
1
+ /** Tiptap's text style, reading a span 1.x sized by its class as styled. */
2
+ export declare const TextStyle: import("@tiptap/core").Mark<import("@tiptap/extension-text-style").TextStyleOptions, any>;
3
+ /** Tiptap's font size, reading 1.x's size classes as the sizes they stood for. */
4
+ export declare const FontSize: import("@tiptap/core").Extension<import("@tiptap/extension-text-style").FontSizeOptions, any>;
@@ -0,0 +1,43 @@
1
+ import { FontSize as TiptapFontSize, TextStyle as TiptapTextStyle } from '@tiptap/extension-text-style';
2
+ // 1.x wrote a size as a span of one of these classes, each standing for one
3
+ // of the site's size properties.
4
+ const CLASS_SIZES = {
5
+ 'tiptap-sm-font': 'var(--sm-font-size)',
6
+ 'tiptap-md-font': 'var(--md-font-size)',
7
+ 'tiptap-lg-font': 'var(--lg-font-size)',
8
+ 'tiptap-xl-font': 'var(--xl-font-size)'
9
+ };
10
+ function classSize(element) {
11
+ const name = Array.from(element.classList).find((name) => name in CLASS_SIZES);
12
+ return name ? CLASS_SIZES[name] : null;
13
+ }
14
+ /** Tiptap's text style, reading a span 1.x sized by its class as styled. */
15
+ export const TextStyle = TiptapTextStyle.extend({
16
+ parseHTML() {
17
+ return [
18
+ ...(this.parent?.() ?? []),
19
+ {
20
+ tag: 'span',
21
+ consuming: false,
22
+ getAttrs: (element) => (classSize(element) ? {} : false)
23
+ }
24
+ ];
25
+ }
26
+ });
27
+ /** Tiptap's font size, reading 1.x's size classes as the sizes they stood for. */
28
+ export const FontSize = TiptapFontSize.extend({
29
+ addGlobalAttributes() {
30
+ return (this.parent?.() ?? []).map(({ types, attributes }) => {
31
+ const { fontSize } = attributes;
32
+ return {
33
+ types,
34
+ attributes: {
35
+ fontSize: {
36
+ ...fontSize,
37
+ parseHTML: (element) => fontSize?.parseHTML?.(element) || classSize(element)
38
+ }
39
+ }
40
+ };
41
+ });
42
+ }
43
+ });
@@ -0,0 +1,33 @@
1
+ /** A format a picture offers its image in, and the widths stored in it. */
2
+ export interface PictureSource {
3
+ type: string;
4
+ srcset: string;
5
+ }
6
+ /** What an image is inserted with. */
7
+ export interface ImageAttributes {
8
+ src: string;
9
+ alt?: string | null;
10
+ title?: string | null;
11
+ width?: number | null;
12
+ height?: number | null;
13
+ srcset?: string | null;
14
+ sizes?: string | null;
15
+ loading?: string | null;
16
+ style?: string | null;
17
+ sources?: PictureSource[];
18
+ }
19
+ declare module '@tiptap/core' {
20
+ interface Commands<ReturnType> {
21
+ responsiveImage: {
22
+ /** Inserts an image with the attributes a responsive one is written with. */
23
+ setImage: (options: ImageAttributes) => ReturnType;
24
+ };
25
+ }
26
+ }
27
+ /**
28
+ * Tiptap's image, taking the attributes a responsive image is written with.
29
+ * Given sources, it is written as a `<picture>`: a `<source>` for each,
30
+ * ahead of the `<img>` a browser drawing none of them is given. Read back,
31
+ * the picture is that image again.
32
+ */
33
+ export declare const Image: import("@tiptap/core").Node<import("@tiptap/extension-image").ImageOptions, any>;
package/dist/image.js ADDED
@@ -0,0 +1,67 @@
1
+ import { mergeAttributes } from '@tiptap/core';
2
+ import TiptapImage from '@tiptap/extension-image';
3
+ /**
4
+ * Tiptap's image, taking the attributes a responsive image is written with.
5
+ * Given sources, it is written as a `<picture>`: a `<source>` for each,
6
+ * ahead of the `<img>` a browser drawing none of them is given. Read back,
7
+ * the picture is that image again.
8
+ */
9
+ export const Image = TiptapImage.extend({
10
+ addAttributes() {
11
+ return {
12
+ ...this.parent?.(),
13
+ srcset: { default: null },
14
+ sizes: { default: null },
15
+ loading: { default: null },
16
+ style: { default: null },
17
+ sources: {
18
+ default: [],
19
+ parseHTML: (element) => sourcesOf(element),
20
+ renderHTML: () => ({})
21
+ }
22
+ };
23
+ },
24
+ parseHTML() {
25
+ return [
26
+ { tag: 'picture', getAttrs: pictureAttributes },
27
+ ...(this.parent?.() ?? [])
28
+ ];
29
+ },
30
+ renderHTML({ node, HTMLAttributes }) {
31
+ const img = [
32
+ 'img',
33
+ mergeAttributes(this.options.HTMLAttributes, HTMLAttributes)
34
+ ];
35
+ const sources = node.attrs['sources'];
36
+ if (sources.length === 0) {
37
+ return img;
38
+ }
39
+ const { sizes } = node.attrs;
40
+ return [
41
+ 'picture',
42
+ {},
43
+ ...sources.map(({ type, srcset }) => [
44
+ 'source',
45
+ { type, srcset, sizes }
46
+ ]),
47
+ img
48
+ ];
49
+ }
50
+ });
51
+ function pictureAttributes(picture) {
52
+ const img = picture.querySelector('img');
53
+ if (!img) {
54
+ return false;
55
+ }
56
+ return Object.fromEntries(Array.from(img.attributes, ({ name, value }) => [name, value]));
57
+ }
58
+ function sourcesOf(element) {
59
+ if (element.tagName !== 'PICTURE') {
60
+ return [];
61
+ }
62
+ return Array.from(element.querySelectorAll('source')).flatMap((source) => {
63
+ const type = source.getAttribute('type');
64
+ const srcset = source.getAttribute('srcset');
65
+ return type && srcset ? [{ type, srcset }] : [];
66
+ });
67
+ }
@@ -0,0 +1,9 @@
1
+ export { TiptapEssentials } from './tiptap-essentials.js';
2
+ export type { TiptapEssentialsOptions } from './tiptap-essentials.js';
3
+ export { FontSize, TextStyle } from './font-size.js';
4
+ export { Image } from './image.js';
5
+ export type { ImageAttributes, PictureSource } from './image.js';
6
+ export { PlainSpaces } from './plain-spaces.js';
7
+ export { Table } from './table.js';
8
+ export type { TableOptions } from './table.js';
9
+ export { Youtube } from './youtube.js';
package/dist/index.js CHANGED
@@ -1,45 +1,6 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "Editor", {
7
- enumerable: true,
8
- get: function get() {
9
- return _editor["default"];
10
- }
11
- });
12
- Object.defineProperty(exports, "Extension", {
13
- enumerable: true,
14
- get: function get() {
15
- return _core.Extension;
16
- }
17
- });
18
- Object.defineProperty(exports, "Mark", {
19
- enumerable: true,
20
- get: function get() {
21
- return _core.Mark;
22
- }
23
- });
24
- Object.defineProperty(exports, "Node", {
25
- enumerable: true,
26
- get: function get() {
27
- return _core.Node;
28
- }
29
- });
30
- Object.defineProperty(exports, "TiptapEssentials", {
31
- enumerable: true,
32
- get: function get() {
33
- return _tiptapEssentials.TiptapEssentials;
34
- }
35
- });
36
- Object.defineProperty(exports, "mergeAttributes", {
37
- enumerable: true,
38
- get: function get() {
39
- return _core.mergeAttributes;
40
- }
41
- });
42
- var _core = require("@tiptap/core");
43
- var _editor = _interopRequireDefault(require("./editor"));
44
- var _tiptapEssentials = require("./tiptap-essentials");
45
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
1
+ export { TiptapEssentials } from './tiptap-essentials.js';
2
+ export { FontSize, TextStyle } from './font-size.js';
3
+ export { Image } from './image.js';
4
+ export { PlainSpaces } from './plain-spaces.js';
5
+ export { Table } from './table.js';
6
+ export { Youtube } from './youtube.js';
@@ -0,0 +1,7 @@
1
+ import { Extension } from '@tiptap/core';
2
+ /**
3
+ * Pasted text with its no-break spaces read as plain ones. A page copied from
4
+ * holds them wherever its layout wanted words kept together, which in a body
5
+ * would stop its lines breaking where the reader's window needs them to.
6
+ */
7
+ export declare const PlainSpaces: Extension<any, any>;
@@ -0,0 +1,35 @@
1
+ import { Extension } from '@tiptap/core';
2
+ import { Fragment, Slice } from '@tiptap/pm/model';
3
+ import { Plugin, PluginKey } from '@tiptap/pm/state';
4
+ const NO_BREAK_SPACE = '\u{a0}';
5
+ /**
6
+ * Pasted text with its no-break spaces read as plain ones. A page copied from
7
+ * holds them wherever its layout wanted words kept together, which in a body
8
+ * would stop its lines breaking where the reader's window needs them to.
9
+ */
10
+ export const PlainSpaces = Extension.create({
11
+ name: 'plainSpaces',
12
+ addProseMirrorPlugins() {
13
+ return [
14
+ new Plugin({
15
+ key: new PluginKey('plainSpaces'),
16
+ props: {
17
+ transformPasted: (slice) => new Slice(plain(slice.content), slice.openStart, slice.openEnd)
18
+ }
19
+ })
20
+ ];
21
+ }
22
+ });
23
+ function plain(fragment) {
24
+ const nodes = [];
25
+ fragment.forEach((node) => {
26
+ if (node.isText) {
27
+ const text = node.text?.replaceAll(NO_BREAK_SPACE, ' ') ?? '';
28
+ nodes.push(node.type.schema.text(text, node.marks));
29
+ }
30
+ else {
31
+ nodes.push(node.copy(plain(node.content)));
32
+ }
33
+ });
34
+ return Fragment.fromArray(nodes);
35
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * The markup the library writes for each feature, as it writes it. Its tests
3
+ * read each back and write it out unchanged; a project storing bodies checks
4
+ * against them that it keeps what the editor writes.
5
+ */
6
+ export declare const picture: string;
7
+ export declare const table: string;
8
+ export declare const video: string;
9
+ export declare const size = "<p><span style=\"font-size: var(--lg-font-size);\">Large</span> text</p>";
@@ -0,0 +1,17 @@
1
+ /**
2
+ * The markup the library writes for each feature, as it writes it. Its tests
3
+ * read each back and write it out unchanged; a project storing bodies checks
4
+ * against them that it keeps what the editor writes.
5
+ */
6
+ export const picture = '<picture><source type="image/jxl" srcset="https://static.example/uploads/store/photo-300.jxl 300w" sizes="auto">' +
7
+ '<img src="https://static.example/uploads/store/photo-1200.jpg" alt="A harbour" title="A harbour" ' +
8
+ 'srcset="https://static.example/uploads/store/photo-300.jpg 300w" sizes="auto" loading="lazy" ' +
9
+ 'style="width: 100%; aspect-ratio: 3 / 2;"></picture>';
10
+ export const table = '<div class="table-responsive" role="region" tabindex="0" aria-label="Table">' +
11
+ '<table class="tiptap-table"><tbody>' +
12
+ '<tr><th><p>Port</p></th><th><p>Ships</p></th></tr>' +
13
+ '<tr><td><p>Chattogram</p></td><td><p>12</p></td></tr>' +
14
+ '</tbody></table></div>';
15
+ export const video = '<div data-youtube-video=""><iframe width="640" height="480" allowfullscreen="true" ' +
16
+ 'src="https://www.youtube.com/embed/M7lc1UVf-VE?start=90&amp;rel=1" title="A talk"></iframe></div>';
17
+ export const size = '<p><span style="font-size: var(--lg-font-size);">Large</span> text</p>';
@@ -0,0 +1,16 @@
1
+ import { type TableOptions as TiptapTableOptions } from '@tiptap/extension-table';
2
+ export interface TableOptions extends TiptapTableOptions {
3
+ /**
4
+ * What a screen reader calls the region a table too wide for the page
5
+ * scrolls in, which a keyboard can then reach. Without one, the table
6
+ * scrolls in a plain box.
7
+ */
8
+ region: string | null;
9
+ }
10
+ /**
11
+ * Tiptap's table, written inside a box it scrolls in when it is too wide for
12
+ * the page, and without the column widths Tiptap gives every table. The
13
+ * editor draws its own copy without the region's tab stop: inside the editable
14
+ * area, one would take the focus from the editor whenever a cell is clicked.
15
+ */
16
+ export declare const Table: import("@tiptap/core").Node<TableOptions, any>;
package/dist/table.js ADDED
@@ -0,0 +1,45 @@
1
+ import { mergeAttributes } from '@tiptap/core';
2
+ import { Table as TiptapTable } from '@tiptap/extension-table';
3
+ /**
4
+ * Tiptap's table, written inside a box it scrolls in when it is too wide for
5
+ * the page, and without the column widths Tiptap gives every table. The
6
+ * editor draws its own copy without the region's tab stop: inside the editable
7
+ * area, one would take the focus from the editor whenever a cell is clicked.
8
+ */
9
+ export const Table = TiptapTable.extend({
10
+ addOptions() {
11
+ return {
12
+ ...this.parent(),
13
+ HTMLAttributes: { class: 'tiptap-table' },
14
+ region: null
15
+ };
16
+ },
17
+ renderHTML({ HTMLAttributes }) {
18
+ const { region } = this.options;
19
+ const box = region
20
+ ? { role: 'region', tabindex: '0', 'aria-label': region }
21
+ : {};
22
+ return [
23
+ 'div',
24
+ { class: 'table-responsive', ...box },
25
+ [
26
+ 'table',
27
+ mergeAttributes(this.options.HTMLAttributes, HTMLAttributes),
28
+ ['tbody', 0]
29
+ ]
30
+ ];
31
+ },
32
+ addNodeView() {
33
+ return ({ HTMLAttributes }) => {
34
+ const dom = document.createElement('div');
35
+ dom.className = 'table-responsive';
36
+ const table = dom.appendChild(document.createElement('table'));
37
+ const attributes = mergeAttributes(this.options.HTMLAttributes, HTMLAttributes);
38
+ for (const [name, value] of Object.entries(attributes)) {
39
+ table.setAttribute(name, String(value));
40
+ }
41
+ const contentDOM = table.appendChild(document.createElement('tbody'));
42
+ return { dom, contentDOM };
43
+ };
44
+ }
45
+ });
@@ -0,0 +1,32 @@
1
+ import { Extension } from '@tiptap/core';
2
+ import type { ImageOptions } from '@tiptap/extension-image';
3
+ import { type SuperscriptExtensionOptions } from '@tiptap/extension-superscript';
4
+ import { type TableKitOptions } from '@tiptap/extension-table';
5
+ import { type TextAlignOptions } from '@tiptap/extension-text-align';
6
+ import { type FontSizeOptions, type TextStyleKitOptions } from '@tiptap/extension-text-style';
7
+ import type { YoutubeOptions } from '@tiptap/extension-youtube';
8
+ import { type StarterKitOptions } from '@tiptap/starter-kit';
9
+ import { type TableOptions } from './table.js';
10
+ type Part<Options> = Partial<Options> | false;
11
+ export interface TiptapEssentialsOptions {
12
+ starterKit: Part<StarterKitOptions>;
13
+ /** TableKit's options, its table being the library's. */
14
+ tableKit: (Partial<Omit<TableKitOptions, 'table'>> & {
15
+ table?: Part<TableOptions>;
16
+ }) | false;
17
+ /** TextStyleKit's options, its font size being the library's. */
18
+ textStyleKit: (Partial<Omit<TextStyleKitOptions, 'fontSize'>> & {
19
+ fontSize?: Part<FontSizeOptions>;
20
+ }) | false;
21
+ textAlign: Part<TextAlignOptions>;
22
+ superscript: Part<SuperscriptExtensionOptions>;
23
+ image: Part<ImageOptions>;
24
+ youtube: Part<YoutubeOptions>;
25
+ plainSpaces: Record<string, never> | false;
26
+ }
27
+ /**
28
+ * Tiptap's kits and the library's own parts as one extension, each part
29
+ * configured, or left out by `false`, through the option of its name.
30
+ */
31
+ export declare const TiptapEssentials: Extension<TiptapEssentialsOptions, any>;
32
+ export {};
@@ -1,223 +1,75 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.TiptapEssentials = void 0;
7
- var _core = require("@tiptap/core");
8
- var _extensionBlockquote = _interopRequireDefault(require("@tiptap/extension-blockquote"));
9
- var _extensionBold = _interopRequireDefault(require("@tiptap/extension-bold"));
10
- var _extensionBulletList = _interopRequireDefault(require("@tiptap/extension-bullet-list"));
11
- var _extensionCode = _interopRequireDefault(require("@tiptap/extension-code"));
12
- var _extensionCodeBlock = _interopRequireDefault(require("@tiptap/extension-code-block"));
13
- var _extensionDocument = _interopRequireDefault(require("@tiptap/extension-document"));
14
- var _extensionDropcursor = _interopRequireDefault(require("@tiptap/extension-dropcursor"));
15
- var _extensionGapcursor = _interopRequireDefault(require("@tiptap/extension-gapcursor"));
16
- var _extensionHardBreak = _interopRequireDefault(require("@tiptap/extension-hard-break"));
17
- var _extensionHeading = _interopRequireDefault(require("@tiptap/extension-heading"));
18
- var _extensionHistory = _interopRequireDefault(require("@tiptap/extension-history"));
19
- var _extensionHorizontalRule = _interopRequireDefault(require("@tiptap/extension-horizontal-rule"));
20
- var _extensionImage = _interopRequireDefault(require("@tiptap/extension-image"));
21
- var _extensionItalic = _interopRequireDefault(require("@tiptap/extension-italic"));
22
- var _extensionLink = _interopRequireDefault(require("@tiptap/extension-link"));
23
- var _extensionListItem = _interopRequireDefault(require("@tiptap/extension-list-item"));
24
- var _extensionOrderedList = _interopRequireDefault(require("@tiptap/extension-ordered-list"));
25
- var _extensionParagraph = _interopRequireDefault(require("@tiptap/extension-paragraph"));
26
- var _extensionStrike = _interopRequireDefault(require("@tiptap/extension-strike"));
27
- var _extensionSuperscript = _interopRequireDefault(require("@tiptap/extension-superscript"));
28
- var _extensionTable = _interopRequireDefault(require("@tiptap/extension-table"));
29
- var _extensionTableCell = _interopRequireDefault(require("@tiptap/extension-table-cell"));
30
- var _extensionTableHeader = _interopRequireDefault(require("@tiptap/extension-table-header"));
31
- var _extensionTableRow = _interopRequireDefault(require("@tiptap/extension-table-row"));
32
- var _extensionText = _interopRequireDefault(require("@tiptap/extension-text"));
33
- var _extensionTextAlign = _interopRequireDefault(require("@tiptap/extension-text-align"));
34
- var _extensionUnderline = _interopRequireDefault(require("@tiptap/extension-underline"));
35
- var _spanWrapper = require("./marks/span-wrapper");
36
- var _iframe = require("./nodes/iframe");
37
- var _youtube = require("./extensions/youtube");
38
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
39
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
40
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
41
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
42
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
43
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
44
- function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
45
- var TiptapEssentials = _core.Extension.create({
46
- name: 'tiptapEssentials',
47
- addOptions: function addOptions() {
48
- var _this$parent;
49
- return _objectSpread(_objectSpread({}, (_this$parent = this.parent) === null || _this$parent === void 0 ? void 0 : _this$parent.call(this)), {}, {
50
- blockquote: true,
51
- bold: true,
52
- bulletList: true,
53
- code: true,
54
- codeBlock: true,
55
- document: true,
56
- dropcursor: true,
57
- gapcursor: true,
58
- hardBreak: true,
59
- heading: true,
60
- history: true,
61
- horizontalRule: true,
62
- iframe: true,
63
- image: true,
64
- italic: true,
65
- link: true,
66
- listItem: true,
67
- orderedList: true,
68
- paragraph: true,
69
- spanWrapper: true,
70
- strike: true,
71
- superscript: true,
72
- table: true,
73
- tableCell: true,
74
- tableHeader: true,
75
- tableRow: true,
76
- text: true,
77
- textAlign: true,
78
- underline: true,
79
- youtube: true
80
- });
81
- },
82
- addExtensions: function addExtensions() {
83
- var extensions = [];
84
- if (this.options.blockquote !== false) {
85
- extensions.push(_extensionBlockquote["default"]);
86
- }
87
- if (this.options.bold !== false) {
88
- extensions.push(_extensionBold["default"]);
89
- }
90
- if (this.options.bulletList !== false) {
91
- extensions.push(_extensionBulletList["default"]);
92
- }
93
- if (this.options.code !== false) {
94
- extensions.push(_extensionCode["default"]);
95
- }
96
- if (this.options.codeBlock !== false) {
97
- extensions.push(_extensionCodeBlock["default"]);
98
- }
99
- if (this.options.document !== false) {
100
- extensions.push(_extensionDocument["default"]);
101
- }
102
- if (this.options.dropcursor !== false) {
103
- extensions.push(_extensionDropcursor["default"]);
104
- }
105
- if (this.options.gapcursor !== false) {
106
- extensions.push(_extensionGapcursor["default"]);
107
- }
108
- if (this.options.hardBreak !== false) {
109
- extensions.push(_extensionHardBreak["default"]);
110
- }
111
- if (this.options.heading !== false) {
112
- extensions.push(_extensionHeading["default"]);
113
- }
114
- if (this.options.history !== false) {
115
- extensions.push(_extensionHistory["default"]);
116
- }
117
- if (this.options.horizontalRule !== false) {
118
- extensions.push(_extensionHorizontalRule["default"]);
119
- }
120
- if (this.options.iframe !== false) {
121
- extensions.push(_iframe.Iframe);
122
- }
123
- if (this.options.image !== false) {
124
- extensions.push(_extensionImage["default"].extend({
125
- addAttributes: function addAttributes() {
126
- return _objectSpread(_objectSpread({}, this.parent()), {}, {
127
- srcset: {
128
- "default": null
129
- },
130
- sizes: {
131
- "default": null
1
+ import { Extension } from '@tiptap/core';
2
+ import Superscript, {} from '@tiptap/extension-superscript';
3
+ import { TableKit } from '@tiptap/extension-table';
4
+ import TextAlign, {} from '@tiptap/extension-text-align';
5
+ import { TextStyle as TiptapTextStyle, TextStyleKit } from '@tiptap/extension-text-style';
6
+ import StarterKit, {} from '@tiptap/starter-kit';
7
+ import { FontSize, TextStyle } from './font-size.js';
8
+ import { Image } from './image.js';
9
+ import { PlainSpaces } from './plain-spaces.js';
10
+ import { Table } from './table.js';
11
+ import { Youtube } from './youtube.js';
12
+ /**
13
+ * Tiptap's kits and the library's own parts as one extension, each part
14
+ * configured, or left out by `false`, through the option of its name.
15
+ */
16
+ export const TiptapEssentials = Extension.create({
17
+ name: 'tiptapEssentials',
18
+ addOptions() {
19
+ return {
20
+ starterKit: {},
21
+ tableKit: {},
22
+ textStyleKit: {},
23
+ textAlign: {
24
+ types: ['heading', 'paragraph'],
25
+ alignments: ['start', 'end', 'left', 'center', 'right', 'justify']
132
26
  },
133
- classNames: {
134
- "default": null
135
- },
136
- style: {
137
- "default": null
138
- },
139
- loading: {
140
- "default": 'lazy'
141
- }
142
- });
27
+ superscript: {},
28
+ image: {},
29
+ youtube: {},
30
+ plainSpaces: {}
31
+ };
32
+ },
33
+ addExtensions() {
34
+ const { starterKit, tableKit, textStyleKit, textAlign, superscript, image, youtube, plainSpaces } = this.options;
35
+ const extensions = [];
36
+ if (starterKit !== false) {
37
+ extensions.push(StarterKit.configure(starterKit));
143
38
  }
144
- }));
145
- }
146
- if (this.options.italic !== false) {
147
- extensions.push(_extensionItalic["default"]);
148
- }
149
- if (this.options.link !== false) {
150
- extensions.push(_extensionLink["default"].extend({
151
- addAttributes: function addAttributes() {
152
- return _objectSpread(_objectSpread({}, this.parent()), {}, {
153
- title: {
154
- "default": null
39
+ if (tableKit !== false) {
40
+ const { table = {}, ...rest } = tableKit;
41
+ extensions.push(TableKit.configure({ ...rest, table: false }));
42
+ if (table !== false) {
43
+ extensions.push(Table.configure(table));
155
44
  }
156
- });
157
45
  }
158
- }));
159
- }
160
- if (this.options.listItem !== false) {
161
- extensions.push(_extensionListItem["default"]);
162
- }
163
- if (this.options.orderedList !== false) {
164
- extensions.push(_extensionOrderedList["default"]);
165
- }
166
- if (this.options.paragraph !== false) {
167
- extensions.push(_extensionParagraph["default"]);
168
- }
169
- if (this.options.spanWrapper !== false) {
170
- extensions.push(_spanWrapper.SpanWrapper);
171
- }
172
- if (this.options.strike !== false) {
173
- extensions.push(_extensionStrike["default"]);
174
- }
175
- if (this.options.superscript !== false) {
176
- extensions.push(_extensionSuperscript["default"]);
177
- }
178
- if (this.options.table !== false) {
179
- extensions.push(_extensionTable["default"].extend({
180
- renderHTML: function renderHTML(_ref) {
181
- var HTMLAttributes = _ref.HTMLAttributes;
182
- return ['div', {
183
- "class": 'table-responsive'
184
- }, ['table', HTMLAttributes, ['tbody', 0]]];
185
- },
186
- addAttributes: function addAttributes() {
187
- var _this$parent2;
188
- return _objectSpread(_objectSpread({}, (_this$parent2 = this.parent) === null || _this$parent2 === void 0 ? void 0 : _this$parent2.call(this)), {}, {
189
- "class": {
190
- "default": 'tiptap-table'
46
+ if (textStyleKit !== false) {
47
+ const { fontSize = {}, textStyle = {}, ...rest } = textStyleKit;
48
+ extensions.push(TextStyleKit.configure({ ...rest, fontSize: false, textStyle: false }));
49
+ if (textStyle !== false) {
50
+ // A span 1.x sized is read as styled only where its size is kept.
51
+ const style = fontSize === false ? TiptapTextStyle : TextStyle;
52
+ extensions.push(style.configure(textStyle));
53
+ }
54
+ if (fontSize !== false) {
55
+ extensions.push(FontSize.configure(fontSize));
191
56
  }
192
- });
193
57
  }
194
- }));
195
- }
196
- if (this.options.tableCell !== false) {
197
- extensions.push(_extensionTableCell["default"]);
198
- }
199
- if (this.options.tableHeader !== false) {
200
- extensions.push(_extensionTableHeader["default"]);
201
- }
202
- if (this.options.tableRow !== false) {
203
- extensions.push(_extensionTableRow["default"]);
204
- }
205
- if (this.options.text !== false) {
206
- extensions.push(_extensionText["default"]);
207
- }
208
- if (this.options.textAlign !== false) {
209
- extensions.push(_extensionTextAlign["default"].configure({
210
- types: ['heading', 'paragraph'],
211
- alignments: ['start', 'end', 'left', 'center', 'right', 'justify']
212
- }));
213
- }
214
- if (this.options.underline !== false) {
215
- extensions.push(_extensionUnderline["default"]);
216
- }
217
- if (this.options.youtube !== false) {
218
- extensions.push(_youtube.Youtube);
58
+ if (textAlign !== false) {
59
+ extensions.push(TextAlign.configure(textAlign));
60
+ }
61
+ if (superscript !== false) {
62
+ extensions.push(Superscript.configure(superscript));
63
+ }
64
+ if (image !== false) {
65
+ extensions.push(Image.configure(image));
66
+ }
67
+ if (youtube !== false) {
68
+ extensions.push(Youtube.configure(youtube));
69
+ }
70
+ if (plainSpaces !== false) {
71
+ extensions.push(PlainSpaces);
72
+ }
73
+ return extensions;
219
74
  }
220
- return extensions;
221
- }
222
75
  });
223
- exports.TiptapEssentials = TiptapEssentials;
@@ -0,0 +1,21 @@
1
+ declare module '@tiptap/core' {
2
+ interface Commands<ReturnType> {
3
+ titledYoutube: {
4
+ /** Inserts a video, named by its title. */
5
+ setYoutubeVideo: (options: {
6
+ src: string;
7
+ title: string;
8
+ start?: number;
9
+ width?: number | string;
10
+ height?: number | string;
11
+ }) => ReturnType;
12
+ };
13
+ }
14
+ }
15
+ /**
16
+ * Tiptap's YouTube video, named by a title, which a page names its thumbnail
17
+ * and its player by. The editor draws it as its thumbnail: drawing the player
18
+ * would load YouTube's for every video as the editor opens. Read as well from
19
+ * the frame 1.x wrote, a bare `<iframe>` of a YouTube address.
20
+ */
21
+ export declare const Youtube: import("@tiptap/core").Node<import("@tiptap/extension-youtube").YoutubeOptions, any>;
@@ -0,0 +1,50 @@
1
+ import TiptapYoutube from '@tiptap/extension-youtube';
2
+ // What a body keeps of a video's frame: Tiptap writes a dozen more, each of
3
+ // them in its address as well.
4
+ const KEPT = ['src', 'title', 'width', 'height', 'allowfullscreen'];
5
+ const VIDEO_ID = /(?:[?&]v=|\/embed\/|youtu\.be\/|\/shorts\/|\/live\/)([\w-]{11})/;
6
+ /**
7
+ * Tiptap's YouTube video, named by a title, which a page names its thumbnail
8
+ * and its player by. The editor draws it as its thumbnail: drawing the player
9
+ * would load YouTube's for every video as the editor opens. Read as well from
10
+ * the frame 1.x wrote, a bare `<iframe>` of a YouTube address.
11
+ */
12
+ export const Youtube = TiptapYoutube.extend({
13
+ addAttributes() {
14
+ return {
15
+ ...this.parent?.(),
16
+ title: { default: null }
17
+ };
18
+ },
19
+ parseHTML() {
20
+ return [
21
+ ...(this.parent?.() ?? []),
22
+ {
23
+ tag: 'iframe[src]',
24
+ getAttrs: (element) => element
25
+ .getAttribute('src')
26
+ ?.startsWith('https://www.youtube.com/embed/')
27
+ ? null
28
+ : false
29
+ }
30
+ ];
31
+ },
32
+ renderHTML(props) {
33
+ const [tag, box, [, frame]] = this.parent(props);
34
+ const kept = Object.fromEntries(Object.entries(frame).filter(([name]) => KEPT.includes(name)));
35
+ return [tag, box, ['iframe', kept]];
36
+ },
37
+ addNodeView() {
38
+ return ({ node }) => {
39
+ const dom = document.createElement('div');
40
+ dom.setAttribute('data-youtube-video', '');
41
+ const thumbnail = dom.appendChild(document.createElement('img'));
42
+ const id = VIDEO_ID.exec(String(node.attrs['src'] ?? ''))?.[1];
43
+ if (id) {
44
+ thumbnail.setAttribute('src', `https://i.ytimg.com/vi/${id}/hqdefault.jpg`);
45
+ }
46
+ thumbnail.setAttribute('alt', String(node.attrs['title'] ?? ''));
47
+ return { dom };
48
+ };
49
+ }
50
+ });
package/package.json CHANGED
@@ -1,52 +1,53 @@
1
1
  {
2
2
  "name": "tiptap-essentials",
3
- "version": "1.2.0",
3
+ "version": "2.0.0-beta.1",
4
4
  "description": "Essential extensions of Tiptap",
5
- "main": "index.js",
5
+ "type": "module",
6
+ "exports": {
7
+ ".": {
8
+ "types": "./dist/index.d.ts",
9
+ "default": "./dist/index.js"
10
+ },
11
+ "./samples": {
12
+ "types": "./dist/samples.d.ts",
13
+ "default": "./dist/samples.js"
14
+ }
15
+ },
16
+ "types": "./dist/index.d.ts",
17
+ "files": [
18
+ "dist"
19
+ ],
6
20
  "scripts": {
7
- "build": "babel src -d dist",
8
- "prepublish": "npm run build"
21
+ "build": "rm -rf dist && tsc",
22
+ "test": "vitest run",
23
+ "prepack": "npm run build",
24
+ "prepublishOnly": "npm test",
25
+ "write-samples": "npm run build && node scripts/write-samples.mjs"
9
26
  },
10
27
  "repository": {
11
28
  "type": "git",
12
29
  "url": "git://github.com/musaffa/tiptap-essentials.git"
13
30
  },
31
+ "peerDependencies": {
32
+ "@tiptap/core": "^3.35.0",
33
+ "@tiptap/pm": "^3.35.0"
34
+ },
14
35
  "dependencies": {
15
- "@tiptap/core": "^2.11.9",
16
- "@tiptap/pm": "^2.11.9",
17
- "@tiptap/extension-blockquote": "^2.11.9",
18
- "@tiptap/extension-bold": "^2.11.9",
19
- "@tiptap/extension-bullet-list": "^2.11.9",
20
- "@tiptap/extension-code": "^2.11.9",
21
- "@tiptap/extension-code-block": "^2.11.9",
22
- "@tiptap/extension-document": "^2.11.9",
23
- "@tiptap/extension-dropcursor": "^2.11.9",
24
- "@tiptap/extension-gapcursor": "^2.11.9",
25
- "@tiptap/extension-hard-break": "^2.11.9",
26
- "@tiptap/extension-heading": "^2.11.9",
27
- "@tiptap/extension-history": "^2.11.9",
28
- "@tiptap/extension-horizontal-rule": "^2.11.9",
29
- "@tiptap/extension-image": "^2.11.9",
30
- "@tiptap/extension-italic": "^2.11.9",
31
- "@tiptap/extension-link": "^2.11.9",
32
- "@tiptap/extension-list-item": "^2.11.9",
33
- "@tiptap/extension-ordered-list": "^2.11.9",
34
- "@tiptap/extension-paragraph": "^2.11.9",
35
- "@tiptap/extension-strike": "^2.11.9",
36
- "@tiptap/extension-superscript": "^2.11.9",
37
- "@tiptap/extension-table": "^2.11.9",
38
- "@tiptap/extension-table-cell": "^2.11.9",
39
- "@tiptap/extension-table-header": "^2.11.9",
40
- "@tiptap/extension-table-row": "^2.11.9",
41
- "@tiptap/extension-text": "^2.11.9",
42
- "@tiptap/extension-text-align": "^2.11.9",
43
- "@tiptap/extension-underline": "^2.11.9"
36
+ "@tiptap/extension-image": "^3.35.0",
37
+ "@tiptap/extension-superscript": "^3.35.0",
38
+ "@tiptap/extension-table": "^3.35.0",
39
+ "@tiptap/extension-text-align": "^3.35.0",
40
+ "@tiptap/extension-text-style": "^3.35.0",
41
+ "@tiptap/extension-youtube": "^3.35.0",
42
+ "@tiptap/starter-kit": "^3.35.0"
44
43
  },
45
- "author": "Ahmad Musaffa",
46
- "license": "MIT",
47
44
  "devDependencies": {
48
- "@babel/cli": "^7.16.0",
49
- "@babel/core": "^7.16.0",
50
- "@babel/preset-env": "^7.16.0"
51
- }
45
+ "@tiptap/core": "3.35.0",
46
+ "@tiptap/pm": "3.35.0",
47
+ "happy-dom": "^21.0.4",
48
+ "typescript": "^6.0.3",
49
+ "vitest": "^5.1.1"
50
+ },
51
+ "author": "Ahmad Musaffa",
52
+ "license": "MIT"
52
53
  }
package/dist/editor.js DELETED
@@ -1,42 +0,0 @@
1
- "use strict";
2
-
3
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports["default"] = void 0;
8
- var _core = require("@tiptap/core");
9
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
10
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
11
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
12
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
13
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
14
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
15
- function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
16
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
17
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
18
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
19
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
20
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
21
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
22
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
23
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
24
- var CustomEditor = /*#__PURE__*/function (_Editor) {
25
- _inherits(CustomEditor, _Editor);
26
- var _super = _createSuper(CustomEditor);
27
- function CustomEditor(args) {
28
- _classCallCheck(this, CustomEditor);
29
- return _super.call(this, _objectSpread({
30
- editorProps: {
31
- transformPastedText: function transformPastedText(text) {
32
- return text.replace(/\xA0/g, ' ');
33
- },
34
- transformPastedHTML: function transformPastedHTML(html) {
35
- return html.replace(/\xA0/g, ' ');
36
- }
37
- }
38
- }, args));
39
- }
40
- return _createClass(CustomEditor);
41
- }(_core.Editor);
42
- exports["default"] = CustomEditor;
@@ -1,36 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.Youtube = void 0;
7
- var _core = require("@tiptap/core");
8
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
9
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
10
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
11
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
12
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
13
- function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
14
- var Youtube = _core.Extension.create({
15
- name: 'youtube',
16
- addCommands: function addCommands() {
17
- return {
18
- setYoutubeLink: function setYoutubeLink(attrs) {
19
- return function (_ref) {
20
- var commands = _ref.commands;
21
- var cAttrs = {
22
- src: attrs.src.replace('watch?v=', 'embed/'),
23
- style: 'width: 100%; aspect-ratio: 1200 / 660; border: 0;',
24
- allow: 'autoplay',
25
- allowfullscreen: 'true'
26
- };
27
- return commands.insertContent({
28
- type: 'iframe',
29
- attrs: _objectSpread(_objectSpread({}, attrs), cAttrs)
30
- });
31
- };
32
- }
33
- };
34
- }
35
- });
36
- exports.Youtube = Youtube;
@@ -1,27 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.SpanWrapper = void 0;
7
- var _core = require("@tiptap/core");
8
- var SpanWrapper = _core.Mark.create({
9
- name: 'spanWrapper',
10
- addAttributes: function addAttributes() {
11
- return {
12
- "class": {
13
- "default": null
14
- }
15
- };
16
- },
17
- parseHTML: function parseHTML() {
18
- return [{
19
- tag: 'span'
20
- }];
21
- },
22
- renderHTML: function renderHTML(_ref) {
23
- var HTMLAttributes = _ref.HTMLAttributes;
24
- return ['span', (0, _core.mergeAttributes)(this.options.HTMLAttributes, HTMLAttributes), 0];
25
- }
26
- });
27
- exports.SpanWrapper = SpanWrapper;
@@ -1,48 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.Iframe = void 0;
7
- var _core = require("@tiptap/core");
8
- var Iframe = _core.Node.create({
9
- name: 'iframe',
10
- group: 'inline',
11
- inline: true,
12
- draggable: true,
13
- addOptions: function addOptions() {
14
- return {
15
- HTMLAttributes: {}
16
- };
17
- },
18
- addAttributes: function addAttributes() {
19
- return {
20
- src: {},
21
- title: {
22
- "default": null
23
- },
24
- style: {
25
- "default": null
26
- },
27
- loading: {
28
- "default": 'lazy'
29
- },
30
- allow: {
31
- "default": null
32
- },
33
- allowfullscreen: {
34
- "default": 'false'
35
- }
36
- };
37
- },
38
- parseHTML: function parseHTML() {
39
- return [{
40
- tag: 'iframe[src]'
41
- }];
42
- },
43
- renderHTML: function renderHTML(_ref) {
44
- var HTMLAttributes = _ref.HTMLAttributes;
45
- return ['iframe', (0, _core.mergeAttributes)(this.options.HTMLAttributes, HTMLAttributes)];
46
- }
47
- });
48
- exports.Iframe = Iframe;
package/index.js DELETED
@@ -1 +0,0 @@
1
- module.exports = require("./dist");