@panneau/editor 5.0.0-alpha.17 → 5.0.0-alpha.19

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/extensions/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAYjD,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAG9C,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,KAAK,eAAe,EAAE,MAAM,OAAO,CAAC;AA8B9E,MAAM,WAAW,yBAAyB;IACtC,+FAA+F;IAC/F,UAAU,CAAC,EAAE,SAAS,YAAY,EAAE,CAAC;IACrC,sCAAsC;IACtC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,yCAAyC;IACzC,IAAI,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC;CACnC;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,EACrC,UAAe,EACf,WAAW,EACX,IAAS,GACZ,GAAE,yBAA8B,GAAG,YAAY,EAAE,CAoCjD;AAED,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/extensions/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAYjD,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAG9C,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,KAAK,eAAe,EAAE,MAAM,OAAO,CAAC;AAqC9E,MAAM,WAAW,yBAAyB;IACtC,+FAA+F;IAC/F,UAAU,CAAC,EAAE,SAAS,YAAY,EAAE,CAAC;IACrC,sCAAsC;IACtC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,yCAAyC;IACzC,IAAI,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC;CACnC;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,EACrC,UAAe,EACf,WAAW,EACX,IAAS,GACZ,GAAE,yBAA8B,GAAG,YAAY,EAAE,CAoCjD;AAED,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,CAAC"}
@@ -41,6 +41,10 @@ var KeptLink = Link.extend({
41
41
  ];
42
42
  }
43
43
  });
