UNPKG

@wordpress/editor

Version:
75 lines (73 loc) 2.6 kB
"use strict"; 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/format.js var format_exports = {}; __export(format_exports, { NOTE_FORMAT_NAME: () => NOTE_FORMAT_NAME, noteFormat: () => noteFormat }); module.exports = __toCommonJS(format_exports); var import_i18n = require("@wordpress/i18n"); var import_element = require("@wordpress/element"); var import_data = require("@wordpress/data"); var import_interface = require("@wordpress/interface"); var import_store = require("../../store/index.cjs"); var import_constants = require("./constants.cjs"); var import_lock_unlock = require("../../lock-unlock.cjs"); var NOTE_FORMAT_NAME = "core/note"; var noteFormat = { title: (0, import_i18n.__)("Note"), tagName: "mark", className: "wp-note", attributes: { "data-id": "data-id" }, edit: NoteFormat }; function NoteFormat({ isActive, activeAttributes }) { const { getActiveComplementaryArea } = (0, import_data.useSelect)(import_interface.store); const { getSelectedNote } = (0, import_lock_unlock.unlock)((0, import_data.useSelect)(import_store.store)); const { selectNote } = (0, import_lock_unlock.unlock)((0, import_data.useDispatch)(import_store.store)); const noteId = activeAttributes?.["data-id"]; (0, import_element.useEffect)(() => { if (!isActive || !noteId) { return; } if (!import_constants.SIDEBARS.includes(getActiveComplementaryArea("core"))) { return; } if (String(getSelectedNote()) === String(noteId)) { return; } selectNote(Number(noteId)); }, [ isActive, noteId, getActiveComplementaryArea, getSelectedNote, selectNote ]); return null; } // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { NOTE_FORMAT_NAME, noteFormat }); //# sourceMappingURL=format.cjs.map