@tldraw/commenting 5.7.0-canary.ef9966b67dee → 5.7.0-canary.f58edb2cdca7
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-cjs/index.js +1 -1
- package/dist-cjs/ui/comment-extensions.js +4 -1
- package/dist-cjs/ui/comment-extensions.js.map +2 -2
- package/dist-esm/index.mjs +1 -1
- package/dist-esm/ui/comment-extensions.mjs +11 -2
- package/dist-esm/ui/comment-extensions.mjs.map +2 -2
- package/package.json +5 -5
- package/src/canvas/comment-render.test.ts +8 -1
- package/src/ui/comment-extensions.ts +18 -5
package/dist-cjs/index.js
CHANGED
|
@@ -145,7 +145,7 @@ var import_state = require("./canvas/state");
|
|
|
145
145
|
var import_thread_state = require("./canvas/thread-state");
|
|
146
146
|
(0, import_utils.registerTldrawLibraryVersion)(
|
|
147
147
|
"@tldraw/commenting",
|
|
148
|
-
"5.7.0-canary.
|
|
148
|
+
"5.7.0-canary.f58edb2cdca7",
|
|
149
149
|
"cjs"
|
|
150
150
|
);
|
|
151
151
|
//# sourceMappingURL=index.js.map
|
|
@@ -24,7 +24,10 @@ __export(comment_extensions_exports, {
|
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(comment_extensions_exports);
|
|
26
26
|
var import_tldraw = require("tldraw");
|
|
27
|
-
const
|
|
27
|
+
const TASK_EXTENSION_NAMES = /* @__PURE__ */ new Set([import_tldraw.TaskList.name, import_tldraw.TaskItem.name, import_tldraw.TaskItemToggleExtension.name]);
|
|
28
|
+
const commentTipTapExtensions = (0, import_tldraw.getTipTapDefaultExtensions)({ heading: false }).filter(
|
|
29
|
+
(extension) => !TASK_EXTENSION_NAMES.has(extension.name)
|
|
30
|
+
);
|
|
28
31
|
const EMPTY_COMMENT = (0, import_tldraw.toRichText)("");
|
|
29
32
|
function isCommentEmpty(richText) {
|
|
30
33
|
if (richText.content.length === 0) return true;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/ui/comment-extensions.ts"],
|
|
4
|
-
"sourcesContent": ["import {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,
|
|
4
|
+
"sourcesContent": ["import {\n\tgetTipTapDefaultExtensions,\n\tTaskItem,\n\tTaskItemToggleExtension,\n\tTaskList,\n\tTLRichText,\n\ttoRichText,\n} from 'tldraw'\n\n// A posted comment is static HTML with nothing to write a click back to, so a checkbox there would\n// toggle on screen and snap back.\nconst TASK_EXTENSION_NAMES = new Set([TaskList.name, TaskItem.name, TaskItemToggleExtension.name])\n\n/**\n * tldraw's default rich-text extension set, minus headings and task lists \u2014 the deliberately\n * limited set used for both the comment composer and comment display. Comments support paragraphs,\n * bold, italic, lists, links, code, and highlight. Built from tldraw's shared factory so the config\n * stays in lockstep with the text shape's defaults rather than drifting from a copy.\n */\nexport const commentTipTapExtensions = getTipTapDefaultExtensions({ heading: false }).filter(\n\t(extension) => !TASK_EXTENSION_NAMES.has(extension.name)\n)\n\n/** An empty comment document \u2014 the seed value for a fresh composer and its post-submit reset. */\nexport const EMPTY_COMMENT: TLRichText = toRichText('')\n\n/**\n * Whether a rich-text comment body has no text. Mirrors tldraw's private `isEmptyRichText`: an\n * empty doc can be encoded as an empty `content` array or a single empty paragraph.\n */\nexport function isCommentEmpty(richText: TLRichText): boolean {\n\tif (richText.content.length === 0) return true\n\tif (richText.content.length === 1) {\n\t\tconst node = richText.content[0] as any\n\t\tif (!node.content || node.content.length === 0) return true\n\t}\n\treturn false\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAOO;AAIP,MAAM,uBAAuB,oBAAI,IAAI,CAAC,uBAAS,MAAM,uBAAS,MAAM,sCAAwB,IAAI,CAAC;AAQ1F,MAAM,8BAA0B,0CAA2B,EAAE,SAAS,MAAM,CAAC,EAAE;AAAA,EACrF,CAAC,cAAc,CAAC,qBAAqB,IAAI,UAAU,IAAI;AACxD;AAGO,MAAM,oBAA4B,0BAAW,EAAE;AAM/C,SAAS,eAAe,UAA+B;AAC7D,MAAI,SAAS,QAAQ,WAAW,EAAG,QAAO;AAC1C,MAAI,SAAS,QAAQ,WAAW,GAAG;AAClC,UAAM,OAAO,SAAS,QAAQ,CAAC;AAC/B,QAAI,CAAC,KAAK,WAAW,KAAK,QAAQ,WAAW,EAAG,QAAO;AAAA,EACxD;AACA,SAAO;AACR;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist-esm/index.mjs
CHANGED
|
@@ -108,7 +108,7 @@ import {
|
|
|
108
108
|
import { anchorPagePoint, focusThread, shapeAnchorAt } from "./canvas/thread-state.mjs";
|
|
109
109
|
registerTldrawLibraryVersion(
|
|
110
110
|
"@tldraw/commenting",
|
|
111
|
-
"5.7.0-canary.
|
|
111
|
+
"5.7.0-canary.f58edb2cdca7",
|
|
112
112
|
"esm"
|
|
113
113
|
);
|
|
114
114
|
export {
|
|
@@ -1,5 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
getTipTapDefaultExtensions,
|
|
3
|
+
TaskItem,
|
|
4
|
+
TaskItemToggleExtension,
|
|
5
|
+
TaskList,
|
|
6
|
+
toRichText
|
|
7
|
+
} from "tldraw";
|
|
8
|
+
const TASK_EXTENSION_NAMES = /* @__PURE__ */ new Set([TaskList.name, TaskItem.name, TaskItemToggleExtension.name]);
|
|
9
|
+
const commentTipTapExtensions = getTipTapDefaultExtensions({ heading: false }).filter(
|
|
10
|
+
(extension) => !TASK_EXTENSION_NAMES.has(extension.name)
|
|
11
|
+
);
|
|
3
12
|
const EMPTY_COMMENT = toRichText("");
|
|
4
13
|
function isCommentEmpty(richText) {
|
|
5
14
|
if (richText.content.length === 0) return true;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/ui/comment-extensions.ts"],
|
|
4
|
-
"sourcesContent": ["import {
|
|
5
|
-
"mappings": "AAAA,SAAS,
|
|
4
|
+
"sourcesContent": ["import {\n\tgetTipTapDefaultExtensions,\n\tTaskItem,\n\tTaskItemToggleExtension,\n\tTaskList,\n\tTLRichText,\n\ttoRichText,\n} from 'tldraw'\n\n// A posted comment is static HTML with nothing to write a click back to, so a checkbox there would\n// toggle on screen and snap back.\nconst TASK_EXTENSION_NAMES = new Set([TaskList.name, TaskItem.name, TaskItemToggleExtension.name])\n\n/**\n * tldraw's default rich-text extension set, minus headings and task lists \u2014 the deliberately\n * limited set used for both the comment composer and comment display. Comments support paragraphs,\n * bold, italic, lists, links, code, and highlight. Built from tldraw's shared factory so the config\n * stays in lockstep with the text shape's defaults rather than drifting from a copy.\n */\nexport const commentTipTapExtensions = getTipTapDefaultExtensions({ heading: false }).filter(\n\t(extension) => !TASK_EXTENSION_NAMES.has(extension.name)\n)\n\n/** An empty comment document \u2014 the seed value for a fresh composer and its post-submit reset. */\nexport const EMPTY_COMMENT: TLRichText = toRichText('')\n\n/**\n * Whether a rich-text comment body has no text. Mirrors tldraw's private `isEmptyRichText`: an\n * empty doc can be encoded as an empty `content` array or a single empty paragraph.\n */\nexport function isCommentEmpty(richText: TLRichText): boolean {\n\tif (richText.content.length === 0) return true\n\tif (richText.content.length === 1) {\n\t\tconst node = richText.content[0] as any\n\t\tif (!node.content || node.content.length === 0) return true\n\t}\n\treturn false\n}\n"],
|
|
5
|
+
"mappings": "AAAA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,OACM;AAIP,MAAM,uBAAuB,oBAAI,IAAI,CAAC,SAAS,MAAM,SAAS,MAAM,wBAAwB,IAAI,CAAC;AAQ1F,MAAM,0BAA0B,2BAA2B,EAAE,SAAS,MAAM,CAAC,EAAE;AAAA,EACrF,CAAC,cAAc,CAAC,qBAAqB,IAAI,UAAU,IAAI;AACxD;AAGO,MAAM,gBAA4B,WAAW,EAAE;AAM/C,SAAS,eAAe,UAA+B;AAC7D,MAAI,SAAS,QAAQ,WAAW,EAAG,QAAO;AAC1C,MAAI,SAAS,QAAQ,WAAW,GAAG;AAClC,UAAM,OAAO,SAAS,QAAQ,CAAC;AAC/B,QAAI,CAAC,KAAK,WAAW,KAAK,QAAQ,WAAW,EAAG,QAAO;AAAA,EACxD;AACA,SAAO;AACR;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tldraw/commenting",
|
|
3
3
|
"description": "tldraw commenting UI components.",
|
|
4
|
-
"version": "5.7.0-canary.
|
|
4
|
+
"version": "5.7.0-canary.f58edb2cdca7",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "tldraw Inc.",
|
|
7
7
|
"email": "hello@tldraw.com"
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"src"
|
|
33
33
|
],
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@tldraw/driver": "5.7.0-canary.
|
|
35
|
+
"@tldraw/driver": "5.7.0-canary.f58edb2cdca7",
|
|
36
36
|
"@types/react": "^19.2.7",
|
|
37
37
|
"@types/react-dom": "^19.2.3",
|
|
38
38
|
"react": "^19.2.1",
|
|
@@ -50,9 +50,9 @@
|
|
|
50
50
|
"@tiptap/core": "^3.12.1",
|
|
51
51
|
"@tiptap/pm": "^3.12.1",
|
|
52
52
|
"@tiptap/react": "^3.12.1",
|
|
53
|
-
"@tldraw/mentions": "5.7.0-canary.
|
|
54
|
-
"@tldraw/utils": "5.7.0-canary.
|
|
55
|
-
"tldraw": "5.7.0-canary.
|
|
53
|
+
"@tldraw/mentions": "5.7.0-canary.f58edb2cdca7",
|
|
54
|
+
"@tldraw/utils": "5.7.0-canary.f58edb2cdca7",
|
|
55
|
+
"tldraw": "5.7.0-canary.f58edb2cdca7"
|
|
56
56
|
},
|
|
57
57
|
"module": "dist-esm/index.mjs",
|
|
58
58
|
"source": "src/index.ts",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, expect, it } from 'vitest'
|
|
2
|
-
import { EMPTY_COMMENT, isCommentEmpty } from '../ui/comment-extensions'
|
|
2
|
+
import { commentTipTapExtensions, EMPTY_COMMENT, isCommentEmpty } from '../ui/comment-extensions'
|
|
3
3
|
import { renderCommentHtml, renderCommentPlaintext } from './comment-render'
|
|
4
4
|
|
|
5
5
|
const doc = (...content: any[]) => ({ type: 'doc', content }) as any
|
|
@@ -26,6 +26,13 @@ describe('renderCommentHtml', () => {
|
|
|
26
26
|
expect(list).toContain('one')
|
|
27
27
|
})
|
|
28
28
|
|
|
29
|
+
it('leaves task lists out of the limited set', () => {
|
|
30
|
+
// A posted comment is static HTML, so its checkboxes would toggle and never write back.
|
|
31
|
+
expect(commentTipTapExtensions.map((extension) => extension.name)).not.toEqual(
|
|
32
|
+
expect.arrayContaining([expect.stringMatching(/^task/)])
|
|
33
|
+
)
|
|
34
|
+
})
|
|
35
|
+
|
|
29
36
|
it('renders a heading node as a paragraph, never a heading', () => {
|
|
30
37
|
const html = renderCommentHtml(
|
|
31
38
|
doc({ type: 'heading', attrs: { level: 1 }, content: [text('Title')] })
|
|
@@ -1,12 +1,25 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
getTipTapDefaultExtensions,
|
|
3
|
+
TaskItem,
|
|
4
|
+
TaskItemToggleExtension,
|
|
5
|
+
TaskList,
|
|
6
|
+
TLRichText,
|
|
7
|
+
toRichText,
|
|
8
|
+
} from 'tldraw'
|
|
9
|
+
|
|
10
|
+
// A posted comment is static HTML with nothing to write a click back to, so a checkbox there would
|
|
11
|
+
// toggle on screen and snap back.
|
|
12
|
+
const TASK_EXTENSION_NAMES = new Set([TaskList.name, TaskItem.name, TaskItemToggleExtension.name])
|
|
2
13
|
|
|
3
14
|
/**
|
|
4
|
-
* tldraw's default rich-text extension set, minus headings — the deliberately
|
|
5
|
-
* both the comment composer and comment display. Comments support paragraphs,
|
|
6
|
-
* links, code, and highlight
|
|
15
|
+
* tldraw's default rich-text extension set, minus headings and task lists — the deliberately
|
|
16
|
+
* limited set used for both the comment composer and comment display. Comments support paragraphs,
|
|
17
|
+
* bold, italic, lists, links, code, and highlight. Built from tldraw's shared factory so the config
|
|
7
18
|
* stays in lockstep with the text shape's defaults rather than drifting from a copy.
|
|
8
19
|
*/
|
|
9
|
-
export const commentTipTapExtensions = getTipTapDefaultExtensions({ heading: false })
|
|
20
|
+
export const commentTipTapExtensions = getTipTapDefaultExtensions({ heading: false }).filter(
|
|
21
|
+
(extension) => !TASK_EXTENSION_NAMES.has(extension.name)
|
|
22
|
+
)
|
|
10
23
|
|
|
11
24
|
/** An empty comment document — the seed value for a fresh composer and its post-submit reset. */
|
|
12
25
|
export const EMPTY_COMMENT: TLRichText = toRichText('')
|