tiptap-essentials 2.0.0-beta.1 → 2.0.0-beta.3

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.
@@ -0,0 +1,28 @@
1
+ import { Extension } from '@tiptap/core';
2
+ export interface BlockSpacingOptions {
3
+ /** The blocks that can be spaced apart from those around them. */
4
+ types: string[];
5
+ /**
6
+ * The margin space before or after a block takes, as a body writes it:
7
+ * `var(--space-40)`. No space is read or set where null.
8
+ */
9
+ space: string | null;
10
+ }
11
+ declare module '@tiptap/core' {
12
+ interface Commands<ReturnType> {
13
+ blockSpacing: {
14
+ /** Sets every block selected apart from the one before it. */
15
+ addSpaceBefore: () => ReturnType;
16
+ removeSpaceBefore: () => ReturnType;
17
+ /** Sets every block selected apart from the one after it. */
18
+ addSpaceAfter: () => ReturnType;
19
+ removeSpaceAfter: () => ReturnType;
20
+ };
21
+ }
22
+ }
23
+ /**
24
+ * Space before and after a block, as a word processor adds it: one more
25
+ * margin above or below a paragraph or a heading, the one its `space` names.
26
+ * A margin pasted in of any other size is read as none.
27
+ */
28
+ export declare const BlockSpacing: Extension<BlockSpacingOptions, any>;
@@ -0,0 +1,52 @@
1
+ import { Extension, getStyleProperty } from '@tiptap/core';
2
+ const MARGINS = {
3
+ spaceBefore: 'margin-top',
4
+ spaceAfter: 'margin-bottom'
5
+ };
6
+ /**
7
+ * Space before and after a block, as a word processor adds it: one more
8
+ * margin above or below a paragraph or a heading, the one its `space` names.
9
+ * A margin pasted in of any other size is read as none.
10
+ */
11
+ export const BlockSpacing = Extension.create({
12
+ name: 'blockSpacing',
13
+ addOptions() {
14
+ return {
15
+ types: ['paragraph', 'heading'],
16
+ space: null
17
+ };
18
+ },
19
+ addGlobalAttributes() {
20
+ const { types, space } = this.options;
21
+ const attribute = (side) => ({
22
+ default: null,
23
+ parseHTML: (element) => space !== null && getStyleProperty(element, MARGINS[side]) === space
24
+ ? space
25
+ : null,
26
+ renderHTML: (attributes) => attributes[side]
27
+ ? { style: `${MARGINS[side]}: ${attributes[side]}` }
28
+ : {}
29
+ });
30
+ return [
31
+ {
32
+ types,
33
+ attributes: {
34
+ spaceBefore: attribute('spaceBefore'),
35
+ spaceAfter: attribute('spaceAfter')
36
+ }
37
+ }
38
+ ];
39
+ },
40
+ addCommands() {
41
+ const set = (side, value) => () => ({ commands }) => this.options.space !== null &&
42
+ this.options.types
43
+ .map((type) => commands.updateAttributes(type, { [side]: value }))
44
+ .some((response) => response);
45
+ return {
46
+ addSpaceBefore: set('spaceBefore', this.options.space),
47
+ removeSpaceBefore: set('spaceBefore', null),
48
+ addSpaceAfter: set('spaceAfter', this.options.space),
49
+ removeSpaceAfter: set('spaceAfter', null)
50
+ };
51
+ }
52
+ });
@@ -0,0 +1,13 @@
1
+ import { type ColorOptions as TiptapColorOptions } from '@tiptap/extension-text-style';
2
+ export interface ColorOptions extends TiptapColorOptions {
3
+ /**
4
+ * The colours a text may take, as a body writes them:
5
+ * `var(--tiptap-text-red)`. Any colour where null.
6
+ */
7
+ colors: string[] | null;
8
+ }
9
+ /**
10
+ * Tiptap's text colour, held to a palette: a colour pasted in that is not one
11
+ * of it is read as none, and none is set.
12
+ */
13
+ export declare const Color: import("@tiptap/core").Extension<ColorOptions, any>;
package/dist/color.js ADDED
@@ -0,0 +1,37 @@
1
+ import { Color as TiptapColor } from '@tiptap/extension-text-style';
2
+ import { ifListed } from './listed.js';
3
+ /**
4
+ * Tiptap's text colour, held to a palette: a colour pasted in that is not one
5
+ * of it is read as none, and none is set.
6
+ */
7
+ export const Color = TiptapColor.extend({
8
+ addOptions() {
9
+ return {
10
+ ...this.parent(),
11
+ colors: null
12
+ };
13
+ },
14
+ addGlobalAttributes() {
15
+ const { colors } = this.options;
16
+ return (this.parent?.() ?? []).map(({ types, attributes }) => {
17
+ const { color } = attributes;
18
+ return {
19
+ types,
20
+ attributes: {
21
+ color: {
22
+ ...color,
23
+ parseHTML: (element) => ifListed(color?.parseHTML?.(element), colors)
24
+ }
25
+ }
26
+ };
27
+ });
28
+ },
29
+ addCommands() {
30
+ const commands = this.parent();
31
+ return {
32
+ ...commands,
33
+ setColor: (color) => (props) => ifListed(color, this.options.colors) !== null &&
34
+ commands.setColor(color)(props)
35
+ };
36
+ }
37
+ });
@@ -1,4 +1,14 @@
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>;
1
+ import { type FontSizeOptions as TiptapFontSizeOptions } from '@tiptap/extension-text-style';
2
+ export interface FontSizeOptions extends TiptapFontSizeOptions {
3
+ /**
4
+ * The sizes a text may take, as a body writes them: `var(--lg-font-size)`.
5
+ * Any where null.
6
+ */
7
+ fontSizes: string[] | null;
8
+ }
9
+ /**
10
+ * Tiptap's font size, held to a set of sizes, and reading 1.x's size classes
11
+ * as the sizes they stood for: a size pasted in that is not one of the set is
12
+ * read as none, and none is set.
13
+ */
14
+ export declare const FontSize: import("@tiptap/core").Extension<FontSizeOptions, any>;
package/dist/font-size.js CHANGED
@@ -1,4 +1,5 @@
1
- import { FontSize as TiptapFontSize, TextStyle as TiptapTextStyle } from '@tiptap/extension-text-style';
1
+ import { FontSize as TiptapFontSize } from '@tiptap/extension-text-style';
2
+ import { ifListed } from './listed.js';
2
3
  // 1.x wrote a size as a span of one of these classes, each standing for one
