MCPcopy
hub / github.com/codex-team/editor.js / Paste

Class Paste

src/components/modules/paste.ts:111–1005  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

109 * @version 2.0.0
110 */
111export default class Paste extends Module {
112 /** If string`s length is greater than this number we don't check paste patterns */
113 public static readonly PATTERN_PROCESSING_MAX_LENGTH = 450;
114
115 /** Custom EditorJS mime-type to handle in-editor copy/paste actions */
116 public readonly MIME_TYPE = 'application/x-editor-js';
117
118 /**
119 * Tags` substitutions parameters
120 */
121 private toolsTags: { [tag: string]: TagSubstitute } = {};
122
123 /**
124 * Store tags to substitute by tool name
125 */
126 private tagsByTool: { [tools: string]: string[] } = {};
127
128 /** Patterns` substitutions parameters */
129 private toolsPatterns: PatternSubstitute[] = [];
130
131 /** Files` substitutions parameters */
132 private toolsFiles: {
133 [tool: string]: FilesSubstitution;
134 } = {};
135
136 /**
137 * List of tools which do not need a paste handling
138 */
139 private exceptionList: string[] = [];
140
141 /**
142 * Set onPaste callback and collect tools` paste configurations
143 */
144 public async prepare(): Promise<void> {
145 this.processTools();
146 }
147
148 /**
149 * Set read-only state
150 *
151 * @param {boolean} readOnlyEnabled - read only flag value
152 */
153 public toggleReadOnly(readOnlyEnabled: boolean): void {
154 if (!readOnlyEnabled) {
155 this.setCallback();
156 } else {
157 this.unsetCallback();
158 }
159 }
160
161 /**
162 * Handle pasted or dropped data transfer object
163 *
164 * @param {DataTransfer} dataTransfer - pasted or dropped data transfer object
165 * @param {boolean} isDragNDrop - true if data transfer comes from drag'n'drop events
166 */
167 public async processDataTransfer(dataTransfer: DataTransfer, isDragNDrop = false): Promise<void> {
168 const { Tools } = this.Editor;

Callers

nothing calls this directly

Calls 9

getTagsConfigMethod · 0.95
getFilesConfigMethod · 0.95
getPatternsConfigMethod · 0.95
isNativeBehaviourMethod · 0.95
processDataTransferMethod · 0.95
createMethod · 0.65
closeMethod · 0.65
pushMethod · 0.45

Tested by

no test coverage detected