@fibery/prosemirror-schema 4.4.2 → 4.5.0

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,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.code_block = void 0;
4
- const prosemirror_model_1 = require("prosemirror-model");
5
4
  const getLanguageFromEditorStyle = (dom) => {
6
5
  return dom.getAttribute("data-language") || undefined;
7
6
  };
@@ -61,27 +60,6 @@ exports.code_block = {
61
60
  return { language };
62
61
  },
63
62
  },
64
- // Handle VSCode paste
65
- {
66
- tag: "div[style]",
67
- preserveWhitespace: "full",
68
- getAttrs: (domNode) => {
69
- const dom = domNode;
70
- if (dom.style.whiteSpace === "pre" ||
71
- (dom.style.fontFamily && dom.style.fontFamily.toLowerCase().indexOf("monospace") > -1)) {
72
- return {};
73
- }
74
- return false;
75
- },
76
- getContent: (domNode, schema) => {
77
- const dom = domNode;
78
- const code = Array.from(dom.children)
79
- .map((child) => child.textContent)
80
- .filter((x) => x !== undefined)
81
- .join("\n");
82
- return code ? prosemirror_model_1.Fragment.from(schema.text(code)) : prosemirror_model_1.Fragment.empty;
83
- },
84
- },
85
63
  // Handle GitHub/Gist paste
86
64
  {
87
65
  tag: "table[style]",
@@ -1,6 +1,7 @@
1
1
  type Emoji = {
2
2
  name: string;
3
3
  shortNames: string[];
4
+ colons: string;
4
5
  native?: string;
5
6
  };
6
7
  export type EmojiOptions = {
@@ -27,8 +27,13 @@ const makeEmoji = ({ getEmoji } = defaultOptions) => ({
27
27
  tag: `span[${typeAttr}]`,
28
28
  getAttrs(domNode) {
29
29
  const dom = domNode;
30
+ const code = dom.getAttribute(codeAttr);
31
+ const alias = dom.textContent;
32
+ // If emoji is not found by code attr, try alias, that is stored as text content
33
+ // This handles the case when we have a custom emoji matching by alias, but not by id (copied from another workspace)
34
+ const emoji = (code && getEmoji(code)) || (alias && getEmoji(alias)) || null;
30
35
  return {
31
- code: dom.getAttribute(codeAttr),
36
+ code: emoji ? emoji.colons : alias,
32
37
  };
33
38
  },
34
39
  },
@@ -2,6 +2,20 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.makeMedia = void 0;
4
4
  const resizable_node_attrs_1 = require("../resizable-node-attrs");
5
+ function toBoolean(attr) {
6
+ if (typeof attr === "boolean") {
7
+ return attr;
8
+ }
9
+ if (typeof attr === "string") {
10
+ if (attr === "false") {
11
+ return false;
12
+ }
13
+ if (attr === "true") {
14
+ return true;
15
+ }
16
+ }
17
+ return Boolean(attr);
18
+ }
5
19
  const makeMedia = ({ mediaToDom }) => ({
6
20
  inline: false,
7
21
  attrs: {
@@ -14,9 +28,11 @@ const makeMedia = ({ mediaToDom }) => ({
14
28
  {
15
29
  tag: "div[data-url]",
16
30
  getAttrs(dom) {
31
+ const htmlElement = dom;
17
32
  return {
18
- url: dom.getAttribute("data-url"),
19
- ...(0, resizable_node_attrs_1.createParseDomAttrs)(dom),
33
+ url: htmlElement.getAttribute("data-url"),
34
+ compatibleMode: toBoolean(htmlElement.getAttribute("data-compatible-mode")),
35
+ ...(0, resizable_node_attrs_1.createParseDomAttrs)(htmlElement),
20
36
  };
21
37
  },
22
38
  },
@@ -25,9 +41,10 @@ const makeMedia = ({ mediaToDom }) => ({
25
41
  if (mediaToDom) {
26
42
  return mediaToDom(node);
27
43
  }
28
- const { url } = node.attrs;
44
+ const { url, compatibleMode } = node.attrs;
29
45
  const attrs = {
30
46
  "data-url": url,
47
+ "data-compatible-mode": compatibleMode,
31
48
  contenteditable: "false",
32
49
  ...(0, resizable_node_attrs_1.createToDomAttrs)(node),
33
50
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fibery/prosemirror-schema",
3
- "version": "4.4.2",
3
+ "version": "4.5.0",
4
4
  "description": "Fibery prosemirror schema",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./lib/index.d.ts",