44
+ /** Line breaks with Shift Enter only: in a form, ⌘ Enter (Ctrl Enter elsewhere) saves. */
45
+ var LineBreak = HardBreak.extend({ addKeyboardShortcuts() {
46
+ return { "Shift-Enter": () => this.editor.commands.setHardBreak() };
47
+ } });
44
48
  /**
45
49
  * The TipTap extensions of the rich text field. Their schema reads everything the field may hold,
46
50
  * whatever its toolbar offers: every heading level, the marks, attributes, and HTML it doesn't
@@ -64,7 +68,7 @@ function createRichTextExtensions({ extensions = [], placeholder, html = {} } =
64
68
  OrderedList,
65
69
  ListItem,
66
70
  ListKeymap,
67
- HardBreak,
71
+ LineBreak,
68
72
  HorizontalRule,
69
73
  ...markExtensions,
70
74
  KeptLink.configure({
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["AnyExtension","Blockquote","Document","HardBreak","Heading","HorizontalRule","Link","BulletList","ListItem","ListKeymap","OrderedList","Paragraph","Text","Dropcursor","Gapcursor","Placeholder","UndoRedo","HtmlAttributes","markExtensions","Paste","HtmlBlock","HtmlInline","HtmlMark","HtmlNodeOptions","KeptLink","extend","addAttributes","parent","order","default","rendered","parseHTML","element","HTMLElement","getAttributeNames","join","renderHTML","props","tag","attributes","Record","mark","attrs","ordered","Object","fromEntries","split","filter","name","undefined","map","RichTextExtensionsOptions","extensions","placeholder","html","Partial","createRichTextExtensions","builtIn","configure","levels","autolink","linkOnPaste","openOnClick","HTMLAttributes","target","rel","class","replaced","Set","extension","has"],"sources":["../../src/extensions/index.ts"],"sourcesContent":["import type { AnyExtension } from '@tiptap/core';\nimport { Blockquote } from '@tiptap/extension-blockquote';\nimport { Document } from '@tiptap/extension-document';\nimport { HardBreak } from '@tiptap/extension-hard-break';\nimport { Heading } from '@tiptap/extension-heading';\nimport { HorizontalRule } from '@tiptap/extension-horizontal-rule';\nimport { Link } from '@tiptap/extension-link';\nimport { BulletList, ListItem, ListKeymap, OrderedList } from '@tiptap/extension-list';\nimport { Paragraph } from '@tiptap/extension-paragraph';\nimport { Text } from '@tiptap/extension-text';\nimport { Dropcursor, Gapcursor, Placeholder, UndoRedo } from '@tiptap/extensions';\n\nimport { HtmlAttributes } from './attributes';\nimport { markExtensions } from './marks';\nimport { Paste } from './paste';\nimport { HtmlBlock, HtmlInline, HtmlMark, type HtmlNodeOptions } from './raw';\n\n/**\n * Links with their attributes in the order they were written in (CKEditor 5 writes `target` and\n * `rel` before `href`), and new links with `href` first.\n */\nconst KeptLink = Link.extend({\n addAttributes() {\n return {\n ...this.parent?.(),\n order: {\n default: null,\n rendered: false,\n parseHTML: (element: HTMLElement) => element.getAttributeNames().join(' ') || null,\n },\n };\n },\n renderHTML(props) {\n const [tag, attributes] = this.parent?.(props) as [string, Record<string, unknown>, 0];\n const order = typeof props.mark.attrs.order === 'string' ? props.mark.attrs.order : 'href';\n const ordered = Object.fromEntries(\n order\n .split(' ')\n .filter((name) => attributes[name] !== undefined && attributes[name] !== null)\n .map((name) => [name, attributes[name]]),\n );\n return [tag, { ...ordered, ...attributes }, 0];\n },\n});\n\nexport interface RichTextExtensionsOptions {\n /** TipTap extensions of the project. One with the name of a built-in extension replaces it. */\n extensions?: readonly AnyExtension[];\n /** Text shown in the empty editor. */\n placeholder?: string;\n /** How kept HTML shows in the editor. */\n html?: Partial<HtmlNodeOptions>;\n}\n\n/**\n * The TipTap extensions of the rich text field. Their schema reads everything the field may hold,\n * whatever its toolbar offers: every heading level, the marks, attributes, and HTML it doesn't\n * edit, kept as it was written.\n */\nexport function createRichTextExtensions({\n extensions = [],\n placeholder,\n html = {},\n}: RichTextExtensionsOptions = {}): AnyExtension[] {\n const builtIn: AnyExtension[] = [\n Document,\n Paragraph,\n Text,\n Heading.configure({ levels: [1, 2, 3, 4, 5, 6] }),\n Blockquote,\n BulletList,\n OrderedList,\n ListItem,\n ListKeymap,\n HardBreak,\n HorizontalRule,\n ...markExtensions,\n KeptLink.configure({\n // Links are added through the toolbar: typing or pasting a URL keeps it as text.\n autolink: false,\n linkOnPaste: false,\n openOnClick: false,\n // No `target` or `rel` on every link: they are set per link.\n HTMLAttributes: { target: null, rel: null, class: null },\n }),\n HtmlAttributes,\n HtmlBlock.configure(html),\n HtmlInline.configure(html),\n HtmlMark,\n Paste,\n UndoRedo,\n Dropcursor,\n Gapcursor,\n ...(placeholder !== undefined && placeholder !== ''\n ? [Placeholder.configure({ placeholder })]\n : []),\n ];\n const replaced = new Set(extensions.map((extension) => extension.name));\n return [...builtIn.filter((extension) => !replaced.has(extension.name)), ...extensions];\n}\n\nexport { HtmlAttributes, HtmlBlock, HtmlInline, HtmlMark };\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAqBA,IAAMwB,WAAWlB,KAAKmB,OAAO;CACzBC,gBAAgB;EACZ,OAAO;GACH,GAAG,KAAKC,SAAS;GACjBC,OAAO;IACHC,SAAS;IACTC,UAAU;IACVC,YAAYC,YAAyBA,QAAQE,kBAAkB,CAAC,CAACC,KAAK,GAAG,KAAK;GAClF;EACJ;CACJ;CACAC,WAAWC,OAAO;EACd,MAAM,CAACC,KAAKC,cAAc,KAAKZ,SAASU,KAAK;EAC7C,MAAMT,QAAQ,OAAOS,MAAMI,KAAKC,MAAMd,UAAU,WAAWS,MAAMI,KAAKC,MAAMd,QAAQ;EAOpF,OAAO;GAACU;GAAK;IAAE,GANCM,OAAOC,YACnBjB,MACKkB,MAAM,GAAG,CAAC,CACVC,QAAQC,SAAST,WAAWS,UAAUC,KAAAA,KAAaV,WAAWS,UAAU,IAAI,CAAC,CAC7EE,KAAKF,SAAS,CAACA,MAAMT,WAAWS,KAAK,CAAC,CAE7BL;IAAS,GAAGJ;GAAW;GAAG;EAAC;CACjD;AACJ,CAAC;;;;;;AAgBD,SAAgBiB,yBAAyB,EACrCJ,aAAa,CAAA,GACbC,aACAC,OAAO,CAAC,MACmB,CAAC,GAAmB;CAC/C,MAAMG,UAA0B;EAC5BvD;EACAS;EACAC;EACAR,QAAQsD,UAAU,EAAEC,QAAQ;GAAC;GAAG;GAAG;GAAG;GAAG;GAAG;EAAC,EAAE,CAAC;EAChD1D;EACAM;EACAG;EACAF;EACAC;EACAN;EACAE;EACA,GAAGa;EACHM,SAASkC,UAAU;GAEfE,UAAU;GACVC,aAAa;GACbC,aAAa;GAEbC,gBAAgB;IAAEC,QAAQ;IAAMC,KAAK;IAAMC,OAAO;GAAK;EAC3D,CAAC;EACDjD;EACAG,UAAUsC,UAAUJ,IAAI;EACxBjC,WAAWqC,UAAUJ,IAAI;EACzBhC;EACAH;EACAH;EACAH;EACAC;EACA,GAAIuC,gBAAgBJ,KAAAA,KAAaI,gBAAgB,KAC3C,CAACtC,YAAY2C,UAAU,EAAEL,YAAY,CAAC,CAAC,IACvC,CAAA;CAAG;CAEb,MAAMc,WAAW,IAAIC,IAAIhB,WAAWF,KAAKmB,cAAcA,UAAUrB,IAAI,CAAC;CACtE,OAAO,CAAC,GAAGS,QAAQV,QAAQsB,cAAc,CAACF,SAASG,IAAID,UAAUrB,IAAI,CAAC,GAAG,GAAGI,UAAU;AAC1F"}
1
+ {"version":3,"file":"index.js","names":["AnyExtension","Blockquote","Document","HardBreak","Heading","HorizontalRule","Link","BulletList","ListItem","ListKeymap","OrderedList","Paragraph","Text","Dropcursor","Gapcursor","Placeholder","UndoRedo","HtmlAttributes","markExtensions","Paste","HtmlBlock","HtmlInline","HtmlMark","HtmlNodeOptions","KeptLink","extend","addAttributes","parent","order","default","rendered","parseHTML","element","HTMLElement","getAttributeNames","join","renderHTML","props","tag","attributes","Record","mark","attrs","ordered","Object","fromEntries","split","filter","name","undefined","map","LineBreak","addKeyboardShortcuts","Shift-Enter","editor","commands","setHardBreak","RichTextExtensionsOptions","extensions","placeholder","html","Partial","createRichTextExtensions","builtIn","configure","levels","autolink","linkOnPaste","openOnClick","HTMLAttributes","target","rel","class","replaced","Set","extension","has"],"sources":["../../src/extensions/index.ts"],"sourcesContent":["import type { AnyExtension } from '@tiptap/core';\nimport { Blockquote } from '@tiptap/extension-blockquote';\nimport { Document } from '@tiptap/extension-document';\nimport { HardBreak } from '@tiptap/extension-hard-break';\nimport { Heading } from '@tiptap/extension-heading';\nimport { HorizontalRule } from '@tiptap/extension-horizontal-rule';\nimport { Link } from '@tiptap/extension-link';\nimport { BulletList, ListItem, ListKeymap, OrderedList } from '@tiptap/extension-list';\nimport { Paragraph } from '@tiptap/extension-paragraph';\nimport { Text } from '@tiptap/extension-text';\nimport { Dropcursor, Gapcursor, Placeholder, UndoRedo } from '@tiptap/extensions';\n\nimport { HtmlAttributes } from './attributes';\nimport { markExtensions } from './marks';\nimport { Paste } from './paste';\nimport { HtmlBlock, HtmlInline, HtmlMark, type HtmlNodeOptions } from './raw';\n\n/**\n * Links with their attributes in the order they were written in (CKEditor 5 writes `target` and\n * `rel` before `href`), and new links with `href` first.\n */\nconst KeptLink = Link.extend({\n addAttributes() {\n return {\n ...this.parent?.(),\n order: {\n default: null,\n rendered: false,\n parseHTML: (element: HTMLElement) => element.getAttributeNames().join(' ') || null,\n },\n };\n },\n renderHTML(props) {\n const [tag, attributes] = this.parent?.(props) as [string, Record<string, unknown>, 0];\n const order = typeof props.mark.attrs.order === 'string' ? props.mark.attrs.order : 'href';\n const ordered = Object.fromEntries(\n order\n .split(' ')\n .filter((name) => attributes[name] !== undefined && attributes[name] !== null)\n .map((name) => [name, attributes[name]]),\n );\n return [tag, { ...ordered, ...attributes }, 0];\n },\n});\n\n/** Line breaks with Shift Enter only: in a form, ⌘ Enter (Ctrl Enter elsewhere) saves. */\nconst LineBreak = HardBreak.extend({\n addKeyboardShortcuts() {\n return { 'Shift-Enter': () => this.editor.commands.setHardBreak() };\n },\n});\n\nexport interface RichTextExtensionsOptions {\n /** TipTap extensions of the project. One with the name of a built-in extension replaces it. */\n extensions?: readonly AnyExtension[];\n /** Text shown in the empty editor. */\n placeholder?: string;\n /** How kept HTML shows in the editor. */\n html?: Partial<HtmlNodeOptions>;\n}\n\n/**\n * The TipTap extensions of the rich text field. Their schema reads everything the field may hold,\n * whatever its toolbar offers: every heading level, the marks, attributes, and HTML it doesn't\n * edit, kept as it was written.\n */\nexport function createRichTextExtensions({\n extensions = [],\n placeholder,\n html = {},\n}: RichTextExtensionsOptions = {}): AnyExtension[] {\n const builtIn: AnyExtension[] = [\n Document,\n Paragraph,\n Text,\n Heading.configure({ levels: [1, 2, 3, 4, 5, 6] }),\n Blockquote,\n BulletList,\n OrderedList,\n ListItem,\n ListKeymap,\n LineBreak,\n HorizontalRule,\n ...markExtensions,\n KeptLink.configure({\n // Links are added through the toolbar: typing or pasting a URL keeps it as text.\n autolink: false,\n linkOnPaste: false,\n openOnClick: false,\n // No `target` or `rel` on every link: they are set per link.\n HTMLAttributes: { target: null, rel: null, class: null },\n }),\n HtmlAttributes,\n HtmlBlock.configure(html),\n HtmlInline.configure(html),\n HtmlMark,\n Paste,\n UndoRedo,\n Dropcursor,\n Gapcursor,\n ...(placeholder !== undefined && placeholder !== ''\n ? [Placeholder.configure({ placeholder })]\n : []),\n ];\n const replaced = new Set(extensions.map((extension) => extension.name));\n return [...builtIn.filter((extension) => !replaced.has(extension.name)), ...extensions];\n}\n\nexport { HtmlAttributes, HtmlBlock, HtmlInline, HtmlMark };\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAqBA,IAAMwB,WAAWlB,KAAKmB,OAAO;CACzBC,gBAAgB;EACZ,OAAO;GACH,GAAG,KAAKC,SAAS;GACjBC,OAAO;IACHC,SAAS;IACTC,UAAU;IACVC,YAAYC,YAAyBA,QAAQE,kBAAkB,CAAC,CAACC,KAAK,GAAG,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c,WAAW,IAAIC,IAAIhB,WAAWR,KAAKyB,cAAcA,UAAU3B,IAAI,CAAC;CACtE,OAAO,CAAC,GAAGe,QAAQhB,QAAQ4B,cAAc,CAACF,SAASG,IAAID,UAAU3B,IAAI,CAAC,GAAG,GAAGU,UAAU;AAC1F"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@panneau/editor",
3
- "version": "5.0.0-alpha.17",
3
+ "version": "5.0.0-alpha.19",
4
4
  "description": "The rich text field of Panneau, on TipTap 3: HTML storage, a toolbar and block styles set from the definition, and extensions from plugins.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -41,10 +41,10 @@
41
41
  "react-intl": "^12.0.0"
42
42
  },
43
43
  "dependencies": {
44
- "@panneau/fields": "5.0.0-alpha.17",
45
- "@panneau/intl": "5.0.0-alpha.17",
46
- "@panneau/protocol": "5.0.0-alpha.17",
47
- "@panneau/ui": "5.0.0-alpha.17",
44
+ "@panneau/fields": "5.0.0-alpha.19",
45
+ "@panneau/intl": "5.0.0-alpha.19",
46
+ "@panneau/protocol": "5.0.0-alpha.19",
47
+ "@panneau/ui": "5.0.0-alpha.19",
48
48
  "@tiptap/extension-blockquote": "^3.32.1",
49
49
  "@tiptap/extension-bold": "^3.32.1",
50
50
  "@tiptap/extension-code": "^3.32.1",