@wordpress/editor
Version:
Enhanced block editor for WordPress posts.
67 lines (65 loc) • 2.55 kB
JavaScript
;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// packages/editor/src/components/collab-sidebar/note-highlight-styles.js
var note_highlight_styles_exports = {};
__export(note_highlight_styles_exports, {
NoteHighlightStyles: () => NoteHighlightStyles,
buildHighlightCss: () => buildHighlightCss
});
module.exports = __toCommonJS(note_highlight_styles_exports);
var import_element = require("@wordpress/element");
var import_block_editor = require("@wordpress/block-editor");
var import_utils = require("./utils.cjs");
var REST_ALPHA = "40";
var ACTIVE_ALPHA = "80";
var BASE_RESET = "mark.wp-note{background-color:transparent;color:inherit;}";
function buildHighlightCss(threads, selectedId = null) {
const rules = [BASE_RESET];
for (const thread of threads ?? []) {
if (!thread?.id) {
continue;
}
const color = (0, import_utils.getAvatarBorderColor)(thread.author ?? 0);
const sel = (0, import_utils.getNoteMarkerSelector)(thread.id);
rules.push(`${sel}{background-color:${color}${REST_ALPHA};}`);
rules.push(
`${sel}:hover,${sel}:focus-within{background-color:${color}${ACTIVE_ALPHA};}`
);
if (selectedId && String(selectedId) === String(thread.id)) {
rules.push(
`${sel}{background-color:${color}${ACTIVE_ALPHA};}`
);
}
}
return rules.join("");
}
function NoteHighlightStyles({ threads, selectedId }) {
const css = (0, import_element.useMemo)(
() => buildHighlightCss(threads, selectedId),
[threads, selectedId]
);
(0, import_block_editor.useStyleOverride)({ id: "core-note-highlights", css });
return null;
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
NoteHighlightStyles,
buildHighlightCss
});
//# sourceMappingURL=note-highlight-styles.cjs.map