@react-fabric/lexical 1.0.0-beta.60 → 1.0.0-beta.62
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/css/_lexical.css +61 -0
- package/dist/cjs/node_modules/date-fns/_lib/addLeadingZeros.js +9 -0
- package/dist/cjs/node_modules/date-fns/_lib/defaultOptions.js +9 -0
- package/dist/cjs/node_modules/date-fns/_lib/format/formatters.js +779 -0
- package/dist/cjs/node_modules/date-fns/_lib/format/lightFormatters.js +96 -0
- package/dist/cjs/node_modules/date-fns/_lib/format/longFormatters.js +68 -0
- package/dist/cjs/node_modules/date-fns/_lib/getRoundingMethod.js +12 -0
- package/dist/cjs/node_modules/date-fns/_lib/getTimezoneOffsetInMilliseconds.js +33 -0
- package/dist/cjs/node_modules/date-fns/_lib/normalizeDates.js +13 -0
- package/dist/cjs/node_modules/date-fns/_lib/normalizeInterval.js +10 -0
- package/dist/cjs/node_modules/date-fns/_lib/protectedTokens.js +29 -0
- package/dist/cjs/node_modules/date-fns/add.js +73 -0
- package/dist/cjs/node_modules/date-fns/addDays.js +46 -0
- package/dist/cjs/node_modules/date-fns/addHours.js +39 -0
- package/dist/cjs/node_modules/date-fns/addMilliseconds.js +39 -0
- package/dist/cjs/node_modules/date-fns/addMinutes.js +41 -0
- package/dist/cjs/node_modules/date-fns/addMonths.js +80 -0
- package/dist/cjs/node_modules/date-fns/addQuarters.js +38 -0
- package/dist/cjs/node_modules/date-fns/addWeeks.js +38 -0
- package/dist/cjs/node_modules/date-fns/addYears.js +38 -0
- package/dist/cjs/node_modules/date-fns/compareAsc.js +50 -0
- package/dist/cjs/node_modules/date-fns/constants.js +66 -0
- package/dist/cjs/node_modules/date-fns/constructFrom.js +54 -0
- package/dist/cjs/node_modules/date-fns/differenceInCalendarDays.js +67 -0
- package/dist/cjs/node_modules/date-fns/differenceInCalendarMonths.js +47 -0
- package/dist/cjs/node_modules/date-fns/differenceInCalendarYears.js +43 -0
- package/dist/cjs/node_modules/date-fns/differenceInDays.js +112 -0
- package/dist/cjs/node_modules/date-fns/differenceInHours.js +46 -0
- package/dist/cjs/node_modules/date-fns/differenceInMilliseconds.js +34 -0
- package/dist/cjs/node_modules/date-fns/differenceInMinutes.js +50 -0
- package/dist/cjs/node_modules/date-fns/differenceInMonths.js +65 -0
- package/dist/cjs/node_modules/date-fns/differenceInSeconds.js +41 -0
- package/dist/cjs/node_modules/date-fns/differenceInYears.js +67 -0
- package/dist/cjs/node_modules/date-fns/endOfDay.js +40 -0
- package/dist/cjs/node_modules/date-fns/endOfDecade.js +45 -0
- package/dist/cjs/node_modules/date-fns/endOfHour.js +40 -0
- package/dist/cjs/node_modules/date-fns/endOfMinute.js +40 -0
- package/dist/cjs/node_modules/date-fns/endOfMonth.js +42 -0
- package/dist/cjs/node_modules/date-fns/endOfQuarter.js +43 -0
- package/dist/cjs/node_modules/date-fns/endOfWeek.js +58 -0
- package/dist/cjs/node_modules/date-fns/endOfYear.js +42 -0
- package/dist/cjs/node_modules/date-fns/format.js +431 -0
- package/dist/cjs/node_modules/date-fns/getDayOfYear.js +39 -0
- package/dist/cjs/node_modules/date-fns/getISOWeek.js +45 -0
- package/dist/cjs/node_modules/date-fns/getISOWeekYear.js +57 -0
- package/dist/cjs/node_modules/date-fns/getWeek.js +59 -0
- package/dist/cjs/node_modules/date-fns/getWeekYear.js +80 -0
- package/dist/cjs/node_modules/date-fns/intervalToDuration.js +70 -0
- package/dist/cjs/node_modules/date-fns/isAfter.js +30 -0
- package/dist/cjs/node_modules/date-fns/isBefore.js +30 -0
- package/dist/cjs/node_modules/date-fns/isDate.js +46 -0
- package/dist/cjs/node_modules/date-fns/isLastDayOfMonth.js +33 -0
- package/dist/cjs/node_modules/date-fns/isSameMonth.js +48 -0
- package/dist/cjs/node_modules/date-fns/isSameWeek.js +56 -0
- package/dist/cjs/node_modules/date-fns/isSameYear.js +40 -0
- package/dist/cjs/node_modules/date-fns/isValid.js +44 -0
- package/dist/cjs/node_modules/date-fns/locale/_lib/buildFormatLongFn.js +12 -0
- package/dist/cjs/node_modules/date-fns/locale/_lib/buildLocalizeFn.js +66 -0
- package/dist/cjs/node_modules/date-fns/locale/_lib/buildMatchFn.js +61 -0
- package/dist/cjs/node_modules/date-fns/locale/_lib/buildMatchPatternFn.js +24 -0
- package/dist/cjs/node_modules/date-fns/locale/ar-SA/_lib/formatDistance.js +139 -0
- package/dist/cjs/node_modules/date-fns/locale/ar-SA/_lib/formatLong.js +43 -0
- package/dist/cjs/node_modules/date-fns/locale/ar-SA/_lib/formatRelative.js +15 -0
- package/dist/cjs/node_modules/date-fns/locale/ar-SA/_lib/localize.js +166 -0
- package/dist/cjs/node_modules/date-fns/locale/ar-SA/_lib/match.js +146 -0
- package/dist/cjs/node_modules/date-fns/locale/ar-SA.js +32 -0
- package/dist/cjs/node_modules/date-fns/locale/de/_lib/formatDistance.js +200 -0
- package/dist/cjs/node_modules/date-fns/locale/de/_lib/formatLong.js +44 -0
- package/dist/cjs/node_modules/date-fns/locale/de/_lib/formatRelative.js +15 -0
- package/dist/cjs/node_modules/date-fns/locale/de/_lib/localize.js +195 -0
- package/dist/cjs/node_modules/date-fns/locale/de/_lib/match.js +138 -0
- package/dist/cjs/node_modules/date-fns/locale/de.js +36 -0
- package/dist/cjs/node_modules/date-fns/locale/en-US/_lib/formatDistance.js +105 -0
- package/dist/cjs/node_modules/date-fns/locale/en-US/_lib/formatLong.js +43 -0
- package/dist/cjs/node_modules/date-fns/locale/en-US/_lib/formatRelative.js +15 -0
- package/dist/cjs/node_modules/date-fns/locale/en-US/_lib/localize.js +191 -0
- package/dist/cjs/node_modules/date-fns/locale/en-US/_lib/match.js +136 -0
- package/dist/cjs/node_modules/date-fns/locale/en-US.js +33 -0
- package/dist/cjs/node_modules/date-fns/locale/es/_lib/formatDistance.js +105 -0
- package/dist/cjs/node_modules/date-fns/locale/es/_lib/formatLong.js +43 -0
- package/dist/cjs/node_modules/date-fns/locale/es/_lib/formatRelative.js +29 -0
- package/dist/cjs/node_modules/date-fns/locale/es/_lib/localize.js +168 -0
- package/dist/cjs/node_modules/date-fns/locale/es/_lib/match.js +142 -0
- package/dist/cjs/node_modules/date-fns/locale/es.js +36 -0
- package/dist/cjs/node_modules/date-fns/locale/fr/_lib/formatDistance.js +104 -0
- package/dist/cjs/node_modules/date-fns/locale/fr/_lib/formatLong.js +43 -0
- package/dist/cjs/node_modules/date-fns/locale/fr/_lib/formatRelative.js +15 -0
- package/dist/cjs/node_modules/date-fns/locale/fr/_lib/localize.js +169 -0
- package/dist/cjs/node_modules/date-fns/locale/fr/_lib/match.js +137 -0
- package/dist/cjs/node_modules/date-fns/locale/fr.js +33 -0
- package/dist/cjs/node_modules/date-fns/locale/hi/_lib/formatDistance.js +109 -0
- package/dist/cjs/node_modules/date-fns/locale/hi/_lib/formatLong.js +43 -0
- package/dist/cjs/node_modules/date-fns/locale/hi/_lib/formatRelative.js +15 -0
- package/dist/cjs/node_modules/date-fns/locale/hi/_lib/localize.js +233 -0
- package/dist/cjs/node_modules/date-fns/locale/hi/_lib/match.js +141 -0
- package/dist/cjs/node_modules/date-fns/locale/hi.js +32 -0
- package/dist/cjs/node_modules/date-fns/locale/it/_lib/formatDistance.js +105 -0
- package/dist/cjs/node_modules/date-fns/locale/it/_lib/formatLong.js +43 -0
- package/dist/cjs/node_modules/date-fns/locale/it/_lib/formatRelative.js +70 -0
- package/dist/cjs/node_modules/date-fns/locale/it/_lib/localize.js +168 -0
- package/dist/cjs/node_modules/date-fns/locale/it/_lib/match.js +137 -0
- package/dist/cjs/node_modules/date-fns/locale/it.js +34 -0
- package/dist/cjs/node_modules/date-fns/locale/ja/_lib/formatDistance.js +119 -0
- package/dist/cjs/node_modules/date-fns/locale/ja/_lib/formatLong.js +43 -0
- package/dist/cjs/node_modules/date-fns/locale/ja/_lib/formatRelative.js +16 -0
- package/dist/cjs/node_modules/date-fns/locale/ja/_lib/localize.js +181 -0
- package/dist/cjs/node_modules/date-fns/locale/ja/_lib/match.js +122 -0
- package/dist/cjs/node_modules/date-fns/locale/ja.js +36 -0
- package/dist/cjs/node_modules/date-fns/locale/ko/_lib/formatDistance.js +105 -0
- package/dist/cjs/node_modules/date-fns/locale/ko/_lib/formatLong.js +43 -0
- package/dist/cjs/node_modules/date-fns/locale/ko/_lib/formatRelative.js +15 -0
- package/dist/cjs/node_modules/date-fns/locale/ko/_lib/localize.js +171 -0
- package/dist/cjs/node_modules/date-fns/locale/ko/_lib/match.js +119 -0
- package/dist/cjs/node_modules/date-fns/locale/ko.js +34 -0
- package/dist/cjs/node_modules/date-fns/locale/pt/_lib/formatDistance.js +105 -0
- package/dist/cjs/node_modules/date-fns/locale/pt/_lib/formatLong.js +43 -0
- package/dist/cjs/node_modules/date-fns/locale/pt/_lib/formatRelative.js +26 -0
- package/dist/cjs/node_modules/date-fns/locale/pt/_lib/localize.js +168 -0
- package/dist/cjs/node_modules/date-fns/locale/pt/_lib/match.js +141 -0
- package/dist/cjs/node_modules/date-fns/locale/pt.js +33 -0
- package/dist/cjs/node_modules/date-fns/locale/ru/_lib/formatDistance.js +250 -0
- package/dist/cjs/node_modules/date-fns/locale/ru/_lib/formatLong.js +40 -0
- package/dist/cjs/node_modules/date-fns/locale/ru/_lib/formatRelative.js +92 -0
- package/dist/cjs/node_modules/date-fns/locale/ru/_lib/localize.js +214 -0
- package/dist/cjs/node_modules/date-fns/locale/ru/_lib/match.js +142 -0
- package/dist/cjs/node_modules/date-fns/locale/ru.js +33 -0
- package/dist/cjs/node_modules/date-fns/locale/zh-CN/_lib/formatDistance.js +105 -0
- package/dist/cjs/node_modules/date-fns/locale/zh-CN/_lib/formatLong.js +43 -0
- package/dist/cjs/node_modules/date-fns/locale/zh-CN/_lib/formatRelative.js +35 -0
- package/dist/cjs/node_modules/date-fns/locale/zh-CN/_lib/localize.js +187 -0
- package/dist/cjs/node_modules/date-fns/locale/zh-CN/_lib/match.js +134 -0
- package/dist/cjs/node_modules/date-fns/locale/zh-CN.js +36 -0
- package/dist/cjs/node_modules/date-fns/startOfDay.js +40 -0
- package/dist/cjs/node_modules/date-fns/startOfDecade.js +45 -0
- package/dist/cjs/node_modules/date-fns/startOfHour.js +40 -0
- package/dist/cjs/node_modules/date-fns/startOfISOWeek.js +40 -0
- package/dist/cjs/node_modules/date-fns/startOfISOWeekYear.js +47 -0
- package/dist/cjs/node_modules/date-fns/startOfMinute.js +40 -0
- package/dist/cjs/node_modules/date-fns/startOfMonth.js +42 -0
- package/dist/cjs/node_modules/date-fns/startOfQuarter.js +43 -0
- package/dist/cjs/node_modules/date-fns/startOfWeek.js +58 -0
- package/dist/cjs/node_modules/date-fns/startOfWeekYear.js +69 -0
- package/dist/cjs/node_modules/date-fns/startOfYear.js +41 -0
- package/dist/cjs/node_modules/date-fns/toDate.js +51 -0
- package/dist/cjs/packages/date/dist/esm/display/DateDuration.js +178 -0
- package/dist/cjs/packages/date/dist/esm/hijri/DateConverter.js +154 -0
- package/dist/cjs/packages/date/dist/esm/hijri/FormatDate.js +116 -0
- package/dist/cjs/packages/date/dist/esm/hijri/HijriDate.js +531 -0
- package/dist/cjs/packages/date/dist/esm/hijri/StringDateParser.js +74 -0
- package/dist/cjs/packages/date/dist/esm/hijri/index.js +21 -0
- package/dist/cjs/packages/date/dist/esm/hijri/initializer.js +113 -0
- package/dist/cjs/packages/date/dist/esm/hijri/locales.js +19 -0
- package/dist/cjs/packages/date/dist/esm/hijri/safe.js +17 -0
- package/dist/cjs/packages/date/dist/esm/i18n/ar/date.json.js +213 -0
- package/dist/cjs/packages/date/dist/esm/i18n/en/date.json.js +83 -0
- package/{src/plugins/StickyPlugin.ts → dist/cjs/packages/date/dist/esm/i18n/index.js} +10 -15
- package/dist/cjs/packages/date/dist/esm/types/index.js +46 -0
- package/dist/cjs/packages/date/dist/esm/utils/dateUtil.js +472 -0
- package/dist/cjs/packages/lexical/src/editor/LexicalEditor.js +36 -13
- package/dist/cjs/packages/lexical/src/hooks/useFormatWatcher.js +101 -95
- package/dist/cjs/packages/lexical/src/i18n/ar/lexical.json.js +30 -0
- package/dist/cjs/packages/lexical/src/i18n/en/lexical.json.js +30 -0
- package/dist/cjs/packages/lexical/src/i18n/index.js +33 -0
- package/dist/cjs/packages/lexical/src/index.js +1 -0
- package/dist/cjs/packages/lexical/src/plugins/CommentPlugin.js +477 -0
- package/dist/cjs/packages/lexical/src/plugins/DraggableBlockPlugin.js +13 -16
- package/dist/cjs/packages/lexical/src/plugins/ToolbarPlugin.js +35 -22
- package/dist/esm/node_modules/date-fns/_lib/addLeadingZeros.js +9 -0
- package/dist/esm/node_modules/date-fns/_lib/defaultOptions.js +9 -0
- package/dist/esm/node_modules/date-fns/_lib/format/formatters.js +779 -0
- package/dist/esm/node_modules/date-fns/_lib/format/lightFormatters.js +96 -0
- package/dist/esm/node_modules/date-fns/_lib/format/longFormatters.js +68 -0
- package/dist/esm/node_modules/date-fns/_lib/getRoundingMethod.js +12 -0
- package/dist/esm/node_modules/date-fns/_lib/getTimezoneOffsetInMilliseconds.js +33 -0
- package/dist/esm/node_modules/date-fns/_lib/normalizeDates.js +13 -0
- package/dist/esm/node_modules/date-fns/_lib/normalizeInterval.js +10 -0
- package/dist/esm/node_modules/date-fns/_lib/protectedTokens.js +27 -0
- package/dist/esm/node_modules/date-fns/add.js +70 -0
- package/dist/esm/node_modules/date-fns/addDays.js +43 -0
- package/dist/esm/node_modules/date-fns/addHours.js +36 -0
- package/dist/esm/node_modules/date-fns/addMilliseconds.js +36 -0
- package/dist/esm/node_modules/date-fns/addMinutes.js +38 -0
- package/dist/esm/node_modules/date-fns/addMonths.js +77 -0
- package/dist/esm/node_modules/date-fns/addQuarters.js +35 -0
- package/dist/esm/node_modules/date-fns/addWeeks.js +35 -0
- package/dist/esm/node_modules/date-fns/addYears.js +35 -0
- package/dist/esm/node_modules/date-fns/compareAsc.js +47 -0
- package/dist/esm/node_modules/date-fns/constants.js +62 -0
- package/dist/esm/node_modules/date-fns/constructFrom.js +51 -0
- package/dist/esm/node_modules/date-fns/differenceInCalendarDays.js +64 -0
- package/dist/esm/node_modules/date-fns/differenceInCalendarMonths.js +44 -0
- package/dist/esm/node_modules/date-fns/differenceInCalendarYears.js +40 -0
- package/dist/esm/node_modules/date-fns/differenceInDays.js +109 -0
- package/dist/esm/node_modules/date-fns/differenceInHours.js +43 -0
- package/dist/esm/node_modules/date-fns/differenceInMilliseconds.js +31 -0
- package/dist/esm/node_modules/date-fns/differenceInMinutes.js +47 -0
- package/dist/esm/node_modules/date-fns/differenceInMonths.js +62 -0
- package/dist/esm/node_modules/date-fns/differenceInSeconds.js +38 -0
- package/dist/esm/node_modules/date-fns/differenceInYears.js +64 -0
- package/dist/esm/node_modules/date-fns/endOfDay.js +37 -0
- package/dist/esm/node_modules/date-fns/endOfDecade.js +42 -0
- package/dist/esm/node_modules/date-fns/endOfHour.js +37 -0
- package/dist/esm/node_modules/date-fns/endOfMinute.js +37 -0
- package/dist/esm/node_modules/date-fns/endOfMonth.js +39 -0
- package/dist/esm/node_modules/date-fns/endOfQuarter.js +40 -0
- package/dist/esm/node_modules/date-fns/endOfWeek.js +55 -0
- package/dist/esm/node_modules/date-fns/endOfYear.js +39 -0
- package/dist/esm/node_modules/date-fns/format.js +425 -0
- package/dist/esm/node_modules/date-fns/getDayOfYear.js +36 -0
- package/dist/esm/node_modules/date-fns/getISOWeek.js +42 -0
- package/dist/esm/node_modules/date-fns/getISOWeekYear.js +54 -0
- package/dist/esm/node_modules/date-fns/getWeek.js +56 -0
- package/dist/esm/node_modules/date-fns/getWeekYear.js +77 -0
- package/dist/esm/node_modules/date-fns/intervalToDuration.js +67 -0
- package/dist/esm/node_modules/date-fns/isAfter.js +27 -0
- package/dist/esm/node_modules/date-fns/isBefore.js +27 -0
- package/dist/esm/node_modules/date-fns/isDate.js +43 -0
- package/dist/esm/node_modules/date-fns/isLastDayOfMonth.js +30 -0
- package/dist/esm/node_modules/date-fns/isSameMonth.js +45 -0
- package/dist/esm/node_modules/date-fns/isSameWeek.js +53 -0
- package/dist/esm/node_modules/date-fns/isSameYear.js +37 -0
- package/dist/esm/node_modules/date-fns/isValid.js +41 -0
- package/dist/esm/node_modules/date-fns/locale/_lib/buildFormatLongFn.js +12 -0
- package/dist/esm/node_modules/date-fns/locale/_lib/buildLocalizeFn.js +66 -0
- package/dist/esm/node_modules/date-fns/locale/_lib/buildMatchFn.js +61 -0
- package/dist/esm/node_modules/date-fns/locale/_lib/buildMatchPatternFn.js +24 -0
- package/dist/esm/node_modules/date-fns/locale/ar-SA/_lib/formatDistance.js +139 -0
- package/dist/esm/node_modules/date-fns/locale/ar-SA/_lib/formatLong.js +43 -0
- package/dist/esm/node_modules/date-fns/locale/ar-SA/_lib/formatRelative.js +15 -0
- package/dist/esm/node_modules/date-fns/locale/ar-SA/_lib/localize.js +166 -0
- package/dist/esm/node_modules/date-fns/locale/ar-SA/_lib/match.js +146 -0
- package/dist/esm/node_modules/date-fns/locale/ar-SA.js +29 -0
- package/dist/esm/node_modules/date-fns/locale/de/_lib/formatDistance.js +200 -0
- package/dist/esm/node_modules/date-fns/locale/de/_lib/formatLong.js +44 -0
- package/dist/esm/node_modules/date-fns/locale/de/_lib/formatRelative.js +15 -0
- package/dist/esm/node_modules/date-fns/locale/de/_lib/localize.js +195 -0
- package/dist/esm/node_modules/date-fns/locale/de/_lib/match.js +138 -0
- package/dist/esm/node_modules/date-fns/locale/de.js +33 -0
- package/dist/esm/node_modules/date-fns/locale/en-US/_lib/formatDistance.js +105 -0
- package/dist/esm/node_modules/date-fns/locale/en-US/_lib/formatLong.js +43 -0
- package/dist/esm/node_modules/date-fns/locale/en-US/_lib/formatRelative.js +15 -0
- package/dist/esm/node_modules/date-fns/locale/en-US/_lib/localize.js +191 -0
- package/dist/esm/node_modules/date-fns/locale/en-US/_lib/match.js +136 -0
- package/dist/esm/node_modules/date-fns/locale/en-US.js +30 -0
- package/dist/esm/node_modules/date-fns/locale/es/_lib/formatDistance.js +105 -0
- package/dist/esm/node_modules/date-fns/locale/es/_lib/formatLong.js +43 -0
- package/dist/esm/node_modules/date-fns/locale/es/_lib/formatRelative.js +29 -0
- package/dist/esm/node_modules/date-fns/locale/es/_lib/localize.js +168 -0
- package/dist/esm/node_modules/date-fns/locale/es/_lib/match.js +142 -0
- package/dist/esm/node_modules/date-fns/locale/es.js +33 -0
- package/dist/esm/node_modules/date-fns/locale/fr/_lib/formatDistance.js +104 -0
- package/dist/esm/node_modules/date-fns/locale/fr/_lib/formatLong.js +43 -0
- package/dist/esm/node_modules/date-fns/locale/fr/_lib/formatRelative.js +15 -0
- package/dist/esm/node_modules/date-fns/locale/fr/_lib/localize.js +169 -0
- package/dist/esm/node_modules/date-fns/locale/fr/_lib/match.js +137 -0
- package/dist/esm/node_modules/date-fns/locale/fr.js +30 -0
- package/dist/esm/node_modules/date-fns/locale/hi/_lib/formatDistance.js +109 -0
- package/dist/esm/node_modules/date-fns/locale/hi/_lib/formatLong.js +43 -0
- package/dist/esm/node_modules/date-fns/locale/hi/_lib/formatRelative.js +15 -0
- package/dist/esm/node_modules/date-fns/locale/hi/_lib/localize.js +231 -0
- package/dist/esm/node_modules/date-fns/locale/hi/_lib/match.js +141 -0
- package/dist/esm/node_modules/date-fns/locale/hi.js +29 -0
- package/dist/esm/node_modules/date-fns/locale/it/_lib/formatDistance.js +105 -0
- package/dist/esm/node_modules/date-fns/locale/it/_lib/formatLong.js +43 -0
- package/dist/esm/node_modules/date-fns/locale/it/_lib/formatRelative.js +70 -0
- package/dist/esm/node_modules/date-fns/locale/it/_lib/localize.js +168 -0
- package/dist/esm/node_modules/date-fns/locale/it/_lib/match.js +137 -0
- package/dist/esm/node_modules/date-fns/locale/it.js +31 -0
- package/dist/esm/node_modules/date-fns/locale/ja/_lib/formatDistance.js +119 -0
- package/dist/esm/node_modules/date-fns/locale/ja/_lib/formatLong.js +43 -0
- package/dist/esm/node_modules/date-fns/locale/ja/_lib/formatRelative.js +16 -0
- package/dist/esm/node_modules/date-fns/locale/ja/_lib/localize.js +181 -0
- package/dist/esm/node_modules/date-fns/locale/ja/_lib/match.js +122 -0
- package/dist/esm/node_modules/date-fns/locale/ja.js +33 -0
- package/dist/esm/node_modules/date-fns/locale/ko/_lib/formatDistance.js +105 -0
- package/dist/esm/node_modules/date-fns/locale/ko/_lib/formatLong.js +43 -0
- package/dist/esm/node_modules/date-fns/locale/ko/_lib/formatRelative.js +15 -0
- package/dist/esm/node_modules/date-fns/locale/ko/_lib/localize.js +171 -0
- package/dist/esm/node_modules/date-fns/locale/ko/_lib/match.js +119 -0
- package/dist/esm/node_modules/date-fns/locale/ko.js +31 -0
- package/dist/esm/node_modules/date-fns/locale/pt/_lib/formatDistance.js +105 -0
- package/dist/esm/node_modules/date-fns/locale/pt/_lib/formatLong.js +43 -0
- package/dist/esm/node_modules/date-fns/locale/pt/_lib/formatRelative.js +26 -0
- package/dist/esm/node_modules/date-fns/locale/pt/_lib/localize.js +168 -0
- package/dist/esm/node_modules/date-fns/locale/pt/_lib/match.js +141 -0
- package/dist/esm/node_modules/date-fns/locale/pt.js +30 -0
- package/dist/esm/node_modules/date-fns/locale/ru/_lib/formatDistance.js +250 -0
- package/dist/esm/node_modules/date-fns/locale/ru/_lib/formatLong.js +40 -0
- package/dist/esm/node_modules/date-fns/locale/ru/_lib/formatRelative.js +92 -0
- package/dist/esm/node_modules/date-fns/locale/ru/_lib/localize.js +214 -0
- package/dist/esm/node_modules/date-fns/locale/ru/_lib/match.js +142 -0
- package/dist/esm/node_modules/date-fns/locale/ru.js +30 -0
- package/dist/esm/node_modules/date-fns/locale/zh-CN/_lib/formatDistance.js +105 -0
- package/dist/esm/node_modules/date-fns/locale/zh-CN/_lib/formatLong.js +43 -0
- package/dist/esm/node_modules/date-fns/locale/zh-CN/_lib/formatRelative.js +35 -0
- package/dist/esm/node_modules/date-fns/locale/zh-CN/_lib/localize.js +187 -0
- package/dist/esm/node_modules/date-fns/locale/zh-CN/_lib/match.js +134 -0
- package/dist/esm/node_modules/date-fns/locale/zh-CN.js +33 -0
- package/dist/esm/node_modules/date-fns/startOfDay.js +37 -0
- package/dist/esm/node_modules/date-fns/startOfDecade.js +42 -0
- package/dist/esm/node_modules/date-fns/startOfHour.js +37 -0
- package/dist/esm/node_modules/date-fns/startOfISOWeek.js +37 -0
- package/dist/esm/node_modules/date-fns/startOfISOWeekYear.js +44 -0
- package/dist/esm/node_modules/date-fns/startOfMinute.js +37 -0
- package/dist/esm/node_modules/date-fns/startOfMonth.js +39 -0
- package/dist/esm/node_modules/date-fns/startOfQuarter.js +40 -0
- package/dist/esm/node_modules/date-fns/startOfWeek.js +55 -0
- package/dist/esm/node_modules/date-fns/startOfWeekYear.js +66 -0
- package/dist/esm/node_modules/date-fns/startOfYear.js +38 -0
- package/dist/esm/node_modules/date-fns/toDate.js +48 -0
- package/dist/esm/packages/date/dist/esm/display/DateDuration.js +178 -0
- package/dist/esm/packages/date/dist/esm/hijri/DateConverter.js +152 -0
- package/dist/esm/packages/date/dist/esm/hijri/FormatDate.js +113 -0
- package/dist/esm/packages/date/dist/esm/hijri/HijriDate.js +528 -0
- package/dist/esm/packages/date/dist/esm/hijri/StringDateParser.js +74 -0
- package/dist/esm/packages/date/dist/esm/hijri/index.js +21 -0
- package/dist/esm/packages/date/dist/esm/hijri/initializer.js +113 -0
- package/dist/esm/packages/date/dist/esm/hijri/locales.js +18 -0
- package/dist/esm/packages/date/dist/esm/hijri/safe.js +14 -0
- package/dist/esm/packages/date/dist/esm/i18n/ar/date.json.js +209 -0
- package/dist/esm/packages/date/dist/esm/i18n/en/date.json.js +79 -0
- package/dist/esm/packages/date/dist/esm/i18n/index.js +33 -0
- package/dist/esm/packages/date/dist/esm/types/index.js +45 -0
- package/dist/esm/packages/date/dist/esm/utils/dateUtil.js +474 -0
- package/dist/esm/packages/lexical/src/editor/LexicalEditor.js +37 -14
- package/dist/esm/packages/lexical/src/hooks/useFormatWatcher.js +43 -37
- package/dist/esm/packages/lexical/src/i18n/ar/lexical.json.js +25 -0
- package/dist/esm/packages/lexical/src/i18n/en/lexical.json.js +25 -0
- package/dist/esm/packages/lexical/src/i18n/index.js +33 -0
- package/dist/esm/packages/lexical/src/index.js +1 -0
- package/dist/esm/packages/lexical/src/plugins/CommentPlugin.js +477 -0
- package/dist/esm/packages/lexical/src/plugins/DraggableBlockPlugin.js +11 -14
- package/dist/esm/packages/lexical/src/plugins/ToolbarPlugin.js +36 -23
- package/dist/types/editor/LexicalEditor.d.ts +12 -3
- package/dist/types/hooks/useFormatWatcher.d.ts +2 -1
- package/dist/types/i18n/index.d.ts +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/plugins/CommentPlugin.d.ts +5 -0
- package/dist/types/plugins/DraggableBlockPlugin.d.ts +2 -1
- package/package.json +5 -5
- package/src/editor/LexicalEditor.tsx +65 -18
- package/src/hooks/useFormatWatcher.ts +3 -0
- package/src/i18n/ar/lexical.json +18 -0
- package/src/i18n/en/lexical.json +18 -0
- package/src/i18n/index.ts +28 -0
- package/src/index.ts +2 -0
- package/src/plugins/CommentPlugin.tsx +554 -0
- package/src/plugins/DraggableBlockPlugin.tsx +5 -10
- package/src/plugins/ToolbarPlugin.tsx +34 -23
- package/dist/cjs/_virtual/prism.js +0 -5
- package/dist/cjs/node_modules/@lexical/clipboard/LexicalClipboard.dev.js +0 -474
- package/dist/cjs/node_modules/@lexical/clipboard/LexicalClipboard.js +0 -21
- package/dist/cjs/node_modules/@lexical/clipboard/LexicalClipboard.prod.js +0 -27
- package/dist/cjs/node_modules/@lexical/code/LexicalCode.dev.js +0 -1537
- package/dist/cjs/node_modules/@lexical/code/LexicalCode.js +0 -25
- package/dist/cjs/node_modules/@lexical/code/LexicalCode.prod.js +0 -57
- package/dist/cjs/node_modules/@lexical/html/LexicalHtml.dev.js +0 -252
- package/dist/cjs/node_modules/@lexical/html/LexicalHtml.js +0 -19
- package/dist/cjs/node_modules/@lexical/html/LexicalHtml.prod.js +0 -18
- package/dist/cjs/node_modules/@lexical/link/LexicalLink.dev.js +0 -572
- package/dist/cjs/node_modules/@lexical/link/LexicalLink.js +0 -17
- package/dist/cjs/node_modules/@lexical/link/LexicalLink.prod.js +0 -25
- package/dist/cjs/node_modules/@lexical/list/LexicalList.dev.js +0 -1614
- package/dist/cjs/node_modules/@lexical/list/LexicalList.js +0 -29
- package/dist/cjs/node_modules/@lexical/list/LexicalList.prod.js +0 -36
- package/dist/cjs/node_modules/@lexical/rich-text/LexicalRichText.dev.js +0 -838
- package/dist/cjs/node_modules/@lexical/rich-text/LexicalRichText.js +0 -29
- package/dist/cjs/node_modules/@lexical/rich-text/LexicalRichText.prod.js +0 -26
- package/dist/cjs/node_modules/@lexical/selection/LexicalSelection.dev.js +0 -1057
- package/dist/cjs/node_modules/@lexical/selection/LexicalSelection.js +0 -39
- package/dist/cjs/node_modules/@lexical/selection/LexicalSelection.prod.js +0 -45
- package/dist/cjs/node_modules/@lexical/table/LexicalTable.dev.js +0 -4207
- package/dist/cjs/node_modules/@lexical/table/LexicalTable.js +0 -23
- package/dist/cjs/node_modules/@lexical/table/LexicalTable.prod.js +0 -68
- package/dist/cjs/node_modules/@lexical/utils/LexicalUtils.dev.js +0 -1166
- package/dist/cjs/node_modules/@lexical/utils/LexicalUtils.js +0 -47
- package/dist/cjs/node_modules/@lexical/utils/LexicalUtils.prod.js +0 -81
- package/dist/cjs/node_modules/@mdi/js/mdi.js +0 -8
- package/dist/cjs/node_modules/prismjs/components/prism-c.js +0 -82
- package/dist/cjs/node_modules/prismjs/components/prism-clike.js +0 -33
- package/dist/cjs/node_modules/prismjs/components/prism-cpp.js +0 -101
- package/dist/cjs/node_modules/prismjs/components/prism-css.js +0 -66
- package/dist/cjs/node_modules/prismjs/components/prism-java.js +0 -126
- package/dist/cjs/node_modules/prismjs/components/prism-javascript.js +0 -174
- package/dist/cjs/node_modules/prismjs/components/prism-markdown.js +0 -417
- package/dist/cjs/node_modules/prismjs/components/prism-markup.js +0 -188
- package/dist/cjs/node_modules/prismjs/components/prism-objectivec.js +0 -14
- package/dist/cjs/node_modules/prismjs/components/prism-powershell.js +0 -60
- package/dist/cjs/node_modules/prismjs/components/prism-python.js +0 -67
- package/dist/cjs/node_modules/prismjs/components/prism-rust.js +0 -130
- package/dist/cjs/node_modules/prismjs/components/prism-sql.js +0 -34
- package/dist/cjs/node_modules/prismjs/components/prism-swift.js +0 -150
- package/dist/cjs/node_modules/prismjs/components/prism-typescript.js +0 -62
- package/dist/cjs/node_modules/prismjs/prism.js +0 -1951
- package/dist/cjs/packages/lexical/src/components/StickyComponent.js +0 -221
- package/dist/cjs/packages/lexical/src/nodes/StickyNode.js +0 -218
- package/dist/cjs/packages/lexical/src/plugins/StickyPlugin.js +0 -20
- package/dist/esm/_virtual/prism.js +0 -5
- package/dist/esm/node_modules/@lexical/clipboard/LexicalClipboard.dev.js +0 -465
- package/dist/esm/node_modules/@lexical/clipboard/LexicalClipboard.js +0 -19
- package/dist/esm/node_modules/@lexical/clipboard/LexicalClipboard.prod.js +0 -18
- package/dist/esm/node_modules/@lexical/code/LexicalCode.dev.js +0 -1512
- package/dist/esm/node_modules/@lexical/code/LexicalCode.js +0 -21
- package/dist/esm/node_modules/@lexical/code/LexicalCode.prod.js +0 -32
- package/dist/esm/node_modules/@lexical/html/LexicalHtml.dev.js +0 -251
- package/dist/esm/node_modules/@lexical/html/LexicalHtml.js +0 -18
- package/dist/esm/node_modules/@lexical/html/LexicalHtml.prod.js +0 -17
- package/dist/esm/node_modules/@lexical/link/LexicalLink.dev.js +0 -563
- package/dist/esm/node_modules/@lexical/link/LexicalLink.js +0 -17
- package/dist/esm/node_modules/@lexical/link/LexicalLink.prod.js +0 -16
- package/dist/esm/node_modules/@lexical/list/LexicalList.dev.js +0 -1595
- package/dist/esm/node_modules/@lexical/list/LexicalList.js +0 -23
- package/dist/esm/node_modules/@lexical/list/LexicalList.prod.js +0 -17
- package/dist/esm/node_modules/@lexical/rich-text/LexicalRichText.dev.js +0 -830
- package/dist/esm/node_modules/@lexical/rich-text/LexicalRichText.js +0 -23
- package/dist/esm/node_modules/@lexical/rich-text/LexicalRichText.prod.js +0 -18
- package/dist/esm/node_modules/@lexical/selection/LexicalSelection.dev.js +0 -1028
- package/dist/esm/node_modules/@lexical/selection/LexicalSelection.js +0 -28
- package/dist/esm/node_modules/@lexical/selection/LexicalSelection.prod.js +0 -16
- package/dist/esm/node_modules/@lexical/table/LexicalTable.dev.js +0 -4156
- package/dist/esm/node_modules/@lexical/table/LexicalTable.js +0 -20
- package/dist/esm/node_modules/@lexical/table/LexicalTable.prod.js +0 -17
- package/dist/esm/node_modules/@lexical/utils/LexicalUtils.dev.js +0 -1102
- package/dist/esm/node_modules/@lexical/utils/LexicalUtils.js +0 -32
- package/dist/esm/node_modules/@lexical/utils/LexicalUtils.prod.js +0 -17
- package/dist/esm/node_modules/@mdi/js/mdi.js +0 -7
- package/dist/esm/node_modules/prismjs/components/prism-c.js +0 -82
- package/dist/esm/node_modules/prismjs/components/prism-clike.js +0 -33
- package/dist/esm/node_modules/prismjs/components/prism-cpp.js +0 -101
- package/dist/esm/node_modules/prismjs/components/prism-css.js +0 -66
- package/dist/esm/node_modules/prismjs/components/prism-java.js +0 -126
- package/dist/esm/node_modules/prismjs/components/prism-javascript.js +0 -174
- package/dist/esm/node_modules/prismjs/components/prism-markdown.js +0 -417
- package/dist/esm/node_modules/prismjs/components/prism-markup.js +0 -188
- package/dist/esm/node_modules/prismjs/components/prism-objectivec.js +0 -14
- package/dist/esm/node_modules/prismjs/components/prism-powershell.js +0 -60
- package/dist/esm/node_modules/prismjs/components/prism-python.js +0 -67
- package/dist/esm/node_modules/prismjs/components/prism-rust.js +0 -130
- package/dist/esm/node_modules/prismjs/components/prism-sql.js +0 -34
- package/dist/esm/node_modules/prismjs/components/prism-swift.js +0 -150
- package/dist/esm/node_modules/prismjs/components/prism-typescript.js +0 -62
- package/dist/esm/node_modules/prismjs/prism.js +0 -1951
- package/dist/esm/packages/lexical/src/components/StickyComponent.js +0 -221
- package/dist/esm/packages/lexical/src/nodes/StickyNode.js +0 -216
- package/dist/esm/packages/lexical/src/plugins/StickyPlugin.js +0 -20
- package/dist/types/components/StickyComponent.d.ts +0 -9
- package/dist/types/nodes/StickyNode.d.ts +0 -34
- package/dist/types/plugins/StickyPlugin.d.ts +0 -1
- package/src/components/StickyComponent.tsx +0 -271
- package/src/nodes/StickyNode.tsx +0 -249
|
@@ -0,0 +1,554 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* React Fabric
|
|
3
|
+
* @version: 1.0.0
|
|
4
|
+
*
|
|
5
|
+
*
|
|
6
|
+
* The MIT License (MIT)
|
|
7
|
+
* Copyright (c) 2024 Adarsh Pastakia
|
|
8
|
+
*
|
|
9
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
|
10
|
+
* and associated documentation files (the "Software"), to deal in the Software without restriction,
|
|
11
|
+
* including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
12
|
+
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
|
13
|
+
* subject to the following conditions:
|
|
14
|
+
*
|
|
15
|
+
* The above copyright notice and this permission notice shall be included in all copies or substantial
|
|
16
|
+
* portions of the Software.
|
|
17
|
+
*
|
|
18
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
|
19
|
+
* TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
20
|
+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
21
|
+
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
|
|
25
|
+
import {
|
|
26
|
+
Badge,
|
|
27
|
+
Button,
|
|
28
|
+
Card,
|
|
29
|
+
Content,
|
|
30
|
+
Flyout,
|
|
31
|
+
Footer,
|
|
32
|
+
Icon,
|
|
33
|
+
Modal,
|
|
34
|
+
useOverlayService,
|
|
35
|
+
type ModalProps,
|
|
36
|
+
} from "@react-fabric/core";
|
|
37
|
+
import { DateDuration } from "@react-fabric/date";
|
|
38
|
+
import { Textarea } from "@react-fabric/form";
|
|
39
|
+
import { compareValues } from "@react-fabric/utilities";
|
|
40
|
+
import classNames from "classnames";
|
|
41
|
+
import {
|
|
42
|
+
$getNearestNodeFromDOMNode,
|
|
43
|
+
$getNodeByKey,
|
|
44
|
+
$getRoot,
|
|
45
|
+
$getState,
|
|
46
|
+
$isElementNode,
|
|
47
|
+
$setState,
|
|
48
|
+
createState,
|
|
49
|
+
type LexicalEditor,
|
|
50
|
+
} from "lexical";
|
|
51
|
+
import { useEffect, useEffectEvent, useRef, useState } from "react";
|
|
52
|
+
import { createPortal } from "react-dom";
|
|
53
|
+
import { useTranslation } from "react-i18next";
|
|
54
|
+
import { Point, Rect, isHTMLElement } from "../utils";
|
|
55
|
+
|
|
56
|
+
const SPACE = 4;
|
|
57
|
+
|
|
58
|
+
const Downward = 1;
|
|
59
|
+
const Upward = -1;
|
|
60
|
+
const Indeterminate = 0;
|
|
61
|
+
|
|
62
|
+
let prevIndex = Infinity;
|
|
63
|
+
|
|
64
|
+
function getCurrentIndex(keysLength: number): number {
|
|
65
|
+
if (keysLength === 0) {
|
|
66
|
+
return Infinity;
|
|
67
|
+
}
|
|
68
|
+
if (prevIndex >= 0 && prevIndex < keysLength) {
|
|
69
|
+
return prevIndex;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return Math.floor(keysLength / 2);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function getTopLevelNodeKeys(editor: LexicalEditor): string[] {
|
|
76
|
+
return editor.getEditorState().read(() => $getRoot().getChildrenKeys());
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function getBlockElement(
|
|
80
|
+
anchorElem: HTMLElement,
|
|
81
|
+
editor: LexicalEditor,
|
|
82
|
+
event: MouseEvent,
|
|
83
|
+
): HTMLElement | null {
|
|
84
|
+
const anchorElementRect = anchorElem.getBoundingClientRect();
|
|
85
|
+
const topLevelNodeKeys = getTopLevelNodeKeys(editor);
|
|
86
|
+
|
|
87
|
+
let blockElem: HTMLElement | null = null;
|
|
88
|
+
|
|
89
|
+
editor.getEditorState().read(() => {
|
|
90
|
+
let index = getCurrentIndex(topLevelNodeKeys.length);
|
|
91
|
+
let direction = Indeterminate;
|
|
92
|
+
|
|
93
|
+
while (index >= 0 && index < topLevelNodeKeys.length) {
|
|
94
|
+
const key = topLevelNodeKeys[index];
|
|
95
|
+
const elem = editor.getElementByKey(key);
|
|
96
|
+
if (elem === null) {
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
const point = new Point(event.x, event.y);
|
|
100
|
+
const domRect = Rect.fromDOM(elem);
|
|
101
|
+
const { marginTop, marginBottom } = window.getComputedStyle(elem);
|
|
102
|
+
|
|
103
|
+
const rect = domRect.generateNewRect({
|
|
104
|
+
bottom: domRect.bottom + parseFloat(marginBottom),
|
|
105
|
+
left: anchorElementRect.left,
|
|
106
|
+
right: anchorElementRect.right,
|
|
107
|
+
top: domRect.top - parseFloat(marginTop),
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
const {
|
|
111
|
+
result,
|
|
112
|
+
reason: { isOnTopSide, isOnBottomSide },
|
|
113
|
+
} = rect.contains(point);
|
|
114
|
+
|
|
115
|
+
if (result) {
|
|
116
|
+
blockElem = elem;
|
|
117
|
+
prevIndex = index;
|
|
118
|
+
break;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
if (direction === Indeterminate) {
|
|
122
|
+
if (isOnTopSide) {
|
|
123
|
+
direction = Upward;
|
|
124
|
+
} else if (isOnBottomSide) {
|
|
125
|
+
direction = Downward;
|
|
126
|
+
} else {
|
|
127
|
+
// stop search block element
|
|
128
|
+
direction = Infinity;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
index += direction;
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
return blockElem;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
interface ICommentEntry {
|
|
140
|
+
username: string;
|
|
141
|
+
timestamp: string;
|
|
142
|
+
comment: string;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
interface IComment extends ICommentEntry {
|
|
146
|
+
lastUpdate: string;
|
|
147
|
+
replies: ICommentEntry[];
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const commentState = createState<"comment", IComment>("comment", {
|
|
151
|
+
parse: (v) =>
|
|
152
|
+
typeof v === "string" ? JSON.parse(v) : typeof v === "object" ? v : null,
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
function setMenuPosition(
|
|
156
|
+
targetElem: HTMLElement | null,
|
|
157
|
+
floatingElem: HTMLElement,
|
|
158
|
+
anchorElem: HTMLElement,
|
|
159
|
+
) {
|
|
160
|
+
if (!targetElem) {
|
|
161
|
+
floatingElem.style.opacity = "0";
|
|
162
|
+
floatingElem.style.transform = "translate(-10000px, -10000px)";
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
const targetRect = targetElem.getBoundingClientRect();
|
|
167
|
+
const targetStyle = window.getComputedStyle(targetElem);
|
|
168
|
+
const floatingElemRect = floatingElem.getBoundingClientRect();
|
|
169
|
+
const anchorElementRect = anchorElem.getBoundingClientRect();
|
|
170
|
+
|
|
171
|
+
const top =
|
|
172
|
+
targetRect.top +
|
|
173
|
+
(parseInt(targetStyle.lineHeight, 10) - floatingElemRect.height) / 2 -
|
|
174
|
+
anchorElementRect.top;
|
|
175
|
+
|
|
176
|
+
const left = SPACE;
|
|
177
|
+
|
|
178
|
+
floatingElem.style.opacity = "1";
|
|
179
|
+
floatingElem.style.transform = `translate(-${left}px, ${top}px)`;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function useCommentMenu(
|
|
183
|
+
editor: LexicalEditor,
|
|
184
|
+
anchorElem: HTMLElement,
|
|
185
|
+
username: string,
|
|
186
|
+
openForm: (props: { sample: string }) => Promise<string>,
|
|
187
|
+
): JSX.Element {
|
|
188
|
+
const scrollerElem = anchorElem.parentElement;
|
|
189
|
+
|
|
190
|
+
const menuRef = useRef<HTMLDivElement>(null);
|
|
191
|
+
const [draggableBlockElem, setDraggableBlockElem] =
|
|
192
|
+
useState<HTMLElement | null>(null);
|
|
193
|
+
|
|
194
|
+
useEffect(() => {
|
|
195
|
+
function onMouseMove(event: MouseEvent) {
|
|
196
|
+
const target = event.target as HTMLElement;
|
|
197
|
+
if (!isHTMLElement(target)) {
|
|
198
|
+
setDraggableBlockElem(null);
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
const _draggableBlockElem = getBlockElement(anchorElem, editor, event);
|
|
203
|
+
editor.update(() => {
|
|
204
|
+
const node =
|
|
205
|
+
_draggableBlockElem &&
|
|
206
|
+
$getNearestNodeFromDOMNode(_draggableBlockElem);
|
|
207
|
+
if (node) {
|
|
208
|
+
const comment = $getState(node, commentState);
|
|
209
|
+
setDraggableBlockElem(comment === null ? _draggableBlockElem : null);
|
|
210
|
+
} else {
|
|
211
|
+
setDraggableBlockElem(null);
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
function onMouseLeave() {
|
|
217
|
+
setDraggableBlockElem(null);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
scrollerElem?.addEventListener("mousemove", onMouseMove);
|
|
221
|
+
scrollerElem?.addEventListener("mouseleave", onMouseLeave);
|
|
222
|
+
|
|
223
|
+
return () => {
|
|
224
|
+
scrollerElem?.removeEventListener("mousemove", onMouseMove);
|
|
225
|
+
scrollerElem?.removeEventListener("mouseleave", onMouseLeave);
|
|
226
|
+
};
|
|
227
|
+
}, [scrollerElem, anchorElem, editor]);
|
|
228
|
+
|
|
229
|
+
useEffect(() => {
|
|
230
|
+
if (menuRef.current) {
|
|
231
|
+
setMenuPosition(draggableBlockElem, menuRef.current, anchorElem);
|
|
232
|
+
}
|
|
233
|
+
}, [anchorElem, draggableBlockElem]);
|
|
234
|
+
|
|
235
|
+
const addComment = () => {
|
|
236
|
+
editor.update(() => {
|
|
237
|
+
const node =
|
|
238
|
+
draggableBlockElem && $getNearestNodeFromDOMNode(draggableBlockElem);
|
|
239
|
+
|
|
240
|
+
if (node && $isElementNode(node)) {
|
|
241
|
+
draggableBlockElem.scrollIntoView({
|
|
242
|
+
behavior: "smooth",
|
|
243
|
+
block: "center",
|
|
244
|
+
});
|
|
245
|
+
void openForm({ sample: node.getTextContent().substring(0, 128) }).then(
|
|
246
|
+
(comment) => {
|
|
247
|
+
editor.update(() => {
|
|
248
|
+
comment &&
|
|
249
|
+
$setState(node, commentState, {
|
|
250
|
+
username,
|
|
251
|
+
comment,
|
|
252
|
+
timestamp: new Date().toISOString(),
|
|
253
|
+
lastUpdate: new Date().toISOString(),
|
|
254
|
+
replies: [],
|
|
255
|
+
});
|
|
256
|
+
});
|
|
257
|
+
return true;
|
|
258
|
+
},
|
|
259
|
+
);
|
|
260
|
+
}
|
|
261
|
+
});
|
|
262
|
+
};
|
|
263
|
+
|
|
264
|
+
return createPortal(
|
|
265
|
+
<>
|
|
266
|
+
<div
|
|
267
|
+
role="none"
|
|
268
|
+
ref={menuRef}
|
|
269
|
+
onClick={addComment}
|
|
270
|
+
className="rounded px-0.5 py-px select-none opacity-0 absolute right-0 top-0 will-change-transform cursor-pointer hover:bg-primary-50"
|
|
271
|
+
>
|
|
272
|
+
<svg
|
|
273
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
274
|
+
viewBox="0 0 24 24"
|
|
275
|
+
className="w-4 h-4 opacity-30 pointer-events-none"
|
|
276
|
+
>
|
|
277
|
+
<title>comment-plus-outline</title>
|
|
278
|
+
<path d="M9,22A1,1 0 0,1 8,21V18H4A2,2 0 0,1 2,16V4C2,2.89 2.9,2 4,2H20A2,2 0 0,1 22,4V16A2,2 0 0,1 20,18H13.9L10.2,21.71C10,21.9 9.75,22 9.5,22V22H9M10,16V19.08L13.08,16H20V4H4V16H10M11,6H13V9H16V11H13V14H11V11H8V9H11V6Z" />
|
|
279
|
+
</svg>
|
|
280
|
+
</div>
|
|
281
|
+
</>,
|
|
282
|
+
anchorElem,
|
|
283
|
+
);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
const CommentCard = ({
|
|
287
|
+
sample,
|
|
288
|
+
nodeKey,
|
|
289
|
+
comment,
|
|
290
|
+
onSelect,
|
|
291
|
+
onReply,
|
|
292
|
+
}: {
|
|
293
|
+
sample: string;
|
|
294
|
+
nodeKey: string;
|
|
295
|
+
comment: IComment;
|
|
296
|
+
onSelect: (key: string) => void;
|
|
297
|
+
onReply: (key: string, reply: string) => void;
|
|
298
|
+
}) => {
|
|
299
|
+
const { t } = useTranslation("lexical");
|
|
300
|
+
const [reply, setReply] = useState<string | null>(null);
|
|
301
|
+
return (
|
|
302
|
+
<Card data-key={nodeKey} className="mb-2" onClick={() => onSelect(nodeKey)}>
|
|
303
|
+
<div className="line-clamp-2 mb-4">{sample}</div>
|
|
304
|
+
<div className="text-xs truncate mb-2 text-tint-500">
|
|
305
|
+
<div className="font-medium">{comment.username}</div>
|
|
306
|
+
<DateDuration date={comment.timestamp} />
|
|
307
|
+
</div>
|
|
308
|
+
<div className="text-sm">{comment.comment}</div>
|
|
309
|
+
{comment.replies?.length > 0 && (
|
|
310
|
+
<div className="bg-alternate ps-2 border-s-2 border-s-tint-200">
|
|
311
|
+
{comment.replies.map((reply, idx) => (
|
|
312
|
+
<div key={idx} className="px-2 py-1">
|
|
313
|
+
<div className="text-xs truncate mb-2 text-tint-500">
|
|
314
|
+
<div className="font-medium">{reply.username}</div>
|
|
315
|
+
<DateDuration date={reply.timestamp} />
|
|
316
|
+
</div>
|
|
317
|
+
<div className="text-sm">{reply.comment}</div>
|
|
318
|
+
</div>
|
|
319
|
+
))}
|
|
320
|
+
</div>
|
|
321
|
+
)}
|
|
322
|
+
<Footer>
|
|
323
|
+
<div className="p-px text-xs bg-base">
|
|
324
|
+
<Textarea
|
|
325
|
+
placeholder={t("reply") + "..."}
|
|
326
|
+
rows={1}
|
|
327
|
+
value={reply}
|
|
328
|
+
onChange={setReply}
|
|
329
|
+
onEnterPressed={() =>
|
|
330
|
+
reply && (onReply(nodeKey, reply), setReply(null))
|
|
331
|
+
}
|
|
332
|
+
decorateEnd={
|
|
333
|
+
<Button
|
|
334
|
+
size="sm"
|
|
335
|
+
variant="link"
|
|
336
|
+
icon="icon-[mdi--send]"
|
|
337
|
+
aria-label="reply"
|
|
338
|
+
onClick={() =>
|
|
339
|
+
reply && (onReply(nodeKey, reply), setReply(null))
|
|
340
|
+
}
|
|
341
|
+
/>
|
|
342
|
+
}
|
|
343
|
+
/>
|
|
344
|
+
</div>
|
|
345
|
+
</Footer>
|
|
346
|
+
</Card>
|
|
347
|
+
);
|
|
348
|
+
};
|
|
349
|
+
|
|
350
|
+
const CommentFlyout = ({
|
|
351
|
+
comments,
|
|
352
|
+
activeKey,
|
|
353
|
+
onClose,
|
|
354
|
+
onSelect,
|
|
355
|
+
onReply,
|
|
356
|
+
}: ModalProps<{
|
|
357
|
+
activeKey?: string;
|
|
358
|
+
onSelect: (key: string) => void;
|
|
359
|
+
onReply: (key: string, reply: string) => void;
|
|
360
|
+
comments: Array<{ sample: string; nodeKey: string; comment: IComment }>;
|
|
361
|
+
}>) => {
|
|
362
|
+
const contentRef = useRef<HTMLDivElement>(null);
|
|
363
|
+
useEffect(() => {
|
|
364
|
+
activeKey &&
|
|
365
|
+
setTimeout(() => {
|
|
366
|
+
contentRef.current
|
|
367
|
+
?.querySelector(`[data-key="${activeKey}"]`)
|
|
368
|
+
?.scrollIntoView({
|
|
369
|
+
behavior: "smooth",
|
|
370
|
+
block: "center",
|
|
371
|
+
});
|
|
372
|
+
}, 100);
|
|
373
|
+
}, [activeKey]);
|
|
374
|
+
return (
|
|
375
|
+
<Flyout
|
|
376
|
+
onClose={onClose}
|
|
377
|
+
title="Comments"
|
|
378
|
+
icon="icon-[mdi--comment-text-multiple]"
|
|
379
|
+
hideMask
|
|
380
|
+
align="end"
|
|
381
|
+
size="sm"
|
|
382
|
+
headerClassName="border-b border-primary-500 text-sm font-medium"
|
|
383
|
+
>
|
|
384
|
+
<Content ref={contentRef}>
|
|
385
|
+
{comments.map((props) => (
|
|
386
|
+
<CommentCard
|
|
387
|
+
key={props.nodeKey}
|
|
388
|
+
{...props}
|
|
389
|
+
onSelect={onSelect}
|
|
390
|
+
onReply={onReply}
|
|
391
|
+
/>
|
|
392
|
+
))}
|
|
393
|
+
</Content>
|
|
394
|
+
</Flyout>
|
|
395
|
+
);
|
|
396
|
+
};
|
|
397
|
+
|
|
398
|
+
const CommentForm = ({ onClose, sample }: ModalProps & { sample: string }) => {
|
|
399
|
+
const { t } = useTranslation("lexical");
|
|
400
|
+
const [comment, setComment] = useState<string | null>(null);
|
|
401
|
+
return (
|
|
402
|
+
<Modal onClose={onClose} size="sm" title={t("addComment")}>
|
|
403
|
+
<Content className="p-px grid text-sm">
|
|
404
|
+
<div className="px-2 py-1 line-clamp-2">{sample}</div>
|
|
405
|
+
<Textarea
|
|
406
|
+
placeholder={t("addComment") + "..."}
|
|
407
|
+
rows={4}
|
|
408
|
+
autoFocus
|
|
409
|
+
value={comment}
|
|
410
|
+
onChange={setComment}
|
|
411
|
+
onEnterPressed={() => comment && onClose(comment)}
|
|
412
|
+
decorateEnd={
|
|
413
|
+
<Button
|
|
414
|
+
size="sm"
|
|
415
|
+
variant="link"
|
|
416
|
+
icon="icon-[mdi--send]"
|
|
417
|
+
aria-label="add comment"
|
|
418
|
+
onClick={() => comment && onClose(comment)}
|
|
419
|
+
/>
|
|
420
|
+
}
|
|
421
|
+
/>
|
|
422
|
+
</Content>
|
|
423
|
+
</Modal>
|
|
424
|
+
);
|
|
425
|
+
};
|
|
426
|
+
|
|
427
|
+
const commentHandler = (
|
|
428
|
+
editor: LexicalEditor,
|
|
429
|
+
anchorElem: HTMLElement,
|
|
430
|
+
username: string,
|
|
431
|
+
) => {
|
|
432
|
+
const [comments, setComments] = useState<
|
|
433
|
+
Array<{ sample: string; nodeKey: string; comment: IComment }>
|
|
434
|
+
>([]);
|
|
435
|
+
const [FlyoutEl, openFlyout, closeFlyout] = useOverlayService(CommentFlyout);
|
|
436
|
+
const [ModalEl, openModal] = useOverlayService(CommentForm);
|
|
437
|
+
|
|
438
|
+
const scrollIntoView = useEffectEvent((key: string) => {
|
|
439
|
+
const el = editor.getElementByKey(key);
|
|
440
|
+
if (el) {
|
|
441
|
+
el.scrollIntoView({
|
|
442
|
+
behavior: "smooth",
|
|
443
|
+
block: "center",
|
|
444
|
+
});
|
|
445
|
+
el.classList.add("editor-comment-hilight");
|
|
446
|
+
setTimeout(() => {
|
|
447
|
+
el.classList.remove("editor-comment-hilight");
|
|
448
|
+
}, 1000);
|
|
449
|
+
}
|
|
450
|
+
});
|
|
451
|
+
const addReply = useEffectEvent((key: string, reply: string) => {
|
|
452
|
+
editor.update(() => {
|
|
453
|
+
const node = $getNodeByKey(key);
|
|
454
|
+
if (node) {
|
|
455
|
+
const comment = $getState(node, commentState);
|
|
456
|
+
if (comment) {
|
|
457
|
+
comment.lastUpdate = new Date().toISOString();
|
|
458
|
+
comment.replies.unshift({
|
|
459
|
+
username,
|
|
460
|
+
comment: reply,
|
|
461
|
+
timestamp: new Date().toISOString(),
|
|
462
|
+
});
|
|
463
|
+
$setState(node, commentState, comment);
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
});
|
|
467
|
+
});
|
|
468
|
+
const handleOpenFlyout = useEffectEvent((activeKey?: string) => {
|
|
469
|
+
if (!activeKey && closeFlyout) {
|
|
470
|
+
closeFlyout();
|
|
471
|
+
}
|
|
472
|
+
void openFlyout({ activeKey });
|
|
473
|
+
});
|
|
474
|
+
|
|
475
|
+
useEffect(() => {
|
|
476
|
+
return editor.registerUpdateListener(({ editorState }) => {
|
|
477
|
+
const comments: KeyValue[] = [];
|
|
478
|
+
editorState.read(() => {
|
|
479
|
+
$getRoot()
|
|
480
|
+
.getChildren()
|
|
481
|
+
.forEach((node) => {
|
|
482
|
+
const comment = $getState(node, commentState);
|
|
483
|
+
const element = editor.getElementByKey(node.getKey());
|
|
484
|
+
element?.classList.remove("editor-has-comment");
|
|
485
|
+
if (comment !== null) {
|
|
486
|
+
element?.classList.add("editor-has-comment");
|
|
487
|
+
element?.addEventListener("click", (e) => {
|
|
488
|
+
if (e.offsetX < 0) {
|
|
489
|
+
handleOpenFlyout(node.getKey());
|
|
490
|
+
}
|
|
491
|
+
});
|
|
492
|
+
comments.push({
|
|
493
|
+
nodeKey: node.getKey(),
|
|
494
|
+
sample: node.getTextContent().substring(0, 128),
|
|
495
|
+
comment,
|
|
496
|
+
});
|
|
497
|
+
}
|
|
498
|
+
});
|
|
499
|
+
});
|
|
500
|
+
setComments(
|
|
501
|
+
comments.sort(compareValues("desc", "comment.lastUpdate")) as any,
|
|
502
|
+
);
|
|
503
|
+
});
|
|
504
|
+
}, [editor]);
|
|
505
|
+
return (
|
|
506
|
+
<>
|
|
507
|
+
{useCommentMenu(editor, anchorElem, username, openModal)}
|
|
508
|
+
<div className="fixed inset-x-0 bottom-0 max-w-[21cm] mx-auto text-end">
|
|
509
|
+
{comments.length > 0 && (
|
|
510
|
+
<Badge
|
|
511
|
+
value={comments.length}
|
|
512
|
+
max={99}
|
|
513
|
+
placement="top-end"
|
|
514
|
+
className="-me-4"
|
|
515
|
+
>
|
|
516
|
+
<Icon
|
|
517
|
+
rounded
|
|
518
|
+
onClick={async () => handleOpenFlyout()}
|
|
519
|
+
icon="icon-[mdi--comment-text-multiple]"
|
|
520
|
+
className={classNames(
|
|
521
|
+
"text-2xl outline p-2 -me-4",
|
|
522
|
+
closeFlyout
|
|
523
|
+
? "bg-primary-50 text-primary-500"
|
|
524
|
+
: "bg-dimmed text-muted hover:text-dimmed",
|
|
525
|
+
)}
|
|
526
|
+
/>
|
|
527
|
+
</Badge>
|
|
528
|
+
)}
|
|
529
|
+
</div>
|
|
530
|
+
{
|
|
531
|
+
<FlyoutEl
|
|
532
|
+
comments={comments}
|
|
533
|
+
onSelect={scrollIntoView}
|
|
534
|
+
onReply={addReply}
|
|
535
|
+
/>
|
|
536
|
+
}
|
|
537
|
+
{<ModalEl />}
|
|
538
|
+
</>
|
|
539
|
+
);
|
|
540
|
+
};
|
|
541
|
+
|
|
542
|
+
export const CommentPlugin = ({
|
|
543
|
+
anchorElem = document.body,
|
|
544
|
+
isPublishMode = true,
|
|
545
|
+
username,
|
|
546
|
+
}: {
|
|
547
|
+
anchorElem?: HTMLElement;
|
|
548
|
+
isPublishMode: boolean;
|
|
549
|
+
username: string;
|
|
550
|
+
}): JSX.Element => {
|
|
551
|
+
const [editor] = useLexicalComposerContext();
|
|
552
|
+
if (isPublishMode) return <></>;
|
|
553
|
+
return commentHandler(editor, anchorElem, username);
|
|
554
|
+
};
|
|
@@ -147,15 +147,12 @@ function setMenuPosition(
|
|
|
147
147
|
return;
|
|
148
148
|
}
|
|
149
149
|
|
|
150
|
-
const scrollTop = targetElem.closest(".lexical-scroller")?.scrollTop ?? 0;
|
|
151
|
-
|
|
152
150
|
const targetRect = targetElem.getBoundingClientRect();
|
|
153
151
|
const targetStyle = window.getComputedStyle(targetElem);
|
|
154
152
|
const floatingElemRect = floatingElem.getBoundingClientRect();
|
|
155
153
|
const anchorElementRect = anchorElem.getBoundingClientRect();
|
|
156
154
|
|
|
157
155
|
const top =
|
|
158
|
-
scrollTop +
|
|
159
156
|
targetRect.top +
|
|
160
157
|
(parseInt(targetStyle.lineHeight, 10) - floatingElemRect.height) / 2 -
|
|
161
158
|
anchorElementRect.top;
|
|
@@ -224,7 +221,6 @@ function hideTargetLine(targetLineElem: HTMLElement | null) {
|
|
|
224
221
|
function useDraggableBlockMenu(
|
|
225
222
|
editor: LexicalEditor,
|
|
226
223
|
anchorElem: HTMLElement,
|
|
227
|
-
isEditable: boolean,
|
|
228
224
|
): JSX.Element {
|
|
229
225
|
const scrollerElem = anchorElem.parentElement;
|
|
230
226
|
|
|
@@ -377,10 +373,6 @@ function useDraggableBlockMenu(
|
|
|
377
373
|
hideTargetLine(targetLineRef.current);
|
|
378
374
|
}
|
|
379
375
|
|
|
380
|
-
if (draggableBlockElem?.classList?.contains("editor-cover-page")) {
|
|
381
|
-
return <div />;
|
|
382
|
-
}
|
|
383
|
-
|
|
384
376
|
return createPortal(
|
|
385
377
|
<>
|
|
386
378
|
<div
|
|
@@ -400,7 +392,7 @@ function useDraggableBlockMenu(
|
|
|
400
392
|
</svg>
|
|
401
393
|
</div>
|
|
402
394
|
<div
|
|
403
|
-
className="pointer-events-none bg-primary h-1 absolute top-0 left-0 opacity-0 will-change-transform"
|
|
395
|
+
className="pointer-events-none bg-primary-200 h-1 absolute top-0 left-0 opacity-0 will-change-transform"
|
|
404
396
|
ref={targetLineRef}
|
|
405
397
|
/>
|
|
406
398
|
</>,
|
|
@@ -410,9 +402,12 @@ function useDraggableBlockMenu(
|
|
|
410
402
|
|
|
411
403
|
export const DraggableBlockPlugin = ({
|
|
412
404
|
anchorElem = document.body,
|
|
405
|
+
isEditable = true,
|
|
413
406
|
}: {
|
|
414
407
|
anchorElem?: HTMLElement;
|
|
408
|
+
isEditable: boolean;
|
|
415
409
|
}): JSX.Element => {
|
|
416
410
|
const [editor] = useLexicalComposerContext();
|
|
417
|
-
|
|
411
|
+
if (!isEditable) return <></>;
|
|
412
|
+
return useDraggableBlockMenu(editor, anchorElem);
|
|
418
413
|
};
|