3
4
  // of the site's size properties.
4
5
  const CLASS_SIZES = {
@@ -11,22 +12,20 @@ function classSize(element) {
11
12
  const name = Array.from(element.classList).find((name) => name in CLASS_SIZES);
12
13
  return name ? CLASS_SIZES[name] : null;
13
14
  }
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. */
15
+ /**
16
+ * Tiptap's font size, held to a set of sizes, and reading 1.x's size classes
17
+ * as the sizes they stood for: a size pasted in that is not one of the set is
18
+ * read as none, and none is set.
19
+ */
28
20
  export const FontSize = TiptapFontSize.extend({
21
+ addOptions() {
22
+ return {
23
+ ...this.parent(),
24
+ fontSizes: null
25
+ };
26
+ },
29
27
  addGlobalAttributes() {
28
+ const { fontSizes } = this.options;
30
29
  return (this.parent?.() ?? []).map(({ types, attributes }) => {
31
30
  const { fontSize } = attributes;
32
31
  return {
@@ -34,10 +33,18 @@ export const FontSize = TiptapFontSize.extend({
34
33
  attributes: {
35
34
  fontSize: {
36
35
  ...fontSize,
37
- parseHTML: (element) => fontSize?.parseHTML?.(element) || classSize(element)
36
+ parseHTML: (element) => ifListed(fontSize?.parseHTML?.(element) || classSize(element), fontSizes)
38
37
  }
39
38
  }
40
39
  };
41
40
  });
41
+ },
42
+ addCommands() {
43
+ const commands = this.parent();
44
+ return {
45
+ ...commands,
46
+ setFontSize: (fontSize) => (props) => ifListed(fontSize, this.options.fontSizes) !== null &&
47
+ commands.setFontSize(fontSize)(props)
48
+ };
42
49
  }
43
50
  });
@@ -0,0 +1,19 @@
1
+ import { type HighlightOptions as TiptapHighlightOptions } from '@tiptap/extension-highlight';
2
+ export interface HighlightOptions extends TiptapHighlightOptions {
3
+ /**
4
+ * The colours a highlight may take, as a body writes them:
5
+ * `var(--tiptap-highlight-yellow)`. Any colour where null.
6
+ */
7
+ colors: string[] | null;
8
+ /**
9
+ * The colour of a highlight asked for without one, as its key and
10
+ * `==text==` ask. A highlight of no colour where null, which a browser
11
+ * draws in a yellow of its own.
12
+ */
13
+ defaultColor: string | null;
14
+ }
15
+ /**
16
+ * Tiptap's highlight in many colours, held to a palette: a `mark` pasted in
17
+ * that is not of one of its colours is read as its text, and none is set.
18
+ */
19
+ export declare const Highlight: import("@tiptap/core").Mark<HighlightOptions, any>;
@@ -0,0 +1,69 @@
1
+ import { getStyleProperty, markInputRule, markPasteRule } from '@tiptap/core';
2
+ import { Highlight as TiptapHighlight, inputRegex, pasteRegex } from '@tiptap/extension-highlight';
3
+ import { ifListed } from './listed.js';
4
+ // Where Tiptap's highlight reads its colour from, the first it finds.
5
+ function colorOf(element) {
6
+ return (element.getAttribute('data-color') ||
7
+ getStyleProperty(element, 'background-color') ||
8
+ element.style.backgroundColor);
9
+ }
10
+ /**
11
+ * Tiptap's highlight in many colours, held to a palette: a `mark` pasted in
12
+ * that is not of one of its colours is read as its text, and none is set.
13
+ */
14
+ export const Highlight = TiptapHighlight.extend({
15
+ addOptions() {
16
+ return {
17
+ ...this.parent(),
18
+ multicolor: true,
19
+ colors: null,
20
+ defaultColor: null
21
+ };
22
+ },
23
+ parseHTML() {
24
+ const { colors } = this.options;
25
+ return [
26
+ {
27
+ tag: 'mark',
28
+ getAttrs: (element) => colors === null || ifListed(colorOf(element), colors) !== null
29
+ ? null
30
+ : false
31
+ }
32
+ ];
33
+ },
34
+ addCommands() {
35
+ const commands = this.parent();
36
+ const { colors, defaultColor } = this.options;
37
+ const colored = (attributes) => attributes ?? (defaultColor ? { color: defaultColor } : undefined);
38
+ const allowed = (attributes) => colors === null || ifListed(attributes?.color, colors) !== null;
39
+ return {
40
+ ...commands,
41
+ setHighlight: (attributes) => (props) => allowed(colored(attributes)) &&
42
+ commands.setHighlight(colored(attributes))(props),
43
+ toggleHighlight: (attributes) => (props) => allowed(colored(attributes)) &&
44
+ commands.toggleHighlight(colored(attributes))(props)
45
+ };
46
+ },
47
+ addInputRules() {
48
+ return [
49
+ markInputRule({
50
+ find: inputRegex,
51
+ type: this.type,
52
+ getAttributes: this.options.defaultColor
53
+ ? { color: this.options.defaultColor }
54
+ : undefined
55
+ })
56
+ ];
57
+ },
58
+ addPasteRules() {
59
+ return [
60
+ markPasteRule({
61
+ find: pasteRegex,
62
+ type: this.type,
63
+ getAttributes: this.options.defaultColor
64
+ ? { color: this.options.defaultColor }
65
+ : undefined
66
+ })
67
+ ];
68
+ }
69
+ });
package/dist/index.d.ts CHANGED
@@ -1,9 +1,19 @@
1
1
  export { TiptapEssentials } from './tiptap-essentials.js';
2
2
  export type { TiptapEssentialsOptions } from './tiptap-essentials.js';
3
- export { FontSize, TextStyle } from './font-size.js';
3
+ export { BlockSpacing } from './block-spacing.js';
4
+ export type { BlockSpacingOptions } from './block-spacing.js';
5
+ export { Color } from './color.js';
6
+ export type { ColorOptions } from './color.js';
7
+ export { FontSize } from './font-size.js';
8
+ export type { FontSizeOptions } from './font-size.js';
9
+ export { Highlight } from './highlight.js';
10
+ export type { HighlightOptions } from './highlight.js';
4
11
  export { Image } from './image.js';
5
12
  export type { ImageAttributes, PictureSource } from './image.js';
13
+ export { LineHeight } from './line-height.js';
14
+ export type { LineHeightOptions } from './line-height.js';
6
15
  export { PlainSpaces } from './plain-spaces.js';
7
16
  export { Table } from './table.js';
8
17
  export type { TableOptions } from './table.js';
18
+ export { TextStyle } from './text-style.js';
9
19
  export { Youtube } from './youtube.js';
package/dist/index.js CHANGED
@@ -1,6 +1,11 @@
1
1
  export { TiptapEssentials } from './tiptap-essentials.js';
2
- export { FontSize, TextStyle } from './font-size.js';
2
+ export { BlockSpacing } from './block-spacing.js';
3
+ export { Color } from './color.js';
4
+ export { FontSize } from './font-size.js';
5
+ export { Highlight } from './highlight.js';
3
6
  export { Image } from './image.js';
7
+ export { LineHeight } from './line-height.js';
4
8
  export { PlainSpaces } from './plain-spaces.js';
5
9
  export { Table } from './table.js';
10
+ export { TextStyle } from './text-style.js';
6
11
  export { Youtube } from './youtube.js';
@@ -0,0 +1,15 @@
1
+ import { type LineHeightOptions as TiptapLineHeightOptions } from '@tiptap/extension-text-style';
2
+ export interface LineHeightOptions extends TiptapLineHeightOptions {
3
+ /**
4
+ * The line heights a block may take, as a body writes them:
5
+ * `var(--tiptap-line-height-150)`. Any where null.
6
+ */
7
+ lineHeights: string[] | null;
8
+ }
9
+ /**
10
+ * Tiptap's line height, on paragraphs and headings rather than a span, and
11
+ * held to a set of steps: one pasted in that is not a step is read as none.
12
+ * Tiptap's commands style a span inside the blocks, so these style the blocks
13
+ * themselves, every one the selection touches.
14
+ */
15
+ export declare const LineHeight: import("@tiptap/core").Extension<LineHeightOptions, any>;
@@ -0,0 +1,43 @@
1
+ import { LineHeight as TiptapLineHeight } from '@tiptap/extension-text-style';
2
+ import { ifListed } from './listed.js';
3
+ /**
4
+ * Tiptap's line height, on paragraphs and headings rather than a span, and
5
+ * held to a set of steps: one pasted in that is not a step is read as none.
6
+ * Tiptap's commands style a span inside the blocks, so these style the blocks
7
+ * themselves, every one the selection touches.
8
+ */
9
+ export const LineHeight = TiptapLineHeight.extend({
10
+ addOptions() {
11
+ return {
12
+ ...this.parent(),
13
+ types: ['paragraph', 'heading'],
14
+ lineHeights: null
15
+ };
16
+ },
17
+ addGlobalAttributes() {
18
+ const { lineHeights } = this.options;
19
+ return (this.parent?.() ?? []).map(({ types, attributes }) => {
20
+ const { lineHeight } = attributes;
21
+ return {
22
+ types,
23
+ attributes: {
24
+ lineHeight: {
25
+ ...lineHeight,
26
+ parseHTML: (element) => ifListed(lineHeight?.parseHTML?.(element), lineHeights)
27
+ }
28
+ }
29
+ };
30
+ });
31
+ },
32
+ addCommands() {
33
+ return {
34
+ setLineHeight: (lineHeight) => ({ commands }) => ifListed(lineHeight, this.options.lineHeights) !== null &&
35
+ this.options.types
36
+ .map((type) => commands.updateAttributes(type, { lineHeight }))
37
+ .some((response) => response),
38
+ unsetLineHeight: () => ({ commands }) => this.options.types
39
+ .map((type) => commands.resetAttributes(type, 'lineHeight'))
40
+ .some((response) => response)
41
+ };
42
+ }
43
+ });
@@ -0,0 +1,5 @@
1
+ /**
2
+ * A value read from a body, kept only where the list of the values it may take
3
+ * names it as it is written. Without a list, any value is kept.
4
+ */
5
+ export declare function ifListed(value: unknown, list: readonly string[] | null): string | null;
package/dist/listed.js ADDED
@@ -0,0 +1,10 @@
1
+ /**
2
+ * A value read from a body, kept only where the list of the values it may take
3
+ * names it as it is written. Without a list, any value is kept.
4
+ */
5
+ export function ifListed(value, list) {
6
+ if (typeof value !== 'string') {
7
+ return null;
8
+ }
9
+ return list === null || list.includes(value) ? value : null;
10
+ }
package/dist/samples.d.ts CHANGED
@@ -7,3 +7,6 @@ export declare const picture: string;
7
7
  export declare const table: string;
8
8
  export declare const video: string;
9
9
  export declare const size = "<p><span style=\"font-size: var(--lg-font-size);\">Large</span> text</p>";
10
+ export declare const color = "<p><span style=\"color: var(--tiptap-text-red);\">Red</span> text</p>";
11
+ export declare const highlight: string;
12
+ export declare const spacing: string;
package/dist/samples.js CHANGED
@@ -15,3 +15,8 @@ export const table = '<div class="table-responsive" role="region" tabindex="0" a
15
15
  export const video = '<div data-youtube-video=""><iframe width="640" height="480" allowfullscreen="true" ' +
16
16
  'src="https://www.youtube.com/embed/M7lc1UVf-VE?start=90&amp;rel=1" title="A talk"></iframe></div>';
17
17
  export const size = '<p><span style="font-size: var(--lg-font-size);">Large</span> text</p>';
18
+ export const color = '<p><span style="color: var(--tiptap-text-red);">Red</span> text</p>';
19
+ export const highlight = '<p><mark data-color="var(--tiptap-highlight-yellow)" ' +
20
+ 'style="background-color: var(--tiptap-highlight-yellow); color: inherit;">Marked</mark> text</p>';
21
+ export const spacing = '<p style="line-height: var(--tiptap-line-height-150); margin-top: var(--space-40); ' +
22
+ 'margin-bottom: var(--space-40);">Spaced</p>';
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Tiptap's text style, reading a span only where a style a text keeps is on
3
+ * it — a colour of the palette, one of the sizes. A span whose every style is
4
+ * dropped, a colour off the palette or a font, is read as its text, where
5
+ * Tiptap's would keep it as a bare span.
6
+ */
7
+ export declare const TextStyle: import("@tiptap/core").Mark<import("@tiptap/extension-text-style").TextStyleOptions, any>;
@@ -0,0 +1,38 @@
1
+ import { getAttributesFromExtensions } from '@tiptap/core';
2
+ import { TextStyle as TiptapTextStyle } from '@tiptap/extension-text-style';
3
+ /**
4
+ * Tiptap's text style, reading a span only where a style a text keeps is on
5
+ * it — a colour of the palette, one of the sizes. A span whose every style is
6
+ * dropped, a colour off the palette or a font, is read as its text, where
7
+ * Tiptap's would keep it as a bare span.
8
+ */
9
+ export const TextStyle = TiptapTextStyle.extend({
10
+ parseHTML() {
11
+ const { editor, name } = this;
12
+ const [styled] = (this.parent?.() ?? []);
13
+ let styles;
14
+ // The text's styles are read as a body is, the editor built by then.
15
+ const keepsAStyle = (element) => {
16
+ if (!editor) {
17
+ return element.hasAttribute('style');
18
+ }
19
+ styles ??= getAttributesFromExtensions(editor.extensionManager.extensions).filter(({ type }) => type === name);
20
+ return styles.some(({ attribute }) => {
21
+ const value = attribute.parseHTML?.(element);
22
+ return typeof value === 'string' ? value.trim() !== '' : value != null;
23
+ });
24
+ };
25
+ return [
26
+ {
27
+ tag: 'span',
28
+ consuming: false,
29
+ getAttrs: (element) => {
30
+ // Tiptap's reading of a styled span hands the styles of a span
31
+ // inside it on to that span, which is read on its own.
32
+ styled?.getAttrs?.(element);
33
+ return keepsAStyle(element) ? {} : false;
34
+ }
35
+ }
36
+ ];
37
+ }
38
+ });
@@ -3,9 +3,14 @@ import type { ImageOptions } from '@tiptap/extension-image';
3
3
  import { type SuperscriptExtensionOptions } from '@tiptap/extension-superscript';
4
4
  import { type TableKitOptions } from '@tiptap/extension-table';
5
5
  import { type TextAlignOptions } from '@tiptap/extension-text-align';
6
- import { type FontSizeOptions, type TextStyleKitOptions } from '@tiptap/extension-text-style';
6
+ import { type TextStyleKitOptions } from '@tiptap/extension-text-style';
7
7
  import type { YoutubeOptions } from '@tiptap/extension-youtube';
8
8
  import { type StarterKitOptions } from '@tiptap/starter-kit';
9
+ import { type BlockSpacingOptions } from './block-spacing.js';
10
+ import { type ColorOptions } from './color.js';
11
+ import { type FontSizeOptions } from './font-size.js';
12
+ import { type HighlightOptions } from './highlight.js';
13
+ import { type LineHeightOptions } from './line-height.js';
9
14
  import { type TableOptions } from './table.js';
10
15
  type Part<Options> = Partial<Options> | false;
11
16
  export interface TiptapEssentialsOptions {
@@ -14,10 +19,17 @@ export interface TiptapEssentialsOptions {
14
19
  tableKit: (Partial<Omit<TableKitOptions, 'table'>> & {
15
20
  table?: Part<TableOptions>;
16
21
  }) | false;
17
- /** TextStyleKit's options, its font size being the library's. */
18
- textStyleKit: (Partial<Omit<TextStyleKitOptions, 'fontSize'>> & {
22
+ /**
23
+ * TextStyleKit's options, its text style, font size, colour and line height
24
+ * being the library's.
25
+ */
26
+ textStyleKit: (Partial<Omit<TextStyleKitOptions, 'fontSize' | 'color' | 'lineHeight'>> & {
19
27
  fontSize?: Part<FontSizeOptions>;
28
+ color?: Part<ColorOptions>;
29
+ lineHeight?: Part<LineHeightOptions>;
20
30
  }) | false;
31
+ highlight: Part<HighlightOptions>;
32
+ blockSpacing: Part<BlockSpacingOptions>;
21
33
  textAlign: Part<TextAlignOptions>;
22
34
  superscript: Part<SuperscriptExtensionOptions>;
23
35
  image: Part<ImageOptions>;
@@ -2,12 +2,17 @@ import { Extension } from '@tiptap/core';
2
2
  import Superscript, {} from '@tiptap/extension-superscript';
3
3
  import { TableKit } from '@tiptap/extension-table';
4
4
  import TextAlign, {} from '@tiptap/extension-text-align';
5
- import { TextStyle as TiptapTextStyle, TextStyleKit } from '@tiptap/extension-text-style';
5
+ import { TextStyleKit } from '@tiptap/extension-text-style';
6
6
  import StarterKit, {} from '@tiptap/starter-kit';
7
- import { FontSize, TextStyle } from './font-size.js';
7
+ import { BlockSpacing } from './block-spacing.js';
8
+ import { Color } from './color.js';
9
+ import { FontSize } from './font-size.js';
10
+ import { Highlight } from './highlight.js';
8
11
  import { Image } from './image.js';
12
+ import { LineHeight } from './line-height.js';
9
13
  import { PlainSpaces } from './plain-spaces.js';
10
14
  import { Table } from './table.js';
15
+ import { TextStyle } from './text-style.js';
11
16
  import { Youtube } from './youtube.js';
12
17
  /**
13
18
  * Tiptap's kits and the library's own parts as one extension, each part
@@ -24,6 +29,8 @@ export const TiptapEssentials = Extension.create({
24
29
  types: ['heading', 'paragraph'],
25
30
  alignments: ['start', 'end', 'left', 'center', 'right', 'justify']
26
31
  },
32
+ highlight: {},
33
+ blockSpacing: {},
27
34
  superscript: {},
28
35
  image: {},
29
36
  youtube: {},
@@ -31,7 +38,7 @@ export const TiptapEssentials = Extension.create({
31
38
  };
32
39
  },
33
40
  addExtensions() {
34
- const { starterKit, tableKit, textStyleKit, textAlign, superscript, image, youtube, plainSpaces } = this.options;
41
+ const { starterKit, tableKit, textStyleKit, highlight, blockSpacing, textAlign, superscript, image, youtube, plainSpaces } = this.options;
35
42
  const extensions = [];
36
43
  if (starterKit !== false) {
37
44
  extensions.push(StarterKit.configure(starterKit));
@@ -44,16 +51,32 @@ export const TiptapEssentials = Extension.create({
44
51
  }
45
52
  }
46
53
  if (textStyleKit !== false) {
47
- const { fontSize = {}, textStyle = {}, ...rest } = textStyleKit;
48
- extensions.push(TextStyleKit.configure({ ...rest, fontSize: false, textStyle: false }));
54
+ const { fontSize = {}, color = {}, lineHeight = {}, textStyle = {}, ...rest } = textStyleKit;
55
+ extensions.push(TextStyleKit.configure({
56
+ ...rest,
57
+ fontSize: false,
58
+ color: false,
59
+ lineHeight: false,
60
+ textStyle: false
61
+ }));
49
62
  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));
63
+ extensions.push(TextStyle.configure(textStyle));
53
64
  }
54
65
  if (fontSize !== false) {
55
66
  extensions.push(FontSize.configure(fontSize));
56
67
  }
68
+ if (color !== false) {
69
+ extensions.push(Color.configure(color));
70
+ }
71
+ if (lineHeight !== false) {
72
+ extensions.push(LineHeight.configure(lineHeight));
73
+ }
74
+ }
75
+ if (highlight !== false) {
76
+ extensions.push(Highlight.configure(highlight));
77
+ }
78
+ if (blockSpacing !== false) {
79
+ extensions.push(BlockSpacing.configure(blockSpacing));
57
80
  }
58
81
  if (textAlign !== false) {
59
82
  extensions.push(TextAlign.configure(textAlign));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tiptap-essentials",
3
- "version": "2.0.0-beta.1",
3
+ "version": "2.0.0-beta.3",
4
4
  "description": "Essential extensions of Tiptap",
5
5
  "type": "module",
6
6
  "exports": {
@@ -33,6 +33,7 @@
33
33
  "@tiptap/pm": "^3.35.0"
34
34
  },
35
35
  "dependencies": {
36
+ "@tiptap/extension-highlight": "^3.35.0",
36
37
  "@tiptap/extension-image": "^3.35.0",
37
38
  "@tiptap/extension-superscript": "^3.35.0",
38
39
  "@tiptap/extension-table": "^3.35.0",