platejs 54.0.0-beta.2 → 54.0.0-beta.4
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 +1 -1
- package/THIRD_PARTY_NOTICES.md +56 -0
- package/dist/{AIChatRequestContext-BMVWhfPV.d.ts → AIChatRequestContext-DrUahdTc.d.ts} +2 -2
- package/dist/{BaseSuggestionPlugin-DBl3fqnm.d.ts → BaseSuggestionPlugin-_7Ka6nY3.d.ts} +7 -3
- package/dist/{PlateStatic-DhNv2ejp.d.ts → PlateStatic-D3Cb-QwH.d.ts} +7 -7
- package/dist/ai/index.d.ts +1 -1
- package/dist/ai/react/AIChatPlugin.js +113 -78
- package/dist/ai/react/CopilotPlugin.js +1 -1
- package/dist/ai/react/index.d.ts +23 -16
- package/dist/authored/index.d.ts +4 -4
- package/dist/code-block/codemirror/createCodeMirrorAdapter.js +12 -9
- package/dist/code-block/codemirror/index.d.ts +1 -1
- package/dist/{combobox-DkBGgyd3.d.ts → combobox-Dr0OYZIE.d.ts} +2 -2
- package/dist/{comparison-types-CYnJ35qU.d.ts → comparison-types-DdwE6mYq-BogsHoUO.d.ts} +10 -2
- package/dist/compiler/index.d.ts +2 -2
- package/dist/{core-BJG8l_mk.d.ts → core-BqR-fEDp.d.ts} +493 -116
- package/dist/diff/index.d.ts +2 -2
- package/dist/docs/ai.md +4 -3
- package/dist/docs/api/core/plate-components.md +0 -19
- package/dist/docs/api/core/plate-controller.md +5 -3
- package/dist/docs/api/core/plate-plugin.md +3 -0
- package/dist/docs/api/core/plate-store.md +3 -3
- package/dist/docs/api/core.md +45 -5
- package/dist/docs/api/dom.md +11 -4
- package/dist/docs/api/editor-transforms.md +2 -1
- package/dist/docs/api/react-hooks.md +45 -13
- package/dist/docs/authored-changes.md +9 -4
- package/dist/docs/basic-blocks.md +42 -29
- package/dist/docs/block-placeholder.md +4 -2
- package/dist/docs/blockquote.md +5 -3
- package/dist/docs/board.md +118 -10
- package/dist/docs/code-block.md +47 -0
- package/dist/docs/comment.md +2 -2
- package/dist/docs/discussion.md +1 -1
- package/dist/docs/document-model.md +15 -3
- package/dist/docs/docx.md +1 -1
- package/dist/docs/dom-coverage.md +5 -0
- package/dist/docs/editor.md +50 -4
- package/dist/docs/examples/editable-voids.md +2 -3
- package/dist/docs/external-text.md +2 -0
- package/dist/docs/field.md +370 -0
- package/dist/docs/find.md +9 -6
- package/dist/docs/form.md +2 -0
- package/dist/docs/heading.md +6 -0
- package/dist/docs/installation/manual.md +0 -4
- package/dist/docs/link.md +3 -3
- package/dist/docs/llms.txt +4 -2
- package/dist/docs/markdown.md +270 -14
- package/dist/docs/plugin-components.md +13 -10
- package/dist/docs/plugin-input-rules.md +66 -15
- package/dist/docs/prompt-editor.md +205 -0
- package/dist/docs/roots.md +8 -6
- package/dist/docs/rtl.md +6 -4
- package/dist/docs/selection.md +7 -4
- package/dist/docs/suggestion.md +1 -1
- package/dist/docs/toolbar.md +26 -30
- package/dist/docs/upload.md +106 -17
- package/dist/docx/export/index.d.ts +3 -3
- package/dist/docx/export/lib/docxStaticComponents.js +12 -2
- package/dist/docx/export/lib/exportDocx.js +46 -17
- package/dist/docx/export/lib/internal/xml-builder.js +11 -16
- package/dist/docx/export/lib/reviewPart.js +1 -1
- package/dist/docx/export/lib/reviewProjection.js +52 -10
- package/dist/docx/import/index.d.ts +4 -4
- package/dist/docx/paste/index.d.ts +4 -4
- package/dist/dom/index.d.ts +1 -6
- package/dist/dom/plite-dom.internal.js +2 -2
- package/dist/excalidraw/index.d.ts +3 -2
- package/dist/excalidraw/react/index.d.ts +3 -2
- package/dist/facade.js +2 -2
- package/dist/features/basic-nodes/lib/BaseBlockPlugins.js +13 -5
- package/dist/features/basic-nodes/lib/BaseHeadingPlugins.js +32 -10
- package/dist/features/board/index.d.ts +2 -2
- package/dist/features/board/lib/BaseBoardPlugin.js +14 -1
- package/dist/features/board/lib/boardStroke.internal.js +13 -1
- package/dist/features/board/lib/boardTypes.internal.js +16 -0
- package/dist/features/callout/index.d.ts +3 -2
- package/dist/features/code-block/lib/BaseCodeBlockPlugin.js +14 -5
- package/dist/features/combobox/index.d.ts +2 -2
- package/dist/features/comments/BaseCommentsPlugin.js +33 -17
- package/dist/features/comments/index.d.ts +1 -1
- package/dist/features/date/index.d.ts +3 -2
- package/dist/features/details/index.d.ts +3 -2
- package/dist/features/details/lib/BaseDetailsPlugin.js +25 -12
- package/dist/features/field/index.d.ts +2 -0
- package/dist/features/field/index.js +4 -0
- package/dist/features/field/lib/BaseFieldPlugin.js +360 -0
- package/dist/features/field/lib/applyFieldValues.js +188 -0
- package/dist/features/field/lib/fieldRules.internal.js +204 -0
- package/dist/features/find/index.d.ts +3 -2
- package/dist/features/footnote/index.d.ts +1 -1
- package/dist/features/ink/index.d.ts +1 -1
- package/dist/features/ink/lib/BaseInkPlugin.js +126 -103
- package/dist/features/ink/lib/inkCodec.internal.js +130 -0
- package/dist/features/ink/lib/inkGone.internal.js +229 -48
- package/dist/features/ink/lib/inkPlaces.internal.js +534 -64
- package/dist/features/layout/index.d.ts +1 -1
- package/dist/features/link/lib/BaseLinkPlugin.js +6 -4
- package/dist/features/lint/index.d.ts +3 -2
- package/dist/features/media/index.d.ts +2 -2
- package/dist/features/media/index.js +2 -2
- package/dist/features/media/lib/media/parseMediaUrl.js +11 -1
- package/dist/features/media/lib/media-embed/BaseMediaEmbedPlugin.js +206 -4
- package/dist/features/mention/index.d.ts +5 -4
- package/dist/features/suggestion/index.d.ts +1 -1
- package/dist/features/table/index.d.ts +1 -1
- package/dist/features/table/lib/BaseTablePlugin.js +64 -15
- package/dist/features/table/lib/internal/selection.js +4 -2
- package/dist/features/toc/index.d.ts +1 -1
- package/dist/features/upload/index.d.ts +2 -2
- package/dist/features/upload/lib/BaseUploadPlugin.js +464 -250
- package/dist/history/index.d.ts +2 -2
- package/dist/html/index.d.ts +3 -3
- package/dist/html/server/index.d.ts +1 -1
- package/dist/{htmlTypes-DjeFG3P8.d.ts → htmlTypes-eT2ZGDAj.d.ts} +2 -31
- package/dist/hyperscript/index.d.ts +1 -1
- package/dist/{index-DzD6BIFJ.d.ts → index-B33E1CRJ.d.ts} +295 -6
- package/dist/{index-Cl77E9yr.d.ts → index-B7moSod7.d.ts} +2 -2
- package/dist/{index-hsC_sOn2.d.ts → index-B8-5Sr7I.d.ts} +35 -5
- package/dist/{index-BiQerPJS.d.ts → index-B8QJDAmG.d.ts} +2 -2
- package/dist/{index-BBKGrsG3.d.ts → index-BTx5oK7k.d.ts} +1 -1
- package/dist/{index-iaZOhA76.d.ts → index-BWPcE4ac-Cto_IsNs.d.ts} +7 -1
- package/dist/{index-BU6k1Aev.d.ts → index-BXjLmx1n-CXk17buG.d.ts} +4781 -4584
- package/dist/{index-kLKMc-pI.d.ts → index-BXwU9QH6.d.ts} +2 -2
- package/dist/{index-DTgaSxKr.d.ts → index-BkwR-5hH.d.ts} +40 -4
- package/dist/{index-Bq3sdm3S.d.ts → index-BsV2McRr.d.ts} +5 -4
- package/dist/index-C9Fu-P4E.d.ts +773 -0
- package/dist/{index-D5W-p9bS.d.ts → index-Ca48r1ng.d.ts} +49 -4
- package/dist/{index-CcZbqPqk.d.ts → index-Cob_iBdu.d.ts} +116 -41
- package/dist/{index-Bxfvicyy.d.ts → index-CpY7Xnxw.d.ts} +4 -3
- package/dist/{index-BkR7-GLI.d.ts → index-DNQXzU-X.d.ts} +2 -2
- package/dist/{index-D1CFXA-i.d.ts → index-DPowErHa.d.ts} +471 -141
- package/dist/{index-DaM37gF6.d.ts → index-DShbzec2.d.ts} +38 -23
- package/dist/{index-DC_MNGyu.d.ts → index-DYdObeFQ.d.ts} +3 -3
- package/dist/{index-Bc2Yg_2j.d.ts → index-Dq3Jlj8O-BJ6NxZm0.d.ts} +2 -2
- package/dist/{index-CT7miqQN.d.ts → index-DwWQVwQt.d.ts} +29 -11
- package/dist/{index-xdmCBvlT.d.ts → index-JWgwL5l3.d.ts} +5 -2
- package/dist/{index-DLA2DUR2.d.ts → index-M781pyx9.d.ts} +4 -3
- package/dist/{index-DdIRduDG.d.ts → index-d7io3MzC.d.ts} +3 -2
- package/dist/index.d.ts +4 -4
- package/dist/{react/internal → internal}/penStroke.internal.js +1 -1
- package/dist/internal/plugin/OverridePlugin.js +101 -119
- package/dist/internal/plugin/collectPlateNodeMappings.js +5 -1
- package/dist/internal/plugin/pastedUploadFiles.js +4 -0
- package/dist/internal/plugin/resolvePlugin.js +1 -1
- package/dist/internal/plugin/resolvePlugins.js +3 -0
- package/dist/internal/plugin/uploadDrafts.js +6 -0
- package/dist/internal/utils/mergePlugins.js +1 -0
- package/dist/lib/plugins/element-id/ElementIdPlugin.js +14 -18
- package/dist/lib/plugins/html/HtmlPlugin.js +9 -0
- package/dist/lib/plugins/html/htmlSafety.js +1 -1
- package/dist/lib/plugins/input-rules/InputRulesPlugin.js +77 -28
- package/dist/lib/plugins/input-rules/inputRuleVeto.internal.js +16 -0
- package/dist/markdown/index.d.ts +2 -2
- package/dist/markdown/index.js +3 -1
- package/dist/markdown/lib/MarkdownPlugin.js +14 -11
- package/dist/markdown/lib/RawHtmlPlugin.js +26 -0
- package/dist/markdown/lib/deserializer/mdastToSlate.js +12 -2
- package/dist/markdown/lib/internal/markdownConversion.js +776 -74
- package/dist/markdown/lib/internal/markdownDiagnostics.js +18 -7
- package/dist/markdown/lib/internal/markdownFootnoteWriter.js +35 -0
- package/dist/markdown/lib/internal/markdownFrontmatter.js +102 -0
- package/dist/markdown/lib/internal/markdownIntrinsics.js +125 -43
- package/dist/markdown/lib/internal/markdownLine.js +5 -3
- package/dist/markdown/lib/internal/markdownMappings.js +19 -7
- package/dist/markdown/lib/internal/markdownOpenTail.js +381 -0
- package/dist/markdown/lib/internal/markdownRawHtml.js +353 -0
- package/dist/markdown/lib/internal/markdownSegments.js +57 -48
- package/dist/markdown/lib/internal/markdownTags.js +29 -9
- package/dist/markdown/lib/serializer/convertNodesSerialize.js +10 -8
- package/dist/markdown/lib/serializer/convertPhrasingSerialize.js +226 -0
- package/dist/markdown/lib/serializer/listToMdastTree.js +2 -0
- package/dist/math/index.d.ts +3 -2
- package/dist/math/react/index.d.ts +4 -3
- package/dist/migrations/index.d.ts +3 -3
- package/dist/migrations/migratePlateV54.js +4 -6
- package/dist/migrations/migratePlateV54RetiredMarks.internal.js +23 -8
- package/dist/migrations/migratePlateV54Suggestions.internal.js +2 -2
- package/dist/migrations/v53-manifest.internal.js +4 -0
- package/dist/pagination/index.d.ts +1 -1
- package/dist/pagination/react/index.d.ts +4 -4
- package/dist/react/components/EditorContentView.internal.js +42 -23
- package/dist/react/components/EditorProvider.js +5 -5
- package/dist/react/components/Plate.js +102 -128
- package/dist/react/components/PlateContainer.js +40 -32
- package/dist/react/components/PlateController.js +28 -16
- package/dist/react/components/PlateRoot.internal.js +3 -2
- package/dist/react/core.js +4 -4
- package/dist/react/features/board/BoardSurface.js +116 -87
- package/dist/react/features/board/boardClipboard.internal.js +15 -5
- package/dist/react/features/board/boardExport.internal.js +470 -0
- package/dist/react/features/board/boardGesture.internal.js +6 -3
- package/dist/react/features/board/boardIndex.internal.js +7 -18
- package/dist/react/features/board/boardPictureStyles.internal.js +415 -0
- package/dist/react/features/board/boardPictures.internal.js +19 -13
- package/dist/react/features/board/boardView.internal.js +190 -50
- package/dist/react/features/board/boardVoice.internal.js +10 -11
- package/dist/react/features/board/index.d.ts +108 -18
- package/dist/react/features/callout/index.d.ts +3 -2
- package/dist/react/features/combobox/index.d.ts +8 -8
- package/dist/react/features/comments/index.d.ts +6 -5
- package/dist/react/features/date/index.d.ts +4 -3
- package/dist/react/features/details/index.d.ts +4 -3
- package/dist/react/features/field/FieldPlugin.js +35 -0
- package/dist/react/features/field/index.d.ts +315 -0
- package/dist/react/features/field/index.js +2 -0
- package/dist/react/features/footnote/index.d.ts +7 -6
- package/dist/react/features/format-painter/index.d.ts +4 -3
- package/dist/react/features/ink/InkContent.js +313 -0
- package/dist/react/features/ink/index.d.ts +57 -33
- package/dist/react/features/ink/index.js +2 -2
- package/dist/react/features/ink/inkCapture.internal.js +39 -17
- package/dist/react/features/ink/inkInput.internal.js +1 -1
- package/dist/react/features/ink/inkLayout.internal.js +6 -3
- package/dist/react/features/ink/inkPaint.internal.js +78 -2
- package/dist/react/features/ink/inkPlacement.internal.js +332 -104
- package/dist/react/features/ink/inkWatch.internal.js +7 -5
- package/dist/react/features/layout/index.d.ts +5 -4
- package/dist/react/features/media/index.d.ts +5 -4
- package/dist/react/features/mention/index.d.ts +6 -5
- package/dist/react/features/resizable/Resizable.js +4 -6
- package/dist/react/features/resizable/index.d.ts +5 -5
- package/dist/react/features/suggestion/index.d.ts +6 -5
- package/dist/react/features/table/TablePlugin.js +4 -11
- package/dist/react/features/table/index.d.ts +10 -8
- package/dist/react/features/table/useTableResize.js +10 -1
- package/dist/react/features/toc/index.d.ts +2 -2
- package/dist/react/features/upload/index.d.ts +11 -6
- package/dist/react/index.d.ts +6 -6
- package/dist/react/index.js +4 -4
- package/dist/react/internal/plate-context.js +434 -188
- package/dist/react/plite-react.js +2 -2
- package/dist/react/plugins/navigation-feedback/NavigationFeedbackPlugin.js +12 -10
- package/dist/react/stores/plate/useEditor.js +32 -14
- package/dist/react/stores/plate/useEditorHistory.js +55 -0
- package/dist/react/stores/plate/useEditorSelector.js +79 -21
- package/dist/react/utils/BlockPlaceholderPlugin.js +5 -2
- package/dist/react/utils/pipeRenderElement.internal.js +1 -1
- package/dist/react/utils/pluginRenderElement.internal.js +1 -1
- package/dist/react/virtualized.d.ts +4 -4
- package/dist/{source-CNKy99Th.d.ts → source-BGohy8vH.d.ts} +4 -4
- package/dist/static/index.d.ts +18 -18
- package/dist/static/internal/renderStaticHtmlWithOverrides.js +2 -2
- package/dist/static/internal/staticPresentation.js +4 -4
- package/dist/static/internal/writeStaticSelectionClipboardData.js +7 -2
- package/dist/tabbable/index.d.ts +1 -1
- package/dist/tabbable/react/index.d.ts +3 -3
- package/dist/testing/index.d.ts +3 -3
- package/dist/yjs/index.d.ts +1 -1
- package/dist/yjs/react/index.d.ts +6 -6
- package/package.json +20 -2
- package/dist/markdown/lib/serializer/convertTextsSerialize.js +0 -163
- package/dist/react/components/EditorSelectionView.js +0 -40
- package/dist/react/features/ink/InkLayer.js +0 -218
- package/dist/react/internal/createPlateTargetScope.js +0 -62
|
@@ -0,0 +1,415 @@
|
|
|
1
|
+
//#region src/react/features/board/boardPictureStyles.internal.ts
|
|
2
|
+
const SVG_NS = "http://www.w3.org/2000/svg";
|
|
3
|
+
const XHTML_NS = "http://www.w3.org/1999/xhtml";
|
|
4
|
+
const PSEUDO = "data-board-picture-pseudo";
|
|
5
|
+
const CURRENT_COLOR = "rgb(1, 2, 3)";
|
|
6
|
+
const PLACEMENT = /* @__PURE__ */ new Set([
|
|
7
|
+
"left",
|
|
8
|
+
"position",
|
|
9
|
+
"top",
|
|
10
|
+
"translate"
|
|
11
|
+
]);
|
|
12
|
+
const SAME_IN_COPY = /* @__PURE__ */ new Set([
|
|
13
|
+
"color",
|
|
14
|
+
"fill",
|
|
15
|
+
"stroke"
|
|
16
|
+
]);
|
|
17
|
+
const SHORTHANDS = [[/^font-variant-/u, "font-variant"], [/^(white-space-collapse|text-wrap-mode)$/u, "white-space"]];
|
|
18
|
+
const presentedAs = (name) => SHORTHANDS.find(([longhand]) => longhand.test(name))?.[1] ?? name;
|
|
19
|
+
const FLEX = /* @__PURE__ */ new Set(["flex", "inline-flex"]);
|
|
20
|
+
const LOGICAL = /(^|-)(block|inline)(-|$)|(start|end)-(start|end)-radius$/u;
|
|
21
|
+
const SIDE = /^(border-(?:top|right|bottom|left)|outline|column-rule)-(style|width|color)$/u;
|
|
22
|
+
const DEPENDS = /* @__PURE__ */ new Map([["perspective-origin", ["perspective"]], ["transform-origin", [
|
|
23
|
+
"offset-path",
|
|
24
|
+
"rotate",
|
|
25
|
+
"scale",
|
|
26
|
+
"transform",
|
|
27
|
+
"translate"
|
|
28
|
+
]]]);
|
|
29
|
+
const INHERITED = /* @__PURE__ */ new Set([
|
|
30
|
+
"-moz-osx-font-smoothing",
|
|
31
|
+
"-moz-text-size-adjust",
|
|
32
|
+
"-webkit-border-horizontal-spacing",
|
|
33
|
+
"-webkit-border-vertical-spacing",
|
|
34
|
+
"-webkit-font-smoothing",
|
|
35
|
+
"-webkit-hyphenate-character",
|
|
36
|
+
"-webkit-line-break",
|
|
37
|
+
"-webkit-locale",
|
|
38
|
+
"-webkit-print-color-adjust",
|
|
39
|
+
"-webkit-rtl-ordering",
|
|
40
|
+
"-webkit-tap-highlight-color",
|
|
41
|
+
"-webkit-text-combine",
|
|
42
|
+
"-webkit-text-decorations-in-effect",
|
|
43
|
+
"-webkit-text-emphasis-color",
|
|
44
|
+
"-webkit-text-emphasis-position",
|
|
45
|
+
"-webkit-text-emphasis-style",
|
|
46
|
+
"-webkit-text-fill-color",
|
|
47
|
+
"-webkit-text-orientation",
|
|
48
|
+
"-webkit-text-security",
|
|
49
|
+
"-webkit-text-size-adjust",
|
|
50
|
+
"-webkit-text-stroke-color",
|
|
51
|
+
"-webkit-text-stroke-width",
|
|
52
|
+
"-webkit-text-zoom",
|
|
53
|
+
"-webkit-touch-callout",
|
|
54
|
+
"-webkit-user-modify",
|
|
55
|
+
"-webkit-writing-mode",
|
|
56
|
+
"accent-color",
|
|
57
|
+
"border-collapse",
|
|
58
|
+
"border-spacing",
|
|
59
|
+
"caption-side",
|
|
60
|
+
"caret-color",
|
|
61
|
+
"clip-rule",
|
|
62
|
+
"color",
|
|
63
|
+
"color-interpolation",
|
|
64
|
+
"color-interpolation-filters",
|
|
65
|
+
"color-rendering",
|
|
66
|
+
"color-scheme",
|
|
67
|
+
"cursor",
|
|
68
|
+
"direction",
|
|
69
|
+
"dominant-baseline",
|
|
70
|
+
"dynamic-range-limit",
|
|
71
|
+
"empty-cells",
|
|
72
|
+
"fill",
|
|
73
|
+
"fill-opacity",
|
|
74
|
+
"fill-rule",
|
|
75
|
+
"font-family",
|
|
76
|
+
"font-feature-settings",
|
|
77
|
+
"font-kerning",
|
|
78
|
+
"font-language-override",
|
|
79
|
+
"font-optical-sizing",
|
|
80
|
+
"font-palette",
|
|
81
|
+
"font-size",
|
|
82
|
+
"font-size-adjust",
|
|
83
|
+
"font-stretch",
|
|
84
|
+
"font-style",
|
|
85
|
+
"font-synthesis-position",
|
|
86
|
+
"font-synthesis-small-caps",
|
|
87
|
+
"font-synthesis-style",
|
|
88
|
+
"font-synthesis-weight",
|
|
89
|
+
"font-variant-alternates",
|
|
90
|
+
"font-variant-caps",
|
|
91
|
+
"font-variant-east-asian",
|
|
92
|
+
"font-variant-emoji",
|
|
93
|
+
"font-variant-ligatures",
|
|
94
|
+
"font-variant-numeric",
|
|
95
|
+
"font-variant-position",
|
|
96
|
+
"font-variation-settings",
|
|
97
|
+
"font-weight",
|
|
98
|
+
"font-width",
|
|
99
|
+
"forced-color-adjust",
|
|
100
|
+
"glyph-orientation-horizontal",
|
|
101
|
+
"glyph-orientation-vertical",
|
|
102
|
+
"hyphenate-character",
|
|
103
|
+
"hyphenate-limit-chars",
|
|
104
|
+
"hyphens",
|
|
105
|
+
"image-orientation",
|
|
106
|
+
"image-rendering",
|
|
107
|
+
"interactivity",
|
|
108
|
+
"kerning",
|
|
109
|
+
"letter-spacing",
|
|
110
|
+
"line-break",
|
|
111
|
+
"line-height",
|
|
112
|
+
"list-style-image",
|
|
113
|
+
"list-style-position",
|
|
114
|
+
"list-style-type",
|
|
115
|
+
"marker-end",
|
|
116
|
+
"marker-mid",
|
|
117
|
+
"marker-start",
|
|
118
|
+
"math-depth",
|
|
119
|
+
"math-shift",
|
|
120
|
+
"math-style",
|
|
121
|
+
"orphans",
|
|
122
|
+
"overflow-wrap",
|
|
123
|
+
"paint-order",
|
|
124
|
+
"pointer-events",
|
|
125
|
+
"print-color-adjust",
|
|
126
|
+
"quotes",
|
|
127
|
+
"ruby-align",
|
|
128
|
+
"ruby-overhang",
|
|
129
|
+
"ruby-position",
|
|
130
|
+
"shape-rendering",
|
|
131
|
+
"speak",
|
|
132
|
+
"speak-as",
|
|
133
|
+
"stroke",
|
|
134
|
+
"stroke-dasharray",
|
|
135
|
+
"stroke-dashoffset",
|
|
136
|
+
"stroke-linecap",
|
|
137
|
+
"stroke-linejoin",
|
|
138
|
+
"stroke-miterlimit",
|
|
139
|
+
"stroke-opacity",
|
|
140
|
+
"stroke-width",
|
|
141
|
+
"tab-size",
|
|
142
|
+
"text-align",
|
|
143
|
+
"text-align-last",
|
|
144
|
+
"text-anchor",
|
|
145
|
+
"text-autospace",
|
|
146
|
+
"text-combine-upright",
|
|
147
|
+
"text-decoration-skip-ink",
|
|
148
|
+
"text-emphasis-color",
|
|
149
|
+
"text-emphasis-position",
|
|
150
|
+
"text-emphasis-style",
|
|
151
|
+
"text-indent",
|
|
152
|
+
"text-justify",
|
|
153
|
+
"text-orientation",
|
|
154
|
+
"text-rendering",
|
|
155
|
+
"text-shadow",
|
|
156
|
+
"text-size-adjust",
|
|
157
|
+
"text-spacing-trim",
|
|
158
|
+
"text-transform",
|
|
159
|
+
"text-underline-offset",
|
|
160
|
+
"text-underline-position",
|
|
161
|
+
"text-wrap",
|
|
162
|
+
"text-wrap-mode",
|
|
163
|
+
"text-wrap-style",
|
|
164
|
+
"visibility",
|
|
165
|
+
"white-space",
|
|
166
|
+
"white-space-collapse",
|
|
167
|
+
"widows",
|
|
168
|
+
"word-break",
|
|
169
|
+
"word-spacing",
|
|
170
|
+
"word-wrap",
|
|
171
|
+
"writing-mode"
|
|
172
|
+
]);
|
|
173
|
+
const PICTURE_ROOT = "data-board-picture-root";
|
|
174
|
+
const familyKey = (family) => family.trim().replace(/^["']|["']$/gu, "").toLowerCase();
|
|
175
|
+
const familiesOf = (value) => value.match(/(?:"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|[^,])+/gu)?.map(familyKey) ?? [];
|
|
176
|
+
const applies = (media) => !media?.mediaText || matchMedia(media.mediaText).matches;
|
|
177
|
+
const sheetRulesOf = (sheet) => {
|
|
178
|
+
if (!sheet || sheet.disabled || !applies(sheet.media)) return [];
|
|
179
|
+
try {
|
|
180
|
+
return [...sheet.cssRules];
|
|
181
|
+
} catch {
|
|
182
|
+
return [];
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
const appliedRulesOf = (rules) => rules.flatMap((rule) => {
|
|
186
|
+
if (typeof CSSImportRule !== "undefined" && rule instanceof CSSImportRule) return appliedRulesOf(sheetRulesOf(rule.styleSheet));
|
|
187
|
+
if (rule instanceof CSSMediaRule ? !matchMedia(rule.conditionText).matches : rule instanceof CSSSupportsRule && !CSS.supports(rule.conditionText)) return [];
|
|
188
|
+
return "cssRules" in rule ? [rule, ...appliedRulesOf([...rule.cssRules])] : [rule];
|
|
189
|
+
});
|
|
190
|
+
/**
|
|
191
|
+
* The hidden iframe the style copy compares with. It joins the picture host in
|
|
192
|
+
* the same append as the drawings and leaves with them. It hides through
|
|
193
|
+
* `visibility`, because Firefox lists no computed property inside an iframe
|
|
194
|
+
* with `display: none`.
|
|
195
|
+
*/
|
|
196
|
+
const pictureFrameOf = (document) => {
|
|
197
|
+
const frame = document.createElement("iframe");
|
|
198
|
+
frame.setAttribute("style", "position: fixed; left: 0px; top: 0px; width: 0px; height: 0px; border: 0px; visibility: hidden;");
|
|
199
|
+
return frame;
|
|
200
|
+
};
|
|
201
|
+
const lifted = (name, value) => {
|
|
202
|
+
const size = Number.parseFloat(value);
|
|
203
|
+
return (name === "width" || name === "height") && size > 0 && value.endsWith("px") ? `${size + .75 * 10 ** (Math.floor(Math.log10(size)) - 5)}px` : value;
|
|
204
|
+
};
|
|
205
|
+
/**
|
|
206
|
+
* Reads, while the drawings and `frame` sit in `host`, the styles that each
|
|
207
|
+
* element under `roots` needs in a saved SVG under the sheet's reset, and each
|
|
208
|
+
* root's `left` and `top`, which place it in the picture.
|
|
209
|
+
*/
|
|
210
|
+
const readPictureStyles = (frame, host, roots) => {
|
|
211
|
+
const document = host.ownerDocument;
|
|
212
|
+
const view = frame.contentWindow;
|
|
213
|
+
if (!view) throw new Error("The picture frame has no window.");
|
|
214
|
+
const inner = view.document;
|
|
215
|
+
const start = inner.createElement("span");
|
|
216
|
+
const shapes = inner.createElementNS(SVG_NS, "svg");
|
|
217
|
+
const copies = /* @__PURE__ */ new Map();
|
|
218
|
+
const copyOf = /* @__PURE__ */ new Map();
|
|
219
|
+
start.setAttribute("style", `all: initial; color: ${CURRENT_COLOR};`);
|
|
220
|
+
for (const root of roots) for (const element of [root, ...root.querySelectorAll("*")]) {
|
|
221
|
+
if (element.namespaceURI !== SVG_NS) continue;
|
|
222
|
+
const shallow = inner.importNode(element, false);
|
|
223
|
+
shallow.removeAttribute("style");
|
|
224
|
+
const key = shallow.outerHTML;
|
|
225
|
+
let copy = copies.get(key);
|
|
226
|
+
if (!copy) {
|
|
227
|
+
copy = shallow;
|
|
228
|
+
copies.set(key, copy);
|
|
229
|
+
shapes.append(copy);
|
|
230
|
+
}
|
|
231
|
+
copyOf.set(element, copy);
|
|
232
|
+
}
|
|
233
|
+
inner.body.append(start, shapes);
|
|
234
|
+
const initial = view.getComputedStyle(start);
|
|
235
|
+
const names = Array.from({ length: initial.length }, (_, at) => initial.item(at));
|
|
236
|
+
const indexOf = new Map(names.map((name, at) => [name, at]));
|
|
237
|
+
const valuesOf = (style) => names.map((name) => style.getPropertyValue(name));
|
|
238
|
+
const startValues = valuesOf(initial);
|
|
239
|
+
const reference = new Map([...copies.values()].map((copy) => [copy, valuesOf(view.getComputedStyle(copy))]));
|
|
240
|
+
const hostValues = valuesOf(getComputedStyle(host));
|
|
241
|
+
const aboveValues = valuesOf(getComputedStyle(host.parentElement ?? host));
|
|
242
|
+
const fromHost = names.map((_, at) => hostValues[at] !== aboveValues[at]);
|
|
243
|
+
const logical = names.map((name) => LOGICAL.test(name));
|
|
244
|
+
const inherited = names.map((name) => INHERITED.has(name));
|
|
245
|
+
const sideOf = names.map((name) => {
|
|
246
|
+
const side = SIDE.exec(name)?.[1];
|
|
247
|
+
return side === void 0 ? null : [indexOf.get(`${side}-width`), indexOf.get(`${side}-style`)];
|
|
248
|
+
});
|
|
249
|
+
const dependsOn = names.map((name) => DEPENDS.get(name)?.flatMap((other) => indexOf.get(other) ?? []));
|
|
250
|
+
const color = indexOf.get("color") ?? -1;
|
|
251
|
+
const display = indexOf.get("display") ?? -1;
|
|
252
|
+
const samples = /* @__PURE__ */ new Map();
|
|
253
|
+
const unsure = [];
|
|
254
|
+
const styles = [];
|
|
255
|
+
const pseudos = [];
|
|
256
|
+
const offsets = /* @__PURE__ */ new Map();
|
|
257
|
+
const writtenOf = (values, parent, placed, copy) => {
|
|
258
|
+
const base = (copy && reference.get(copy)) ?? startValues;
|
|
259
|
+
const written = [];
|
|
260
|
+
values.forEach((value, at) => {
|
|
261
|
+
const name = names[at];
|
|
262
|
+
if (value === "" || logical[at]) return;
|
|
263
|
+
const [width = -1, style = -1] = sideOf[at] ?? [];
|
|
264
|
+
if (sideOf[at] && values[style] !== "hidden" && (values[width] === "0px" || values[style] === "none")) return;
|
|
265
|
+
const depends = dependsOn[at];
|
|
266
|
+
if (depends) {
|
|
267
|
+
if (!depends.every((other) => values[other] === "none")) written.push([name, value]);
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
if (value !== startValues[at] && !samples.has(at)) samples.set(at, value);
|
|
271
|
+
if (inherited[at]) {
|
|
272
|
+
if (placed && at === color) {
|
|
273
|
+
written.push([name, value]);
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
if (placed && fromHost[at] && value === hostValues[at]) return;
|
|
277
|
+
const follows = at !== color && value === values[color];
|
|
278
|
+
const attribute = copy?.getAttribute(name) ?? copy?.getAttribute(presentedAs(name));
|
|
279
|
+
if (attribute !== null && attribute !== void 0) {
|
|
280
|
+
const keyword = attribute.trim().toLowerCase();
|
|
281
|
+
let from = base[at];
|
|
282
|
+
if (keyword === "currentcolor") from = at === color ? parent[at] : values[color];
|
|
283
|
+
if (keyword === "inherit") from = parent[at];
|
|
284
|
+
if (!SAME_IN_COPY.has(name) || value !== from) written.push([name, follows ? "currentcolor" : value]);
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
if (at === color) {
|
|
288
|
+
if (parent[at] !== value) written.push([name, value]);
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
const parentFollows = parent[at] === parent[color];
|
|
292
|
+
if (follows ? !parentFollows : parentFollows || parent[at] !== value) written.push([name, follows ? "currentcolor" : value]);
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
295
|
+
if (value !== (startValues[at] === CURRENT_COLOR ? values[color] : base[at]) || sideOf[at] && name.endsWith("-width")) written.push([name, value]);
|
|
296
|
+
else if (parent[at] !== value) unsure.push([
|
|
297
|
+
written,
|
|
298
|
+
at,
|
|
299
|
+
value
|
|
300
|
+
]);
|
|
301
|
+
});
|
|
302
|
+
return written;
|
|
303
|
+
};
|
|
304
|
+
const visit = (element, parent, placed) => {
|
|
305
|
+
const style = getComputedStyle(element);
|
|
306
|
+
const values = valuesOf(style);
|
|
307
|
+
const html = element.namespaceURI !== SVG_NS;
|
|
308
|
+
const copy = copyOf.get(element);
|
|
309
|
+
if (placed) offsets.set(element, {
|
|
310
|
+
left: Number.parseFloat(style.getPropertyValue("left")) || 0,
|
|
311
|
+
top: Number.parseFloat(style.getPropertyValue("top")) || 0
|
|
312
|
+
});
|
|
313
|
+
styles.push([
|
|
314
|
+
element,
|
|
315
|
+
writtenOf(values, parent, placed, copy),
|
|
316
|
+
FLEX.has(parent[display] ?? "")
|
|
317
|
+
]);
|
|
318
|
+
if (html) {
|
|
319
|
+
const kinds = values[display]?.includes("list-item") ? [
|
|
320
|
+
"::before",
|
|
321
|
+
"::after",
|
|
322
|
+
"::marker"
|
|
323
|
+
] : ["::before", "::after"];
|
|
324
|
+
for (const pseudo of kinds) {
|
|
325
|
+
const generated = getComputedStyle(element, pseudo);
|
|
326
|
+
if (pseudo !== "::marker" && /^(none|normal|)$/u.test(generated.getPropertyValue("content"))) continue;
|
|
327
|
+
pseudos.push([
|
|
328
|
+
element,
|
|
329
|
+
pseudo,
|
|
330
|
+
writtenOf(valuesOf(generated), values, false)
|
|
331
|
+
]);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
for (const child of element.children) visit(child, values, false);
|
|
335
|
+
};
|
|
336
|
+
for (const root of roots) visit(root, startValues, true);
|
|
337
|
+
const tested = [...new Set(unsure.map(([, at]) => at))].filter((at) => samples.has(at));
|
|
338
|
+
if (tested.length > 0) {
|
|
339
|
+
const given = inner.createElement("div");
|
|
340
|
+
const child = inner.createElement("span");
|
|
341
|
+
given.setAttribute("style", ["all: initial;", ...tested.map((at) => `${names[at]}: ${samples.get(at)};`)].join(" "));
|
|
342
|
+
child.setAttribute("style", "all: unset; color: rgb(4, 5, 6);");
|
|
343
|
+
given.append(child);
|
|
344
|
+
inner.body.append(given);
|
|
345
|
+
const outer = view.getComputedStyle(given);
|
|
346
|
+
const taken = view.getComputedStyle(child);
|
|
347
|
+
const inherits = new Set(tested.filter((at) => {
|
|
348
|
+
const value = outer.getPropertyValue(names[at]);
|
|
349
|
+
return value !== startValues[at] && taken.getPropertyValue(names[at]) === value;
|
|
350
|
+
}));
|
|
351
|
+
for (const [written, at, value] of unsure) if (inherits.has(at)) written.push([names[at], value]);
|
|
352
|
+
}
|
|
353
|
+
const declarations = [...styles.map(([, written]) => written), ...pseudos.map((row) => row[2])].flat();
|
|
354
|
+
const valuesNamed = (wanted) => declarations.flatMap(([name, value]) => name === wanted ? [value] : []);
|
|
355
|
+
const applied = appliedRulesOf([...document.styleSheets].flatMap(sheetRulesOf));
|
|
356
|
+
const families = new Set(valuesNamed("font-family").flatMap(familiesOf));
|
|
357
|
+
const counterRules = new Map(applied.flatMap((rule) => typeof CSSCounterStyleRule !== "undefined" && rule instanceof CSSCounterStyleRule ? [[rule.name, rule]] : []));
|
|
358
|
+
const counters = /* @__PURE__ */ new Map();
|
|
359
|
+
const counterNames = valuesNamed("list-style-type");
|
|
360
|
+
for (const name of counterNames) {
|
|
361
|
+
const rule = counterRules.get(name);
|
|
362
|
+
if (!rule || counters.has(name)) continue;
|
|
363
|
+
counters.set(name, rule.cssText);
|
|
364
|
+
const extended = /^extends\s+(\S+)/u.exec(rule.system)?.[1];
|
|
365
|
+
counterNames.push(rule.fallback, ...extended ? [extended] : []);
|
|
366
|
+
}
|
|
367
|
+
return {
|
|
368
|
+
faces: applied.flatMap((rule) => rule instanceof CSSFontFaceRule && families.has(familyKey(rule.style.getPropertyValue("font-family"))) ? [{
|
|
369
|
+
base: rule.parentStyleSheet?.href ?? document.baseURI,
|
|
370
|
+
css: rule.cssText
|
|
371
|
+
}] : []),
|
|
372
|
+
offsets,
|
|
373
|
+
/**
|
|
374
|
+
* Replaces each element's style attribute with what it needs, once the
|
|
375
|
+
* drawings left the host, and returns the counter styles and the
|
|
376
|
+
* pseudo-element rules for the picture's sheet.
|
|
377
|
+
*/
|
|
378
|
+
write: (srgb, nonce) => {
|
|
379
|
+
for (const [element, written, flexItem] of styles) {
|
|
380
|
+
element.removeAttribute("style");
|
|
381
|
+
for (const [name, value] of written) {
|
|
382
|
+
if (offsets.has(element) && PLACEMENT.has(name)) continue;
|
|
383
|
+
element.style.setProperty(name, srgb(lifted(name, value)));
|
|
384
|
+
}
|
|
385
|
+
if (flexItem) element.style.setProperty("flex", "0 0 auto");
|
|
386
|
+
}
|
|
387
|
+
const ids = /* @__PURE__ */ new Map();
|
|
388
|
+
const rules = pseudos.flatMap(([element, pseudo, written]) => {
|
|
389
|
+
const kept = pseudo === "::marker" ? written.filter(([name]) => name === "content" || name === "unicode-bidi" || INHERITED.has(name)) : written;
|
|
390
|
+
if (kept.length === 0) return [];
|
|
391
|
+
let id = ids.get(element);
|
|
392
|
+
if (id === void 0) {
|
|
393
|
+
id = String(ids.size);
|
|
394
|
+
ids.set(element, id);
|
|
395
|
+
element.setAttribute(PSEUDO, id);
|
|
396
|
+
}
|
|
397
|
+
return [`[${PICTURE_ROOT}="${nonce}"] [${PSEUDO}="${id}"]${pseudo} { ${kept.map(([name, value]) => `${name}: ${srgb(lifted(name, value))};`).join(" ")} }`];
|
|
398
|
+
});
|
|
399
|
+
return [...counters.values(), ...rules];
|
|
400
|
+
}
|
|
401
|
+
};
|
|
402
|
+
};
|
|
403
|
+
/**
|
|
404
|
+
* A browser ignores an `@namespace` rule that follows any rule other than
|
|
405
|
+
* `@charset` or `@import`, so it comes first, and `all` leaves out `direction`
|
|
406
|
+
* and `unicode-bidi`, so the reset names them.
|
|
407
|
+
*/
|
|
408
|
+
const pictureSheetOf = (nonce, faces, rules) => [
|
|
409
|
+
`@namespace h url(${XHTML_NS});`,
|
|
410
|
+
`[${PICTURE_ROOT}="${nonce}"] h|* { all: unset; direction: unset; unicode-bidi: unset; }`,
|
|
411
|
+
...faces,
|
|
412
|
+
...rules
|
|
413
|
+
].join("\n");
|
|
414
|
+
//#endregion
|
|
415
|
+
export { PICTURE_ROOT, pictureFrameOf, pictureSheetOf, readPictureStyles };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { subscribeEditorViewState } from "../../../facade.js";
|
|
2
|
+
import "../../../internal/plugin/uploadDrafts.js";
|
|
2
3
|
import { activeElementOf } from "./boardVoice.internal.js";
|
|
3
4
|
//#region src/react/features/board/boardPictures.internal.ts
|
|
4
5
|
const LONGEST_SIDE = 480;
|
|
@@ -14,19 +15,21 @@ const fit = ({ naturalHeight, naturalWidth }) => {
|
|
|
14
15
|
width: naturalWidth * scale
|
|
15
16
|
};
|
|
16
17
|
};
|
|
17
|
-
const createPendingPictures = ({ editor,
|
|
18
|
+
const createPendingPictures = ({ editor, shapes, writable }) => {
|
|
18
19
|
let stop = null;
|
|
19
20
|
const cancel = () => {
|
|
20
21
|
const held = stop;
|
|
21
22
|
stop = null;
|
|
22
23
|
held?.();
|
|
23
24
|
};
|
|
24
|
-
const load = (host,
|
|
25
|
+
const load = (host, sources, loaded) => {
|
|
25
26
|
cancel();
|
|
26
27
|
const view = host.ownerDocument.defaultView;
|
|
27
28
|
if (!view) return;
|
|
28
|
-
const
|
|
29
|
-
const
|
|
29
|
+
const urls = sources.map((source) => typeof source === "string" ? source : view.URL.createObjectURL(source));
|
|
30
|
+
const sizes = sources.map(() => void 0);
|
|
31
|
+
const images = sources.map(() => new view.Image());
|
|
32
|
+
let failed = false;
|
|
30
33
|
const drop = () => {
|
|
31
34
|
if (stop === halt) cancel();
|
|
32
35
|
};
|
|
@@ -35,13 +38,13 @@ const createPendingPictures = ({ editor, mounted, writable }) => {
|
|
|
35
38
|
sizes[at] = size;
|
|
36
39
|
if (sizes.includes(void 0)) return;
|
|
37
40
|
cancel();
|
|
38
|
-
loaded(
|
|
39
|
-
element,
|
|
40
|
-
size: sizes[index] ?? UNLOADED
|
|
41
|
-
})));
|
|
41
|
+
loaded(sizes.map((box) => box ?? UNLOADED), failed);
|
|
42
42
|
};
|
|
43
43
|
const handlers = images.map((image, at) => ({
|
|
44
|
-
error: () =>
|
|
44
|
+
error: () => {
|
|
45
|
+
failed = true;
|
|
46
|
+
settle(at, UNLOADED);
|
|
47
|
+
},
|
|
45
48
|
load: () => settle(at, fit(image))
|
|
46
49
|
}));
|
|
47
50
|
const onPress = (event) => {
|
|
@@ -57,6 +60,9 @@ const createPendingPictures = ({ editor, mounted, writable }) => {
|
|
|
57
60
|
image.removeEventListener("error", handlers[at].error);
|
|
58
61
|
image.src = "";
|
|
59
62
|
});
|
|
63
|
+
sources.forEach((source, at) => {
|
|
64
|
+
if (typeof source !== "string") view.URL.revokeObjectURL(urls[at]);
|
|
65
|
+
});
|
|
60
66
|
view.removeEventListener("keydown", onPress, true);
|
|
61
67
|
view.removeEventListener("pointerdown", onPress, true);
|
|
62
68
|
view.removeEventListener("paste", drop, true);
|
|
@@ -64,10 +70,10 @@ const createPendingPictures = ({ editor, mounted, writable }) => {
|
|
|
64
70
|
stopCommits();
|
|
65
71
|
stopViewState();
|
|
66
72
|
};
|
|
67
|
-
const stopCommits = editor.subscribeCommit(({ changed }) => {
|
|
68
|
-
if (changed.hasAny("document") || changed.hasAny("selection")) drop();
|
|
73
|
+
const stopCommits = editor.subscribeCommit(({ changed, tags }) => {
|
|
74
|
+
if (!tags.includes("upload") && (changed.hasAny("document") || changed.hasAny("selection"))) drop();
|
|
69
75
|
});
|
|
70
|
-
const stopViewState = subscribeEditorViewState(
|
|
76
|
+
const stopViewState = subscribeEditorViewState(shapes, () => {
|
|
71
77
|
if (!writable()) drop();
|
|
72
78
|
});
|
|
73
79
|
stop = halt;
|
|
@@ -78,7 +84,7 @@ const createPendingPictures = ({ editor, mounted, writable }) => {
|
|
|
78
84
|
images.forEach((image, at) => {
|
|
79
85
|
image.addEventListener("load", handlers[at].load);
|
|
80
86
|
image.addEventListener("error", handlers[at].error);
|
|
81
|
-
image.src =
|
|
87
|
+
image.src = urls[at];
|
|
82
88
|
});
|
|
83
89
|
};
|
|
84
90
|
return {
|